Search in sources :

Example 6 with AuditAccessException

use of org.ff4j.exception.AuditAccessException in project ff4j by ff4j.

the class EventRepositoryHBase method purgeAuditTrail.

/**
 * {@inheritDoc}
 */
@Override
public void purgeAuditTrail(EventQueryDefinition query) {
    try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
        try (Table table = hbConn.getTable(AUDIT_TABLENAME)) {
            query.getActionFilters().add(ACTION_CHECK_OK);
            // Scan for ids
            Scan scanQuery = buildQuery(query, Util.set(COL_EVENT_UID), null);
            List<Delete> list = new ArrayList<Delete>();
            try (ResultScanner scanner = table.getScanner(scanQuery)) {
                for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
                    list.add(new Delete(rr.getValue(B_AUDIT_CF, B_EVENT_UID)));
                }
            }
            table.delete(list);
        }
    } catch (IOException e) {
        throw new AuditAccessException("Cannot search audit trail ", e);
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Table(org.apache.hadoop.hbase.client.Table) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) HBaseConnection(org.ff4j.hbase.HBaseConnection) Connection(org.apache.hadoop.hbase.client.Connection) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result) AuditAccessException(org.ff4j.exception.AuditAccessException)

Aggregations

AuditAccessException (org.ff4j.exception.AuditAccessException)6 IOException (java.io.IOException)5 Connection (org.apache.hadoop.hbase.client.Connection)5 Scan (org.apache.hadoop.hbase.client.Scan)5 Table (org.apache.hadoop.hbase.client.Table)5 HBaseConnection (org.ff4j.hbase.HBaseConnection)5 Result (org.apache.hadoop.hbase.client.Result)4 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)4 HashMap (java.util.HashMap)2 EventSeries (org.ff4j.audit.EventSeries)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Delete (org.apache.hadoop.hbase.client.Delete)1 FilterList (org.apache.hadoop.hbase.filter.FilterList)1 SingleColumnValueFilter (org.apache.hadoop.hbase.filter.SingleColumnValueFilter)1 MutableHitCount (org.ff4j.audit.MutableHitCount)1 FeatureAccessException (org.ff4j.exception.FeatureAccessException)1