Search in sources :

Example 1 with NodeProtocolSenderListener

use of org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener in project nifi by apache.

the class Node method start.

public synchronized void start() {
    running = true;
    protocolSender = createNodeProtocolSender();
    clusterCoordinator = createClusterCoordinator();
    clusterCoordinator.setLocalNodeIdentifier(nodeId);
    // clusterCoordinator.setConnected(true);
    final HeartbeatMonitor heartbeatMonitor = createHeartbeatMonitor();
    flowController = FlowController.createClusteredInstance(Mockito.mock(FlowFileEventRepository.class), nodeProperties, null, null, StringEncryptor.createEncryptor(nodeProperties), protocolSender, Mockito.mock(BulletinRepository.class), clusterCoordinator, heartbeatMonitor, electionManager, VariableRegistry.EMPTY_REGISTRY, Mockito.mock(FlowRegistryClient.class));
    try {
        flowController.initializeFlow();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    final NodeProtocolSenderListener senderListener = new NodeProtocolSenderListener(protocolSender, protocolListener);
    try {
        flowController.getStateManagerProvider().getStateManager("Cluster Node Configuration").setState(Collections.singletonMap("Node UUID", nodeId.getId()), Scope.LOCAL);
        flowService = StandardFlowService.createClusteredInstance(flowController, nodeProperties, senderListener, clusterCoordinator, StringEncryptor.createEncryptor(nodeProperties), revisionManager, Mockito.mock(Authorizer.class));
        flowService.start();
        flowService.load(null);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : ClusterProtocolHeartbeatMonitor(org.apache.nifi.cluster.coordination.heartbeat.ClusterProtocolHeartbeatMonitor) HeartbeatMonitor(org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor) IOException(java.io.IOException) NodeProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener) IOException(java.io.IOException)

Example 2 with NodeProtocolSenderListener

use of org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener in project nifi by apache.

the class StandardFlowServiceFactoryBean method getObject.

@Override
public Object getObject() throws Exception {
    if (flowService == null) {
        final FlowController flowController = applicationContext.getBean("flowController", FlowController.class);
        final RevisionManager revisionManager = applicationContext.getBean("revisionManager", RevisionManager.class);
        if (properties.isNode()) {
            final NodeProtocolSenderListener nodeProtocolSenderListener = applicationContext.getBean("nodeProtocolSenderListener", NodeProtocolSenderListener.class);
            final ClusterCoordinator clusterCoordinator = applicationContext.getBean("clusterCoordinator", ClusterCoordinator.class);
            flowService = StandardFlowService.createClusteredInstance(flowController, properties, nodeProtocolSenderListener, clusterCoordinator, encryptor, revisionManager, authorizer);
        } else {
            flowService = StandardFlowService.createStandaloneInstance(flowController, properties, encryptor, revisionManager, authorizer);
        }
    }
    return flowService;
}
Also used : RevisionManager(org.apache.nifi.web.revision.RevisionManager) ClusterCoordinator(org.apache.nifi.cluster.coordination.ClusterCoordinator) FlowController(org.apache.nifi.controller.FlowController) NodeProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener)

Aggregations

NodeProtocolSenderListener (org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener)2 IOException (java.io.IOException)1 ClusterCoordinator (org.apache.nifi.cluster.coordination.ClusterCoordinator)1 ClusterProtocolHeartbeatMonitor (org.apache.nifi.cluster.coordination.heartbeat.ClusterProtocolHeartbeatMonitor)1 HeartbeatMonitor (org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor)1 FlowController (org.apache.nifi.controller.FlowController)1 RevisionManager (org.apache.nifi.web.revision.RevisionManager)1