Search in sources :

Example 1 with AboutDTO

use of org.apache.nifi.web.api.dto.AboutDTO in project kylo by Teradata.

the class NifiConnectionService method isConnected.

private boolean isConnected(boolean logException) {
    try {
        log.debug("Attempt to check isConnection get about entity for {} ", nifiRestClient);
        AboutDTO aboutEntity = nifiRestClient.getNiFiRestClient().about();
        return aboutEntity != null;
    } catch (Exception e) {
        if (logException) {
            log.error("Error assessing Nifi Connection {} ", e);
        }
    }
    return false;
}
Also used : AboutDTO(org.apache.nifi.web.api.dto.AboutDTO)

Example 2 with AboutDTO

use of org.apache.nifi.web.api.dto.AboutDTO in project kylo by Teradata.

the class NifiServiceStatusCheck method nifiStatus.

/**
 * Check to see if NiFi is running
 *
 * @return the status of NiFi
 */
private ServiceComponent nifiStatus() {
    String componentName = "NiFi";
    ServiceComponent component = null;
    try {
        AboutDTO aboutEntity = nifiRestClient.getNifiVersion();
        String nifiVersion = aboutEntity.getVersion();
        component = new DefaultServiceComponent.Builder(componentName + " - " + nifiVersion, ServiceComponent.STATE.UP).message("NiFi is up.").build();
    } catch (Exception e) {
        component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.DOWN).exception(e).build();
    }
    return component;
}
Also used : DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceComponent(com.thinkbiganalytics.servicemonitor.model.ServiceComponent) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) AboutDTO(org.apache.nifi.web.api.dto.AboutDTO)

Example 3 with AboutDTO

use of org.apache.nifi.web.api.dto.AboutDTO in project kylo by Teradata.

the class NifiIntegrationRestController method getAbout.

@GET
@Path("/status")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Retrieves details about NiFi.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns details about NiFi.", response = AboutDTO.class), @ApiResponse(code = 500, message = "NiFi is unavailable.", response = RestResponseStatus.class) })
public Response getAbout() {
    final AboutDTO about = nifiRestClient.about();
    final NiFiClusterSummary clusterSummary = nifiRestClient.clusterSummary();
    return Response.ok(ImmutableMap.of("version", about.getVersion(), "clustered", clusterSummary.getClustered())).build();
}
Also used : NiFiClusterSummary(com.thinkbiganalytics.nifi.rest.model.NiFiClusterSummary) AboutDTO(org.apache.nifi.web.api.dto.AboutDTO) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with AboutDTO

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

the class FlowResource method getAboutInfo.

/**
 * Retrieves details about this NiFi to put in the About dialog.
 *
 * @return An aboutEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("about")
@ApiOperation(value = "Retrieves details about this NiFi to put in the About dialog", response = AboutEntity.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 getAboutInfo() {
    authorizeFlow();
    // create the about dto
    final AboutDTO aboutDTO = new AboutDTO();
    aboutDTO.setTitle("NiFi");
    aboutDTO.setUri(generateResourceUri());
    aboutDTO.setTimezone(new Date());
    // get the content viewer url
    final NiFiProperties properties = getProperties();
    aboutDTO.setContentViewerUrl(properties.getProperty(NiFiProperties.CONTENT_VIEWER_URL));
    final Bundle frameworkBundle = NarClassLoaders.getInstance().getFrameworkBundle();
    if (frameworkBundle != null) {
        final BundleDetails frameworkDetails = frameworkBundle.getBundleDetails();
        // set the version
        aboutDTO.setVersion(frameworkDetails.getCoordinate().getVersion());
        // Get build info
        aboutDTO.setBuildTag(frameworkDetails.getBuildTag());
        aboutDTO.setBuildRevision(frameworkDetails.getBuildRevision());
        aboutDTO.setBuildBranch(frameworkDetails.getBuildBranch());
        aboutDTO.setBuildTimestamp(frameworkDetails.getBuildTimestampDate());
    }
    // create the response entity
    final AboutEntity entity = new AboutEntity();
    entity.setAbout(aboutDTO);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) BundleDetails(org.apache.nifi.bundle.BundleDetails) Bundle(org.apache.nifi.bundle.Bundle) AboutEntity(org.apache.nifi.web.api.entity.AboutEntity) AboutDTO(org.apache.nifi.web.api.dto.AboutDTO) Date(java.util.Date) 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)

Aggregations

AboutDTO (org.apache.nifi.web.api.dto.AboutDTO)4 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 NiFiClusterSummary (com.thinkbiganalytics.nifi.rest.model.NiFiClusterSummary)1 DefaultServiceComponent (com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent)1 ServiceComponent (com.thinkbiganalytics.servicemonitor.model.ServiceComponent)1 Date (java.util.Date)1 Consumes (javax.ws.rs.Consumes)1 Bundle (org.apache.nifi.bundle.Bundle)1 BundleDetails (org.apache.nifi.bundle.BundleDetails)1 NiFiProperties (org.apache.nifi.util.NiFiProperties)1 AboutEntity (org.apache.nifi.web.api.entity.AboutEntity)1