Java Code Examples for org.apache.nifi.components.state.Scope#CLUSTER
The following examples show how to use
org.apache.nifi.components.state.Scope#CLUSTER .
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: MockStateManager.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public synchronized boolean replace(final StateMap oldValue, final Map<String, String> newValue, final Scope scope) throws IOException { verifyAnnotation(scope); if (scope == Scope.CLUSTER) { if (oldValue == clusterStateMap) { verifyCanSet(scope); clusterStateMap = new MockStateMap(newValue, versionIndex.incrementAndGet()); return true; } return false; } else { if (oldValue == localStateMap) { verifyCanSet(scope); localStateMap = new MockStateMap(newValue, versionIndex.incrementAndGet()); return true; } return false; } }
Example 2
Source File: MockStateManager.java From nifi with Apache License 2.0 | 6 votes |
@Override public synchronized boolean replace(final StateMap oldValue, final Map<String, String> newValue, final Scope scope) throws IOException { verifyAnnotation(scope); if (scope == Scope.CLUSTER) { if (oldValue == clusterStateMap) { verifyCanSet(scope); clusterStateMap = new MockStateMap(newValue, versionIndex.incrementAndGet()); return true; } return false; } else { if (oldValue == localStateMap) { verifyCanSet(scope); localStateMap = new MockStateMap(newValue, versionIndex.incrementAndGet()); return true; } return false; } }
Example 3
Source File: MockStateManager.java From nifi with Apache License 2.0 | 6 votes |
public MockStateManager(final Object component) { final Stateful stateful = component.getClass().getAnnotation(Stateful.class); if (stateful == null) { usesLocalState = false; usesClusterState = false; } else { final Scope[] scopes = stateful.scopes(); boolean local = false; boolean cluster = false; for (final Scope scope : scopes) { if (scope == Scope.LOCAL) { local = true; } else if (scope == Scope.CLUSTER) { cluster = true; } } usesLocalState = local; usesClusterState = cluster; } }
Example 4
Source File: MockStateManager.java From nifi with Apache License 2.0 | 5 votes |
private String getValue(final String key, final Scope scope) { final StateMap stateMap; if (scope == Scope.CLUSTER) { stateMap = clusterStateMap; } else { stateMap = localStateMap; } return stateMap.get(key); }
Example 5
Source File: TailFile.java From nifi with Apache License 2.0 | 5 votes |
private Scope getStateScope(final ProcessContext context) { final String location = context.getProperty(STATE_LOCATION).getValue(); if (LOCATION_REMOTE.getValue().equalsIgnoreCase(location)) { return Scope.CLUSTER; } return Scope.LOCAL; }
Example 6
Source File: MockStateManager.java From nifi with Apache License 2.0 | 5 votes |
private void verifyAnnotation(final Scope scope) { // ensure that the @Stateful annotation is present with the appropriate Scope if ((scope == Scope.LOCAL && !usesLocalState) || (scope == Scope.CLUSTER && !usesClusterState)) { Assert.fail("Component is attempting to set or retrieve state with a scope of " + scope + " but does not declare that it will use " + scope + " state. A @Stateful annotation should be added to the component with a scope of " + scope); } }
Example 7
Source File: MockStateManager.java From localization_nifi with Apache License 2.0 | 5 votes |
private String getValue(final String key, final Scope scope) { final StateMap stateMap; if (scope == Scope.CLUSTER) { stateMap = clusterStateMap; } else { stateMap = localStateMap; } return stateMap.get(key); }
Example 8
Source File: MockStateManager.java From nifi with Apache License 2.0 | 5 votes |
private synchronized StateMap retrieveState(final Scope scope) { verifyAnnotation(scope); if (scope == Scope.CLUSTER) { return clusterStateMap; } else { return localStateMap; } }
Example 9
Source File: TailFile.java From localization_nifi with Apache License 2.0 | 5 votes |
private Scope getStateScope(final ProcessContext context) { final String location = context.getProperty(STATE_LOCATION).getValue(); if (LOCATION_REMOTE.getValue().equalsIgnoreCase(location)) { return Scope.CLUSTER; } return Scope.LOCAL; }
Example 10
Source File: ListFile.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override protected Scope getStateScope(final ProcessContext context) { final String location = context.getProperty(DIRECTORY_LOCATION).getValue(); if (LOCATION_REMOTE.getValue().equalsIgnoreCase(location)) { return Scope.CLUSTER; } return Scope.LOCAL; }
Example 11
Source File: MockStateManager.java From nifi with Apache License 2.0 | 5 votes |
@Override public synchronized void setState(final Map<String, String> state, final Scope scope) throws IOException { verifyAnnotation(scope); verifyCanSet(scope); final StateMap stateMap = new MockStateMap(state, versionIndex.incrementAndGet()); if (scope == Scope.CLUSTER) { clusterStateMap = stateMap; } else { localStateMap = stateMap; } }
Example 12
Source File: ListFTP.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override protected Scope getStateScope(final ProcessContext context) { // Use cluster scope so that component can be run on Primary Node Only and can still // pick up where it left off, even if the Primary Node changes. return Scope.CLUSTER; }
Example 13
Source File: RedisStateProvider.java From nifi with Apache License 2.0 | 4 votes |
@Override public Scope[] getSupportedScopes() { return new Scope[] {Scope.CLUSTER}; }
Example 14
Source File: ZooKeeperStateProvider.java From nifi with Apache License 2.0 | 4 votes |
@Override public Scope[] getSupportedScopes() { return new Scope[]{Scope.CLUSTER}; }
Example 15
Source File: ListFTP.java From nifi with Apache License 2.0 | 4 votes |
@Override protected Scope getStateScope(final PropertyContext context) { // Use cluster scope so that component can be run on Primary Node Only and can still // pick up where it left off, even if the Primary Node changes. return Scope.CLUSTER; }
Example 16
Source File: TestAbstractListProcessor.java From nifi with Apache License 2.0 | 4 votes |
@Override protected Scope getStateScope(final PropertyContext context) { return Scope.CLUSTER; }
Example 17
Source File: ListAzureBlobStorage.java From nifi with Apache License 2.0 | 4 votes |
@Override protected Scope getStateScope(final PropertyContext context) { return Scope.CLUSTER; }
Example 18
Source File: MockStateManager.java From nifi with Apache License 2.0 | 2 votes |
/** * Ensures that the state was set for the given scope, regardless of what the value was. * * @param scope the scope */ public void assertStateSet(final Scope scope) { final StateMap stateMap = (scope == Scope.CLUSTER) ? clusterStateMap : localStateMap; Assert.assertNotSame("Expected state to be set for Scope " + scope + ", but it was not set", -1L, stateMap.getVersion()); }
Example 19
Source File: MockStateManager.java From localization_nifi with Apache License 2.0 | 2 votes |
/** * Ensures that the state was not set for the given scope * * @param scope the scope */ public void assertStateNotSet(final Scope scope) { final StateMap stateMap = (scope == Scope.CLUSTER) ? clusterStateMap : localStateMap; Assert.assertEquals("Expected state not to be set for Scope " + scope + ", but it was set", -1L, stateMap.getVersion()); }
Example 20
Source File: MockStateManager.java From localization_nifi with Apache License 2.0 | 2 votes |
/** * Ensures that the state was set for the given scope, regardless of what the value was. * * @param scope the scope */ public void assertStateSet(final Scope scope) { final StateMap stateMap = (scope == Scope.CLUSTER) ? clusterStateMap : localStateMap; Assert.assertNotSame("Expected state to be set for Scope " + scope + ", but it was not set", -1L, stateMap.getVersion()); }