try {
monitorPublisher.publish(new GfacExperimentStateChangeRequest(new MonitorID(jobExecutionContext)
, GfacExperimentState.INHANDLERSINVOKING));
for (GFacHandlerConfig handlerClassName : handlers) {
Class<? extends GFacHandler> handlerClass;
GFacHandler handler;
try {
handlerClass = Class.forName(handlerClassName.getClassName().trim()).asSubclass(GFacHandler.class);
handler = handlerClass.newInstance();
String plState = GFacUtils.getPluginState(zk, jobExecutionContext, handlerClassName.getClassName());
int state = 0;
try {
state = Integer.valueOf(plState);
} catch (NumberFormatException e) {
}
if (state >= GfacPluginState.INVOKED.getValue()) {
if (handler instanceof GFacRecoverableHandler) {
// if these already ran we re-run only recoverable handlers
log.info(handlerClassName.getClassName() + " is a recoverable handler so we recover the handler");
GFacUtils.createPluginZnode(zk, jobExecutionContext, handlerClassName.getClassName(), GfacPluginState.INVOKING);
((GFacRecoverableHandler) handler).recover(jobExecutionContext);
GFacUtils.updatePluginState(zk, jobExecutionContext, handlerClassName.getClassName(), GfacPluginState.COMPLETED);
} else {
log.info(handlerClassName.getClassName() + " is not a recoverable handler so we do not run because it already ran in last-run");
}
} else {
log.info(handlerClassName.getClassName() + " never ran so we run this is normal mode");
GFacUtils.createPluginZnode(zk, jobExecutionContext, handlerClassName.getClassName(), GfacPluginState.INVOKING);
handler.initProperties(handlerClassName.getProperties());
handler.invoke(jobExecutionContext);
GFacUtils.updatePluginState(zk, jobExecutionContext, handlerClassName.getClassName(), GfacPluginState.COMPLETED);
}
} catch (GFacHandlerException e) {
throw new GFacException("Error Executing a InFlow Handler", e.getCause());
} catch (ClassNotFoundException e) {