use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BatchPluginUtils method getRunningCluster.
BatchCluster getRunningCluster(ProcessInstance processInstance, int nodeId) {
ProcessModel processModel = processInstance.getProcessModel();
String processId = processModel.getId();
if (batchClusters.containsKey(processId)) {
Map<Integer, List<BatchCluster>> batchClustersOfProcess = batchClusters.get(processId);
if (batchClustersOfProcess.containsKey(nodeId)) {
List<BatchCluster> clusters = batchClustersOfProcess.get(nodeId);
for (BatchCluster bc : clusters) {
List<ProcessInstance> clusterProcessInstances = bc.getProcessInstances();
if (bc.getState() == BatchClusterState.RUNNING && clusterProcessInstances.contains(processInstance)) {
return bc;
}
}
}
}
return null;
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BatchPluginUtils method scheduleNextEventInBatchProcess.
// if the execution type is sequential-taskbased, this is responsible for scheduling the same event of the next process instance, if it exists
void scheduleNextEventInBatchProcess(ScyllaEvent event, ProcessInstance processInstance) {
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
ProcessModel processModel = processInstance.getProcessModel();
int parentNodeId = processModel.getNodeIdInParent();
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
if (cluster != null && cluster.hasExecutionType(BatchClusterExecutionType.SEQUENTIAL_TASKBASED)) {
// Get the other events or tasks from this batch to be scheduled after the current one...
Integer nodeId = event.getNodeId();
Pair<ScyllaEvent, ProcessInstance> eventToSchedule = cluster.getNotPIEvents(nodeId);
if (eventToSchedule != null) {
eventToSchedule.getValue0().schedule(eventToSchedule.getValue1());
// System.out.println("Scheduled " + eventToSchedule.getValue0().getDisplayName() + " for process instance " + eventToSchedule.getValue1());
}
if (parentProcessInstance != cluster.getResponsibleProcessInstance()) {
// ..and save the next events before them getting clered
ScyllaEvent nextEvent = event.getNextEventMap().get(0);
Integer nodeIdOfNextElement = nextEvent.getNodeId();
cluster.addPIEvent(nodeIdOfNextElement, nextEvent, processInstance);
// System.out.println("Added " + nextEvent.getDisplayName() + " to cluster queue for process instance " + processInstance);
}
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BatchTBPlugin method eventRoutine.
@SuppressWarnings("unchecked")
@Override
public void eventRoutine(TaskBeginEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
// System.out.println(event + " with display name " + event.getDisplayName() + " || " + event.getNextEventMap() + " and source " + event.getSource());
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
ProcessSimulationComponents desmojObjects = event.getDesmojObjects();
// SimulationModel model = (SimulationModel) desmojEvent.getModel();
int nodeId = event.getNodeId();
ProcessModel processModel = processInstance.getProcessModel();
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
int parentNodeId = processModel.getNodeIdInParent();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
// If we are the representative (first executed) process instance we add the setUp time for this task
if (cluster != null && parentProcessInstance == cluster.getResponsibleProcessInstance()) {
// therefore we fist take a sample of the setUp distribution
double setUpTimeToAdd = desmojObjects.getSetUpDistributionSample(nodeId);
TimeUnit unit = desmojObjects.getSetUpDistributionTimeUnit(nodeId);
TimeSpan setUpTimeToAddAsTimeSpan = new TimeSpan(setUpTimeToAdd, unit);
// get the old value (this will always be the entry 0 in our map, because it's always the next)
double standardTime = event.getTimeSpanToNextEventMap().get(0).getTimeAsDouble(TimeUnit.SECONDS);
// and overwrite the time to the next task in the timeSpanToNextEventMap (=set the calculated time as the new time)
TimeSpan timeForTaskWithSetUp = new TimeSpan(standardTime + setUpTimeToAddAsTimeSpan.getTimeAsDouble(TimeUnit.SECONDS), TimeUnit.SECONDS);
event.getTimeSpanToNextEventMap().put(0, timeForTaskWithSetUp);
}
}
// SimulationConfiguration simulationConfiguration = desmojObjects.getSimulationConfiguration();
/*Map<Integer, BatchActivity> batchActivities = (Map<Integer, BatchActivity>) simulationConfiguration
.getExtensionValue(getName(), "batchActivities");*/
Map<Integer, BatchActivity> batchActivities = processModel.getBatchActivities();
if (batchActivities.containsKey(nodeId) && processModel.getSubProcesses().containsKey(nodeId)) {
// subprocess plugin wants to schedule BPMNStartEvents for subprocess
// we prevent it
Map<Integer, ScyllaEvent> nextEventMap = event.getNextEventMap();
Map<Integer, TimeSpan> timeSpanToNextEventMap = event.getTimeSpanToNextEventMap();
for (Integer indexOfSubprocessBPMNStartEvent : nextEventMap.keySet()) {
ScyllaEvent eventToSchedule = nextEventMap.get(indexOfSubprocessBPMNStartEvent);
if (eventToSchedule instanceof BPMNStartEvent || eventToSchedule instanceof TaskTerminateEvent) {
nextEventMap.remove(indexOfSubprocessBPMNStartEvent);
timeSpanToNextEventMap.remove(indexOfSubprocessBPMNStartEvent);
break;
}
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BatchTCPlugin method eventRoutine.
@Override
public void eventRoutine(TaskCancelEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
ProcessModel processModel = processInstance.getProcessModel();
int parentNodeId = processModel.getNodeIdInParent();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
if (cluster != null) {
List<TaskTerminateEvent> parentalEndEvents = cluster.getParentalEndEvents();
for (TaskTerminateEvent pee : parentalEndEvents) {
TaskCancelEvent cancelEvent = new TaskCancelEvent(pee.getModel(), pee.getSource(), pee.getSimulationTimeOfSource(), pee.getDesmojObjects(), pee.getProcessInstance(), pee.getNodeId());
cancelEvent.schedule(pee.getProcessInstance());
}
parentalEndEvents.clear();
pluginInstance.setClusterToTerminated(parentProcessInstance, parentNodeId);
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BatchTEPlugin method eventRoutine.
@SuppressWarnings("unchecked")
@Override
public void eventRoutine(TaskEnableEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
pluginInstance.logTaskEventForNonResponsiblePI(event, processInstance);
// ProcessSimulationComponents desmojObjects = event.getDesmojObjects();
// SimulationModel model = (SimulationModel) desmojEvent.getModel();
int nodeId = event.getNodeId();
ProcessModel processModel = processInstance.getProcessModel();
// SimulationConfiguration simulationConfiguration = desmojObjects.getSimulationConfiguration();
/*Map<Integer, BatchActivity> batchActivities = (Map<Integer, BatchActivity>) simulationConfiguration
.getExtensionValue(getName(), "batchActivities");*/
Map<Integer, BatchActivity> batchActivities = processModel.getBatchActivities();
if (batchActivities.containsKey(nodeId) && processModel.getSubProcesses().containsKey(nodeId)) {
// in any case: put taskbeginevent of subprocess container on hold
// String source = desmojEvent.getSource();
int indexOfSubprocessBeginEvent = 0;
Map<Integer, ScyllaEvent> nextEventMap = event.getNextEventMap();
Map<Integer, TimeSpan> timeSpanToNextEventMap = event.getTimeSpanToNextEventMap();
// Map<String, TaskBeginEvent> subprocessStartEventsOnHold =
// pluginInstance.getSubprocessStartEventsOnHold();
TaskBeginEvent subprocessBeginEvent = (TaskBeginEvent) nextEventMap.get(indexOfSubprocessBeginEvent);
pluginInstance.assignToBatchCluster(processInstance, nodeId, subprocessBeginEvent);
nextEventMap.remove(indexOfSubprocessBeginEvent);
timeSpanToNextEventMap.remove(indexOfSubprocessBeginEvent);
}
}
Aggregations