You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by rm...@apache.org on 2014/09/19 23:32:52 UTC
[1/9] git commit: Argus-5
Repository: incubator-argus
Updated Branches:
refs/heads/master a9a959919 -> 4eacc7a8d
Argus-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/2b0ee421
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/2b0ee421
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/2b0ee421
Branch: refs/heads/master
Commit: 2b0ee4219db5bd79c930e6ac579ecffcb5e67168
Parents: 1490df2
Author: rmani <rm...@hortonworks.com>
Authored: Thu Sep 11 12:30:32 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Thu Sep 11 12:30:32 2014 -0700
----------------------------------------------------------------------
.../hadoop/log/HdfsFileAppender.java | 1437 ++++++++++++++++++
1 file changed, 1437 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/2b0ee421/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
new file mode 100644
index 0000000..3398d8a
--- /dev/null
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
@@ -0,0 +1,1437 @@
+package com.xasecure.authorization.hadoop.log;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.PrivilegedExceptionAction;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.helpers.LogLog;
+
+
+/********************************
+* HdfsFileAppender
+*
+**********************************/
+public class HdfsFileAppender extends FileAppender {
+
+
+ /**
+ * maximal number of retries to connect to the hdfs.
+ */
+
+
+ // Constants for checking the DatePattern
+ public static final String MINUTES ="Min";
+ public static final String HOURS ="Hr";
+ public static final String DAYS ="Day";
+ public static final String WEEKS ="Week";
+ public static final String MONTHS ="Month";
+
+ // The code assumes that the following constants are in a increasing sequence.
+ public static final int TOP_OF_TROUBLE = -1;
+ public static final int TOP_OF_MINUTE = 0;
+ public static final int TOP_OF_HOUR = 1;
+ public static final int HALF_DAY = 2;
+ public static final int TOP_OF_DAY = 3;
+ public static final int TOP_OF_WEEK = 4;
+ public static final int TOP_OF_MONTH = 5;
+
+ /**
+ * The date pattern. By default, the pattern is set to "1Day" meaning daily rollover.
+ */
+ private String hdfsFileRollingInterval = "1Day";
+
+ private String FileRollingInterval = "1Day";
+
+ /**
+ * The log file will be renamed to the value of the scheduledFilename variable when the next interval is entered. For example, if the rollover period is one
+ * hour, the log file will be renamed to the value of "scheduledFilename" at the beginning of the next hour. The precise time when a rollover occurs depends
+ * on logging activity.
+ */
+ private String scheduledFilename;
+
+ private String scheduledFileCache;
+
+ /**
+ * The next time we estimate a rollover should occur.
+ */
+ private long nextCheck = System.currentTimeMillis() - 1;
+
+ private long prevnextCheck = nextCheck;
+
+ private long nextCheckLocal = System.currentTimeMillis() -1;
+
+ private long prevnextCheckLocal = nextCheckLocal;
+
+ private Date now = new Date();
+
+ private Date nowLocal = now;
+
+ private SimpleDateFormat sdf;
+
+ private RollingCalendar rc = new RollingCalendar();
+
+ private RollingCalendar rcLocal = new RollingCalendar();
+
+ private FileOutputStream ostream = null;
+
+ private String fileSystemName;
+
+ private Layout layout = null;
+
+ private String encoding = null;
+
+ private String hdfsfileName = null;
+
+ private String actualhdfsfileName = null;
+
+ private String scheduledhdfsFileName = null;
+
+ private String fileCache = null;
+
+ private HdfsSink hs = null;
+
+ private Writer cachewriter = null;
+
+ private FileOutputStream cacheOstream = null;
+
+ private boolean hdfsAvailable = false;
+
+ private long hdfsNextCheck = System.currentTimeMillis() - 1;
+
+ private boolean timeCheck = false;
+
+ private int hdfsFileRollOffset = 0;
+
+ private int FileRollOffset = 0;
+
+ private boolean firstTime = true;
+
+ private boolean firstTimeLocal = true;
+
+ private String HdfsLiveUpdate = "true";
+
+
+ boolean hdfsUpdateAllowed = true;
+
+ private String hdfsCheckInterval=null;
+
+ private String processUser = null;
+
+ private String datePattern = "'.'yyyy-MM-dd-HH-mm";
+
+ /**
+ * The gmtTimeZone is used only in computeCheckPeriod() method.
+ */
+ private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
+
+ private static final String DEFAULT_HDFSCHECKINTERVAL = "2min";
+
+ /**
+ * The default constructor does nothing.
+ */
+ public HdfsFileAppender() {
+
+ }
+
+ /**
+ * Instantiate a <code>HdfsFileAppender</code> and open the file designated by <code>filename</code>. The opened filename will become the output destination for this appender.
+ */
+ public HdfsFileAppender(Layout layout, String filename, String hdfsFileRollingInterval,String FileRollingInterval, String HdfsLiveUpdate, String hdfsCheckInterval) throws IOException{
+ super(layout, filename, true);
+ this.hdfsFileRollingInterval = hdfsFileRollingInterval;
+ this.FileRollingInterval = FileRollingInterval;
+ this.HdfsLiveUpdate = HdfsLiveUpdate;
+ this.hdfsCheckInterval = hdfsCheckInterval;
+
+ activateOptions();
+ }
+
+ /**
+ * The <b>hdfsFileRollingInterval</b> takes a string like 1min, 5min,... 1hr, 2hrs,.. 1day, 2days... 1week, 2weeks.. 1month, 2months.. for hdfs File rollover schedule.
+ */
+ public void sethdfsFileRollingInterval(String pattern) {
+ hdfsFileRollingInterval = pattern;
+ }
+
+ /** Returns the value of the <b>hdfsFileRollingInterval</b> option. */
+ public String gethdfsFileRollingInterval() {
+ return hdfsFileRollingInterval;
+ }
+
+ /**
+ * The <b>LocalDatePattern</b> takes a string like 1min, 5min,... 1hr, 2hrs,.. 1day, 2days... 1week, 2weeks.. 1month, 2months.. for local cache File rollover schedule.
+ */
+ public void setFileRollingInterval(String pattern) {
+ FileRollingInterval = pattern;
+ }
+
+ /** Returns the value of the <b>FileRollingInterval</b> option. */
+ public String getFileRollingInterval() {
+ return FileRollingInterval;
+ }
+
+ /**
+ * This will set liveHdfsUpdate flag , where true will update hdfs live else false will create local cache files and copy the files to hdfs
+ */
+ public void setHdfsLiveUpdate(String val) {
+ HdfsLiveUpdate=val;
+ }
+
+ /** Returns the value of the <b>FileRollingInterval</b> option. */
+ public String getHdfsLiveUpdate() {
+ return HdfsLiveUpdate;
+ }
+
+ public String gethdfsCheckInterval() {
+ return hdfsCheckInterval;
+ }
+
+ public void sethdfsCheckInterval(String val){
+ hdfsCheckInterval = ( hdfsCheckInterval != null) ? val : DEFAULT_HDFSCHECKINTERVAL;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String value) {
+ encoding = value;
+ }
+
+ public void activateOptions() {
+ super.activateOptions();
+
+ sdf = new SimpleDateFormat(datePattern);
+ processUser=System.getProperties().getProperty("user.name");
+
+ if(hdfsFileRollingInterval != null && fileName != null) {
+ now.setTime(System.currentTimeMillis());
+ int type = computeCheckPeriod(hdfsFileRollingInterval);
+ hdfsFileRollOffset = getTimeOffset(hdfsFileRollingInterval);
+ printHdfsPeriodicity(type,hdfsFileRollOffset);
+ rc.setType(type);
+ LogLog.debug("File name: " + fileName);
+ File file = new File(fileName);
+ //scheduledFilename = fileName +"." +file.lastModified();
+ //scheduledhdfsFileName = hdfsfileName + "." + file.lastModified();
+ scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));
+ scheduledhdfsFileName = hdfsfileName+sdf.format(new Date(file.lastModified()));
+ firstTime = true;
+ LogLog.debug("Local and hdfs Files" + scheduledFilename + " " +scheduledhdfsFileName) ;
+
+ } else {
+ LogLog.error("Either File or hdfsFileRollingInterval options are not set for appender [" + name + "].");
+ }
+
+ // Local Cache File
+
+ if (FileRollingInterval != null && fileCache != null){
+ nowLocal.setTime(System.currentTimeMillis());
+ int localtype = computeCheckPeriod(FileRollingInterval);
+ FileRollOffset = getTimeOffset(FileRollingInterval);
+ printLocalPeriodicity(localtype,FileRollOffset);
+ rcLocal.setType(localtype);
+ LogLog.debug("LocalCacheFile name: " + fileCache);
+ File fileCachehandle = new File(fileCache);
+ //scheduledFileCache = fileCache+"."+fileCachehandle.lastModified();
+ scheduledFileCache = fileCache+sdf.format(new Date(fileCachehandle.lastModified()));
+ firstTimeLocal = true;
+
+ } else {
+ LogLog.error("Either File or LocalDatePattern options are not set for appender [" + name + "].");
+ }
+
+ if (HdfsLiveUpdate.equalsIgnoreCase("true")) {
+ hdfsUpdateAllowed = true;
+ } else if (HdfsLiveUpdate.equalsIgnoreCase("false")) {
+ hdfsUpdateAllowed = false;
+ }
+
+ actualhdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
+
+ }
+
+
+
+ public int computeCheckPeriod(String timePattern){
+
+ if ( timePattern.indexOf(MINUTES) > 0 || timePattern.indexOf(MINUTES.toLowerCase()) > 0|| timePattern.indexOf(MINUTES.toUpperCase()) > 0 ) {
+ return TOP_OF_MINUTE;
+ }
+ if ( timePattern.indexOf(HOURS) > 0 || timePattern.indexOf(HOURS.toLowerCase()) > 0|| timePattern.indexOf(HOURS.toUpperCase()) > 0 ) {
+ return TOP_OF_HOUR;
+ }
+ if ( timePattern.indexOf(DAYS) > 0 || timePattern.indexOf(DAYS.toLowerCase()) > 0|| timePattern.indexOf(DAYS.toUpperCase()) > 0 ) {
+ return TOP_OF_DAY;
+ }
+ if ( timePattern.indexOf(WEEKS) > 0 || timePattern.indexOf(WEEKS.toLowerCase()) > 0|| timePattern.indexOf(WEEKS.toUpperCase()) > 0 ) {
+ return TOP_OF_WEEK;
+ }
+ if ( timePattern.indexOf(MONTHS) > 0 || timePattern.indexOf(MONTHS.toLowerCase()) > 0|| timePattern.indexOf(MONTHS.toUpperCase()) > 0 ) {
+ return TOP_OF_MONTH;
+ }
+
+ return TOP_OF_TROUBLE;
+ }
+
+
+ private void printHdfsPeriodicity(int type, int offset) {
+ switch(type) {
+ case TOP_OF_MINUTE:
+ LogLog.debug("Appender [" + name + "] to be rolled every " + offset + " minute.");
+ break;
+ case TOP_OF_HOUR:
+ LogLog.debug("Appender [" + name + "] to be rolled on top of every " + offset + " hour.");
+ break;
+ case HALF_DAY:
+ LogLog.debug("Appender [" + name + "] to be rolled at midday and midnight.");
+ break;
+ case TOP_OF_DAY:
+ LogLog.debug("Appender [" + name + "] to be rolled on top of every " + offset + " day.");
+ break;
+ case TOP_OF_WEEK:
+ LogLog.debug("Appender [" + name + "] to be rolled on top of every " + offset + " week.");
+ break;
+ case TOP_OF_MONTH:
+ LogLog.debug("Appender [" + name + "] to be rolled at start of every " + offset + " month.");
+ break;
+ default:
+ LogLog.warn("Unknown periodicity for appender [" + name + "].");
+ }
+ }
+
+
+ public int getTimeOffset(String timePattern){
+ int index;
+ int offset=-1;
+
+ if ( (index = timePattern.indexOf(MINUTES)) > 0 || (index = timePattern.indexOf(MINUTES.toLowerCase())) > 0|| (index = timePattern.indexOf(MINUTES.toUpperCase())) > 0 ) {
+
+ offset = Integer.parseInt(timePattern.substring(0,index));
+
+ }
+ if ( (index = timePattern.indexOf(HOURS)) > 0 || (index =timePattern.indexOf(HOURS.toLowerCase())) > 0|| (index=timePattern.indexOf(HOURS.toUpperCase())) > 0 ) {
+ offset = Integer.parseInt(timePattern.substring(0,index));
+
+ }
+ if ( (index = timePattern.indexOf(DAYS)) > 0 || (index =timePattern.indexOf(DAYS.toLowerCase())) > 0|| (index=timePattern.indexOf(DAYS.toUpperCase())) > 0 ) {
+ offset = Integer.parseInt(timePattern.substring(0,index));
+
+ }
+
+ if ( (index = timePattern.indexOf(WEEKS)) > 0 || (index =timePattern.indexOf(WEEKS.toLowerCase())) > 0|| (index=timePattern.indexOf(WEEKS.toUpperCase())) > 0 ) {
+ offset = Integer.parseInt(timePattern.substring(0,index));
+
+ }
+
+ if ( (index = timePattern.indexOf(MONTHS)) > 0 || (index =timePattern.indexOf(MONTHS.toLowerCase())) > 0|| (index=timePattern.indexOf(MONTHS.toUpperCase())) > 0 ) {
+ offset = Integer.parseInt(timePattern.substring(0,index));
+
+ }
+
+ return offset;
+ }
+
+ private void printLocalPeriodicity(int type, int offset) {
+ switch(type) {
+ case TOP_OF_MINUTE:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled every " + offset + " minute.");
+ break;
+ case TOP_OF_HOUR:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled on top of every " + offset + " hour.");
+ break;
+ case HALF_DAY:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled at midday and midnight.");
+ break;
+ case TOP_OF_DAY:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled on top of every " + offset + " day.");
+ break;
+ case TOP_OF_WEEK:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled on top of every " + offset + " week.");
+ break;
+ case TOP_OF_MONTH:
+ LogLog.debug("Appender [" + name + "] Local File to be rolled at start of every " + offset + " month.");
+ break;
+ default:
+ LogLog.warn("Unknown periodicity for appender [" + name + "].");
+ }
+ }
+
+
+
+
+ /**
+ * Rollover the current file to a new file.
+ */
+ private void rollOver() throws IOException {
+ /* Compute filename, but only if hdfsFileRollingInterval is specified */
+ if(hdfsFileRollingInterval == null) {
+ errorHandler.error("Missing hdfsFileRollingInterval option in rollOver().");
+ return;
+ }
+
+ long epochNow = System.currentTimeMillis();
+ //String datedFilename = fileName + "." + epochNow;
+ //String datedhdfsFileName = hdfsfileName + "." + epochNow;
+
+ String datedFilename =fileName+sdf.format(epochNow);
+ String datedhdfsFileName = hdfsfileName+sdf.format(epochNow);
+
+ LogLog.debug("In rollOver epochNow" + epochNow + " " + "nextCheck: " + prevnextCheck );
+
+
+ // It is too early to roll over because we are still within the bounds of the current interval. Rollover will occur once the next interval is reached.
+
+ if (epochNow < prevnextCheck) {
+ return;
+ }
+
+ // close current file, and rename it to datedFilename
+ this.closeFile();
+
+ LogLog.debug("Rolling Over hdfs file to " + scheduledhdfsFileName);
+
+
+ if ( hdfsAvailable ) {
+ rollOverHdfsFile(scheduledhdfsFileName);
+ actualhdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
+ }
+
+ try {
+ // This will also close the file. This is OK since multiple close operations are safe.
+ this.setFile(fileName, false, this.bufferedIO, this.bufferSize);
+ } catch(IOException e) {
+ errorHandler.error("setFile(" + fileName + ", false) call failed.");
+ }
+ scheduledFilename = datedFilename;
+ scheduledhdfsFileName = datedhdfsFileName;
+
+ }
+
+
+ /**
+ * Rollover the current Local file to a new file.
+ */
+ private void rollOverLocal() throws IOException {
+ /* Compute filename, but only if datePattern is specified */
+ if(FileRollingInterval == null) {
+ errorHandler.error("Missing LocalDatePattern option in rollOverLocal().");
+ return;
+ }
+
+ long epochNow = System.currentTimeMillis();
+
+ //String datedCacheFileName = fileCache + "." + epochNow;
+ String datedCacheFileName = fileCache+sdf.format(epochNow);
+ LogLog.debug("In rollOverLocal() epochNow" + epochNow + " " + "nextCheckLocal: " + prevnextCheckLocal );
+
+ // It is too early to roll over because we are still within the bounds of the current interval. Rollover will occur once the next interval is reached.
+ if (epochNow < prevnextCheckLocal ) {
+ return;
+ }
+
+ if (new File(fileCache).length() != 0 ) {
+ LogLog.debug("Rolling Local cache to " + scheduledFileCache);
+
+ this.closeCacheWriter();
+
+ File target = new File(scheduledFileCache);
+ if (target.exists()) {
+ target.delete();
+ }
+
+ File file = new File(fileCache);
+
+ boolean result = file.renameTo(target);
+
+ if(result) {
+ LogLog.debug(fileCache +" -> "+ scheduledFileCache);
+ } else {
+ LogLog.error("Failed to rename cache file ["+fileCache+"] to ["+scheduledFileCache+"].");
+ }
+ setfileCacheWriter();
+ scheduledFileCache = datedCacheFileName;
+ }
+ }
+
+
+ /**
+ * <p>
+ * Sets and <i>opens</i> the file where the log output will go. The specified file must be writable.
+ * <p>
+ * If there was already an opened file, then the previous file is closed first.
+ * <p>
+ * <b>Do not use this method directly. To configure a FileAppender or one of its subclasses, set its properties one by one and then call
+ * activateOptions.</b>
+ *
+ * @param fileName The path to the log file.
+ * @param append If true will append to fileName. Otherwise will truncate fileName.
+ */
+ public void setFile(String file) {
+ // Trim spaces from both ends. The users probably does not want
+ // trailing spaces in file names.
+ String val = file.trim();
+
+ fileName = val;
+ fileCache=val+".cache";
+
+ }
+
+ @Override
+ public synchronized void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize) throws IOException {
+ LogLog.debug("setFile called: "+fileName+", "+append);
+
+ // It does not make sense to have immediate flush and bufferedIO.
+ if(bufferedIO) {
+ setImmediateFlush(false);
+ }
+
+ reset();
+
+ try {
+ //
+ // attempt to create file
+ //
+ ostream = new FileOutputStream(fileName, append);
+ } catch(FileNotFoundException ex) {
+ //
+ // if parent directory does not exist then
+ // attempt to create it and try to create file
+ // see bug 9150
+ //
+ File umFile = new File(fileName);
+ String parentName = umFile.getParent();
+
+ if (parentName != null) {
+ File parentDir = new File(parentName);
+ if(!parentDir.exists() && parentDir.mkdirs()) {
+ ostream = new FileOutputStream(fileName, append);
+ } else {
+ throw ex;
+ }
+ } else {
+ throw ex;
+ }
+ }
+
+ Writer fw = createWriter(ostream);
+ if(bufferedIO) {
+ fw = new BufferedWriter(fw, bufferSize);
+ }
+ this.setQWForFiles(fw);
+ this.fileName = fileName;
+ this.fileAppend = append;
+ this.bufferedIO = bufferedIO;
+ this.bufferSize = bufferSize;
+
+ //set cache file
+ setfileCacheWriter();
+
+ writeHeader();
+
+ LogLog.debug("setFile ended");
+ }
+
+ public void setHdfsDestination(final String name) {
+ //Setting the fileSystemname
+
+ String hostName = null;
+
+ String val = name.trim();
+
+ try {
+
+ hostName = InetAddress.getLocalHost().getHostName();
+ val=val.replaceAll("%hostname%", hostName);
+ String hostStr[] = val.split(":");
+ if ( hostStr.length > 0 ) {
+ fileSystemName = hostStr[0]+":"+hostStr[1]+":"+hostStr[2];
+
+ hdfsfileName = hostStr[3];
+
+ } else {
+ LogLog.error("Failed to set HdfsSystem and File");
+ }
+
+ } catch (UnknownHostException uhe) {
+ LogLog.error("Setting the Hdfs Desitination Failed", uhe);
+ }
+
+ LogLog.debug("FileSystemName:" + fileSystemName + "fileName:"+ hdfsfileName);
+
+ }
+
+ /**
+ * This method differentiates HdfsFileAppender from its super class.
+ * <p>
+ * Before actually logging, this method will check whether it is time to do a rollover. If it is, it will schedule the next rollover time and then rollover.
+ */
+ @Override
+ protected void subAppend(LoggingEvent event) {
+ LogLog.debug("Called subAppend for logging into hdfs...");
+
+ //String logPath = (String)event.getMDC(Log4jAuditProvider.MDC_VAR_LOG_RESOURCE_PATH) ;
+
+ //LogLog.debug("Log Path " + logPath);
+
+ /*
+ if (logPath.startsWith(fileName)) {
+ return ;
+ }
+ */
+ long n = System.currentTimeMillis();
+ if(n >= nextCheck) {
+ now.setTime(n);
+ prevnextCheck = nextCheck;
+ nextCheck = rc.getNextCheckMillis(now,hdfsFileRollOffset);
+ if ( firstTime) {
+ prevnextCheck = nextCheck;
+ firstTime = false;
+ }
+ try {
+ if (hdfsUpdateAllowed) {
+ rollOver();
+ }
+ } catch(IOException e) {
+ LogLog.error("rollOver() failed.", e);
+ }
+ }
+
+ long nLocal = System.currentTimeMillis();
+ if ( nLocal > nextCheckLocal ) {
+ nowLocal.setTime(nLocal);
+ prevnextCheckLocal = nextCheckLocal;
+ nextCheckLocal = rcLocal.getNextCheckMillis(nowLocal, FileRollOffset);
+ if ( firstTimeLocal) {
+ prevnextCheckLocal = nextCheckLocal;
+ firstTimeLocal = false;
+ }
+ try {
+ rollOverLocal();
+ } catch(IOException e) {
+ LogLog.error("rollOverLocal() failed.", e);
+ }
+ }
+
+ this.layout = this.getLayout();
+ this.encoding = this.getEncoding();
+
+ // Append HDFS
+ appendHDFSFileSystem(event);
+
+
+ //super.subAppend(event);
+ }
+
+ @Override
+ protected
+ void reset() {
+ closeWriter();
+ this.qw = null;
+ //this.
+ this.closehdfsWriter();
+ this.closeCacheWriter();
+ }
+
+ @Override
+ public synchronized void close() {
+ LogLog.debug("Closing all resource..");
+ this.closeFile();
+ this.closehdfsWriter();
+ this.closehdfsostream();
+ this.closeFileSystem();
+ }
+
+ @Override
+ protected void closeFile() {
+ try {
+ if(this.ostream != null) {
+ this.ostream.close();
+ this.ostream = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close output stream", ie);
+ }
+ this.closehdfsWriter();
+ this.closehdfsostream();
+ }
+
+ @Override
+ protected void closeWriter() {
+ try {
+ if(this.qw != null) {
+ this.qw.close();
+ this.qw = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close writer", ie);
+ }
+ }
+
+ @Override
+ public void finalize() {
+ super.finalize();
+ close();
+ }
+
+
+ /******* HDFS Appender methods ***********/
+
+ //private void appendHDFSFileSystem(String fileNameSystem, String filename, String fileCache,boolean append, boolean bufferedIO, int bufferSize, Layout layout, String encoding, LoggingEvent event, String scheduledFileCache, Writer cacheWriter,boolean hdfsUpdateAllowed ) {
+
+ private void appendHDFSFileSystem(LoggingEvent event) {
+
+ long currentTime = System.currentTimeMillis();
+
+ try {
+
+ if ( currentTime >= hdfsNextCheck ) {
+
+ LogLog.debug("About to Open fileSystem" + fileSystemName+" "+actualhdfsfileName) ;
+ hs = openHdfsSink(fileSystemName,actualhdfsfileName,fileCache,fileAppend,bufferedIO,bufferSize,layout,encoding,scheduledFileCache,cachewriter,hdfsUpdateAllowed,processUser);
+ if (hdfsUpdateAllowed) {
+ // stream into hdfs only when liveHdfsUpdate flag is true else write to cache file.
+ hs.setOsteam();
+ hs.setWriter();
+ hs.append(event);
+ } else {
+ writeToCache(event);
+ }
+ hdfsAvailable = true;
+
+ } else {
+ // Write the Log To cache file util time to check hdfs availability
+ hdfsAvailable = false;
+ LogLog.debug("Hdfs Down..Will check hdfs vailability after " + hdfsNextCheck + "Current Time :" +hdfsNextCheck ) ;
+ writeToCache(event);
+ }
+ }
+ catch(Throwable t) {
+ // Write the Log To cache file if hdfs connect error out.
+ hdfsAvailable = false;
+ if ( !timeCheck ) {
+ int hdfscheckInterval = getTimeOffset(hdfsCheckInterval);
+ hdfsNextCheck = System.currentTimeMillis()+(1000*60*hdfscheckInterval);
+ timeCheck = true;
+ LogLog.debug("Hdfs Down..Will check hdfs vailability after " + hdfsCheckInterval , t) ;
+
+ }
+ writeToCache(event);
+ }
+
+ //hs.closehdfsWriter();
+ //hs.closehdfsostream();
+ }
+
+
+ private HdfsSink openHdfsSink(String fileSystemName,String filename, String fileCache, boolean append, boolean bufferedIO,int bufferSize,Layout layout, String encoding, String scheduledCacheFile, Writer cacheWriter,boolean hdfsUpdateAllowed,String processUser) throws Throwable {
+
+ HdfsSink hs = null;
+ hs = HdfsSink.getInstance();
+ if ( hs != null)
+
+ LogLog.debug("Hdfs Sink successfully instatiated");
+ try {
+ hs.init(fileSystemName, filename, fileCache, append, bufferedIO, bufferSize, layout, encoding,scheduledCacheFile,cacheWriter,hdfsUpdateAllowed,processUser);
+
+ } catch (Throwable t) {
+ throw t;
+ }
+ return hs;
+
+ }
+
+ private void closehdfsostream() {
+ if (hs != null ){
+ LogLog.debug("Closing hdfs outstream") ;
+ hs.closehdfsostream();
+ }
+ }
+
+ private void closehdfsWriter() {
+
+ if (hs != null) {
+ LogLog.debug("Closing hdfs Writer") ;
+ hs.closehdfsWriter();
+ }
+ }
+
+ private void closeFileSystem() {
+ hs.closeHdfsSink();
+ }
+
+ private void rollOverHdfsFile(String scheduleHdfsFileName){
+ try {
+ // Rollover hdfs file.
+ hs.rollOverHdfsFile(scheduleHdfsFileName);
+ } catch (IOException ie) {
+ // TODO..what needs to happend if rollover of hdfs file fails.
+ LogLog.debug("Rollover of hdfs failed..") ;
+ }
+ }
+
+
+ /****** Cache File Methods **/
+
+
+ public void setfileCacheWriter() {
+
+ try {
+ setfileCacheOstream(fileCache);
+ } catch(IOException ie) {
+ LogLog.error("Logging failed while tring to write into Cache File..", ie);
+ }
+ LogLog.debug("Setting Cache Writer..");
+ cachewriter = createCacheFileWriter(cacheOstream);
+ if(bufferedIO) {
+ cachewriter = new BufferedWriter(cachewriter, bufferSize);
+ }
+ }
+
+
+ private void setfileCacheOstream(String fileCache) throws IOException {
+
+ try {
+ cacheOstream = new FileOutputStream(fileCache, true);
+ } catch(FileNotFoundException ex) {
+ String parentName = new File(fileCache).getParent();
+ if (parentName != null) {
+ File parentDir = new File(parentName);
+ if(!parentDir.exists() && parentDir.mkdirs()) {
+ cacheOstream = new FileOutputStream(fileName, true);
+ } else {
+ throw ex;
+ }
+ } else {
+ throw ex;
+ }
+ }
+ }
+
+
+ public OutputStreamWriter createCacheFileWriter(OutputStream os ) {
+ OutputStreamWriter retval = null;
+
+ if(encoding != null) {
+ try {
+ retval = new OutputStreamWriter(os, encoding);
+ } catch(IOException ie) {
+ LogLog.warn("Error initializing output writer.");
+ LogLog.warn("Unsupported encoding?");
+ }
+ }
+ if(retval == null) {
+ retval = new OutputStreamWriter(os);
+ }
+ return retval;
+ }
+
+
+ public void writeToCache(LoggingEvent event) {
+
+ try {
+ LogLog.debug("Writing log to Cache.." + "layout: "+ this.layout.format(event) + "ignoresThowable: "+layout.ignoresThrowable() + "Writer:" + cachewriter.toString());
+
+ cachewriter.write(this.layout.format(event));
+ cachewriter.flush();
+
+ if(layout.ignoresThrowable()) {
+ String[] s = event.getThrowableStrRep();
+ if (s != null) {
+ int len = s.length;
+ for(int i = 0; i < len; i++) {
+ LogLog.debug("Log:" + s[i]);
+ cachewriter.write(s[i]);
+ cachewriter.write(Layout.LINE_SEP);
+ cachewriter.flush();
+ }
+ }
+ }
+ } catch (IOException ie) {
+ LogLog.error("Unable to log event message to hdfs:", ie);
+ }
+ }
+
+ public void rollOverCacheFile() {
+
+ if (new File(fileCache).length() != 0 ) {
+
+ long epochNow = System.currentTimeMillis();
+
+ //String datedCacheFileName = fileCache + "." + epochNow;
+ String datedCacheFileName = fileCache + "." + epochNow;
+ LogLog.debug("Rolling over remaining cache File to new file"+ datedCacheFileName);
+ closeCacheWriter();
+
+ File target = new File(datedCacheFileName);
+ if (target.exists()) {
+ target.delete();
+ }
+
+ File file = new File(fileCache);
+
+ boolean result = file.renameTo(target);
+
+ if(result) {
+ LogLog.debug(fileCache +" -> "+ datedCacheFileName);
+ } else {
+ LogLog.error("Failed to rename cache file ["+fileCache+"] to ["+datedCacheFileName+"].");
+ }
+ }
+ }
+
+ public void closeCacheWriter() {
+ try {
+ if(cachewriter != null) {
+ cachewriter.close();
+ cachewriter = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close cache writer", ie);
+ }
+ }
+}
+
+/**
+ * RollingCalendar is a helper class to HdfsFileAppender. Given a periodicity type and the current time, it computes the start of the next interval.
+ */
+
+class RollingCalendar extends GregorianCalendar {
+ private static final long serialVersionUID = 1L;
+
+ private int type = HdfsFileAppender.TOP_OF_TROUBLE;
+
+ RollingCalendar() {
+ super();
+ }
+
+ RollingCalendar(TimeZone tz, Locale locale) {
+ super(tz, locale);
+ }
+
+ void setType(int type) {
+ this.type = type;
+ }
+
+ public long getNextCheckMillis(Date now, int offset) {
+ return getNextCheckDate(now,offset).getTime();
+ }
+
+ public Date getNextCheckDate(Date now,int offset) {
+ this.setTime(now);
+
+ switch(this.type) {
+ case HdfsFileAppender.TOP_OF_MINUTE:
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ this.add(Calendar.MINUTE, offset);
+ break;
+ case HdfsFileAppender.TOP_OF_HOUR:
+ this.set(Calendar.MINUTE, 0);
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ this.add(Calendar.HOUR_OF_DAY, offset);
+ break;
+ case HdfsFileAppender.HALF_DAY:
+ this.set(Calendar.MINUTE, 0);
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ int hour = get(Calendar.HOUR_OF_DAY);
+ if(hour < 12) {
+ this.set(Calendar.HOUR_OF_DAY, 12);
+ } else {
+ this.set(Calendar.HOUR_OF_DAY, 0);
+ this.add(Calendar.DAY_OF_MONTH, 1);
+ }
+ break;
+ case HdfsFileAppender.TOP_OF_DAY:
+ this.set(Calendar.HOUR_OF_DAY, 0);
+ this.set(Calendar.MINUTE, 0);
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ this.add(Calendar.DATE, offset);
+ break;
+ case HdfsFileAppender.TOP_OF_WEEK:
+ this.set(Calendar.DAY_OF_WEEK, getFirstDayOfWeek());
+ this.set(Calendar.HOUR_OF_DAY, 0);
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ this.add(Calendar.WEEK_OF_YEAR, offset);
+ break;
+ case HdfsFileAppender.TOP_OF_MONTH:
+ this.set(Calendar.DATE, 1);
+ this.set(Calendar.HOUR_OF_DAY, 0);
+ this.set(Calendar.SECOND, 0);
+ this.set(Calendar.MILLISECOND, 0);
+ this.add(Calendar.MONTH, offset);
+ break;
+ default:
+ throw new IllegalStateException("Unknown periodicity type.");
+ }
+ return getTime();
+ }
+
+
+}
+
+
+/*************
+ * Hdfs Sink
+ *
+ *************/
+
+class HdfsSink {
+
+ private Configuration conf = null;
+ private FileSystem fs= null;
+ private Path pt = null;
+ private FSDataOutputStream hdfsostream = null;
+ private String fsName = null;
+ private String fileName = null;
+ private String fileCache = null;
+ private Layout layout = null;
+ private String encoding = null;
+ private Writer hdfswriter = null;
+ private int bufferSize;
+ private boolean bufferedIO=false;
+ private static int fstime=0;
+ private CacheFileWatcher cfw = null;
+ private boolean hdfsUpdateAllowed=true;
+ private String scheduledCacheFile=null;
+ private String processUser=null;
+
+
+ HdfsSink() {
+ }
+
+ private static final ThreadLocal<HdfsSink> hdfssink = new ThreadLocal<HdfsSink>() {
+ protected HdfsSink initialValue() {
+ return new HdfsSink();
+ }
+ };
+
+ public static HdfsSink getInstance() {
+ return hdfssink.get();
+ }
+
+ public void init(String fileSystemName, String fileName, String fileCache,boolean append, boolean bufferedIO, int bufferSize, Layout layout, String encoding, String scheduledCacheFile, Writer cacheWriter, boolean hdfsUpdateAllowed, String processUser) throws IOException, InterruptedException{
+ this.conf= new Configuration();
+ this.fsName=fileSystemName;
+ this.fileName=fileName;
+ this.layout=layout;
+ this.encoding=encoding;
+ this.bufferSize=bufferSize;
+ this.bufferedIO=bufferedIO;
+ this.fileCache=fileCache;
+ this.hdfsUpdateAllowed=hdfsUpdateAllowed;
+ this.scheduledCacheFile=scheduledCacheFile;
+ this.processUser=processUser;
+
+ try {
+ conf.set("dfs.replication", "1");
+
+ if ( fs == null) {
+ LogLog.debug("Opening Connection to hdfs Sytem");
+
+ UserGroupInformation ugi = UserGroupInformation.createProxyUser(this.processUser, UserGroupInformation.getLoginUser());
+ ugi.doAs( new PrivilegedExceptionAction<Void>() {
+ public Void run() throws IOException {
+ fs = FileSystem.get(conf);
+ return null;
+ }
+ });
+
+ if ( cfw == null) {
+ // Start the CacheFileWatcher to move the Cache file.
+
+ LogLog.debug("About to run CacheFilWatcher...");
+ Path hdfsfilePath = getParent();
+ cfw = new CacheFileWatcher(this.fs,this.fileCache,hdfsfilePath,this.scheduledCacheFile,cacheWriter,this.hdfsUpdateAllowed,conf);
+ cfw.start();
+ }
+
+ }
+
+ } catch(IOException ie) {
+
+ LogLog.error("Unable to Create hdfs logfile:" + ie.getMessage());
+ throw ie;
+ }
+
+ LogLog.debug("HdfsSystem up: " + fsName + "FS Object:" + fs);
+ }
+
+ public int getfstime() {
+ return fstime;
+ }
+ public FileSystem getFileSystem() {
+ return fs;
+ }
+
+ public Path getPath() {
+ return pt;
+ }
+
+ public Path getParent() {
+ Path pt = new Path(this.fileName);
+ return pt.getParent();
+ }
+
+ public void setOsteam() throws IOException {
+ try {
+ pt = new Path(fileName);
+ // if file Exist append it
+ if(fs.exists(pt)) {
+ LogLog.debug("Appending File: "+ this.fsName+":"+this.fileName);
+ if (hdfsostream !=null) {
+ hdfsostream.close();
+ }
+ hdfsostream=fs.append(pt);
+
+ } else {
+
+ LogLog.debug("Creating File directories in hdfs if not present...");
+ String parentName = new Path(fileName).getParent().toString();
+ if(parentName != null) {
+ Path parentDir = new Path(parentName);
+ if (!fs.exists(parentDir) ) {
+ LogLog.debug("Creating Parent Directory: " + parentDir );
+ fs.mkdirs(parentDir);
+ }
+ }
+ hdfsostream = fs.create(pt);
+ }
+ } catch (IOException ie) {
+ LogLog.debug("Error While appending hdfsd file." + ie);
+ throw ie;
+ }
+ }
+
+ public void setWriter() {
+
+ LogLog.debug("Setting Writer..");
+ hdfswriter = createhdfsWriter(hdfsostream);
+ if(bufferedIO) {
+ hdfswriter = new BufferedWriter(hdfswriter, bufferSize);
+ }
+ }
+
+ public Writer getWriter() {
+ return hdfswriter;
+ }
+
+ public void append(LoggingEvent event) throws IOException {
+ try {
+ LogLog.debug("Writing log to HDFS." + "layout: "+ this.layout.format(event) + "ignoresThowable: "+layout.ignoresThrowable() + "Writer:" + hdfswriter.toString());
+
+ hdfswriter.write(this.layout.format(event));
+ hdfswriter.flush();
+ if(layout.ignoresThrowable()) {
+ String[] s = event.getThrowableStrRep();
+ if (s != null) {
+ int len = s.length;
+ for(int i = 0; i < len; i++) {
+ LogLog.debug("Log:" + s[i]);
+ hdfswriter.write(s[i]);
+ hdfswriter.write(Layout.LINE_SEP);
+ hdfswriter.flush();
+ }
+ }
+ }
+ } catch (IOException ie) {
+ LogLog.error("Unable to log event message to hdfs:", ie);
+ throw ie;
+ }
+ }
+
+ public void writeHeader() throws IOException {
+ LogLog.debug("Writing log header...");
+ try {
+ if(layout != null) {
+ String h = layout.getHeader();
+ if(h != null && hdfswriter != null)
+ LogLog.debug("Log header:" + h);
+ hdfswriter.write(h);
+ hdfswriter.flush();
+ }
+ } catch (IOException ie) {
+ LogLog.error("Unable to log header message to hdfs:", ie);
+ throw ie;
+ }
+ }
+
+ public
+ void writeFooter() throws IOException{
+ LogLog.debug("Writing footer header...");
+ try {
+ if(layout != null) {
+ String f = layout.getFooter();
+ if(f != null && hdfswriter != null) {
+ LogLog.debug("Log:" + f);
+ hdfswriter.write(f);
+ hdfswriter.flush();
+ }
+ }
+ } catch (IOException ie) {
+ LogLog.debug("Unable to log header message to hdfs:", ie);
+ throw ie;
+ }
+
+ }
+
+ public void closehdfsostream() {
+ try {
+ if(this.hdfsostream != null) {
+ this.hdfsostream.close();
+ this.hdfsostream = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close output stream", ie);
+ }
+
+ }
+
+ public void closehdfsWriter() {
+ try {
+ if(hdfswriter != null) {
+ hdfswriter.close();
+ hdfswriter = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to hfds writer", ie);
+ }
+ }
+
+ public void closeHdfsSink() {
+ try {
+ if (fs !=null) {
+ fs.close();
+ }
+ } catch (IOException ie) {
+ LogLog.error("Unable to close hdfs " + fs ,ie);
+ }
+ }
+
+
+ public OutputStreamWriter createhdfsWriter(FSDataOutputStream os ) {
+ OutputStreamWriter retval = null;
+
+ if(encoding != null) {
+ try {
+ retval = new OutputStreamWriter(os, encoding);
+ } catch(IOException ie) {
+ LogLog.warn("Error initializing output writer.");
+ LogLog.warn("Unsupported encoding?");
+ }
+ }
+ if(retval == null) {
+ retval = new OutputStreamWriter(os);
+ }
+ return retval;
+ }
+
+ public void rollOverHdfsFile(String scheduledHdfsFilename) throws IOException {
+
+ /* try {
+
+ Path target = new Path(scheduledHdfsFilename);
+ if(this.fs.exists(target)) {
+ this.fs.delete(target, true);
+ }
+
+ Path file = new Path(this.fileName);
+ boolean result = this.fs.rename(file, target);
+ if(result) {
+ LogLog.debug(fileName + " -> " + scheduledHdfsFilename);
+ } else {
+ LogLog.error("Failed to rename [" + fileName + "] to [" + scheduledHdfsFilename + "].");
+ }
+
+ }catch(IOException ie) {
+
+ LogLog.error("Unable to rollover hdfs file ",ie);
+ throw ie;
+ } */
+ }
+ }
+
+
+// CacheFileWatcher Thread
+
+class CacheFileWatcher extends Thread {
+ Configuration conf = null;
+ FileSystem fs = null;
+ String cacheFile = null;
+ File parentDir = null;
+ File[] files = null;
+ Path fsPath = null;
+ Path hdfsfilePath = null;
+ Writer cacheWriter = null;
+ String scheduledFileCache = null;
+ boolean hdfsUpdateAllowed=true;
+ boolean cacheFilesCopied = false;
+
+ CacheFileWatcher(FileSystem fs, String cacheFile, Path hdfsfilePath, String scheduledFileCache, Writer cacheWriter, boolean hdfsUpdateAllowed, Configuration conf) {
+ this.fs = fs;
+ this.cacheFile = cacheFile;
+ this.conf = conf;
+ this.hdfsfilePath = hdfsfilePath;
+ this.scheduledFileCache = scheduledFileCache;
+ this.cacheWriter = cacheWriter;
+ this.hdfsUpdateAllowed = hdfsUpdateAllowed;
+ }
+
+
+ public void run(){
+
+ LogLog.debug("CacheFileWatcher Started");
+
+
+ while (!cacheFilesCopied ){
+
+ if (hdfsUpdateAllowed) {
+ rollRemainingCacheFile();
+ }
+
+ if ( !cacheFilePresent(cacheFile) ) {
+
+
+ try {
+ Thread.sleep(1000*60*2);
+ } catch (InterruptedException ie) {
+ LogLog.error("Unable to complete the CatchFileWatcher Sleep", ie);
+ }
+ } else {
+ try {
+ copyCacheFilesToHdfs();
+ if (hdfsUpdateAllowed) {
+ cacheFilesCopied = true;
+ } else {
+ cacheFilesCopied = false;
+ }
+ } catch (Throwable t) {
+ // Error While copying the file to hdfs and thread goes for sleep and check later
+ cacheFilesCopied = false;
+ LogLog. error("Error while copying Cache Files to hdfs..Sleeping for next try",t);
+
+ try {
+ Thread.sleep(1000*60*2);
+ } catch (InterruptedException ie) {
+ LogLog.error("Unable to complete the CatchFileWatcher Sleep", ie);
+ }
+ }
+ }
+ }
+ }
+
+ public boolean cacheFilePresent(String filename) {
+ String parent = new File(filename).getParent();
+ if ( parent != null ) {
+ parentDir = new File(parent);
+ fsPath = new Path(parent);
+ files = parentDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File parentDir, String name) {
+ return name.matches(".*cache.+");
+ }
+ });
+ if ( files.length > 0) {
+ LogLog.debug("CacheFile Present..");
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public void copyCacheFilesToHdfs() throws Throwable{
+
+ try {
+
+ if (!fs.exists(hdfsfilePath) ) {
+ LogLog.debug("Creating Parent Directory: " + hdfsfilePath );
+ fs.mkdirs(hdfsfilePath);
+ }
+ } catch ( Throwable t) {
+ throw t;
+ }
+
+
+ for ( File cacheFile : files) {
+ try {
+ LogLog.debug("Copying Files..." + "File Path: " + fsPath + "CacheFile: " +cacheFile + "HDFS Path:" + hdfsfilePath);
+ FileUtil.copy(cacheFile, this.fs, this.hdfsfilePath, true, this.conf);
+ } catch (Throwable t) {
+
+ throw t;
+ }
+ }
+ }
+
+ public void rollRemainingCacheFile() {
+ String datePattern = "'.'yyyy-MM-dd-HH-mm";
+ SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
+ if (new File(cacheFile).length() != 0 ) {
+ long epochNow = System.currentTimeMillis();
+
+ //String datedCacheFileName = cacheFile + "." + epochNow;
+ String datedCacheFileName = cacheFile + sdf.format(epochNow);
+
+ LogLog.debug("Rolling over remaining cache File "+ datedCacheFileName);
+ closeCacheFile();
+
+ File target = new File(datedCacheFileName);
+ if (target.exists()) {
+ target.delete();
+ }
+
+ File file = new File(cacheFile);
+
+ boolean result = file.renameTo(target);
+
+ if(result) {
+ LogLog.debug(cacheFile +" -> "+ datedCacheFileName);
+ } else {
+ LogLog.error("Failed to rename cache file ["+cacheFile+"] to ["+datedCacheFileName+"].");
+ }
+
+ }
+ }
+
+ public void closeCacheFile() {
+ try {
+ if(cacheWriter != null) {
+ cacheWriter.close();
+ cacheWriter = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close cache writer", ie);
+ }
+ }
+}
+
+
[4/9] git commit: ARGUS-5
Posted by rm...@apache.org.
ARGUS-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/5c29ec20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/5c29ec20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/5c29ec20
Branch: refs/heads/master
Commit: 5c29ec203fab50f8a2ad037185bd89d7db33a7aa
Parents: 84c2244
Author: rmani <rm...@hortonworks.com>
Authored: Fri Sep 12 23:22:20 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Fri Sep 12 23:22:20 2014 -0700
----------------------------------------------------------------------
.../hadoop/log/HdfsFileAppender.java | 34 ++++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/5c29ec20/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
index 86a9bb1..1beb016 100644
--- a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
@@ -952,8 +952,7 @@ class HdfsSink {
private static final String DS_REPLICATION_VAL = "1";
private static final String DS_REPLICATION_KEY = "dfs.replication";
- private static final String FS_DEFAULT_NAME_KEY = "ds.default.name";
-
+ private static final String FS_DEFAULT_NAME_KEY = "fs.default.name";
private Configuration conf = null;
private FileSystem fs= null;
private Path pt = null;
@@ -985,8 +984,8 @@ class HdfsSink {
return hdfssink.get();
}
- public void init(String fileSystemName, String fileName, String fileCache,boolean append, boolean bufferedIO, int bufferSize, Layout layout, String encoding, String scheduledCacheFile, Writer cacheWriter, boolean hdfsUpdateAllowed, String processUser) throws IOException, InterruptedException{
- this.conf= new Configuration();
+ public void init(String fileSystemName, String fileName, String fileCache,boolean append, boolean bufferedIO, int bufferSize, Layout layout, String encoding, String scheduledCacheFile, Writer cacheWriter, boolean hdfsUpdateAllowed, String processUser) throws Exception{
+
this.fsName=fileSystemName;
this.fileName=fileName;
this.layout=layout;
@@ -996,20 +995,21 @@ class HdfsSink {
this.fileCache=fileCache;
this.hdfsUpdateAllowed=hdfsUpdateAllowed;
this.processUser=processUser;
-
+
+ final Configuration conf= new Configuration();
+ conf.set(DS_REPLICATION_KEY,DS_REPLICATION_VAL);
+ conf.set(FS_DEFAULT_NAME_KEY, fsName);
+
try {
-
- conf.set(DS_REPLICATION_KEY,DS_REPLICATION_VAL);
- conf.set(FS_DEFAULT_NAME_KEY, this.fsName);
-
- if ( fs == null) {
+ if ( fs == null) {
LogLog.debug("Opening Connection to hdfs Sytem" + this.fsName);
UserGroupInformation ugi = UserGroupInformation.createProxyUser(this.processUser, UserGroupInformation.getLoginUser());
- ugi.doAs( new PrivilegedExceptionAction<Void>() {
- public Void run() throws IOException {
- fs = FileSystem.get(conf);
- return null;
+ fs = ugi.doAs( new PrivilegedExceptionAction<FileSystem>() {
+ public FileSystem run() throws Exception {
+ FileSystem filesystem = FileSystem.get(conf);
+ LogLog.debug("Inside UGI.." + fsName + " " + filesystem);
+ return filesystem;
}
});
@@ -1024,7 +1024,7 @@ class HdfsSink {
}
- } catch(IOException ie) {
+ } catch(Exception ie) {
LogLog.error("Unable to Create hdfs logfile:" + ie.getMessage());
throw ie;
@@ -1054,14 +1054,14 @@ class HdfsSink {
pt = new Path(this.fileName);
// if file Exist append it
if(fs.exists(pt)) {
- LogLog.debug("Appending File: "+ this.fsName+":"+this.fileName);
+ LogLog.debug("Appending File: "+ this.fsName+":"+this.fileName+fs);
if (hdfsostream !=null) {
hdfsostream.close();
}
hdfsostream=fs.append(pt);
} else {
- LogLog.debug("Creating File directories in hdfs if not present.."+ this.fsName+":"+this.fileName);
+ LogLog.debug("Creating File directories in hdfs if not present.."+ this.fsName+":"+this.fileName + fs);
String parentName = new Path(this.fileName).getParent().toString();
if(parentName != null) {
Path parentDir = new Path(parentName);
[6/9] git commit: Argus-60
Posted by rm...@apache.org.
Argus-60
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/d34e0565
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/d34e0565
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/d34e0565
Branch: refs/heads/master
Commit: d34e05656568bb308f8b5f583409a0f333c328d5
Parents: a6f5be8
Author: rmani <rm...@hortonworks.com>
Authored: Wed Sep 17 11:13:51 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Wed Sep 17 11:13:51 2014 -0700
----------------------------------------------------------------------
hbase-agent/scripts/install.sh | 2 ++
hive-agent/scripts/install.sh | 2 ++
2 files changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/d34e0565/hbase-agent/scripts/install.sh
----------------------------------------------------------------------
diff --git a/hbase-agent/scripts/install.sh b/hbase-agent/scripts/install.sh
index cc34922..b4f99ed 100644
--- a/hbase-agent/scripts/install.sh
+++ b/hbase-agent/scripts/install.sh
@@ -223,6 +223,8 @@ ssltruststoreCred=`grep '^SSL_TRUSTSTORE_PASSWORD' ${install_dir}/install.proper
create_jceks ${ssltruststoreAlias} ${ssltruststoreCred} ${CredFile}
+chmod go+rx ${pardir}
+chmod go+r ${CredFile}
chown ${CONFIG_FILE_OWNER} ${CredFile}
PROP_ARGS="-p ${install_dir}/install.properties"
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/d34e0565/hive-agent/scripts/install.sh
----------------------------------------------------------------------
diff --git a/hive-agent/scripts/install.sh b/hive-agent/scripts/install.sh
index da16618..b9305d7 100644
--- a/hive-agent/scripts/install.sh
+++ b/hive-agent/scripts/install.sh
@@ -197,6 +197,8 @@ ssltruststoreCred=`grep '^SSL_TRUSTSTORE_PASSWORD' ${install_dir}/install.proper
create_jceks ${ssltruststoreAlias} ${ssltruststoreCred} ${CredFile}
+chmod go+rx ${pardir}
+chmod go+r ${CredFile}
chown ${CONFIG_FILE_OWNER} ${CredFile}
PROP_ARGS="-p ${install_dir}/install.properties"
[2/9] git commit: ARGUS-42
Posted by rm...@apache.org.
ARGUS-42
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/3272c005
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/3272c005
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/3272c005
Branch: refs/heads/master
Commit: 3272c005b3af021974e9f85cbc3e3e409d60c532
Parents: 2b0ee42
Author: rmani <rm...@hortonworks.com>
Authored: Thu Sep 11 16:44:58 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Thu Sep 11 16:44:58 2014 -0700
----------------------------------------------------------------------
.../java/com/xasecure/pdp/config/ConfigWatcher.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/3272c005/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
----------------------------------------------------------------------
diff --git a/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java b/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
index 449db16..e286cfb 100644
--- a/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
+++ b/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
@@ -260,7 +260,7 @@ public abstract class ConfigWatcher extends Thread {
if (response != null) {
- Boolean responsePresent = true;
+ boolean responsePresent = true;
int responseStatus = response.getStatus();
if ( fetchPolicyfromCahce(responsePresent,responseStatus,lastStoredFileName) ) {
@@ -277,6 +277,7 @@ public abstract class ConfigWatcher extends Thread {
policyContainer = newPolicyContainer;
lastModifiedTime = policyContainer.getLastUpdatedTimeInEpoc();
isChanged = true;
+ policyCacheLoadedOnce = false;
if (LOG.isDebugEnabled()) {
LOG.debug("Got response: 200 with {change in lastupdatedTime}\n" + gson.toJson(newPolicyContainer));
}
@@ -313,12 +314,14 @@ public abstract class ConfigWatcher extends Thread {
}
} catch (Throwable t) {
- Boolean responsePresent = false;
+ boolean responsePresent = false;
int responseStatus = -1;
-
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Policy Manager Failed",t);
+ }
if ( fetchPolicyfromCahce(responsePresent,responseStatus,lastStoredFileName) ) {
/* Successfully found the Policy Cache file and loaded */
- isChanged = true;
+ isChanged = false;
} else {
LOG.error("Unable to complete isFileChanged() call for [" + url + "]", t);
// force the policy update to get fresh copy
@@ -478,7 +481,7 @@ public abstract class ConfigWatcher extends Thread {
return agentName ;
}
- private boolean fetchPolicyfromCahce( Boolean responsePresent, int responseStatus, String lastStoredFileName){
+ private boolean fetchPolicyfromCahce( boolean responsePresent, int responseStatus, String lastStoredFileName){
boolean cacheFound = false;
@@ -509,7 +512,7 @@ public abstract class ConfigWatcher extends Thread {
policyCacheLoadedOnce = true;
} catch( FileNotFoundException fe ){
-
+
/* unable to get the last stored policy, raise warning for unavailability of policy cache file and continue...*/
if ( this.lastStoredFileName == null ) {
LOG.info("Policy cache file not found...XAagent authorization not enabled");
[7/9] git commit: Argus-59
Posted by rm...@apache.org.
Argus-59
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/3b7c7121
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/3b7c7121
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/3b7c7121
Branch: refs/heads/master
Commit: 3b7c71211a458fe809c3df55ab64ce61db2a3415
Parents: d34e056
Author: rmani <rm...@hortonworks.com>
Authored: Wed Sep 17 14:43:43 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Wed Sep 17 14:43:43 2014 -0700
----------------------------------------------------------------------
.../java/com/xasecure/audit/provider/Log4jAuditProvider.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/3b7c7121/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
index e9c7bd4..391053f 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
@@ -21,6 +21,8 @@ package com.xasecure.audit.provider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import com.xasecure.audit.model.AuditEventBase;
@@ -38,8 +40,9 @@ public class Log4jAuditProvider implements AuditProvider {
public void log(AuditEventBase event) {
if(! AUDITLOG.isInfoEnabled())
return;
-
- AUDITLOG.info(event.toString());
+ Gson gson= new GsonBuilder().setPrettyPrinting().create();
+ String eventAsJson = gson.toJson(event.toString()) ;
+ AUDITLOG.info(eventAsJson);
}
@Override
[9/9] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-argus.git
Posted by rm...@apache.org.
Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-argus.git
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/4eacc7a8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/4eacc7a8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/4eacc7a8
Branch: refs/heads/master
Commit: 4eacc7a8dcd8f473f45bee0b6819f2535597c3dc
Parents: 6d3618f a9a9599
Author: rmani <rm...@hortonworks.com>
Authored: Fri Sep 19 14:31:33 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Fri Sep 19 14:32:41 2014 -0700
----------------------------------------------------------------------
agents-audit/pom.xml | 1 +
.../java/com/xasecure/audit/dao/BaseDao.java | 29 +-
.../java/com/xasecure/audit/dao/DaoManager.java | 21 +-
.../audit/dao/XAHBaseAuditEventDao.java | 21 +-
.../xasecure/audit/dao/XAHdfsAuditEventDao.java | 21 +-
.../xasecure/audit/dao/XAHiveAuditEventDao.java | 21 +-
.../xasecure/audit/entity/XXBaseAuditEvent.java | 25 +-
.../audit/entity/XXBaseAuditEvent_.java | 21 +-
.../audit/entity/XXHBaseAuditEvent.java | 21 +-
.../audit/entity/XXHBaseAuditEvent_.java | 21 +-
.../xasecure/audit/entity/XXHdfsAuditEvent.java | 21 +-
.../audit/entity/XXHdfsAuditEvent_.java | 21 +-
.../xasecure/audit/entity/XXHiveAuditEvent.java | 21 +-
.../audit/entity/XXHiveAuditEvent_.java | 21 +-
.../xasecure/audit/model/AuditEventBase.java | 21 +-
.../audit/model/EnumRepositoryType.java | 21 +-
.../xasecure/audit/model/HBaseAuditEvent.java | 21 +-
.../xasecure/audit/model/HdfsAuditEvent.java | 21 +-
.../xasecure/audit/model/HiveAuditEvent.java | 21 +-
.../audit/provider/AsyncAuditProvider.java | 21 +-
.../audit/provider/DbAuditProvider.java | 2 +-
.../com/xasecure/audit/test/TestEvents.java | 21 +-
agents-common/pom.xml | 1 +
.../xasecure/admin/client/XaAdminClient.java | 21 +-
.../admin/client/XaAdminRESTClient.java | 21 +-
.../admin/client/datatype/GrantRevokeData.java | 35 +-
.../hadoop/config/XaSecureConfiguration.java | 25 +-
.../authorization/utils/StringUtil.java | 21 +-
agents-cred/pom.xml | 1 +
.../utils/XaSecureCredentialProvider.java | 21 +-
agents-impl/pom.xml | 1 +
.../pdp/config/Jersey2PolicyRefresher.java | 25 +-
.../pdp/config/PolicyChangeListener.java | 21 +-
.../pdp/config/gson/ExcludeSerialization.java | 21 +-
.../config/gson/PolicyExclusionStrategy.java | 21 +-
.../pdp/constants/XaSecureConstants.java | 21 +-
.../com/xasecure/pdp/hbase/HBaseAuthDB.java | 25 +-
.../com/xasecure/pdp/hbase/HBaseAuthRules.java | 25 +-
.../com/xasecure/pdp/hbase/URLBasedAuthDB.java | 25 +-
.../xasecure/pdp/hbase/XASecureAuthorizer.java | 25 +-
.../xasecure/pdp/hdfs/AdminPolicyChecker.java | 21 +-
.../com/xasecure/pdp/hdfs/URLBasedAuthDB.java | 25 +-
.../xasecure/pdp/hdfs/XASecureAuthorizer.java | 21 +-
.../java/com/xasecure/pdp/hive/HiveAuthDB.java | 25 +-
.../com/xasecure/pdp/hive/HiveAuthRule.java | 25 +-
.../pdp/hive/HiveAuthorizationProviderBase.java | 25 +-
.../com/xasecure/pdp/hive/URLBasedAuthDB.java | 25 +-
.../xasecure/pdp/hive/XASecureAuthorizer.java | 21 +-
.../java/com/xasecure/pdp/model/Policy.java | 21 +-
.../com/xasecure/pdp/model/PolicyContainer.java | 21 +-
.../com/xasecure/pdp/model/ResourcePath.java | 21 +-
.../com/xasecure/pdp/model/RolePermission.java | 21 +-
.../com/xasecure/pdp/storm/StormAuthRule.java | 21 +-
.../com/xasecure/pdp/storm/URLBasedAuthDB.java | 21 +-
.../xasecure/pdp/storm/XASecureAuthorizer.java | 21 +-
.../com/xasecure/pdp/utils/XaSecureUtils.java | 25 +-
agents-installer/pom.xml | 1 +
.../utils/install/XmlConfigChanger.java | 21 +-
credentialbuilder/pom.xml | 1 +
.../credentialapi/CredentialReader.java | 21 +-
.../com/hortonworks/credentialapi/buildks.java | 35 +-
embededwebserver/pom.xml | 1 +
.../xasecure/server/tomcat/EmbededServer.java | 67 +-
.../server/tomcat/StopEmbededServer.java | 21 +-
hbase-agent/conf/xasecure-audit-changes.cfg | 7 +-
hbase-agent/pom.xml | 1 +
hbase-agent/scripts/install.properties | 24 +-
hbase-agent/scripts/install.sh | 61 +-
.../com/xasecure/authorization/hbase/Crypt.java | 25 +-
.../hbase/HBaseAccessController.java | 25 +-
.../hbase/HBaseAccessControllerFactory.java | 25 +-
.../hbase/XaSecureAccessControlFilter.java | 25 +-
.../hbase/XaSecureAuthorizationCoprocessor.java | 61 +-
.../security/access/XaAccessControlLists.java | 7 +-
hdfs-agent/conf/xasecure-audit-changes.cfg | 3 +-
hdfs-agent/pom.xml | 1 +
hdfs-agent/scripts/install.properties | 24 +-
hdfs-agent/scripts/install.sh | 60 +-
.../hadoop/HDFSAccessVerifier.java | 25 +-
.../hadoop/HDFSAccessVerifierFactory.java | 25 +-
.../agent/AuthCodeInjectionJavaAgent.java | 25 +-
.../agent/HadoopAuthClassTransformer.java | 25 +-
.../XaSecureAccessControlException.java | 25 +-
.../namenode/XaSecureFSPermissionChecker.java | 25 +-
hive-agent/conf/xasecure-audit-changes.cfg | 5 +-
hive-agent/pom.xml | 1 +
hive-agent/scripts/install.properties | 25 +
hive-agent/scripts/install.sh | 54 ++
.../authorization/hive/XaHiveAccessContext.java | 21 +-
.../hive/XaHiveAccessVerifier.java | 21 +-
.../hive/XaHiveAccessVerifierFactory.java | 21 +-
.../hive/XaHiveObjectAccessInfo.java | 21 +-
.../hive/authorizer/XaSecureHiveAuthorizer.java | 37 +-
.../authorizer/XaSecureHiveAuthorizerBase.java | 21 +-
.../XaSecureHiveAuthorizerFactory.java | 21 +-
.../hive/constants/XaSecureHiveConstants.java | 21 +-
knox-agent/conf/xasecure-audit-changes.cfg | 5 +-
knox-agent/pom.xml | 1 +
knox-agent/scripts/install.properties | 24 +-
knox-agent/scripts/install.sh | 64 +-
lookup-client/pom.xml | 1 +
.../com/xasecure/hadoop/client/HadoopFS.java | 21 +-
.../xasecure/hadoop/client/HadoopFSTester.java | 21 +-
.../hadoop/client/config/BaseClient.java | 21 +-
.../hadoop/client/config/HadoopClassLoader.java | 21 +-
.../client/config/HadoopConfigHolder.java | 21 +-
.../client/exceptions/HadoopException.java | 21 +-
.../com/xasecure/hbase/client/HBaseClient.java | 21 +-
.../hbase/client/HBaseClientTester.java | 21 +-
.../com/xasecure/hive/client/HiveClient.java | 21 +-
.../xasecure/hive/client/HiveClientTester.java | 21 +-
.../com/xasecure/storm/client/StormClient.java | 223 +++++
.../storm/client/json/model/Topology.java | 47 ++
.../client/json/model/TopologyListResponse.java | 38 +
.../security/KrbPasswordSaverLoginModule.java | 21 +-
.../hadoop/security/SecureClientLogin.java | 25 +-
pom.xml | 1 +
.../db/oracle/create_dbversion_catalog.sql | 10 +
.../db/oracle/patches/001-groupsource.sql | 14 +
.../db/oracle/patches/002-policyname.sql | 14 +
.../db/oracle/patches/003-knoxrepo.sql | 34 +
.../patches/006-createdefaultpublicgroup.sql | 14 +
security-admin/db/oracle/xa_audit_db_oracle.sql | 88 ++
security-admin/db/oracle/xa_core_db_oracle.sql | 563 +++++++++++++
.../db/patches/007-updateBlankPolicyName.sql | 171 ++++
.../db/patches/008-removeTrailingSlash.sql | 129 +++
security-admin/pom.xml | 7 +-
security-admin/scripts/install.properties | 41 +-
security-admin/scripts/install.sh | 820 +++++++++++++++----
.../unix/jaas/RoleUserAuthorityGranter.java | 21 +-
.../com/xasecure/biz/AssetConnectionMgr.java | 54 +-
.../main/java/com/xasecure/biz/AssetMgr.java | 128 ++-
.../java/com/xasecure/biz/AssetMgrBase.java | 27 +-
.../src/main/java/com/xasecure/biz/BaseMgr.java | 21 +-
.../main/java/com/xasecure/biz/HadoopFSMgr.java | 21 +-
.../main/java/com/xasecure/biz/HiveFSMgr.java | 21 +-
.../main/java/com/xasecure/biz/SessionMgr.java | 21 +-
.../src/main/java/com/xasecure/biz/UserMgr.java | 21 +-
.../main/java/com/xasecure/biz/UserMgrBase.java | 27 +-
.../main/java/com/xasecure/biz/XABizUtil.java | 576 +++----------
.../main/java/com/xasecure/biz/XAuditMgr.java | 21 +-
.../java/com/xasecure/biz/XAuditMgrBase.java | 27 +-
.../main/java/com/xasecure/biz/XUserMgr.java | 21 +-
.../java/com/xasecure/biz/XUserMgrBase.java | 27 +-
.../java/com/xasecure/common/AppConstants.java | 33 +-
.../java/com/xasecure/common/ContextUtil.java | 21 +-
.../main/java/com/xasecure/common/DateUtil.java | 21 +-
.../com/xasecure/common/ErrorMessageUtil.java | 21 +-
.../main/java/com/xasecure/common/GUIDUtil.java | 21 +-
.../main/java/com/xasecure/common/HTTPUtil.java | 21 +-
.../main/java/com/xasecure/common/JSONUtil.java | 21 +-
.../java/com/xasecure/common/MessageEnums.java | 21 +-
.../java/com/xasecure/common/MyCallBack.java | 21 +-
.../java/com/xasecure/common/PasswordUtils.java | 143 ++++
.../com/xasecure/common/PropertiesUtil.java | 21 +-
.../java/com/xasecure/common/RESTErrorUtil.java | 21 +-
.../com/xasecure/common/RequestContext.java | 21 +-
.../com/xasecure/common/SearchCriteria.java | 21 +-
.../java/com/xasecure/common/SearchField.java | 21 +-
.../java/com/xasecure/common/SearchGroup.java | 21 +-
.../java/com/xasecure/common/SearchUtil.java | 25 +-
.../java/com/xasecure/common/SearchValue.java | 21 +-
.../java/com/xasecure/common/SortField.java | 21 +-
.../java/com/xasecure/common/StringUtil.java | 26 +-
.../com/xasecure/common/TimedEventUtil.java | 21 +-
.../com/xasecure/common/UserSessionBase.java | 21 +-
.../java/com/xasecure/common/XACommonEnums.java | 27 +-
.../java/com/xasecure/common/XAConfigUtil.java | 21 +-
.../java/com/xasecure/common/XAConstants.java | 21 +-
.../xasecure/common/XAJAXBContextResolver.java | 21 +-
.../java/com/xasecure/common/XASearchUtil.java | 21 +-
.../annotation/XAAnnotationClassName.java | 21 +-
.../annotation/XAAnnotationJSMgrName.java | 21 +-
.../common/annotation/XAAnnotationRestAPI.java | 21 +-
.../java/com/xasecure/common/db/BaseDao.java | 46 +-
.../xasecure/common/db/JPABeanCallbacks.java | 21 +-
.../java/com/xasecure/common/view/VEnum.java | 21 +-
.../com/xasecure/common/view/VEnumElement.java | 21 +-
.../java/com/xasecure/common/view/VList.java | 29 +-
.../com/xasecure/common/view/VTrxLogAttr.java | 21 +-
.../com/xasecure/common/view/ViewBaseBean.java | 21 +-
.../credentialapi/CredentialReader.java | 21 +-
.../main/java/com/xasecure/db/XADaoManager.java | 29 +-
.../java/com/xasecure/db/XADaoManagerBase.java | 27 +-
.../java/com/xasecure/db/XXAccessAuditDao.java | 27 +-
.../main/java/com/xasecure/db/XXAssetDao.java | 27 +-
.../java/com/xasecure/db/XXAuditMapDao.java | 27 +-
.../java/com/xasecure/db/XXAuthSessionDao.java | 27 +-
.../com/xasecure/db/XXCredentialStoreDao.java | 27 +-
.../main/java/com/xasecure/db/XXDBBaseDao.java | 27 +-
.../main/java/com/xasecure/db/XXGroupDao.java | 31 +-
.../java/com/xasecure/db/XXGroupGroupDao.java | 27 +-
.../java/com/xasecure/db/XXGroupUserDao.java | 29 +-
.../main/java/com/xasecure/db/XXPermMapDao.java | 27 +-
.../com/xasecure/db/XXPolicyExportAuditDao.java | 27 +-
.../java/com/xasecure/db/XXPortalUserDao.java | 33 +-
.../com/xasecure/db/XXPortalUserRoleDao.java | 29 +-
.../java/com/xasecure/db/XXResourceDao.java | 29 +-
.../main/java/com/xasecure/db/XXTrxLogDao.java | 27 +-
.../main/java/com/xasecure/db/XXUserDao.java | 31 +-
.../java/com/xasecure/entity/XXAccessAudit.java | 41 +-
.../main/java/com/xasecure/entity/XXAsset.java | 41 +-
.../java/com/xasecure/entity/XXAuditMap.java | 41 +-
.../java/com/xasecure/entity/XXAuthSession.java | 41 +-
.../com/xasecure/entity/XXCredentialStore.java | 41 +-
.../main/java/com/xasecure/entity/XXDBBase.java | 49 +-
.../main/java/com/xasecure/entity/XXGroup.java | 42 +-
.../java/com/xasecure/entity/XXGroupGroup.java | 42 +-
.../java/com/xasecure/entity/XXGroupUser.java | 41 +-
.../java/com/xasecure/entity/XXPermMap.java | 41 +-
.../xasecure/entity/XXPolicyExportAudit.java | 41 +-
.../java/com/xasecure/entity/XXPortalUser.java | 44 +-
.../com/xasecure/entity/XXPortalUserRole.java | 41 +-
.../java/com/xasecure/entity/XXResource.java | 41 +-
.../main/java/com/xasecure/entity/XXTrxLog.java | 42 +-
.../main/java/com/xasecure/entity/XXUser.java | 41 +-
.../com/xasecure/entity/view/VXXTrxLog.java | 32 +-
.../src/main/java/com/xasecure/json/Folder.java | 21 +-
.../com/xasecure/json/JsonDateSerializer.java | 21 +-
.../java/com/xasecure/patch/BaseLoader.java | 21 +-
.../patch/PatchPasswordEncryption_J10001.java | 84 ++
.../main/java/com/xasecure/rest/AssetREST.java | 42 +-
.../main/java/com/xasecure/rest/PublicAPIs.java | 74 +-
.../main/java/com/xasecure/rest/UserREST.java | 21 +-
.../main/java/com/xasecure/rest/XAuditREST.java | 21 +-
.../main/java/com/xasecure/rest/XUserREST.java | 21 +-
.../security/context/XAContextHolder.java | 21 +-
.../security/context/XASecurityContext.java | 21 +-
.../xasecure/security/handler/Permission.java | 21 +-
.../handler/XADomainObjectSecurityHandler.java | 21 +-
.../security/listener/SpringEventListener.java | 21 +-
.../standalone/StandaloneSecurityHandler.java | 21 +-
.../CustomLogoutSuccessHandler.java | 21 +-
.../authentication/XAAuthFailureHandler.java | 21 +-
.../authentication/XAAuthSuccessHandler.java | 21 +-
.../XAAuthenticationEntryPoint.java | 21 +-
.../security/web/filter/MyRememberMeFilter.java | 21 +-
.../XASecurityContextFormationFilter.java | 21 +-
.../XAUsernamePasswordAuthenticationFilter.java | 21 +-
.../service/AbstractBaseResourceService.java | 24 +-
.../xasecure/service/AuthSessionService.java | 21 +-
.../xasecure/service/PublicAPIServiceBase.java | 21 +-
.../java/com/xasecure/service/UserService.java | 21 +-
.../com/xasecure/service/UserServiceBase.java | 27 +-
.../xasecure/service/XAccessAuditService.java | 21 +-
.../service/XAccessAuditServiceBase.java | 27 +-
.../com/xasecure/service/XAgentService.java | 21 +-
.../com/xasecure/service/XAssetService.java | 95 ++-
.../com/xasecure/service/XAssetServiceBase.java | 27 +-
.../com/xasecure/service/XAuditMapService.java | 21 +-
.../xasecure/service/XAuditMapServiceBase.java | 27 +-
.../service/XCredentialStoreService.java | 21 +-
.../service/XCredentialStoreServiceBase.java | 27 +-
.../xasecure/service/XGroupGroupService.java | 21 +-
.../service/XGroupGroupServiceBase.java | 27 +-
.../com/xasecure/service/XGroupService.java | 21 +-
.../com/xasecure/service/XGroupServiceBase.java | 27 +-
.../com/xasecure/service/XGroupUserService.java | 21 +-
.../xasecure/service/XGroupUserServiceBase.java | 27 +-
.../com/xasecure/service/XPermMapService.java | 21 +-
.../xasecure/service/XPermMapServiceBase.java | 27 +-
.../service/XPolicyExportAuditService.java | 21 +-
.../service/XPolicyExportAuditServiceBase.java | 27 +-
.../com/xasecure/service/XPolicyService.java | 107 ++-
.../xasecure/service/XPortalUserService.java | 21 +-
.../service/XPortalUserServiceBase.java | 27 +-
.../xasecure/service/XRepositoryService.java | 36 +-
.../com/xasecure/service/XResourceService.java | 26 +-
.../xasecure/service/XResourceServiceBase.java | 27 +-
.../com/xasecure/service/XTrxLogService.java | 21 +-
.../xasecure/service/XTrxLogServiceBase.java | 27 +-
.../java/com/xasecure/service/XUserService.java | 21 +-
.../com/xasecure/service/XUserServiceBase.java | 27 +-
.../service/filter/XARESTAPIFilter.java | 21 +-
.../main/java/com/xasecure/util/CLIUtil.java | 21 +-
.../main/java/com/xasecure/util/RestUtil.java | 21 +-
.../main/java/com/xasecure/util/XAEnumUtil.java | 45 +-
.../main/java/com/xasecure/util/XARestUtil.java | 21 +-
.../java/com/xasecure/view/VXAccessAudit.java | 27 +-
.../com/xasecure/view/VXAccessAuditList.java | 27 +-
.../main/java/com/xasecure/view/VXAsset.java | 27 +-
.../java/com/xasecure/view/VXAssetList.java | 27 +-
.../main/java/com/xasecure/view/VXAuditMap.java | 27 +-
.../java/com/xasecure/view/VXAuditMapList.java | 27 +-
.../java/com/xasecure/view/VXAuditRecord.java | 21 +-
.../com/xasecure/view/VXAuditRecordList.java | 21 +-
.../java/com/xasecure/view/VXAuthSession.java | 27 +-
.../com/xasecure/view/VXAuthSessionList.java | 27 +-
.../com/xasecure/view/VXCredentialStore.java | 27 +-
.../xasecure/view/VXCredentialStoreList.java | 27 +-
.../java/com/xasecure/view/VXDataObject.java | 27 +-
.../main/java/com/xasecure/view/VXGroup.java | 27 +-
.../java/com/xasecure/view/VXGroupGroup.java | 27 +-
.../com/xasecure/view/VXGroupGroupList.java | 27 +-
.../java/com/xasecure/view/VXGroupList.java | 27 +-
.../java/com/xasecure/view/VXGroupUser.java | 27 +-
.../java/com/xasecure/view/VXGroupUserList.java | 27 +-
.../src/main/java/com/xasecure/view/VXLong.java | 27 +-
.../main/java/com/xasecure/view/VXMessage.java | 27 +-
.../com/xasecure/view/VXPasswordChange.java | 27 +-
.../main/java/com/xasecure/view/VXPermMap.java | 27 +-
.../java/com/xasecure/view/VXPermMapList.java | 27 +-
.../main/java/com/xasecure/view/VXPermObj.java | 29 +-
.../java/com/xasecure/view/VXPermObjList.java | 29 +-
.../main/java/com/xasecure/view/VXPolicy.java | 29 +-
.../com/xasecure/view/VXPolicyExportAudit.java | 27 +-
.../xasecure/view/VXPolicyExportAuditList.java | 27 +-
.../java/com/xasecure/view/VXPolicyList.java | 29 +-
.../java/com/xasecure/view/VXPortalUser.java | 27 +-
.../com/xasecure/view/VXPortalUserList.java | 27 +-
.../java/com/xasecure/view/VXRepository.java | 29 +-
.../com/xasecure/view/VXRepositoryList.java | 29 +-
.../main/java/com/xasecure/view/VXResource.java | 27 +-
.../java/com/xasecure/view/VXResourceList.java | 27 +-
.../main/java/com/xasecure/view/VXResponse.java | 27 +-
.../main/java/com/xasecure/view/VXString.java | 27 +-
.../java/com/xasecure/view/VXStringList.java | 27 +-
.../main/java/com/xasecure/view/VXTrxLog.java | 27 +-
.../java/com/xasecure/view/VXTrxLogList.java | 27 +-
.../src/main/java/com/xasecure/view/VXUser.java | 27 +-
.../main/java/com/xasecure/view/VXUserList.java | 27 +-
.../src/main/webapp/copyrightPluginList.html | 2 +-
security-admin/src/main/webapp/images/logo.png | Bin 0 -> 4160 bytes
security-admin/src/main/webapp/index.html | 4 +-
security-admin/src/main/webapp/login.jsp | 6 +-
security-admin/src/main/webapp/scripts/App.js | 25 +-
security-admin/src/main/webapp/scripts/Init.js | 21 +-
security-admin/src/main/webapp/scripts/Main.js | 21 +-
.../src/main/webapp/scripts/RegionManager.js | 21 +-
.../collection_bases/VXAccessAuditListBase.js | 25 +-
.../scripts/collection_bases/VXAssetListBase.js | 25 +-
.../collection_bases/VXAuditMapListBase.js | 25 +-
.../collection_bases/VXAuditRecordListBase.js | 25 +-
.../collection_bases/VXAuthSessionListBase.js | 25 +-
.../scripts/collection_bases/VXGroupListBase.js | 25 +-
.../collection_bases/VXPermMapListBase.js | 25 +-
.../VXPolicyExportAuditListBase.js | 25 +-
.../collection_bases/VXPortalUserListBase.js | 25 +-
.../collection_bases/VXResourceListBase.js | 25 +-
.../collection_bases/VXTrxLogListBase.js | 25 +-
.../scripts/collection_bases/VXUserListBase.js | 25 +-
.../scripts/collections/VXAccessAuditList.js | 25 +-
.../webapp/scripts/collections/VXAssetList.js | 25 +-
.../scripts/collections/VXAuditMapList.js | 25 +-
.../scripts/collections/VXAuditRecordList.js | 25 +-
.../scripts/collections/VXAuthSessionList.js | 25 +-
.../webapp/scripts/collections/VXGroupList.js | 25 +-
.../webapp/scripts/collections/VXPermMapList.js | 25 +-
.../collections/VXPolicyExportAuditList.js | 25 +-
.../scripts/collections/VXPortalUserList.js | 25 +-
.../scripts/collections/VXResourceList.js | 25 +-
.../webapp/scripts/collections/VXTrxLogList.js | 25 +-
.../webapp/scripts/collections/VXUserList.js | 25 +-
.../scripts/collections/XABaseCollection.js | 25 +-
.../src/main/webapp/scripts/communicator.js | 21 +-
.../webapp/scripts/controllers/Controller.js | 25 +-
.../src/main/webapp/scripts/mgrs/SessionMgr.js | 25 +-
.../scripts/model_bases/VXAccessAuditBase.js | 25 +-
.../webapp/scripts/model_bases/VXAssetBase.js | 25 +-
.../scripts/model_bases/VXAuditMapBase.js | 25 +-
.../scripts/model_bases/VXAuditRecordBase.js | 25 +-
.../scripts/model_bases/VXAuthSessionBase.js | 25 +-
.../webapp/scripts/model_bases/VXGroupBase.js | 25 +-
.../scripts/model_bases/VXPasswordChangeBase.js | 25 +-
.../webapp/scripts/model_bases/VXPermMapBase.js | 25 +-
.../model_bases/VXPolicyExportAuditBase.js | 25 +-
.../scripts/model_bases/VXPortalUserBase.js | 25 +-
.../scripts/model_bases/VXResourceBase.js | 25 +-
.../webapp/scripts/model_bases/VXTrxLogBase.js | 25 +-
.../webapp/scripts/model_bases/VXUserBase.js | 25 +-
.../src/main/webapp/scripts/models/VAppState.js | 29 +-
.../main/webapp/scripts/models/VXAccessAudit.js | 25 +-
.../src/main/webapp/scripts/models/VXAsset.js | 25 +-
.../main/webapp/scripts/models/VXAuditMap.js | 25 +-
.../main/webapp/scripts/models/VXAuditRecord.js | 25 +-
.../main/webapp/scripts/models/VXAuthSession.js | 25 +-
.../src/main/webapp/scripts/models/VXGroup.js | 25 +-
.../webapp/scripts/models/VXPasswordChange.js | 25 +-
.../src/main/webapp/scripts/models/VXPermMap.js | 25 +-
.../scripts/models/VXPolicyExportAudit.js | 25 +-
.../main/webapp/scripts/models/VXPortalUser.js | 31 +-
.../main/webapp/scripts/models/VXResource.js | 25 +-
.../src/main/webapp/scripts/models/VXTrxLog.js | 25 +-
.../src/main/webapp/scripts/models/VXUser.js | 25 +-
.../main/webapp/scripts/models/XABaseModel.js | 25 +-
.../src/main/webapp/scripts/modules/Vent.js | 19 +
.../src/main/webapp/scripts/modules/XALinks.js | 32 +-
.../main/webapp/scripts/modules/XAOverrides.js | 21 +-
.../scripts/modules/globalize/message/en.js | 27 +-
.../main/webapp/scripts/prelogin/XAPrelogin.js | 19 +
.../src/main/webapp/scripts/routers/Router.js | 21 +-
.../src/main/webapp/scripts/utils/XAEnums.js | 25 +-
.../src/main/webapp/scripts/utils/XAGlobals.js | 25 +-
.../main/webapp/scripts/utils/XALangSupport.js | 21 +-
.../webapp/scripts/utils/XATemplateHelpers.js | 25 +-
.../src/main/webapp/scripts/utils/XAUtils.js | 49 +-
.../main/webapp/scripts/utils/XAViewUtils.js | 25 +-
.../scripts/views/accounts/AccountCreate.js | 25 +-
.../views/accounts/AccountDetailLayout.js | 25 +-
.../scripts/views/accounts/AccountForm.js | 25 +-
.../views/accounts/AccountTableLayout.js | 25 +-
.../webapp/scripts/views/asset/AssetCreate.js | 25 +-
.../webapp/scripts/views/asset/AssetForm.js | 25 +-
.../scripts/views/asset/AssetTableLayout.js | 25 +-
.../webapp/scripts/views/common/AddGroup.js | 25 +-
.../webapp/scripts/views/common/BreadCrumbs.js | 21 +-
.../scripts/views/common/DashboardLayout.js | 25 +-
.../webapp/scripts/views/common/ErrorView.js | 25 +-
.../main/webapp/scripts/views/common/Footer.js | 25 +-
.../scripts/views/common/FormInputItemList.js | 19 +
.../webapp/scripts/views/common/ProfileBar.js | 25 +-
.../main/webapp/scripts/views/common/Spinner.js | 25 +-
.../main/webapp/scripts/views/common/TopNav.js | 25 +-
.../scripts/views/common/UserPermissionList.js | 19 +
.../webapp/scripts/views/common/XABackgrid.js | 25 +-
.../scripts/views/common/XATableLayout.js | 25 +-
.../webapp/scripts/views/folders/FolderInfo.js | 25 +-
.../scripts/views/hbase/HbasePolicyCreate.js | 29 +-
.../scripts/views/hbase/HbasePolicyForm.js | 33 +-
.../scripts/views/hbase/HbaseTableLayout.js | 32 +-
.../scripts/views/hdfs/HDFSTableLayout.js | 32 +-
.../scripts/views/hive/HivePolicyCreate.js | 29 +-
.../webapp/scripts/views/hive/HivePolicyForm.js | 25 +-
.../scripts/views/hive/HiveTableLayout.js | 32 +-
.../scripts/views/knox/KnoxPolicyCreate.js | 29 +-
.../webapp/scripts/views/knox/KnoxPolicyForm.js | 25 +-
.../scripts/views/knox/KnoxTableLayout.js | 32 +-
.../webapp/scripts/views/policy/PolicyCreate.js | 29 +-
.../webapp/scripts/views/policy/PolicyForm.js | 25 +-
.../views/policymanager/PolicyManagerLayout.js | 25 +-
.../webapp/scripts/views/reports/AuditLayout.js | 25 +-
.../scripts/views/reports/LoginSessionDetail.js | 25 +-
.../views/reports/OperationDiffDetail.js | 25 +-
.../scripts/views/reports/UserAccessLayout.js | 25 +-
.../scripts/views/storm/StormPolicyCreate.js | 33 +-
.../scripts/views/storm/StormPolicyForm.js | 27 +-
.../scripts/views/storm/StormTableLayout.js | 36 +-
.../webapp/scripts/views/user/UserProfile.js | 25 +-
.../scripts/views/user/UserProfileForm.js | 27 +-
.../webapp/scripts/views/users/GroupCreate.js | 25 +-
.../webapp/scripts/views/users/GroupForm.js | 25 +-
.../webapp/scripts/views/users/UserCreate.js | 25 +-
.../main/webapp/scripts/views/users/UserForm.js | 31 +-
.../main/webapp/scripts/views/users/UserInfo.js | 25 +-
.../scripts/views/users/UserTableLayout.js | 37 +-
security-admin/src/main/webapp/styles/xa.css | 12 +-
.../webapp/templates/common/Footer_tmpl.html | 2 +-
.../templates/hbase/HbasePolicyCreate_tmpl.html | 5 +-
.../templates/hbase/HbasePolicyForm_tmpl.html | 5 +-
.../templates/hbase/HbaseTableLayout_tmpl.html | 6 +-
.../templates/hdfs/HDFSTableLayout_tmpl.html | 8 +-
.../templates/hdfs/PolicyCreate_tmpl.html | 4 +
.../webapp/templates/hdfs/PolicyForm_tmpl.html | 5 +-
.../main/webapp/templates/helpers/XAHelpers.js | 21 +-
.../templates/hive/HivePolicyCreate_tmpl.html | 5 +-
.../templates/hive/HivePolicyForm_tmpl.html | 5 +-
.../templates/hive/HiveTableLayout_tmpl.html | 6 +-
.../templates/knox/KnoxPolicyCreate_tmpl.html | 5 +-
.../templates/knox/KnoxPolicyForm_tmpl.html | 5 +-
.../templates/knox/KnoxTableLayout_tmpl.html | 6 +-
.../templates/storm/StormPolicyCreate_tmpl.html | 5 +-
.../templates/storm/StormPolicyForm_tmpl.html | 5 +-
.../templates/storm/StormTableLayout_tmpl.html | 6 +-
.../templates/users/UserTableLayout_tmpl.html | 6 +-
.../java/com/xasecure/rest/TestPublicAPIs.java | 21 +-
.../test/java/com/xasecure/util/BaseTest.java | 21 +-
src/main/assembly/admin-web.xml | 1 +
src/main/assembly/hbase-agent.xml | 1 +
src/main/assembly/hdfs-agent.xml | 1 +
src/main/assembly/hive-agent.xml | 1 +
src/main/assembly/knox-agent.xml | 58 +-
src/main/assembly/storm-agent.xml | 1 +
src/main/assembly/usersync.xml | 1 +
storm-agent/conf/xasecure-audit-changes.cfg | 3 +-
storm-agent/pom.xml | 1 +
storm-agent/scripts/install.properties | 23 +-
storm-agent/scripts/install.sh | 63 +-
.../storm/XaStormAccessVerifier.java | 21 +-
.../storm/XaStormAccessVerifierFactory.java | 21 +-
.../authorizer/XaSecureStormAuthorizer.java | 21 +-
ugsync/pom.xml | 1 +
.../process/LdapUserGroupBuilder.java | 21 +-
.../process/PolicyMgrUserGroupBuilder.java | 21 +-
.../config/UserGroupSyncConfig.java | 21 +-
.../model/GetXGroupListResponse.java | 21 +-
.../model/GetXUserGroupListResponse.java | 21 +-
.../model/GetXUserListResponse.java | 21 +-
.../xasecure/unixusersync/model/MUserInfo.java | 21 +-
.../xasecure/unixusersync/model/XGroupInfo.java | 21 +-
.../unixusersync/model/XUserGroupInfo.java | 21 +-
.../xasecure/unixusersync/model/XUserInfo.java | 21 +-
.../unixusersync/poc/InvalidGroupException.java | 21 +-
.../unixusersync/poc/InvalidUserException.java | 21 +-
.../unixusersync/poc/ListUserGroupTest.java | 21 +-
.../xasecure/unixusersync/poc/ListUserTest.java | 21 +-
.../unixusersync/poc/ListXaSecureUser.java | 21 +-
.../unixusersync/poc/ListXaSecureUserGroup.java | 21 +-
.../unixusersync/poc/RestClientPost.java | 21 +-
.../poc/XaSecureClientUserGroupMapping.java | 21 +-
.../unixusersync/poc/XaSecureJSONParser.java | 21 +-
.../poc/XaSecureUpdateUserGroupMapping.java | 21 +-
.../poc/XaSecureUserGroupMapping.java | 21 +-
.../process/PolicyMgrUserGroupBuilder.java | 21 +-
.../process/UnixUserGroupBuilder.java | 21 +-
.../xasecure/usergroupsync/UserGroupSink.java | 21 +-
.../xasecure/usergroupsync/UserGroupSource.java | 21 +-
.../xasecure/usergroupsync/UserGroupSync.java | 21 +-
unixauthclient/pom.xml | 1 +
.../unix/jaas/ConsolePromptCallbackHandler.java | 21 +-
.../unix/jaas/RemoteUnixLoginModule.java | 21 +-
.../unix/jaas/UnixGroupPrincipal.java | 21 +-
.../unix/jaas/UnixUserPrincipal.java | 21 +-
.../UnixAuthenticationTester.java | 21 +-
unixauthnative/pom.xml | 1 +
unixauthservice/pom.xml | 1 +
.../authentication/PasswordValidator.java | 21 +-
.../UnixAuthenticationService.java | 21 +-
517 files changed, 11888 insertions(+), 3028 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/4eacc7a8/hbase-agent/scripts/install.sh
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/4eacc7a8/hive-agent/scripts/install.sh
----------------------------------------------------------------------
[5/9] git commit: ARGUS-64
Posted by rm...@apache.org.
ARGUS-64
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/a6f5be8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/a6f5be8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/a6f5be8a
Branch: refs/heads/master
Commit: a6f5be8a7b7d7a4daa3358d386d2a5467bb6bebf
Parents: 5c29ec2
Author: rmani <rm...@hortonworks.com>
Authored: Tue Sep 16 18:21:13 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Tue Sep 16 18:21:13 2014 -0700
----------------------------------------------------------------------
.../com/xasecure/pdp/config/ConfigWatcher.java | 12 +++-
.../xasecure/pdp/config/PolicyRefresher.java | 68 +++++++++++++-------
2 files changed, 54 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a6f5be8a/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
----------------------------------------------------------------------
diff --git a/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java b/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
index e286cfb..f510328 100644
--- a/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
+++ b/agents-impl/src/main/java/com/xasecure/pdp/config/ConfigWatcher.java
@@ -92,6 +92,7 @@ public abstract class ConfigWatcher extends Thread {
private static XaSecureCredentialProvider xasecurecp = null;
+
public abstract void doOnChange();
private String keyStoreFile = null ;
@@ -110,7 +111,9 @@ public abstract class ConfigWatcher extends Thread {
private String sslConfigFileName = null ;
- boolean policyCacheLoadedOnce = false;
+ public boolean policyCacheLoadedOnce = false;
+
+ public boolean cacheModfied = false;
public ConfigWatcher(String url, long aIntervalInMilliSeconds,String sslConfigFileName,String lastStoredFileName) {
super("XaSecureConfigURLWatcher");
@@ -227,11 +230,15 @@ public abstract class ConfigWatcher extends Thread {
LOG.debug("No Change found in the policy from " + url);
}
}
+
+ public boolean iscacheModfied() {
+ return cacheModfied;
+ }
private boolean isFileChanged() {
boolean isChanged = false;
-
+ cacheModfied = false;
try {
Client client = null;
@@ -278,6 +285,7 @@ public abstract class ConfigWatcher extends Thread {
lastModifiedTime = policyContainer.getLastUpdatedTimeInEpoc();
isChanged = true;
policyCacheLoadedOnce = false;
+ cacheModfied = true;
if (LOG.isDebugEnabled()) {
LOG.debug("Got response: 200 with {change in lastupdatedTime}\n" + gson.toJson(newPolicyContainer));
}
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a6f5be8a/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
----------------------------------------------------------------------
diff --git a/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java b/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
index 0b1f38e..c1db8ac 100644
--- a/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
+++ b/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
@@ -76,6 +76,7 @@ public class PolicyRefresher {
this.policyChangeListener = policyChangeListener;
if (this.policyContainer != null) {
savePolicyToFile() ;
+ savePolicyToCacheFile();
notifyPolicyChange() ;
}
}
@@ -124,6 +125,7 @@ public class PolicyRefresher {
PolicyContainer newPolicyContainer = getPolicyContainer() ;
setPolicyContainer(newPolicyContainer) ;
savePolicyToFile() ;
+ savePolicyToCacheFile();
notifyPolicyChange();
};
};
@@ -153,7 +155,10 @@ public class PolicyRefresher {
private void savePolicyToFile() {
-
+ if (!watcherDaemon.iscacheModfied()) {
+ // Do not Save the file if the policy is not modified.
+ return;
+ }
LOG.debug("savePolicyToFile() is called with [" + saveAsFileName + "] - START") ;
String fileName = null;
if (saveAsFileName != null) {
@@ -175,31 +180,46 @@ public class PolicyRefresher {
writer.close();
}
}
-
- if (lastStoredFileName != null) {
- File lastSaveFileName = new File(lastStoredFileName);
-
- try {
- writer = new PrintWriter(new FileWriter(lastSaveFileName));
- writer.println(policyAsJson);
-
- }
- catch(IOException ioe){
- LOG.error("Unable to save the policy into Last Stored Policy File [" + lastSaveFileName.getAbsolutePath() + "]", ioe );
- }
- finally {
- //make the policy file cache to be 600 permission when it gets created and updated
- lastSaveFileName.setReadable(false,false);
- lastSaveFileName.setReadable(true,true);
- if (writer != null) {
- writer.close();
- }
- }
-
- }
+ LOG.debug("savePolicyToFile() is called with [" + fileName + "] - END") ;
}
+ }
+
+ private void savePolicyToCacheFile() {
+
+ if (!watcherDaemon.iscacheModfied()) {
+ // Don't Save the file if the policy is not modified.
+ return;
+ }
+
+ LOG.debug("savePolicyToCacheFile() is called with [" + lastStoredFileName + "] - START") ;
- LOG.debug("savePolicyToFile() is called with [" + fileName + "] - END") ;
+ if (lastStoredFileName != null) {
+
+ File lastSaveFile = new File(lastStoredFileName) ;
+ Gson gson = new GsonBuilder().setPrettyPrinting().setExclusionStrategies(policyExclusionStrategy).create() ;
+ String policyAsJson = gson.toJson(policyContainer) ;
+ PrintWriter writer = null ;
+
+ try {
+ writer = new PrintWriter(new FileWriter(lastSaveFile));
+ writer.println(policyAsJson);
+
+ }
+ catch(IOException ioe){
+ LOG.error("Unable to save the policy into Last Stored Policy File [" + lastSaveFile.getAbsolutePath() + "]", ioe );
+ }
+ finally {
+ //make the policy file cache to be 600 permission when it gets created and updated
+ lastSaveFile.setReadable(false,false);
+ lastSaveFile.setReadable(true,true);
+ if (writer != null) {
+ writer.close();
+ }
+ }
+
+ }
+
+ LOG.debug("savePolicyToCacheFile() is called with [" + lastStoredFileName + "] - END") ;
}
[8/9] git commit: Argus-64
Posted by rm...@apache.org.
Argus-64
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/6d3618fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/6d3618fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/6d3618fc
Branch: refs/heads/master
Commit: 6d3618fcbc5fa1ff6f67388ce0bb1c2b9fda47e3
Parents: 3b7c712
Author: rmani <rm...@hortonworks.com>
Authored: Wed Sep 17 14:47:49 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Fri Sep 19 14:29:53 2014 -0700
----------------------------------------------------------------------
.../xasecure/pdp/config/PolicyRefresher.java | 31 +++++++++++++++-----
1 file changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/6d3618fc/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
----------------------------------------------------------------------
diff --git a/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java b/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
index c1db8ac..60b0074 100644
--- a/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
+++ b/agents-impl/src/main/java/com/xasecure/pdp/config/PolicyRefresher.java
@@ -1,14 +1,29 @@
-/**************************************************************************
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ /**************************************************************************
* *
* The information in this document is proprietary to XASecure Inc., *
* It may not be used, reproduced or disclosed without the written *
* approval from the XASecure Inc., *
* *
* PRIVILEGED AND CONFIDENTIAL XASECURE PROPRIETARY INFORMATION *
- * *
- * Copyright (c) 2013 XASecure, Inc. All rights reserved. *
- * *
- *************************************************************************/
/**
*
@@ -155,7 +170,7 @@ public class PolicyRefresher {
private void savePolicyToFile() {
- if (!watcherDaemon.iscacheModfied()) {
+ if (watcherDaemon != null && !watcherDaemon.iscacheModfied()) {
// Do not Save the file if the policy is not modified.
return;
}
@@ -186,7 +201,7 @@ public class PolicyRefresher {
private void savePolicyToCacheFile() {
- if (!watcherDaemon.iscacheModfied()) {
+ if (watcherDaemon != null && !watcherDaemon.iscacheModfied()) {
// Don't Save the file if the policy is not modified.
return;
}
@@ -211,7 +226,9 @@ public class PolicyRefresher {
finally {
//make the policy file cache to be 600 permission when it gets created and updated
lastSaveFile.setReadable(false,false);
+ lastSaveFile.setWritable(false,false);
lastSaveFile.setReadable(true,true);
+ lastSaveFile.setWritable(true,true);
if (writer != null) {
writer.close();
}
[3/9] git commit: ARGUS-5
Posted by rm...@apache.org.
ARGUS-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/84c22443
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/84c22443
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/84c22443
Branch: refs/heads/master
Commit: 84c22443d2a5aa8207062132f17652fd3d028509
Parents: 3272c00
Author: rmani <rm...@hortonworks.com>
Authored: Fri Sep 12 11:22:10 2014 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Fri Sep 12 11:22:10 2014 -0700
----------------------------------------------------------------------
.../hadoop/log/HdfsFileAppender.java | 345 +++++++------------
1 file changed, 134 insertions(+), 211 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/84c22443/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
index 3398d8a..86a9bb1 100644
--- a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
@@ -37,12 +37,7 @@ import org.apache.log4j.helpers.LogLog;
**********************************/
public class HdfsFileAppender extends FileAppender {
-
- /**
- * maximal number of retries to connect to the hdfs.
- */
-
-
+
// Constants for checking the DatePattern
public static final String MINUTES ="Min";
public static final String HOURS ="Hr";
@@ -64,15 +59,9 @@ public class HdfsFileAppender extends FileAppender {
*/
private String hdfsFileRollingInterval = "1Day";
- private String FileRollingInterval = "1Day";
+ private String fileRollingInterval = "1Day";
- /**
- * The log file will be renamed to the value of the scheduledFilename variable when the next interval is entered. For example, if the rollover period is one
- * hour, the log file will be renamed to the value of "scheduledFilename" at the beginning of the next hour. The precise time when a rollover occurs depends
- * on logging activity.
- */
- private String scheduledFilename;
-
+
private String scheduledFileCache;
/**
@@ -106,15 +95,15 @@ public class HdfsFileAppender extends FileAppender {
private String hdfsfileName = null;
- private String actualhdfsfileName = null;
+ private String actualHdfsfileName = null;
- private String scheduledhdfsFileName = null;
+ private String scheduledHdfsFileName = null;
private String fileCache = null;
private HdfsSink hs = null;
- private Writer cachewriter = null;
+ private Writer cacheWriter = null;
private FileOutputStream cacheOstream = null;
@@ -126,15 +115,14 @@ public class HdfsFileAppender extends FileAppender {
private int hdfsFileRollOffset = 0;
- private int FileRollOffset = 0;
+ private int fileRollOffset = 0;
private boolean firstTime = true;
private boolean firstTimeLocal = true;
- private String HdfsLiveUpdate = "true";
-
-
+ private String hdfsLiveUpdate = "true";
+
boolean hdfsUpdateAllowed = true;
private String hdfsCheckInterval=null;
@@ -157,28 +145,16 @@ public class HdfsFileAppender extends FileAppender {
}
- /**
- * Instantiate a <code>HdfsFileAppender</code> and open the file designated by <code>filename</code>. The opened filename will become the output destination for this appender.
- */
- public HdfsFileAppender(Layout layout, String filename, String hdfsFileRollingInterval,String FileRollingInterval, String HdfsLiveUpdate, String hdfsCheckInterval) throws IOException{
- super(layout, filename, true);
- this.hdfsFileRollingInterval = hdfsFileRollingInterval;
- this.FileRollingInterval = FileRollingInterval;
- this.HdfsLiveUpdate = HdfsLiveUpdate;
- this.hdfsCheckInterval = hdfsCheckInterval;
-
- activateOptions();
- }
/**
* The <b>hdfsFileRollingInterval</b> takes a string like 1min, 5min,... 1hr, 2hrs,.. 1day, 2days... 1week, 2weeks.. 1month, 2months.. for hdfs File rollover schedule.
*/
- public void sethdfsFileRollingInterval(String pattern) {
+ public void setHdfsFileRollingInterval(String pattern) {
hdfsFileRollingInterval = pattern;
}
/** Returns the value of the <b>hdfsFileRollingInterval</b> option. */
- public String gethdfsFileRollingInterval() {
+ public String getHdfsFileRollingInterval() {
return hdfsFileRollingInterval;
}
@@ -186,31 +162,31 @@ public class HdfsFileAppender extends FileAppender {
* The <b>LocalDatePattern</b> takes a string like 1min, 5min,... 1hr, 2hrs,.. 1day, 2days... 1week, 2weeks.. 1month, 2months.. for local cache File rollover schedule.
*/
public void setFileRollingInterval(String pattern) {
- FileRollingInterval = pattern;
+ fileRollingInterval = pattern;
}
/** Returns the value of the <b>FileRollingInterval</b> option. */
public String getFileRollingInterval() {
- return FileRollingInterval;
+ return fileRollingInterval;
}
/**
* This will set liveHdfsUpdate flag , where true will update hdfs live else false will create local cache files and copy the files to hdfs
*/
public void setHdfsLiveUpdate(String val) {
- HdfsLiveUpdate=val;
+ hdfsLiveUpdate=val;
}
/** Returns the value of the <b>FileRollingInterval</b> option. */
public String getHdfsLiveUpdate() {
- return HdfsLiveUpdate;
+ return hdfsLiveUpdate;
}
- public String gethdfsCheckInterval() {
+ public String getHdfsCheckInterval() {
return hdfsCheckInterval;
}
- public void sethdfsCheckInterval(String val){
+ public void setHdfsCheckInterval(String val){
hdfsCheckInterval = ( hdfsCheckInterval != null) ? val : DEFAULT_HDFSCHECKINTERVAL;
}
@@ -236,12 +212,9 @@ public class HdfsFileAppender extends FileAppender {
rc.setType(type);
LogLog.debug("File name: " + fileName);
File file = new File(fileName);
- //scheduledFilename = fileName +"." +file.lastModified();
- //scheduledhdfsFileName = hdfsfileName + "." + file.lastModified();
- scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));
- scheduledhdfsFileName = hdfsfileName+sdf.format(new Date(file.lastModified()));
+ scheduledHdfsFileName = hdfsfileName+sdf.format(new Date(file.lastModified()));
firstTime = true;
- LogLog.debug("Local and hdfs Files" + scheduledFilename + " " +scheduledhdfsFileName) ;
+ LogLog.debug("Local and hdfs Files" + scheduledHdfsFileName + " " +scheduledHdfsFileName) ;
} else {
LogLog.error("Either File or hdfsFileRollingInterval options are not set for appender [" + name + "].");
@@ -249,49 +222,49 @@ public class HdfsFileAppender extends FileAppender {
// Local Cache File
- if (FileRollingInterval != null && fileCache != null){
- nowLocal.setTime(System.currentTimeMillis());
- int localtype = computeCheckPeriod(FileRollingInterval);
- FileRollOffset = getTimeOffset(FileRollingInterval);
- printLocalPeriodicity(localtype,FileRollOffset);
- rcLocal.setType(localtype);
- LogLog.debug("LocalCacheFile name: " + fileCache);
- File fileCachehandle = new File(fileCache);
- //scheduledFileCache = fileCache+"."+fileCachehandle.lastModified();
- scheduledFileCache = fileCache+sdf.format(new Date(fileCachehandle.lastModified()));
- firstTimeLocal = true;
-
+ if (fileRollingInterval != null && fileCache != null){
+ nowLocal.setTime(System.currentTimeMillis());
+ int localtype = computeCheckPeriod(fileRollingInterval);
+ fileRollOffset = getTimeOffset(fileRollingInterval);
+ printLocalPeriodicity(localtype,fileRollOffset);
+ rcLocal.setType(localtype);
+ LogLog.debug("LocalCacheFile name: " + fileCache);
+ File fileCachehandle = new File(fileCache);
+ scheduledFileCache = fileCache+sdf.format(new Date(fileCachehandle.lastModified()));
+ firstTimeLocal = true;
+
} else {
LogLog.error("Either File or LocalDatePattern options are not set for appender [" + name + "].");
}
- if (HdfsLiveUpdate.equalsIgnoreCase("true")) {
- hdfsUpdateAllowed = true;
- } else if (HdfsLiveUpdate.equalsIgnoreCase("false")) {
- hdfsUpdateAllowed = false;
- }
-
- actualhdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
-
+ hdfsUpdateAllowed = Boolean.parseBoolean(hdfsLiveUpdate);
+ actualHdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
}
-
+ public static int containsIgnoreCase(String str1, String str2) {
+ return str1.toLowerCase().indexOf(str2.toLowerCase());
+ }
+
public int computeCheckPeriod(String timePattern){
-
- if ( timePattern.indexOf(MINUTES) > 0 || timePattern.indexOf(MINUTES.toLowerCase()) > 0|| timePattern.indexOf(MINUTES.toUpperCase()) > 0 ) {
+
+ if(containsIgnoreCase(timePattern, MINUTES) > 0) {
return TOP_OF_MINUTE;
}
- if ( timePattern.indexOf(HOURS) > 0 || timePattern.indexOf(HOURS.toLowerCase()) > 0|| timePattern.indexOf(HOURS.toUpperCase()) > 0 ) {
+
+ if(containsIgnoreCase(timePattern, HOURS) > 0) {
return TOP_OF_HOUR;
}
- if ( timePattern.indexOf(DAYS) > 0 || timePattern.indexOf(DAYS.toLowerCase()) > 0|| timePattern.indexOf(DAYS.toUpperCase()) > 0 ) {
+
+ if(containsIgnoreCase(timePattern, DAYS) > 0) {
return TOP_OF_DAY;
}
- if ( timePattern.indexOf(WEEKS) > 0 || timePattern.indexOf(WEEKS.toLowerCase()) > 0|| timePattern.indexOf(WEEKS.toUpperCase()) > 0 ) {
+
+ if(containsIgnoreCase(timePattern, WEEKS) > 0) {
return TOP_OF_WEEK;
}
- if ( timePattern.indexOf(MONTHS) > 0 || timePattern.indexOf(MONTHS.toLowerCase()) > 0|| timePattern.indexOf(MONTHS.toUpperCase()) > 0 ) {
+
+ if(containsIgnoreCase(timePattern, MONTHS) > 0) {
return TOP_OF_MONTH;
}
@@ -329,26 +302,26 @@ public class HdfsFileAppender extends FileAppender {
int index;
int offset=-1;
- if ( (index = timePattern.indexOf(MINUTES)) > 0 || (index = timePattern.indexOf(MINUTES.toLowerCase())) > 0|| (index = timePattern.indexOf(MINUTES.toUpperCase())) > 0 ) {
-
+ if ((index = containsIgnoreCase(timePattern, MINUTES)) > 0) {
offset = Integer.parseInt(timePattern.substring(0,index));
-
}
- if ( (index = timePattern.indexOf(HOURS)) > 0 || (index =timePattern.indexOf(HOURS.toLowerCase())) > 0|| (index=timePattern.indexOf(HOURS.toUpperCase())) > 0 ) {
+
+ if ((index = containsIgnoreCase(timePattern, HOURS)) > 0) {
offset = Integer.parseInt(timePattern.substring(0,index));
}
- if ( (index = timePattern.indexOf(DAYS)) > 0 || (index =timePattern.indexOf(DAYS.toLowerCase())) > 0|| (index=timePattern.indexOf(DAYS.toUpperCase())) > 0 ) {
+
+ if ((index = containsIgnoreCase(timePattern, DAYS)) > 0) {
offset = Integer.parseInt(timePattern.substring(0,index));
}
- if ( (index = timePattern.indexOf(WEEKS)) > 0 || (index =timePattern.indexOf(WEEKS.toLowerCase())) > 0|| (index=timePattern.indexOf(WEEKS.toUpperCase())) > 0 ) {
+ if ((index = containsIgnoreCase(timePattern, WEEKS)) > 0) {
offset = Integer.parseInt(timePattern.substring(0,index));
}
- if ( (index = timePattern.indexOf(MONTHS)) > 0 || (index =timePattern.indexOf(MONTHS.toLowerCase())) > 0|| (index=timePattern.indexOf(MONTHS.toUpperCase())) > 0 ) {
+ if ((index = containsIgnoreCase(timePattern, MONTHS)) > 0) {
offset = Integer.parseInt(timePattern.substring(0,index));
}
@@ -395,15 +368,12 @@ public class HdfsFileAppender extends FileAppender {
}
long epochNow = System.currentTimeMillis();
- //String datedFilename = fileName + "." + epochNow;
- //String datedhdfsFileName = hdfsfileName + "." + epochNow;
-
- String datedFilename =fileName+sdf.format(epochNow);
+
String datedhdfsFileName = hdfsfileName+sdf.format(epochNow);
LogLog.debug("In rollOver epochNow" + epochNow + " " + "nextCheck: " + prevnextCheck );
-
+
// It is too early to roll over because we are still within the bounds of the current interval. Rollover will occur once the next interval is reached.
if (epochNow < prevnextCheck) {
@@ -413,12 +383,12 @@ public class HdfsFileAppender extends FileAppender {
// close current file, and rename it to datedFilename
this.closeFile();
- LogLog.debug("Rolling Over hdfs file to " + scheduledhdfsFileName);
+ LogLog.debug("Rolling Over hdfs file to " + scheduledHdfsFileName);
if ( hdfsAvailable ) {
- rollOverHdfsFile(scheduledhdfsFileName);
- actualhdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
+ // for hdfs file we don't rollover the fike, we rename the file.
+ actualHdfsfileName = hdfsfileName + sdf.format(System.currentTimeMillis());
}
try {
@@ -427,9 +397,7 @@ public class HdfsFileAppender extends FileAppender {
} catch(IOException e) {
errorHandler.error("setFile(" + fileName + ", false) call failed.");
}
- scheduledFilename = datedFilename;
- scheduledhdfsFileName = datedhdfsFileName;
-
+ scheduledHdfsFileName = datedhdfsFileName;
}
@@ -438,14 +406,13 @@ public class HdfsFileAppender extends FileAppender {
*/
private void rollOverLocal() throws IOException {
/* Compute filename, but only if datePattern is specified */
- if(FileRollingInterval == null) {
+ if(fileRollingInterval == null) {
errorHandler.error("Missing LocalDatePattern option in rollOverLocal().");
return;
}
long epochNow = System.currentTimeMillis();
- //String datedCacheFileName = fileCache + "." + epochNow;
String datedCacheFileName = fileCache+sdf.format(epochNow);
LogLog.debug("In rollOverLocal() epochNow" + epochNow + " " + "nextCheckLocal: " + prevnextCheckLocal );
@@ -473,7 +440,7 @@ public class HdfsFileAppender extends FileAppender {
} else {
LogLog.error("Failed to rename cache file ["+fileCache+"] to ["+scheduledFileCache+"].");
}
- setfileCacheWriter();
+ setFileCacheWriter();
scheduledFileCache = datedCacheFileName;
}
}
@@ -496,7 +463,7 @@ public class HdfsFileAppender extends FileAppender {
// trailing spaces in file names.
String val = file.trim();
- fileName = val;
+ fileName=val;
fileCache=val+".cache";
}
@@ -549,7 +516,7 @@ public class HdfsFileAppender extends FileAppender {
this.bufferSize = bufferSize;
//set cache file
- setfileCacheWriter();
+ setFileCacheWriter();
writeHeader();
@@ -594,15 +561,6 @@ public class HdfsFileAppender extends FileAppender {
protected void subAppend(LoggingEvent event) {
LogLog.debug("Called subAppend for logging into hdfs...");
- //String logPath = (String)event.getMDC(Log4jAuditProvider.MDC_VAR_LOG_RESOURCE_PATH) ;
-
- //LogLog.debug("Log Path " + logPath);
-
- /*
- if (logPath.startsWith(fileName)) {
- return ;
- }
- */
long n = System.currentTimeMillis();
if(n >= nextCheck) {
now.setTime(n);
@@ -625,7 +583,7 @@ public class HdfsFileAppender extends FileAppender {
if ( nLocal > nextCheckLocal ) {
nowLocal.setTime(nLocal);
prevnextCheckLocal = nextCheckLocal;
- nextCheckLocal = rcLocal.getNextCheckMillis(nowLocal, FileRollOffset);
+ nextCheckLocal = rcLocal.getNextCheckMillis(nowLocal, fileRollOffset);
if ( firstTimeLocal) {
prevnextCheckLocal = nextCheckLocal;
firstTimeLocal = false;
@@ -653,7 +611,7 @@ public class HdfsFileAppender extends FileAppender {
closeWriter();
this.qw = null;
//this.
- this.closehdfsWriter();
+ this.closeHdfsWriter();
this.closeCacheWriter();
}
@@ -661,8 +619,8 @@ public class HdfsFileAppender extends FileAppender {
public synchronized void close() {
LogLog.debug("Closing all resource..");
this.closeFile();
- this.closehdfsWriter();
- this.closehdfsostream();
+ this.closeHdfsWriter();
+ this.closeHdfsOstream();
this.closeFileSystem();
}
@@ -676,8 +634,8 @@ public class HdfsFileAppender extends FileAppender {
} catch(IOException ie) {
LogLog.error("unable to close output stream", ie);
}
- this.closehdfsWriter();
- this.closehdfsostream();
+ this.closeHdfsWriter();
+ this.closeHdfsOstream();
}
@Override
@@ -701,9 +659,7 @@ public class HdfsFileAppender extends FileAppender {
/******* HDFS Appender methods ***********/
- //private void appendHDFSFileSystem(String fileNameSystem, String filename, String fileCache,boolean append, boolean bufferedIO, int bufferSize, Layout layout, String encoding, LoggingEvent event, String scheduledFileCache, Writer cacheWriter,boolean hdfsUpdateAllowed ) {
-
- private void appendHDFSFileSystem(LoggingEvent event) {
+ private void appendHDFSFileSystem(LoggingEvent event) {
long currentTime = System.currentTimeMillis();
@@ -711,8 +667,8 @@ public class HdfsFileAppender extends FileAppender {
if ( currentTime >= hdfsNextCheck ) {
- LogLog.debug("About to Open fileSystem" + fileSystemName+" "+actualhdfsfileName) ;
- hs = openHdfsSink(fileSystemName,actualhdfsfileName,fileCache,fileAppend,bufferedIO,bufferSize,layout,encoding,scheduledFileCache,cachewriter,hdfsUpdateAllowed,processUser);
+ LogLog.debug("About to Open fileSystem" + fileSystemName+" "+actualHdfsfileName) ;
+ hs = openHdfsSink(fileSystemName,actualHdfsfileName,fileCache,fileAppend,bufferedIO,bufferSize,layout,encoding,scheduledFileCache,cacheWriter,hdfsUpdateAllowed,processUser);
if (hdfsUpdateAllowed) {
// stream into hdfs only when liveHdfsUpdate flag is true else write to cache file.
hs.setOsteam();
@@ -742,9 +698,7 @@ public class HdfsFileAppender extends FileAppender {
}
writeToCache(event);
}
-
- //hs.closehdfsWriter();
- //hs.closehdfsostream();
+
}
@@ -765,18 +719,18 @@ public class HdfsFileAppender extends FileAppender {
}
- private void closehdfsostream() {
+ private void closeHdfsOstream() {
if (hs != null ){
LogLog.debug("Closing hdfs outstream") ;
- hs.closehdfsostream();
+ hs.closeHdfsOstream();
}
}
- private void closehdfsWriter() {
+ private void closeHdfsWriter() {
if (hs != null) {
LogLog.debug("Closing hdfs Writer") ;
- hs.closehdfsWriter();
+ hs.closeHdfsWriter();
}
}
@@ -784,36 +738,27 @@ public class HdfsFileAppender extends FileAppender {
hs.closeHdfsSink();
}
- private void rollOverHdfsFile(String scheduleHdfsFileName){
- try {
- // Rollover hdfs file.
- hs.rollOverHdfsFile(scheduleHdfsFileName);
- } catch (IOException ie) {
- // TODO..what needs to happend if rollover of hdfs file fails.
- LogLog.debug("Rollover of hdfs failed..") ;
- }
- }
-
+
/****** Cache File Methods **/
- public void setfileCacheWriter() {
+ public void setFileCacheWriter() {
try {
- setfileCacheOstream(fileCache);
+ setFileCacheOstream(fileCache);
} catch(IOException ie) {
LogLog.error("Logging failed while tring to write into Cache File..", ie);
}
LogLog.debug("Setting Cache Writer..");
- cachewriter = createCacheFileWriter(cacheOstream);
+ cacheWriter = createCacheFileWriter(cacheOstream);
if(bufferedIO) {
- cachewriter = new BufferedWriter(cachewriter, bufferSize);
+ cacheWriter = new BufferedWriter(cacheWriter, bufferSize);
}
}
- private void setfileCacheOstream(String fileCache) throws IOException {
+ private void setFileCacheOstream(String fileCache) throws IOException {
try {
cacheOstream = new FileOutputStream(fileCache, true);
@@ -854,10 +799,10 @@ public class HdfsFileAppender extends FileAppender {
public void writeToCache(LoggingEvent event) {
try {
- LogLog.debug("Writing log to Cache.." + "layout: "+ this.layout.format(event) + "ignoresThowable: "+layout.ignoresThrowable() + "Writer:" + cachewriter.toString());
+ LogLog.debug("Writing log to Cache.." + "layout: "+ this.layout.format(event) + "ignoresThowable: "+layout.ignoresThrowable() + "Writer:" + cacheWriter.toString());
- cachewriter.write(this.layout.format(event));
- cachewriter.flush();
+ cacheWriter.write(this.layout.format(event));
+ cacheWriter.flush();
if(layout.ignoresThrowable()) {
String[] s = event.getThrowableStrRep();
@@ -865,9 +810,9 @@ public class HdfsFileAppender extends FileAppender {
int len = s.length;
for(int i = 0; i < len; i++) {
LogLog.debug("Log:" + s[i]);
- cachewriter.write(s[i]);
- cachewriter.write(Layout.LINE_SEP);
- cachewriter.flush();
+ cacheWriter.write(s[i]);
+ cacheWriter.write(Layout.LINE_SEP);
+ cacheWriter.flush();
}
}
}
@@ -882,7 +827,6 @@ public class HdfsFileAppender extends FileAppender {
long epochNow = System.currentTimeMillis();
- //String datedCacheFileName = fileCache + "." + epochNow;
String datedCacheFileName = fileCache + "." + epochNow;
LogLog.debug("Rolling over remaining cache File to new file"+ datedCacheFileName);
closeCacheWriter();
@@ -906,9 +850,9 @@ public class HdfsFileAppender extends FileAppender {
public void closeCacheWriter() {
try {
- if(cachewriter != null) {
- cachewriter.close();
- cachewriter = null;
+ if(cacheWriter != null) {
+ cacheWriter.close();
+ cacheWriter = null;
}
} catch(IOException ie) {
LogLog.error("unable to close cache writer", ie);
@@ -1006,6 +950,10 @@ class RollingCalendar extends GregorianCalendar {
class HdfsSink {
+ private static final String DS_REPLICATION_VAL = "1";
+ private static final String DS_REPLICATION_KEY = "dfs.replication";
+ private static final String FS_DEFAULT_NAME_KEY = "ds.default.name";
+
private Configuration conf = null;
private FileSystem fs= null;
private Path pt = null;
@@ -1021,7 +969,6 @@ class HdfsSink {
private static int fstime=0;
private CacheFileWatcher cfw = null;
private boolean hdfsUpdateAllowed=true;
- private String scheduledCacheFile=null;
private String processUser=null;
@@ -1048,14 +995,15 @@ class HdfsSink {
this.bufferedIO=bufferedIO;
this.fileCache=fileCache;
this.hdfsUpdateAllowed=hdfsUpdateAllowed;
- this.scheduledCacheFile=scheduledCacheFile;
this.processUser=processUser;
try {
- conf.set("dfs.replication", "1");
+
+ conf.set(DS_REPLICATION_KEY,DS_REPLICATION_VAL);
+ conf.set(FS_DEFAULT_NAME_KEY, this.fsName);
if ( fs == null) {
- LogLog.debug("Opening Connection to hdfs Sytem");
+ LogLog.debug("Opening Connection to hdfs Sytem" + this.fsName);
UserGroupInformation ugi = UserGroupInformation.createProxyUser(this.processUser, UserGroupInformation.getLoginUser());
ugi.doAs( new PrivilegedExceptionAction<Void>() {
@@ -1070,7 +1018,7 @@ class HdfsSink {
LogLog.debug("About to run CacheFilWatcher...");
Path hdfsfilePath = getParent();
- cfw = new CacheFileWatcher(this.fs,this.fileCache,hdfsfilePath,this.scheduledCacheFile,cacheWriter,this.hdfsUpdateAllowed,conf);
+ cfw = new CacheFileWatcher(this.fs,this.fileCache,hdfsfilePath,cacheWriter,this.hdfsUpdateAllowed,conf);
cfw.start();
}
@@ -1103,7 +1051,7 @@ class HdfsSink {
public void setOsteam() throws IOException {
try {
- pt = new Path(fileName);
+ pt = new Path(this.fileName);
// if file Exist append it
if(fs.exists(pt)) {
LogLog.debug("Appending File: "+ this.fsName+":"+this.fileName);
@@ -1113,9 +1061,8 @@ class HdfsSink {
hdfsostream=fs.append(pt);
} else {
-
- LogLog.debug("Creating File directories in hdfs if not present...");
- String parentName = new Path(fileName).getParent().toString();
+ LogLog.debug("Creating File directories in hdfs if not present.."+ this.fsName+":"+this.fileName);
+ String parentName = new Path(this.fileName).getParent().toString();
if(parentName != null) {
Path parentDir = new Path(parentName);
if (!fs.exists(parentDir) ) {
@@ -1132,12 +1079,11 @@ class HdfsSink {
}
public void setWriter() {
-
LogLog.debug("Setting Writer..");
hdfswriter = createhdfsWriter(hdfsostream);
if(bufferedIO) {
hdfswriter = new BufferedWriter(hdfswriter, bufferSize);
- }
+ }
}
public Writer getWriter() {
@@ -1181,7 +1127,7 @@ class HdfsSink {
} catch (IOException ie) {
LogLog.error("Unable to log header message to hdfs:", ie);
throw ie;
- }
+ }
}
public
@@ -1203,7 +1149,7 @@ class HdfsSink {
}
- public void closehdfsostream() {
+ public void closeHdfsOstream() {
try {
if(this.hdfsostream != null) {
this.hdfsostream.close();
@@ -1215,7 +1161,7 @@ class HdfsSink {
}
- public void closehdfsWriter() {
+ public void closeHdfsWriter() {
try {
if(hdfswriter != null) {
hdfswriter.close();
@@ -1254,53 +1200,33 @@ class HdfsSink {
return retval;
}
- public void rollOverHdfsFile(String scheduledHdfsFilename) throws IOException {
-
- /* try {
-
- Path target = new Path(scheduledHdfsFilename);
- if(this.fs.exists(target)) {
- this.fs.delete(target, true);
- }
- Path file = new Path(this.fileName);
- boolean result = this.fs.rename(file, target);
- if(result) {
- LogLog.debug(fileName + " -> " + scheduledHdfsFilename);
- } else {
- LogLog.error("Failed to rename [" + fileName + "] to [" + scheduledHdfsFilename + "].");
- }
-
- }catch(IOException ie) {
-
- LogLog.error("Unable to rollover hdfs file ",ie);
- throw ie;
- } */
- }
}
// CacheFileWatcher Thread
class CacheFileWatcher extends Thread {
+
+ long CACHEFILE_WATCHER_SLEEP_TIME = 1000*60*2;
+
Configuration conf = null;
- FileSystem fs = null;
- String cacheFile = null;
- File parentDir = null;
- File[] files = null;
- Path fsPath = null;
- Path hdfsfilePath = null;
- Writer cacheWriter = null;
- String scheduledFileCache = null;
- boolean hdfsUpdateAllowed=true;
- boolean cacheFilesCopied = false;
+ private FileSystem fs = null;
+ private String cacheFile = null;
+ private File parentDir = null;
+ private File[] files = null;
+ private Path fsPath = null;
+ private Path hdfsfilePath = null;
+ private Writer cacheWriter = null;
+
+ private boolean hdfsUpdateAllowed=true;
+ private boolean cacheFilesCopied = false;
- CacheFileWatcher(FileSystem fs, String cacheFile, Path hdfsfilePath, String scheduledFileCache, Writer cacheWriter, boolean hdfsUpdateAllowed, Configuration conf) {
+ CacheFileWatcher(FileSystem fs, String cacheFile, Path hdfsfilePath, Writer cacheWriter, boolean hdfsUpdateAllowed, Configuration conf) {
this.fs = fs;
this.cacheFile = cacheFile;
this.conf = conf;
this.hdfsfilePath = hdfsfilePath;
- this.scheduledFileCache = scheduledFileCache;
this.cacheWriter = cacheWriter;
this.hdfsUpdateAllowed = hdfsUpdateAllowed;
}
@@ -1310,7 +1236,6 @@ class CacheFileWatcher extends Thread {
LogLog.debug("CacheFileWatcher Started");
-
while (!cacheFilesCopied ){
if (hdfsUpdateAllowed) {
@@ -1318,10 +1243,9 @@ class CacheFileWatcher extends Thread {
}
if ( !cacheFilePresent(cacheFile) ) {
-
-
+
try {
- Thread.sleep(1000*60*2);
+ Thread.sleep(CACHEFILE_WATCHER_SLEEP_TIME);
} catch (InterruptedException ie) {
LogLog.error("Unable to complete the CatchFileWatcher Sleep", ie);
}
@@ -1339,7 +1263,7 @@ class CacheFileWatcher extends Thread {
LogLog. error("Error while copying Cache Files to hdfs..Sleeping for next try",t);
try {
- Thread.sleep(1000*60*2);
+ Thread.sleep(CACHEFILE_WATCHER_SLEEP_TIME);
} catch (InterruptedException ie) {
LogLog.error("Unable to complete the CatchFileWatcher Sleep", ie);
}
@@ -1398,8 +1322,7 @@ class CacheFileWatcher extends Thread {
if (new File(cacheFile).length() != 0 ) {
long epochNow = System.currentTimeMillis();
- //String datedCacheFileName = cacheFile + "." + epochNow;
- String datedCacheFileName = cacheFile + sdf.format(epochNow);
+ String datedCacheFileName = cacheFile + sdf.format(epochNow);
LogLog.debug("Rolling over remaining cache File "+ datedCacheFileName);
closeCacheFile();
@@ -1423,14 +1346,14 @@ class CacheFileWatcher extends Thread {
}
public void closeCacheFile() {
- try {
- if(cacheWriter != null) {
- cacheWriter.close();
- cacheWriter = null;
- }
- } catch(IOException ie) {
- LogLog.error("unable to close cache writer", ie);
- }
+ try {
+ if(cacheWriter != null) {
+ cacheWriter.close();
+ cacheWriter = null;
+ }
+ } catch(IOException ie) {
+ LogLog.error("unable to close cache writer", ie);
+ }
}
}