Java Code Examples for org.apache.nifi.registry.VariableRegistry#EMPTY_REGISTRY
The following examples show how to use
org.apache.nifi.registry.VariableRegistry#EMPTY_REGISTRY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStandardProcessScheduler.java From nifi with Apache License 2.0 | 6 votes |
@Test(timeout = 10000) public void testProcessorThrowsExceptionOnScheduledRetry() throws InterruptedException { final FailOnScheduledProcessor proc = new FailOnScheduledProcessor(); proc.setDesiredFailureCount(3); proc.initialize(new StandardProcessorInitializationContext(UUID.randomUUID().toString(), null, null, null, KerberosConfig.NOT_CONFIGURED)); final ReloadComponent reloadComponent = Mockito.mock(ReloadComponent.class); final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(proc, systemBundle.getBundleDetails().getCoordinate(), null); final ProcessorNode procNode = new StandardProcessorNode(loggableComponent, UUID.randomUUID().toString(), new StandardValidationContextFactory(serviceProvider, variableRegistry), scheduler, serviceProvider, new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger()); procNode.performValidation(); rootGroup.addProcessor(procNode); scheduler.startProcessor(procNode, true); while (!proc.isSucceess()) { Thread.sleep(5L); } assertEquals(3, proc.getOnScheduledInvocationCount()); }
Example 2
Source File: TestStandardControllerServiceProvider.java From nifi with Apache License 2.0 | 6 votes |
private ProcessorNode createProcessor(final StandardProcessScheduler scheduler, final ControllerServiceProvider serviceProvider) { final ReloadComponent reloadComponent = Mockito.mock(ReloadComponent.class); final Processor processor = new DummyProcessor(); final MockProcessContext context = new MockProcessContext(processor, Mockito.mock(StateManager.class), variableRegistry); final MockProcessorInitializationContext mockInitContext = new MockProcessorInitializationContext(processor, context); processor.initialize(mockInitContext); final LoggableComponent<Processor> dummyProcessor = new LoggableComponent<>(processor, systemBundle.getBundleDetails().getCoordinate(), null); final ProcessorNode procNode = new StandardProcessorNode(dummyProcessor, mockInitContext.getIdentifier(), new StandardValidationContextFactory(serviceProvider, null), scheduler, serviceProvider, new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger()); final FlowManager flowManager = Mockito.mock(FlowManager.class); final FlowController flowController = Mockito.mock(FlowController.class ); Mockito.when(flowController.getFlowManager()).thenReturn(flowManager); final ProcessGroup group = new StandardProcessGroup(UUID.randomUUID().toString(), serviceProvider, scheduler, null, null, flowController, new MutableVariableRegistry(variableRegistry)); group.addProcessor(procNode); procNode.setProcessGroup(group); return procNode; }
Example 3
Source File: ValueLookup.java From nifi with Apache License 2.0 | 6 votes |
/** * Constructs a ValueLookup where values are looked up first based any * provided additional maps, then flowfile properties, then flowfile * attributes, then based on the provided variable registry. The lookup is * immutable and operations which attempt to alter state will throw * UnsupportedOperationException * * @param registry the variable registry to lookup from; may be null * @param flowFile the flowFile to pull attributes from; may be null * @param additionalMaps the maps to pull values from; may be null or empty */ @SuppressWarnings("unchecked") ValueLookup(final VariableRegistry registry, final FlowFile flowFile, final Map<String, String>... additionalMaps) { for (final Map<String, String> map : additionalMaps) { if (map != null && !map.isEmpty()) { maps.add(map); } } if (flowFile != null) { maps.add(ValueLookup.extractFlowFileProperties(flowFile)); maps.add(flowFile.getAttributes()); } this.registry = registry == null ? VariableRegistry.EMPTY_REGISTRY : registry; }
Example 4
Source File: TestQuery.java From nifi with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private String evaluateQueryForEscape(final String queryString, final Map<String, String> attributes) { final FlowFile mockFlowFile = Mockito.mock(FlowFile.class); Mockito.when(mockFlowFile.getAttributes()).thenReturn(attributes); Mockito.when(mockFlowFile.getId()).thenReturn(1L); Mockito.when(mockFlowFile.getEntryDate()).thenReturn(System.currentTimeMillis()); Mockito.when(mockFlowFile.getSize()).thenReturn(1L); Mockito.when(mockFlowFile.getLineageStartDate()).thenReturn(System.currentTimeMillis()); final ValueLookup lookup = new ValueLookup(VariableRegistry.EMPTY_REGISTRY, mockFlowFile); return Query.evaluateExpressions(queryString, lookup, ParameterLookup.EMPTY); }
Example 5
Source File: TestStandardProcessScheduler.java From nifi with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException, ExecutionException { final String uuid = UUID.randomUUID().toString(); final Processor proc = new ServiceReferencingProcessor(); proc.initialize(new StandardProcessorInitializationContext(uuid, null, null, null, KerberosConfig.NOT_CONFIGURED)); final ReloadComponent reloadComponent = Mockito.mock(ReloadComponent.class); final ControllerServiceNode service = flowManager.createControllerService(NoStartServiceImpl.class.getName(), "service", systemBundle.getBundleDetails().getCoordinate(), null, true, true); rootGroup.addControllerService(service); final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(proc, systemBundle.getBundleDetails().getCoordinate(), null); final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(serviceProvider, variableRegistry); final ProcessorNode procNode = new StandardProcessorNode(loggableComponent, uuid, validationContextFactory, scheduler, serviceProvider, new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger()); rootGroup.addProcessor(procNode); Map<String, String> procProps = new HashMap<>(); procProps.put(ServiceReferencingProcessor.SERVICE_DESC.getName(), service.getIdentifier()); procNode.setProperties(procProps); service.performValidation(); scheduler.enableControllerService(service); procNode.performValidation(); scheduler.startProcessor(procNode, true); Thread.sleep(25L); scheduler.stopProcessor(procNode); assertTrue(service.isActive()); assertSame(service.getState(), ControllerServiceState.ENABLING); scheduler.disableControllerService(service).get(); assertFalse(service.isActive()); assertSame(service.getState(), ControllerServiceState.DISABLED); }
Example 6
Source File: TestQuery.java From localization_nifi with Apache License 2.0 | 5 votes |
private String evaluateQueryForEscape(final String queryString, final Map<String, String> attributes) { final FlowFile mockFlowFile = Mockito.mock(FlowFile.class); Mockito.when(mockFlowFile.getAttributes()).thenReturn(attributes); Mockito.when(mockFlowFile.getId()).thenReturn(1L); Mockito.when(mockFlowFile.getEntryDate()).thenReturn(System.currentTimeMillis()); Mockito.when(mockFlowFile.getSize()).thenReturn(1L); Mockito.when(mockFlowFile.getLineageStartDate()).thenReturn(System.currentTimeMillis()); final ValueLookup lookup = new ValueLookup(VariableRegistry.EMPTY_REGISTRY, mockFlowFile); return Query.evaluateExpressions(queryString, lookup); }
Example 7
Source File: TestStandardProcessScheduler.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException { final String uuid = UUID.randomUUID().toString(); final Processor proc = new ServiceReferencingProcessor(); proc.initialize(new StandardProcessorInitializationContext(uuid, null, null, null, null)); final StandardControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(controller, scheduler, null, Mockito.mock(StateManagerProvider.class), variableRegistry, nifiProperties); final ControllerServiceNode service = serviceProvider.createControllerService(NoStartServiceImpl.class.getName(), "service", true); rootGroup.addControllerService(service); final ProcessorNode procNode = new StandardProcessorNode(proc, uuid, new StandardValidationContextFactory(serviceProvider, variableRegistry), scheduler, serviceProvider, nifiProperties, VariableRegistry.EMPTY_REGISTRY, Mockito.mock(ComponentLog.class)); rootGroup.addProcessor(procNode); Map<String,String> procProps = new HashMap<>(); procProps.put(ServiceReferencingProcessor.SERVICE_DESC.getName(), service.getIdentifier()); procNode.setProperties(procProps); scheduler.enableControllerService(service); scheduler.startProcessor(procNode); Thread.sleep(1000L); scheduler.stopProcessor(procNode); assertTrue(service.isActive()); assertTrue(service.getState() == ControllerServiceState.ENABLING); scheduler.disableControllerService(service); assertTrue(service.getState() == ControllerServiceState.DISABLING); assertFalse(service.isActive()); Thread.sleep(2000); assertTrue(service.getState() == ControllerServiceState.DISABLED); }
Example 8
Source File: TestStandardProcessorNode.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void testStart() throws InterruptedException { System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestStandardProcessorNode.class.getResource("/conf/nifi.properties").getFile()); final ProcessorThatThrowsExceptionOnScheduled processor = new ProcessorThatThrowsExceptionOnScheduled(); final String uuid = UUID.randomUUID().toString(); ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, null, null, null, null); processor.initialize(initContext); final StandardProcessorNode procNode = new StandardProcessorNode(processor, uuid, createValidationContextFactory(), null, null, NiFiProperties.createBasicNiFiProperties(null, null), VariableRegistry.EMPTY_REGISTRY, Mockito.mock(ComponentLog.class)); final ScheduledExecutorService taskScheduler = new FlowEngine(2, "TestClasspathResources", true); final StandardProcessContext processContext = new StandardProcessContext(procNode, null, null, null, null); final SchedulingAgentCallback schedulingAgentCallback = new SchedulingAgentCallback() { @Override public void postMonitor() { } @Override public Future<?> invokeMonitoringTask(final Callable<?> task) { return taskScheduler.submit(task); } @Override public void trigger() { Assert.fail("Should not have completed"); } }; procNode.start(taskScheduler, 20000L, processContext, schedulingAgentCallback); Thread.sleep(1000L); assertEquals(1, processor.onScheduledCount); assertEquals(1, processor.onUnscheduledCount); assertEquals(1, processor.onStoppedCount); }
Example 9
Source File: TestStandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 5 votes |
private ProcessorNode createProcessor(final StandardProcessScheduler scheduler, final ControllerServiceProvider serviceProvider) { final ProcessorNode procNode = new StandardProcessorNode(new DummyProcessor(), UUID.randomUUID().toString(), new StandardValidationContextFactory(serviceProvider, null), scheduler, serviceProvider, NiFiProperties.createBasicNiFiProperties(null, null), VariableRegistry.EMPTY_REGISTRY, Mockito.mock(ComponentLog.class)); final ProcessGroup group = new StandardProcessGroup(UUID.randomUUID().toString(), serviceProvider, scheduler, null, null, null, variableRegistry); group.addProcessor(procNode); procNode.setProcessGroup(group); return procNode; }
Example 10
Source File: StatelessPropertyValue.java From nifi with Apache License 2.0 | 4 votes |
public StatelessPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final ParameterLookup parameterLookup) { this(rawValue, serviceLookup, parameterLookup, VariableRegistry.EMPTY_REGISTRY, null); }
Example 11
Source File: MockValidationContext.java From localization_nifi with Apache License 2.0 | 4 votes |
public MockValidationContext(final MockProcessContext processContext) { this(processContext, null, VariableRegistry.EMPTY_REGISTRY); }
Example 12
Source File: StandardPropertyValue.java From nifi with Apache License 2.0 | 4 votes |
public StandardPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final ParameterLookup parameterLookup) { this(rawValue, serviceLookup, parameterLookup, Query.prepare(rawValue), VariableRegistry.EMPTY_REGISTRY); }
Example 13
Source File: MockConfigurationContext.java From nifi with Apache License 2.0 | 4 votes |
public MockConfigurationContext(final Map<PropertyDescriptor, String> properties, final ControllerServiceLookup serviceLookup) { this(null, properties, serviceLookup, VariableRegistry.EMPTY_REGISTRY); }
Example 14
Source File: MockProcessContext.java From nifi with Apache License 2.0 | 4 votes |
public MockProcessContext(final ConfigurableComponent component, final String componentName) { this(component, componentName, new MockStateManager(component), VariableRegistry.EMPTY_REGISTRY); }
Example 15
Source File: TestStandardProcessorNode.java From nifi with Apache License 2.0 | 4 votes |
@Test(timeout = 10000) public void testStart() throws InterruptedException { final ProcessorThatThrowsExceptionOnScheduled processor = new ProcessorThatThrowsExceptionOnScheduled(); final String uuid = UUID.randomUUID().toString(); ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, null, null, null, KerberosConfig.NOT_CONFIGURED); processor.initialize(initContext); final ReloadComponent reloadComponent = mock(ReloadComponent.class); final BundleCoordinate coordinate = mock(BundleCoordinate.class); final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(processor, coordinate, null); final StandardProcessorNode procNode = new StandardProcessorNode(loggableComponent, uuid, createValidationContextFactory(), null, null, new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger()); final ScheduledExecutorService taskScheduler = new FlowEngine(1, "TestClasspathResources", true); final StandardProcessContext processContext = new StandardProcessContext(procNode, null, null, null, () -> false); final SchedulingAgentCallback schedulingAgentCallback = new SchedulingAgentCallback() { @Override public void onTaskComplete() { } @Override public Future<?> scheduleTask(final Callable<?> task) { return taskScheduler.submit(task); } @Override public void trigger() { Assert.fail("Should not have completed"); } }; procNode.performValidation(); procNode.start(taskScheduler, 20000L, 10000L, () -> processContext, schedulingAgentCallback, true); Thread.sleep(1000L); assertEquals(1, processor.onScheduledCount); assertEquals(1, processor.onUnscheduledCount); assertEquals(1, processor.onStoppedCount); }
Example 16
Source File: MockValidationContext.java From nifi with Apache License 2.0 | 4 votes |
public MockValidationContext(final MockProcessContext processContext) { this(processContext, null, VariableRegistry.EMPTY_REGISTRY); }
Example 17
Source File: StandardPropertyValue.java From localization_nifi with Apache License 2.0 | 4 votes |
public StandardPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup) { this(rawValue, serviceLookup, Query.prepare(rawValue), VariableRegistry.EMPTY_REGISTRY); }
Example 18
Source File: MockConfigurationContext.java From localization_nifi with Apache License 2.0 | 4 votes |
public MockConfigurationContext(final Map<PropertyDescriptor, String> properties, final ControllerServiceLookup serviceLookup) { this(null, properties, serviceLookup, VariableRegistry.EMPTY_REGISTRY); }
Example 19
Source File: MockProcessContext.java From localization_nifi with Apache License 2.0 | 4 votes |
public MockProcessContext(final ConfigurableComponent component) { this(component, new MockStateManager(component),VariableRegistry.EMPTY_REGISTRY); }
Example 20
Source File: MockPropertyValue.java From localization_nifi with Apache License 2.0 | 4 votes |
public MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup) { this(rawValue, serviceLookup, VariableRegistry.EMPTY_REGISTRY, null); }