Search in sources :

Example 1 with ControllerStatusDTO

use of org.apache.nifi.web.api.dto.status.ControllerStatusDTO in project nifi by apache.

the class FlowResource method getControllerStatus.

/**
 * Retrieves the status for this NiFi.
 *
 * @return A controllerStatusEntity.
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("status")
@ApiOperation(value = "Gets the current status of this NiFi", response = ControllerStatusEntity.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 = 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 getControllerStatus() throws InterruptedException {
    authorizeFlow();
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    final ControllerStatusDTO controllerStatus = serviceFacade.getControllerStatus();
    // create the response entity
    final ControllerStatusEntity entity = new ControllerStatusEntity();
    entity.setControllerStatus(controllerStatus);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) ControllerStatusEntity(org.apache.nifi.web.api.entity.ControllerStatusEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ControllerStatusDTO

use of org.apache.nifi.web.api.dto.status.ControllerStatusDTO in project nifi by apache.

the class ControllerFacade method getControllerStatus.

/**
 * Gets the status of this controller.
 *
 * @return the status of this controller
 */
public ControllerStatusDTO getControllerStatus() {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final QueueSize controllerQueueSize = flowController.getTotalFlowFileCount(rootGroup);
    final ControllerStatusDTO controllerStatus = new ControllerStatusDTO();
    controllerStatus.setActiveThreadCount(flowController.getActiveThreadCount());
    controllerStatus.setQueued(FormatUtils.formatCount(controllerQueueSize.getObjectCount()) + " / " + FormatUtils.formatDataSize(controllerQueueSize.getByteCount()));
    controllerStatus.setBytesQueued(controllerQueueSize.getByteCount());
    controllerStatus.setFlowFilesQueued(controllerQueueSize.getObjectCount());
    final ProcessGroupCounts counts = rootGroup.getCounts();
    controllerStatus.setRunningCount(counts.getRunningCount());
    controllerStatus.setStoppedCount(counts.getStoppedCount());
    controllerStatus.setInvalidCount(counts.getInvalidCount());
    controllerStatus.setDisabledCount(counts.getDisabledCount());
    controllerStatus.setActiveRemotePortCount(counts.getActiveRemotePortCount());
    controllerStatus.setInactiveRemotePortCount(counts.getInactiveRemotePortCount());
    controllerStatus.setUpToDateCount(counts.getUpToDateCount());
    controllerStatus.setLocallyModifiedCount(counts.getLocallyModifiedCount());
    controllerStatus.setStaleCount(counts.getStaleCount());
    controllerStatus.setLocallyModifiedAndStaleCount(counts.getLocallyModifiedAndStaleCount());
    controllerStatus.setSyncFailureCount(counts.getSyncFailureCount());
    return controllerStatus;
}
Also used : QueueSize(org.apache.nifi.controller.queue.QueueSize) ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Example 3 with ControllerStatusDTO

use of org.apache.nifi.web.api.dto.status.ControllerStatusDTO in project nifi by apache.

the class ControllerStatusEndpointMerger method mergeResponses.

@Override
protected void mergeResponses(ControllerStatusDTO clientDto, Map<NodeIdentifier, ControllerStatusDTO> dtoMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
    ControllerStatusDTO mergedStatus = clientDto;
    for (final Map.Entry<NodeIdentifier, ControllerStatusDTO> entry : dtoMap.entrySet()) {
        final ControllerStatusDTO nodeStatus = entry.getValue();
        if (nodeStatus == mergedStatus) {
            continue;
        }
        StatusMerger.merge(mergedStatus, nodeStatus);
    }
}
Also used : ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) Map(java.util.Map)

Aggregations

ControllerStatusDTO (org.apache.nifi.web.api.dto.status.ControllerStatusDTO)3 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Map (java.util.Map)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 QueueSize (org.apache.nifi.controller.queue.QueueSize)1 ProcessGroup (org.apache.nifi.groups.ProcessGroup)1 ProcessGroupCounts (org.apache.nifi.groups.ProcessGroupCounts)1 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)1 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)1 ControllerStatusEntity (org.apache.nifi.web.api.entity.ControllerStatusEntity)1