Search in sources :

Example 6 with AuditEventBase

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;
}
Also used : AuditEventBase(org.apache.ranger.audit.model.AuditEventBase)

Example 7 with AuditEventBase

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()");
}
Also used : AuditEventBase(org.apache.ranger.audit.model.AuditEventBase)

Example 8 with AuditEventBase

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;
}
Also used : AuditEventBase(org.apache.ranger.audit.model.AuditEventBase)

Example 9 with AuditEventBase

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();
    }
}
Also used : AuditEventBase(org.apache.ranger.audit.model.AuditEventBase)

Example 10 with AuditEventBase

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);
}
Also used : DebugTracer(org.apache.ranger.audit.provider.DebugTracer) LocalFileLogBuffer(org.apache.ranger.audit.provider.LocalFileLogBuffer) AuditEventBase(org.apache.ranger.audit.model.AuditEventBase) Log4jTracer(org.apache.ranger.audit.provider.Log4jTracer)

Aggregations

AuditEventBase (org.apache.ranger.audit.model.AuditEventBase)15 ArrayList (java.util.ArrayList)4 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 AuthzAuditEvent (org.apache.ranger.audit.model.AuthzAuditEvent)1 AuditHandler (org.apache.ranger.audit.provider.AuditHandler)1 DebugTracer (org.apache.ranger.audit.provider.DebugTracer)1 LocalFileLogBuffer (org.apache.ranger.audit.provider.LocalFileLogBuffer)1 Log4jTracer (org.apache.ranger.audit.provider.Log4jTracer)1 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)1 SolrException (org.apache.solr.common.SolrException)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1