use of com.emc.storageos.db.client.model.uimodels.ExecutionState in project coprhd-controller by CoprHD.
the class ExecutionEngineImpl method updateExecutionStatus.
protected void updateExecutionStatus(ExecutionStatus status) {
ExecutionState state = ExecutionUtils.currentContext().getExecutionState();
state.setExecutionStatus(status.name());
if (modelClient != null) {
modelClient.save(state);
}
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionState in project coprhd-controller by CoprHD.
the class ExecutionEngineImpl method finishExecuting.
protected void finishExecuting(ExecutionStatus status) {
ExecutionState state = ExecutionUtils.currentContext().getExecutionState();
state.setCurrentTask("");
state.setEndDate(new Date());
state.setExecutionStatus(status.name());
if (modelClient != null) {
modelClient.save(state);
}
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionState in project coprhd-controller by CoprHD.
the class ExecutionEngineMonitor method killOrder.
/**
* Kills an order that was running within a dead engine.
*
* @param orderId
* the order ID.
* @param detailedMessage
* message to be added to order log
*/
public void killOrder(URI orderId, String detailedMessage) {
try {
Order order = modelClient.orders().findById(orderId);
if (order != null) {
if (log.isInfoEnabled()) {
log.info("Killing order: " + orderId);
}
// Mark the order as failed
order.setOrderStatus(OrderStatus.ERROR.name());
modelClient.save(order);
if (order.getExecutionStateId() != null) {
ExecutionState execState = modelClient.executionStates().findById(order.getExecutionStateId());
// Mark the execution state as failed
execState.setExecutionStatus(ExecutionStatus.FAILED.name());
modelClient.save(execState);
// Find any task logs that are 'in progress' (no elapsed time) and set the elapsed
List<ExecutionTaskLog> logs = modelClient.executionTaskLogs().findByIds(execState.getTaskLogIds());
for (ExecutionTaskLog log : logs) {
if (log.getElapsed() == null) {
// Mark any that were in progress as warnings
log.setLevel(LogLevel.WARN.name());
modelClient.save(log);
}
}
// Add a new log message indicating it failed due to engine termination
addTerminationTaskLog(execState, detailedMessage);
}
}
} catch (RuntimeException e) {
log.error("Failed to terminate order: " + orderId, e);
}
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionState in project coprhd-controller by CoprHD.
the class ExecutionUtils method createContext.
public static void createContext(ModelClient modelClient, Order order) {
// Ensure there is no existing context
destroyContext();
// Initialize the execution state for this order
ExecutionState state = modelClient.executionStates().findById(order.getExecutionStateId());
state.setStartDate(new Date());
ExecutionContext context = currentContext();
context.setOrder(order);
context.setModelClient(modelClient);
context.setExecutionState(state);
URI scheduledEventId = order.getScheduledEventId();
if (scheduledEventId != null) {
ScheduledEvent event = modelClient.findById(ScheduledEvent.class, scheduledEventId);
context.setScheduledEvent(event);
}
CatalogService catalogService = modelClient.catalogServices().findById(order.getCatalogServiceId());
if (null != catalogService) {
context.setServiceName(catalogService.getLabel());
}
List<OrderParameter> orderParameters = modelClient.orderParameters().findByOrderId(order.getId());
Map<String, Object> params = Maps.newLinkedHashMap();
for (OrderParameter param : orderParameters) {
params.put(param.getLabel(), param.getValue());
}
context.setParameters(params);
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionState in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method createOrder.
protected Order createOrder(String name, Map<String, String> params) {
ExecutionState state = new ExecutionState();
modelClient.save(state);
Order order = new Order();
order.setExecutionStateId(state.getId());
CatalogService service = new CatalogService();
service.setLabel(name);
modelClient.save(service);
order.setCatalogServiceId(service.getId());
modelClient.save(order);
int index = 0;
for (Map.Entry<String, String> entry : params.entrySet()) {
OrderParameter param = new OrderParameter();
param.setLabel(entry.getKey());
param.setValue(entry.getValue());
param.setOrderId(order.getId());
modelClient.save(param);
}
return order;
}
Aggregations