public RemoteQueuePartitionDiagnostics getDiagnostics() { return new StandardRemoteQueuePartitionDiagnostics(nodeIdentifier.toString(), priorityQueue.getFlowFileQueueSize()); }
private void addNodeEvent(final NodeIdentifier nodeId, final Severity severity, final String message) { final NodeEvent event = new Event(nodeId.toString(), message, severity); final CircularFifoQueue<NodeEvent> eventQueue = nodeEvents.computeIfAbsent(nodeId, id -> new CircularFifoQueue<>()); synchronized (eventQueue) { eventQueue.add(event); } }
@Override public void run() { final long waitForScheduleNanos = System.nanoTime() - creationNanos; clusterResponse.addTiming("Wait for HTTP Request Replication to be triggered", nodeId.toString(), waitForScheduleNanos); NodeResponse nodeResponse; try { // create and send the request final String requestId = request.getHeaders().get("x-nifi-request-id"); logger.debug("Replicating request {} {} to {}", method, uri.getPath(), nodeId); nodeResponse = replicateRequest(request, nodeId, uri, requestId, clusterResponse); } catch (final Exception e) { nodeResponse = new NodeResponse(nodeId, method, uri, e); logger.warn("Failed to replicate request {} {} to {} due to {}", method, uri.getPath(), nodeId, e.toString()); logger.warn("", e); } if (callback != null) { logger.debug("Request {} {} completed for {}", method, uri.getPath(), nodeId); callback.onCompletion(nodeResponse); } } }
channel = createPeerChannel(socketChannel, nodeIdentifier.toString()); channel.performHandshake();
protected NodeResponse replicateRequest(final PreparedRequest request, final NodeIdentifier nodeId, final URI uri, final String requestId, final StandardAsyncClusterResponse clusterResponse) throws IOException { final Response response; final long startNanos = System.nanoTime(); logger.debug("Replicating request to {} {}, request ID = {}, headers = {}", request.getMethod(), uri, requestId, request.getHeaders()); // invoke the request response = httpClient.replicate(request, uri.toString()); final long nanos = System.nanoTime() - startNanos; clusterResponse.addTiming("Perform HTTP Request", nodeId.toString(), nanos); final NodeResponse nodeResponse = new NodeResponse(nodeId, request.getMethod(), uri, response, System.nanoTime() - startNanos, requestId); if (nodeResponse.is2xx()) { final int length = nodeResponse.getClientResponse().getLength(); if (length > 0) { final boolean canBufferResponse = clusterResponse.requestBuffer(length); if (canBufferResponse) { nodeResponse.bufferResponse(); } } } return nodeResponse; }
final String from = nodeId == null ? hostname : nodeId.toString(); logger.info("Finished processing request {} (type={}, length={} bytes) from {} in {}", requestId, request.getType(), countingIn.getBytesRead(), from, stopWatch.getDuration());
clusterResponse.addTiming("Completed Verification", nodeResponse.getNodeId().toString(), nanos);
success = loadBalanceSession.communicate(); } catch (final Exception e) { logger.error("Failed to communicate with Peer {}", nodeIdentifier.toString(), e); eventReporter.reportEvent(Severity.ERROR, "Load Balanced Connection", "Failed to communicate with Peer " + nodeIdentifier + " when load balancing data for Connection with ID " + loadBalanceSession.getPartition().getConnectionId() + " due to " + e);
final String from = nodeId == null ? hostname : nodeId.toString(); logger.info("Finished processing request {} (type={}, length={} bytes) from {} in {}", requestId, request.getType(), countingIn.getBytesRead(), from, stopWatch.getDuration());