Search in sources :

Example 16 with ProcessScheduler

use of org.apache.nifi.controller.ProcessScheduler in project nifi by apache.

the class TestProcessorLifecycle method validateIdempotencyOfProcessorStartOperation.

/**
 * Will validate the idempotent nature of processor start operation which
 * can be called multiple times without any side-effects.
 */
@Test
public void validateIdempotencyOfProcessorStartOperation() throws Exception {
    final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
    fc = fcsb.getFlowController();
    ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
    this.setControllerRootGroup(fc, testGroup);
    final ProcessorNode testProcNode = fc.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(), fcsb.getSystemBundle().getBundleDetails().getCoordinate());
    testProcNode.setProperties(properties);
    TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
    // sets the scenario for the processor to run
    this.noop(testProcessor);
    final ProcessScheduler ps = fc.getProcessScheduler();
    ps.startProcessor(testProcNode, true);
    ps.startProcessor(testProcNode, true);
    ps.startProcessor(testProcNode, true);
    Thread.sleep(500);
    assertCondition(() -> testProcessor.operationNames.size() == 1);
    assertEquals("@OnScheduled", testProcessor.operationNames.get(0));
}
Also used : ProcessScheduler(org.apache.nifi.controller.ProcessScheduler) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Test(org.junit.Test)

Aggregations

ProcessScheduler (org.apache.nifi.controller.ProcessScheduler)16 ProcessGroup (org.apache.nifi.groups.ProcessGroup)15 ProcessorNode (org.apache.nifi.controller.ProcessorNode)14 Test (org.junit.Test)14 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 AuthorizationRequest (org.apache.nifi.authorization.AuthorizationRequest)1 Authorizer (org.apache.nifi.authorization.Authorizer)1 Connection (org.apache.nifi.connectable.Connection)1 StandardFlowFileQueue (org.apache.nifi.controller.StandardFlowFileQueue)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1 BulletinRepository (org.apache.nifi.reporting.BulletinRepository)1 Ignore (org.junit.Ignore)1