Search in sources :

Example 1 with Severity

use of org.apache.nifi.reporting.Severity in project nifi by apache.

the class NodeClusterCoordinator method disconnectionRequestedByNode.

@Override
public void disconnectionRequestedByNode(final NodeIdentifier nodeId, final DisconnectionCode disconnectionCode, final String explanation) {
    logger.info("{} requested disconnection from cluster due to {}", nodeId, explanation == null ? disconnectionCode : explanation);
    updateNodeStatus(new NodeConnectionStatus(nodeId, disconnectionCode, explanation));
    final Severity severity;
    switch(disconnectionCode) {
        case STARTUP_FAILURE:
        case MISMATCHED_FLOWS:
        case UNKNOWN:
            severity = Severity.ERROR;
            break;
        case LACK_OF_HEARTBEAT:
            severity = Severity.WARNING;
            break;
        default:
            severity = Severity.INFO;
            break;
    }
    reportEvent(nodeId, severity, "Node disconnected from cluster due to " + explanation);
}
Also used : Severity(org.apache.nifi.reporting.Severity)

Example 2 with Severity

use of org.apache.nifi.reporting.Severity 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 3 with Severity

use of org.apache.nifi.reporting.Severity in project nifi by apache.

the class FlowController method createEventReporter.

private static EventReporter createEventReporter(final BulletinRepository bulletinRepository) {
    return new EventReporter() {

        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final Bulletin bulletin = BulletinFactory.createBulletin(category, severity.name(), message);
            bulletinRepository.addBulletin(bulletin);
        }
    };
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) Severity(org.apache.nifi.reporting.Severity) EventReporter(org.apache.nifi.events.EventReporter)

Example 4 with Severity

use of org.apache.nifi.reporting.Severity in project nifi by apache.

the class TestPersistentProvenanceRepository method printTestName.

@Before
public void printTestName() {
    System.out.println("\n\n\n***********************  " + name.getMethodName() + "  *****************************");
    reportedEvents.clear();
    eventReporter = new EventReporter() {

        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(Severity severity, String category, String message) {
            reportedEvents.add(new ReportedEvent(severity, category, message));
            System.out.println(severity + " : " + category + " : " + message);
        }
    };
}
Also used : Severity(org.apache.nifi.reporting.Severity) EventReporter(org.apache.nifi.events.EventReporter) Before(org.junit.Before)

Example 5 with Severity

use of org.apache.nifi.reporting.Severity in project nifi by apache.

the class TestHttpClientTransaction method getClientTransaction.

private HttpClientTransaction getClientTransaction(InputStream is, OutputStream os, SiteToSiteRestApiClient apiClient, TransferDirection direction, String transactionUrl) throws IOException {
    PeerDescription description = null;
    String peerUrl = "";
    HttpCommunicationsSession commsSession = new HttpCommunicationsSession();
    ((HttpInput) commsSession.getInput()).setInputStream(is);
    ((HttpOutput) commsSession.getOutput()).setOutputStream(os);
    String clusterUrl = "";
    Peer peer = new Peer(description, commsSession, peerUrl, clusterUrl);
    String portId = "portId";
    boolean useCompression = false;
    int penaltyMillis = 1000;
    EventReporter eventReporter = new EventReporter() {

        @Override
        public void reportEvent(Severity severity, String category, String message) {
            logger.info("Reporting event... severity={}, category={}, message={}", severity, category, message);
        }
    };
    int protocolVersion = 5;
    HttpClientTransaction transaction = new HttpClientTransaction(protocolVersion, peer, direction, useCompression, portId, penaltyMillis, eventReporter);
    transaction.initialize(apiClient, transactionUrl);
    return transaction;
}
Also used : HttpInput(org.apache.nifi.remote.io.http.HttpInput) PeerDescription(org.apache.nifi.remote.PeerDescription) HttpCommunicationsSession(org.apache.nifi.remote.io.http.HttpCommunicationsSession) Peer(org.apache.nifi.remote.Peer) Severity(org.apache.nifi.reporting.Severity) HttpOutput(org.apache.nifi.remote.io.http.HttpOutput) EventReporter(org.apache.nifi.events.EventReporter)

Aggregations

Severity (org.apache.nifi.reporting.Severity)6 EventReporter (org.apache.nifi.events.EventReporter)5 Before (org.junit.Before)2 IOException (java.io.IOException)1 ReportedEvent (org.apache.nifi.cluster.ReportedEvent)1 NodeClusterCoordinator (org.apache.nifi.cluster.coordination.node.NodeClusterCoordinator)1 ClusterCoordinationProtocolSenderListener (org.apache.nifi.cluster.protocol.impl.ClusterCoordinationProtocolSenderListener)1 SocketProtocolListener (org.apache.nifi.cluster.protocol.impl.SocketProtocolListener)1 JaxbProtocolContext (org.apache.nifi.cluster.protocol.jaxb.JaxbProtocolContext)1 ProtocolMessage (org.apache.nifi.cluster.protocol.message.ProtocolMessage)1 ServerSocketConfiguration (org.apache.nifi.io.socket.ServerSocketConfiguration)1 Peer (org.apache.nifi.remote.Peer)1 PeerDescription (org.apache.nifi.remote.PeerDescription)1 HttpCommunicationsSession (org.apache.nifi.remote.io.http.HttpCommunicationsSession)1 HttpInput (org.apache.nifi.remote.io.http.HttpInput)1 HttpOutput (org.apache.nifi.remote.io.http.HttpOutput)1 Bulletin (org.apache.nifi.reporting.Bulletin)1