[
https://issues.apache.org/jira/browse/NIFI-4849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16395691#comment-16395691
]
ASF GitHub Bot commented on NIFI-4849:
--------------------------------------
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2468#discussion_r173906446
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
---
@@ -4506,6 +4515,123 @@ public ComponentHistoryDTO
getComponentHistory(final String componentId) {
return history;
}
+ private ControllerServiceEntity createControllerServiceEntity(final
String serviceId, final NiFiUser user) {
+ final ControllerServiceNode serviceNode =
controllerServiceDAO.getControllerService(serviceId);
+ return createControllerServiceEntity(serviceNode,
Collections.emptySet(), user);
+ }
+
+ @Override
+ public ProcessorDiagnosticsEntity getProcessorDiagnostics(final String
id) {
+ final ProcessorNode processor = processorDAO.getProcessor(id);
+ final ProcessorStatus processorStatus =
controllerFacade.getProcessorStatus(id);
+
+ // Generate Processor Diagnostics
+ final NiFiUser user = NiFiUserUtils.getNiFiUser();
+ final ProcessorDiagnosticsDTO dto =
controllerFacade.getProcessorDiagnostics(processor, processorStatus,
bulletinRepository, serviceId -> createControllerServiceEntity(serviceId,
user));
+
+ // Filter anything out of diagnostics that the user is not
authorized to see.
+ final List<JVMDiagnosticsSnapshotDTO> jvmDiagnosticsSnaphots = new
ArrayList<>();
+ final JVMDiagnosticsDTO jvmDiagnostics = dto.getJvmDiagnostics();
+ jvmDiagnosticsSnaphots.add(jvmDiagnostics.getAggregateSnapshot());
+
+ // filter controller-related information
+ final boolean canReadController =
authorizableLookup.getController().isAuthorized(authorizer, RequestAction.READ,
user);
+ if (!canReadController) {
+ for (final JVMDiagnosticsSnapshotDTO snapshot :
jvmDiagnosticsSnaphots) {
+ snapshot.setMaxEventDrivenThreads(null);
+ snapshot.setMaxTimerDrivenThreads(null);
+ snapshot.setBundlesLoaded(null);
+ }
+ }
+
+ // filter system diagnostics information
+ final boolean canReadSystem =
authorizableLookup.getSystem().isAuthorized(authorizer, RequestAction.READ,
user);
+ if (!canReadSystem) {
+ for (final JVMDiagnosticsSnapshotDTO snapshot :
jvmDiagnosticsSnaphots) {
+ snapshot.setContentRepositoryStorageUsage(null);
+ snapshot.setCpuCores(null);
+ snapshot.setCpuLoadAverage(null);
+ snapshot.setFlowFileRepositoryStorageUsage(null);
+ snapshot.setMaxHeap(null);
+ snapshot.setMaxHeapBytes(null);
+ snapshot.setProvenanceRepositoryStorageUsage(null);
+ snapshot.setPhysicalMemory(null);
+ snapshot.setPhysicalMemoryBytes(null);
+ snapshot.setGarbageCollectionDiagnostics(null);
+ }
+ }
+
+ // filter connections
+ final Predicate<ConnectionDiagnosticsDTO> connectionAuthorized =
connectionDiagnostics -> {
+ final String connectionId =
connectionDiagnostics.getConnection().getId();
+ return
authorizableLookup.getConnection(connectionId).getAuthorizable().isAuthorized(authorizer,
RequestAction.READ, user);
+ };
+
+ // Function that can be used to remove the Source or Destination
of a ConnectionDTO, if the user is not authorized.
+ final Function<ConnectionDiagnosticsDTO, ConnectionDiagnosticsDTO>
filterSourceDestination = connectionDiagnostics -> {
--- End diff --
Good call. That would mean that the second Function there is not really
needed. Will address.
> Add REST Endpoint for gathering Processor Diagnostics information
> -----------------------------------------------------------------
>
> Key: NIFI-4849
> URL: https://issues.apache.org/jira/browse/NIFI-4849
> Project: Apache NiFi
> Issue Type: Sub-task
> Components: Core Framework
> Reporter: Mark Payne
> Assignee: Mark Payne
> Priority: Major
> Fix For: 1.6.0
>
>
> We need to add a REST endpoint that will use the appropriate resources to
> gather the Processor Diagnostics information. Information to return should
> include things like:
> * Processor config
> * Processor status
> * Garbage Collection info
> * Repo Sizes
> * Connection info for connections whose source or destination is the
> processor
> * Controller Services that the processor is referencing
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)