use of com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus in project kylo by Teradata.
the class InitializeFeed method onTrigger.
/* (non-Javadoc)
* @see org.apache.nifi.processor.AbstractProcessor#onTrigger(org.apache.nifi.processor.ProcessContext, org.apache.nifi.processor.ProcessSession)
*/
@Override
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
FlowFile inputFF = session.get();
if (inputFF != null) {
inputFF = initialize(context, session, inputFF);
InitializationStatus status = getMetadataRecorder().getInitializationStatus(getFeedId(context, inputFF)).orElse(new InitializationStatus(State.PENDING));
switch(status.getState()) {
case PENDING:
pending(context, session, inputFF);
break;
case IN_PROGRESS:
inProgress(context, session, inputFF);
break;
case FAILED:
failed(context, session, inputFF, status.getTimestamp(), false);
break;
case REINITIALIZE:
reinitialize(context, session, inputFF);
break;
case REINITIALIZE_FAILED:
reinitializeFailed(context, session, inputFF, status.getTimestamp());
break;
case SUCCESS:
success(context, session, inputFF);
}
}
}
use of com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus in project kylo by Teradata.
the class MetadataClientRecorder method startFeedInitialization.
/* (non-Javadoc)
* @see com.thinkbiganalytics.nifi.core.api.metadata.MetadataRecorder#startFeedInitialization(java.lang.String)
*/
@Override
public InitializationStatus startFeedInitialization(String feedId) {
InitializationStatus status = new InitializationStatus(InitializationStatus.State.IN_PROGRESS);
try {
this.client.updateCurrentInitStatus(feedId, status);
getInitStatusCache().put(feedId, Optional.of(status));
return status;
} catch (Exception e) {
log.error("Failed to update metadata with feed initialization in-progress status: {}, feed: {}", status.getState(), feedId, e);
getInitStatusCache().invalidate(feedId);
throw new ProcessException("Failed to update metadata with feed initialization in-progress status: " + status + ", feed: " + feedId, e);
}
}
use of com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus in project kylo by Teradata.
the class MetadataClientRecorder method failFeedInitialization.
/* (non-Javadoc)
* @see com.thinkbiganalytics.nifi.core.api.metadata.MetadataRecorder#failFeedInitialization(java.lang.String)
*/
@Override
public InitializationStatus failFeedInitialization(String feedId, boolean isReinitialize) {
InitializationStatus.State state = isReinitialize ? InitializationStatus.State.REINITIALIZE_FAILED : InitializationStatus.State.FAILED;
InitializationStatus status = new InitializationStatus(state);
try {
this.client.updateCurrentInitStatus(feedId, status);
getInitStatusCache().put(feedId, Optional.of(status));
return status;
} catch (Exception e) {
log.error("Failed to update feed initialization failed status: {}, feed: {}", status.getState(), feedId);
getInitStatusCache().invalidate(feedId);
return status;
}
}
use of com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus in project kylo by Teradata.
the class MetadataClientRecorder method completeFeedInitialization.
/* (non-Javadoc)
* @see com.thinkbiganalytics.nifi.core.api.metadata.MetadataRecorder#completeFeedInitialization(java.lang.String)
*/
@Override
public InitializationStatus completeFeedInitialization(String feedId) {
InitializationStatus status = new InitializationStatus(InitializationStatus.State.SUCCESS);
try {
this.client.updateCurrentInitStatus(feedId, status);
getInitStatusCache().put(feedId, Optional.of(status));
return status;
} catch (Exception e) {
log.error("Failed to update metadata with feed initialization completion status: {}, feed: {}", status.getState(), feedId, e);
getInitStatusCache().invalidate(feedId);
throw new ProcessException("Failed to update metadata with feed initialization completion status: " + status + ", feed: " + feedId, e);
}
}
use of com.thinkbiganalytics.metadata.rest.model.feed.InitializationStatus in project kylo by Teradata.
the class FeedsController method putInitializationStatus.
@PUT
@Path("{id}/initstatus")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation("Sets the registration status for the specified feed.")
@ApiResponses({ @ApiResponse(code = 204, message = "The registration status was updated."), @ApiResponse(code = 404, message = "The feed could not be found.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "The registration status could not be updated.", response = RestResponseStatus.class) })
public void putInitializationStatus(@PathParam("id") String feedIdStr, InitializationStatus status) {
LOG.debug("Get feed initialization status {}", feedIdStr);
// TODO Move behavior to a service?
this.metadata.commit(() -> {
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_FEEDS);
com.thinkbiganalytics.metadata.api.feed.Feed.ID feedId = feedProvider.resolveFeed(feedIdStr);
com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(feedId);
if (feed != null) {
com.thinkbiganalytics.metadata.api.feed.InitializationStatus.State newState = com.thinkbiganalytics.metadata.api.feed.InitializationStatus.State.valueOf(status.getState().name());
feed.updateInitStatus(new com.thinkbiganalytics.metadata.api.feed.InitializationStatus(newState));
} else {
throw new WebApplicationException("A feed with the given ID does not exist: " + feedId, Status.NOT_FOUND);
}
});
FeedInitializationChangeEvent event = new FeedInitializationChangeEvent(feedIdStr, status.getState());
this.jmsMessagingTemplate.convertAndSend(this.initStatusChangeTopic, event);
}
Aggregations