Search in sources :

Example 6 with EventReporter

use of org.apache.nifi.events.EventReporter in project nifi by apache.

the class NodeClusterCoordinatorFactoryBean method getObject.

@Override
public NodeClusterCoordinator getObject() throws Exception {
    if (nodeClusterCoordinator == null && properties.isNode()) {
        final ClusterCoordinationProtocolSenderListener protocolSenderListener = applicationContext.getBean("clusterCoordinationProtocolSenderListener", ClusterCoordinationProtocolSenderListener.class);
        final EventReporter eventReporter = applicationContext.getBean("eventReporter", EventReporter.class);
        final ClusterNodeFirewall clusterFirewall = applicationContext.getBean("clusterFirewall", ClusterNodeFirewall.class);
        final RevisionManager revisionManager = applicationContext.getBean("revisionManager", RevisionManager.class);
        final LeaderElectionManager electionManager = applicationContext.getBean("leaderElectionManager", LeaderElectionManager.class);
        final FlowElection flowElection = applicationContext.getBean("flowElection", FlowElection.class);
        final NodeProtocolSender nodeProtocolSender = applicationContext.getBean("nodeProtocolSender", NodeProtocolSender.class);
        nodeClusterCoordinator = new NodeClusterCoordinator(protocolSenderListener, eventReporter, electionManager, flowElection, clusterFirewall, revisionManager, properties, nodeProtocolSender);
    }
    return nodeClusterCoordinator;
}
Also used : NodeProtocolSender(org.apache.nifi.cluster.protocol.NodeProtocolSender) LeaderElectionManager(org.apache.nifi.controller.leader.election.LeaderElectionManager) NodeClusterCoordinator(org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator) ClusterNodeFirewall(org.apache.nifi.cluster.firewall.ClusterNodeFirewall) RevisionManager(org.apache.nifi.web.revision.RevisionManager) FlowElection(org.apache.nifi.cluster.coordination.flow.FlowElection) ClusterCoordinationProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener) EventReporter(org.apache.nifi.events.EventReporter)

Example 7 with EventReporter

use of org.apache.nifi.events.EventReporter in project nifi by apache.

the class ThreadPoolRequestReplicatorFactoryBean method getObject.

@Override
public ThreadPoolRequestReplicator getObject() throws Exception {
    if (replicator == null && nifiProperties.isNode()) {
        final EventReporter eventReporter = applicationContext.getBean("eventReporter", EventReporter.class);
        final ClusterCoordinator clusterCoordinator = applicationContext.getBean("clusterCoordinator", ClusterCoordinator.class);
        final RequestCompletionCallback requestCompletionCallback = applicationContext.getBean("clusterCoordinator", RequestCompletionCallback.class);
        final int corePoolSize = nifiProperties.getClusterNodeProtocolCorePoolSize();
        final int maxPoolSize = nifiProperties.getClusterNodeProtocolMaxPoolSize();
        final int maxConcurrentRequests = nifiProperties.getClusterNodeMaxConcurrentRequests();
        final Client jerseyClient = WebUtils.createClient(null, SslContextFactory.createSslContext(nifiProperties));
        final String connectionTimeout = nifiProperties.getClusterNodeConnectionTimeout();
        final String readTimeout = nifiProperties.getClusterNodeReadTimeout();
        replicator = new ThreadPoolRequestReplicator(corePoolSize, maxPoolSize, maxConcurrentRequests, jerseyClient, clusterCoordinator, connectionTimeout, readTimeout, requestCompletionCallback, eventReporter, nifiProperties);
    }
    return replicator;
}
Also used : ClusterCoordinator(org.apache.nifi.cluster.coordination.ClusterCoordinator) Client(javax.ws.rs.client.Client) ThreadPoolRequestReplicator(org.apache.nifi.cluster.coordination.http.replication.ThreadPoolRequestReplicator) RequestCompletionCallback(org.apache.nifi.cluster.coordination.http.replication.RequestCompletionCallback) EventReporter(org.apache.nifi.events.EventReporter)

Example 8 with EventReporter

use of org.apache.nifi.events.EventReporter in project nifi by apache.

the class TestNodeClusterCoordinator method setup.

@Before
public void setup() throws IOException {
    System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, "src/test/resources/conf/nifi.properties");
    senderListener = Mockito.mock(ClusterCoordinationProtocolSenderListener.class);
    nodeStatuses = Collections.synchronizedList(new ArrayList<>());
    final EventReporter eventReporter = Mockito.mock(EventReporter.class);
    final RevisionManager revisionManager = Mockito.mock(RevisionManager.class);
    Mockito.when(revisionManager.getAllRevisions()).thenReturn(Collections.emptyList());
    coordinator = new NodeClusterCoordinator(senderListener, eventReporter, null, new FirstVoteWinsFlowElection(), null, revisionManager, createProperties(), null) {

        @Override
        void notifyOthersOfNodeStatusChange(NodeConnectionStatus updatedStatus, boolean notifyAllNodes, boolean waitForCoordinator) {
            nodeStatuses.add(updatedStatus);
        }
    };
    final FlowService flowService = Mockito.mock(FlowService.class);
    final StandardDataFlow dataFlow = new StandardDataFlow(new byte[50], new byte[50], new byte[50], new HashSet<>());
    Mockito.when(flowService.createDataFlow()).thenReturn(dataFlow);
    coordinator.setFlowService(flowService);
}
Also used : StandardDataFlow(org.apache.nifi.cluster.protocol.StandardDataFlow) RevisionManager(org.apache.nifi.web.revision.RevisionManager) ArrayList(java.util.ArrayList) ClusterCoordinationProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener) EventReporter(org.apache.nifi.events.EventReporter) FlowService(org.apache.nifi.services.FlowService) Before(org.junit.Before)

