use of org.apache.nifi.web.api.entity.ProcessGroupStatusEntity in project nifi by apache.
the class EntityFactory method createProcessGroupStatusEntity.
public ProcessGroupStatusEntity createProcessGroupStatusEntity(final ProcessGroupStatusDTO status, final PermissionsDTO permissions) {
final ProcessGroupStatusEntity entity = new ProcessGroupStatusEntity();
entity.setCanRead(permissions.getCanRead());
// always set the status, as it's always allowed... just need to provide permission context for merging responses
entity.setProcessGroupStatus(status);
return entity;
}
use of org.apache.nifi.web.api.entity.ProcessGroupStatusEntity in project nifi by apache.
the class GroupStatusEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(ProcessGroupStatusEntity clientEntity, Map<NodeIdentifier, ProcessGroupStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final ProcessGroupStatusDTO mergedProcessGroupStatus = clientEntity.getProcessGroupStatus();
mergedProcessGroupStatus.setNodeSnapshots(new ArrayList<>());
final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
final NodeProcessGroupStatusSnapshotDTO selectedNodeSnapshot = new NodeProcessGroupStatusSnapshotDTO();
selectedNodeSnapshot.setStatusSnapshot(mergedProcessGroupStatus.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedProcessGroupStatus.getNodeSnapshots().add(selectedNodeSnapshot);
for (final Map.Entry<NodeIdentifier, ProcessGroupStatusEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final ProcessGroupStatusEntity nodeProcessGroupStatusEntity = entry.getValue();
final ProcessGroupStatusDTO nodeProcessGroupStatus = nodeProcessGroupStatusEntity.getProcessGroupStatus();
if (nodeProcessGroupStatus == mergedProcessGroupStatus) {
continue;
}
mergeStatus(mergedProcessGroupStatus, clientEntity.getCanRead(), nodeProcessGroupStatus, nodeProcessGroupStatusEntity.getCanRead(), nodeId);
}
}
use of org.apache.nifi.web.api.entity.ProcessGroupStatusEntity in project nifi by apache.
the class FlowResource method getProcessGroupStatus.
/**
* Retrieves the status report for this NiFi.
*
* @param recursive Optional recursive flag that defaults to false. If set to true, all descendant groups and the status of their content will be included.
* @param groupId The group id
* @return A processGroupStatusEntity.
* @throws InterruptedException if interrupted
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}/status")
@ApiOperation(value = "Gets the status for a process group", notes = "The status for a process group includes status for all descendent components. When invoked on the root group with " + "recursive set to true, it will return the current status of every component in the flow.", response = ProcessGroupStatusEntity.class, authorizations = { @Authorization(value = "Read - /flow") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getProcessGroupStatus(@ApiParam(value = "Whether all descendant groups and the status of their content will be included. Optional, defaults to false", required = false) @QueryParam("recursive") @DefaultValue(RECURSIVE) Boolean recursive, @ApiParam(value = "Whether or not to include the breakdown per node. Optional, defaults to false", required = false) @QueryParam("nodewise") @DefaultValue(NODEWISE) Boolean nodewise, @ApiParam(value = "The id of the node where to get the status.", required = false) @QueryParam("clusterNodeId") String clusterNodeId, @ApiParam(value = "The process group id.", required = true) @PathParam("id") String groupId) throws InterruptedException {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
}
if (isReplicateRequest()) {
// determine where this request should be sent
if (clusterNodeId == null) {
final NodeResponse nodeResponse = replicateNodeResponse(HttpMethod.GET);
final ProcessGroupStatusEntity entity = (ProcessGroupStatusEntity) nodeResponse.getUpdatedEntity();
// ensure there is an updated entity (result of merging) and prune the response as necessary
if (entity != null && !nodewise) {
entity.getProcessGroupStatus().setNodeSnapshots(null);
}
return nodeResponse.getResponse();
} else {
return replicate(HttpMethod.GET, clusterNodeId);
}
}
// get the status
final ProcessGroupStatusEntity entity = serviceFacade.getProcessGroupStatus(groupId, recursive);
return generateOkResponse(entity).build();
}
Aggregations