use of org.apache.ranger.audit.model.AuditEventBase in project ranger by apache.
the class Log4JAuditDestination method log.
@Override
public boolean log(Collection<AuditEventBase> events) {
if (!auditLogger.isInfoEnabled()) {
logStatusIfRequired();
addTotalCount(events.size());
return true;
}
for (AuditEventBase event : events) {
log(event);
}
return true;
}
use of org.apache.ranger.audit.model.AuditEventBase in project ranger by apache.
the class AsyncAuditProvider method run.
@Override
public void run() {
LOG.info("==> AsyncAuditProvider.run()");
while (true) {
AuditEventBase event = null;
try {
event = dequeueEvent();
if (event != null) {
super.log(event);
} else {
lastFlushTime = System.currentTimeMillis();
flush();
}
} catch (InterruptedException excp) {
LOG.info("AsyncAuditProvider.run - Interrupted! Breaking out of while loop.");
break;
} catch (Exception excp) {
logFailedEvent(event, excp);
}
}
try {
lastFlushTime = System.currentTimeMillis();
flush();
} catch (Exception excp) {
LOG.error("AsyncAuditProvider.run()", excp);
}
LOG.info("<== AsyncAuditProvider.run()");
}
use of org.apache.ranger.audit.model.AuditEventBase in project ranger by apache.
the class DbAuditProvider method postCreate.
private boolean postCreate(AuditEventBase event) {
boolean ret = true;
if (mCommitBatchSize <= 1) {
ret = commitTransaction();
} else {
mUncommitted.add(event);
if ((mUncommitted.size() % mCommitBatchSize) == 0) {
ret = commitTransaction();
if (!ret) {
for (AuditEventBase evt : mUncommitted) {
if (evt != event) {
logFailedEvent(evt);
}
}
}
mUncommitted.clear();
}
}
return ret;
}
use of org.apache.ranger.audit.model.AuditEventBase in project ranger by apache.
the class DbAuditProvider method flush.
@Override
public void flush() {
if (mUncommitted.size() > 0) {
boolean isSuccess = commitTransaction();
if (!isSuccess) {
for (AuditEventBase evt : mUncommitted) {
logFailedEvent(evt);
}
}
mUncommitted.clear();
}
}
use of org.apache.ranger.audit.model.AuditEventBase in project ranger by apache.
the class HdfsAuditProvider method init.
public void init(Properties props) {
LOG.info("HdfsAuditProvider.init()");
super.init(props);
Map<String, String> hdfsProps = MiscUtil.getPropertiesWithPrefix(props, "xasecure.audit.hdfs.config.");
String encoding = hdfsProps.get("encoding");
String hdfsDestinationDirectory = hdfsProps.get("destination.directory");
String hdfsDestinationFile = hdfsProps.get("destination.file");
int hdfsDestinationFlushIntervalSeconds = MiscUtil.parseInteger(hdfsProps.get("destination.flush.interval.seconds"), 15 * 60);
int hdfsDestinationRolloverIntervalSeconds = MiscUtil.parseInteger(hdfsProps.get("destination.rollover.interval.seconds"), 24 * 60 * 60);
int hdfsDestinationOpenRetryIntervalSeconds = MiscUtil.parseInteger(hdfsProps.get("destination.open.retry.interval.seconds"), 60);
String localFileBufferDirectory = hdfsProps.get("local.buffer.directory");
String localFileBufferFile = hdfsProps.get("local.buffer.file");
int localFileBufferFlushIntervalSeconds = MiscUtil.parseInteger(hdfsProps.get("local.buffer.flush.interval.seconds"), 1 * 60);
int localFileBufferFileBufferSizeBytes = MiscUtil.parseInteger(hdfsProps.get("local.buffer.file.buffer.size.bytes"), 8 * 1024);
int localFileBufferRolloverIntervalSeconds = MiscUtil.parseInteger(hdfsProps.get("local.buffer.rollover.interval.seconds"), 10 * 60);
String localFileBufferArchiveDirectory = hdfsProps.get("local.archive.directory");
int localFileBufferArchiveFileCount = MiscUtil.parseInteger(hdfsProps.get("local.archive.max.file.count"), 10);
// Added for Azure. Note that exact name of these properties is not known as it contains the variable account name in it.
Map<String, String> configProps = MiscUtil.getPropertiesWithPrefix(props, "xasecure.audit.destination.hdfs.config.");
DebugTracer tracer = new Log4jTracer(LOG);
HdfsLogDestination<AuditEventBase> mHdfsDestination = new HdfsLogDestination<AuditEventBase>(tracer);
mHdfsDestination.setDirectory(hdfsDestinationDirectory);
mHdfsDestination.setFile(hdfsDestinationFile);
mHdfsDestination.setFlushIntervalSeconds(hdfsDestinationFlushIntervalSeconds);
mHdfsDestination.setEncoding(encoding);
mHdfsDestination.setRolloverIntervalSeconds(hdfsDestinationRolloverIntervalSeconds);
mHdfsDestination.setOpenRetryIntervalSeconds(hdfsDestinationOpenRetryIntervalSeconds);
mHdfsDestination.setConfigProps(configProps);
LocalFileLogBuffer<AuditEventBase> mLocalFileBuffer = new LocalFileLogBuffer<AuditEventBase>(tracer);
mLocalFileBuffer.setDirectory(localFileBufferDirectory);
mLocalFileBuffer.setFile(localFileBufferFile);
mLocalFileBuffer.setFlushIntervalSeconds(localFileBufferFlushIntervalSeconds);
mLocalFileBuffer.setFileBufferSizeBytes(localFileBufferFileBufferSizeBytes);
mLocalFileBuffer.setEncoding(encoding);
mLocalFileBuffer.setRolloverIntervalSeconds(localFileBufferRolloverIntervalSeconds);
mLocalFileBuffer.setArchiveDirectory(localFileBufferArchiveDirectory);
mLocalFileBuffer.setArchiveFileCount(localFileBufferArchiveFileCount);
setBufferAndDestination(mLocalFileBuffer, mHdfsDestination);
}
Aggregations