use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method suspendInstance.
/**
* Suspend an instance
*
* @param iid Instance Id
* @throws InstanceManagementException If the instance cannot be suspended due to the
* unavailability of Debugger support
*/
public void suspendInstance(long iid) throws InstanceManagementException {
try {
isOperationIsValidForTheCurrentTenant(iid);
} catch (IllegalAccessException ex) {
handleError(ex);
}
DebuggerSupport debugSupport = getDebugger(iid);
if (debugSupport == null) {
String errMsg = "Cannot suspend the instance " + iid + ", Debugger support not available";
log.error(errMsg);
throw new InstanceManagementException(errMsg);
}
debugSupport.suspend(iid);
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method terminateInstance.
/**
* Terminate an instance
*
* @param iid Instance Id
* @throws InstanceManagementException If the instance cannot be terminated due to the
* unavailability of Debugger support
*/
public void terminateInstance(long iid) throws InstanceManagementException {
try {
isOperationIsValidForTheCurrentTenant(iid);
} catch (IllegalAccessException ex) {
handleError(ex);
}
DebuggerSupport debugSupport = getDebugger(iid);
if (debugSupport == null) {
String erMsg = "Cannot terminate the instance " + iid + ", Debugger support not available";
log.error(erMsg);
throw new InstanceManagementException(erMsg);
}
debugSupport.terminate(iid);
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method recoverActivity.
/**
* Retry failed activity of an instance of a process
*
* @param iid Instance ID
* @param aid Activity ID
* @param action Action to perform
*/
public void recoverActivity(final long iid, final long aid, final Action_type1 action) throws InstanceManagementException {
try {
dbexec(new BpelDatabase.Callable<QName>() {
public QName run(BpelDAOConnection conn) throws Exception {
ProcessInstanceDAO instance = conn.getInstance(iid);
if (instance == null) {
return null;
}
for (ActivityRecoveryDAO recovery : instance.getActivityRecoveries()) {
if (recovery.getActivityId() == aid) {
BpelProcess process = ((BpelEngineImpl) bpelServer.getODEBPELServer().getEngine())._activeProcesses.get(instance.getProcess().getProcessId());
if (process != null) {
if (action == Action_type1.cancel) {
process.recoverActivity(instance, recovery.getChannel(), aid, Action_type1.cancel.getValue(), null);
log.info("Activity retrying is canceled for activity: " + aid + " of instance: " + iid);
} else if (action == Action_type1.retry) {
process.recoverActivity(instance, recovery.getChannel(), aid, Action_type1.retry.getValue(), null);
log.info("Activity is retried for activity: " + aid + " of instance: " + iid);
} else {
log.warn("Invalid retry action: " + action + " for activity: " + aid + " of instance: " + iid);
// TODO process fault action
}
break;
}
}
}
return instance.getProcess().getProcessId();
}
});
} catch (Exception e) {
String errMsg = "Exception occurred while recovering the activity: " + aid + " of ths instance: " + iid + " action: " + action.getValue();
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getLongRunningInstances.
/**
* Get long running instances with duration
*
* @param limit The maximum number of instances to be fetched
* @return Long running instances
* @throws InstanceManagementException When an error occurs
*/
public LimitedInstanceInfoType[] getLongRunningInstances(int limit) throws InstanceManagementException {
final List<LimitedInstanceInfoType> longRunningInstances = new ArrayList<LimitedInstanceInfoType>();
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
if (tenantProcessStore.getProcessConfigMap().size() <= 0) {
return longRunningInstances.toArray(new LimitedInstanceInfoType[longRunningInstances.size()]);
}
String filter = "status=ACTIVE";
if (!filter.contains(" pid=")) {
filter = filter + getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet());
}
if (log.isDebugEnabled()) {
log.debug("Instance Filter:" + filter);
}
String orderBy = "started";
final InstanceFilter instanceFilter = new InstanceFilter(filter, orderBy, limit);
try {
BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
bpelDb.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) throws InstanceManagementException {
Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
for (ProcessInstanceDAO piDAO : instances) {
longRunningInstances.add(createLimitedInstanceInfoObject(piDAO));
}
return null;
}
});
} catch (Exception e) {
String errMsg = "Error querying instances from database. Instance Filter:" + instanceFilter.toString();
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
return longRunningInstances.toArray(new LimitedInstanceInfoType[longRunningInstances.size()]);
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException in project carbon-business-process by wso2.
the class Instance method createLimitedInstanceInfoObject.
private LimitedInstanceInfoType createLimitedInstanceInfoObject(ProcessInstanceDAO instanceDAO) throws InstanceManagementException {
LimitedInstanceInfoType instanceInfo = new LimitedInstanceInfoType();
instanceInfo.setIid(Long.toString(instanceDAO.getInstanceId()));
instanceInfo.setPid(instanceDAO.getProcess().getProcessId().toString());
instanceInfo.setStatus(odeInstanceStatusToManagementAPIStatus(instanceDAO.getState()));
instanceInfo.setDateLastActive(toCalendar(instanceDAO.getLastActiveTime()));
instanceInfo.setDateStarted(toCalendar(instanceDAO.getCreateTime()));
return instanceInfo;
}
Aggregations