Search in sources :

Example 1 with HeartbeatMonitor

use of org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor 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 HeartbeatMonitor

use of org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor in project nifi by apache.

the class FlowControllerFactoryBean method getObject.

@Override
public Object getObject() throws Exception {
    if (flowController == null) {
        final FlowFileEventRepository flowFileEventRepository = applicationContext.getBean("flowFileEventRepository", FlowFileEventRepository.class);
        if (properties.isNode()) {
            final NodeProtocolSender nodeProtocolSender = applicationContext.getBean("nodeProtocolSender", NodeProtocolSender.class);
            final HeartbeatMonitor heartbeatMonitor = applicationContext.getBean("heartbeatMonitor", HeartbeatMonitor.class);
            flowController = FlowController.createClusteredInstance(flowFileEventRepository, properties, authorizer, auditService, encryptor, nodeProtocolSender, bulletinRepository, clusterCoordinator, heartbeatMonitor, leaderElectionManager, variableRegistry, flowRegistryClient);
        } else {
            flowController = FlowController.createStandaloneInstance(flowFileEventRepository, properties, authorizer, auditService, encryptor, bulletinRepository, variableRegistry, flowRegistryClient);
        }
    }
    return flowController;
}
Also used : HeartbeatMonitor(org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) NodeProtocolSender(org.apache.nifi.cluster.protocol.NodeProtocolSender)

Aggregations

HeartbeatMonitor (org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor)2 IOException (java.io.IOException)1 ClusterProtocolHeartbeatMonitor (org.apache.nifi.cluster.coordination.heartbeat.ClusterProtocolHeartbeatMonitor)1 NodeProtocolSender (org.apache.nifi.cluster.protocol.NodeProtocolSender)1 NodeProtocolSenderListener (org.apache.nifi.cluster.protocol.impl.NodeProtocolSenderListener)1 FlowFileEventRepository (org.apache.nifi.controller.repository.FlowFileEventRepository)1