use of org.apache.nifi.cluster.protocol.message.ClusterWorkloadRequestMessage in project nifi by apache.
the class NodeClusterCoordinator method getClusterWorkload.
@Override
public Map<NodeIdentifier, NodeWorkload> getClusterWorkload() throws IOException {
final ClusterWorkloadRequestMessage request = new ClusterWorkloadRequestMessage();
final ClusterWorkloadResponseMessage response = nodeProtocolSender.clusterWorkload(request);
return response.getNodeWorkloads();
}
use of org.apache.nifi.cluster.protocol.message.ClusterWorkloadRequestMessage in project nifi by apache.
the class TestJaxbProtocolUtils method testRoundTripClusterWorkloadRequest.
@Test
public void testRoundTripClusterWorkloadRequest() throws JAXBException {
final ClusterWorkloadRequestMessage msg = new ClusterWorkloadRequestMessage();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
JaxbProtocolUtils.JAXB_CONTEXT.createMarshaller().marshal(msg, baos);
final Object unmarshalled = JaxbProtocolUtils.JAXB_CONTEXT.createUnmarshaller().unmarshal(new ByteArrayInputStream(baos.toByteArray()));
assertTrue(unmarshalled instanceof ClusterWorkloadRequestMessage);
}
use of org.apache.nifi.cluster.protocol.message.ClusterWorkloadRequestMessage in project nifi by apache.
the class ClusterProtocolHeartbeatMonitor method handleClusterWorkload.
private ProtocolMessage handleClusterWorkload(final ClusterWorkloadRequestMessage msg) {
final ClusterWorkloadResponseMessage response = new ClusterWorkloadResponseMessage();
final Map<NodeIdentifier, NodeWorkload> workloads = new HashMap<>();
getLatestHeartbeats().values().stream().filter(hb -> NodeConnectionState.CONNECTED.equals(hb.getConnectionStatus().getState())).forEach(hb -> {
NodeWorkload wl = new NodeWorkload();
wl.setReportedTimestamp(hb.getTimestamp());
wl.setSystemStartTime(hb.getSystemStartTime());
wl.setActiveThreadCount(hb.getActiveThreadCount());
wl.setFlowFileCount(hb.getFlowFileCount());
wl.setFlowFileBytes(hb.getFlowFileBytes());
workloads.put(hb.getNodeIdentifier(), wl);
});
response.setNodeWorkloads(workloads);
return response;
}
Aggregations