Search in sources :

Example 1 with MultiDestAuditProvider

use of org.apache.ranger.audit.provider.MultiDestAuditProvider in project ranger by apache.

the class TestAuditQueue method testMultipleQueue.

@Test
public void testMultipleQueue() {
    logger.debug("testAuditAsyncQueue()...");
    int destCount = 3;
    TestConsumer[] testConsumer = new TestConsumer[destCount];
    MultiDestAuditProvider multiQueue = new MultiDestAuditProvider();
    for (int i = 0; i < destCount; i++) {
        testConsumer[i] = new TestConsumer();
        multiQueue.addAuditProvider(testConsumer[i]);
    }
    AuditAsyncQueue queue = new AuditAsyncQueue(multiQueue);
    Properties props = new Properties();
    queue.init(props);
    queue.start();
    int messageToSend = 10;
    for (int i = 0; i < messageToSend; i++) {
        queue.log(createEvent());
    }
    queue.stop();
    queue.waitToComplete();
    // Let's wait for second
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    // ignore
    }
    for (int i = 0; i < destCount; i++) {
        assertEquals("consumer" + i, messageToSend, testConsumer[i].getCountTotal());
        assertEquals("consumer" + i, messageToSend, testConsumer[i].getSumTotal());
    }
}
Also used : MultiDestAuditProvider(org.apache.ranger.audit.provider.MultiDestAuditProvider) AuditAsyncQueue(org.apache.ranger.audit.queue.AuditAsyncQueue) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Properties (java.util.Properties)1 MultiDestAuditProvider (org.apache.ranger.audit.provider.MultiDestAuditProvider)1 AuditAsyncQueue (org.apache.ranger.audit.queue.AuditAsyncQueue)1 Test (org.junit.Test)1