Example 9 with EventReporter

use of org.apache.nifi.events.EventReporter in project nifi by apache.

the class Node method createClusterCoordinator.

@SuppressWarnings("unchecked")
private NodeClusterCoordinator createClusterCoordinator() {
    final EventReporter eventReporter = new EventReporter() {

        @Override
        public void reportEvent(Severity severity, String category, String message) {
            reportedEvents.add(new ReportedEvent(nodeId, severity, message));
        }
    };
    final ServerSocketConfiguration serverSocketConfiguration = new ServerSocketConfiguration();
    serverSocketConfiguration.setSocketTimeout(5000);
    final ProtocolContext<ProtocolMessage> protocolContext = new JaxbProtocolContext<>(JaxbProtocolUtils.JAXB_CONTEXT);
    protocolListener = new SocketProtocolListener(3, Integer.parseInt(nodeProperties.getProperty(NiFiProperties.CLUSTER_NODE_PROTOCOL_PORT)), serverSocketConfiguration, protocolContext);
    try {
        protocolListener.start();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    final ClusterCoordinationProtocolSenderListener protocolSenderListener = new ClusterCoordinationProtocolSenderListener(createCoordinatorProtocolSender(), protocolListener);
    return new NodeClusterCoordinator(protocolSenderListener, eventReporter, electionManager, flowElection, null, revisionManager, nodeProperties, protocolSender);
}
Also used : SocketProtocolListener(org.apache.nifi.cluster.protocol.impl.SocketProtocolListener) NodeClusterCoordinator(org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator) Severity(org.apache.nifi.reporting.Severity) IOException(java.io.IOException) ProtocolMessage(org.apache.nifi.cluster.protocol.message.ProtocolMessage) ReportedEvent(org.apache.nifi.cluster.ReportedEvent) ServerSocketConfiguration(org.apache.nifi.io.socket.ServerSocketConfiguration) JaxbProtocolContext(org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext) ClusterCoordinationProtocolSenderListener(org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener) EventReporter(org.apache.nifi.events.EventReporter)

Example 10 with EventReporter

use of org.apache.nifi.events.EventReporter in project nifi by apache.

the class TestStandardRemoteGroupPort method setupMock.

private void setupMock(final SiteToSiteTransportProtocol protocol, final TransferDirection direction, final SiteToSiteClientConfig siteToSiteClientConfig) throws Exception {
    processGroup = null;
    remoteGroup = mock(RemoteProcessGroup.class);
    scheduler = null;
    siteToSiteClient = mock(SiteToSiteClient.class);
    this.transaction = mock(Transaction.class);
    eventReporter = mock(EventReporter.class);
    final ConnectableType connectableType;
    switch(direction) {
        case SEND:
            connectableType = ConnectableType.REMOTE_INPUT_PORT;
            break;
        case RECEIVE:
            connectableType = ConnectableType.OUTPUT_PORT;
            break;
        default:
            connectableType = null;
            break;
    }
    port = spy(new StandardRemoteGroupPort(ID, ID, NAME, processGroup, remoteGroup, direction, connectableType, null, scheduler, NiFiProperties.createBasicNiFiProperties(null, null)));
    doReturn(true).when(remoteGroup).isTransmitting();
    doReturn(protocol).when(remoteGroup).getTransportProtocol();
    doReturn(REMOTE_CLUSTER_URL).when(remoteGroup).getTargetUri();
    doReturn(siteToSiteClient).when(port).getSiteToSiteClient();
    doReturn(transaction).when(siteToSiteClient).createTransaction(eq(direction));
    doReturn(siteToSiteClientConfig).when(siteToSiteClient).getConfig();
    doReturn(eventReporter).when(remoteGroup).getEventReporter();
}
Also used : SiteToSiteClient(org.apache.nifi.remote.client.SiteToSiteClient) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ConnectableType(org.apache.nifi.connectable.ConnectableType) EventReporter(org.apache.nifi.events.EventReporter)

Aggregations

EventReporter (org.apache.nifi.events.EventReporter)19 Severity (org.apache.nifi.reporting.Severity)6 IOException (java.io.IOException)5 ClusterCoordinationProtocolSenderListener (org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener)5 ArrayList (java.util.ArrayList)4 RevisionManager (org.apache.nifi.web.revision.RevisionManager)4 File (java.io.File)3 List (java.util.List)3 Before (org.junit.Before)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ExecutorService (java.util.concurrent.ExecutorService)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Authorizer (org.apache.nifi.authorization.Authorizer)2 NodeClusterCoordinator (org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator)2 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)2 StandardDataFlow (org.apache.nifi.cluster.protocol.StandardDataFlow)2 RecordReaders (org.apache.nifi.provenance.serialization.RecordReaders)2 EventFileManager (org.apache.nifi.provenance.store.EventFileManager)2