use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderMapper method createNewObject.
public static Order createNewObject(URI tenantId, OrderCreateParam param) {
Order newObject = new Order();
newObject.setId(URIUtil.createId(Order.class));
newObject.setTenant(tenantId.toString());
newObject.setCatalogServiceId(param.getCatalogService());
newObject.setWorkflowDocument(param.getWorkflowDocument());
if (param.getScheduledEventId() != null) {
newObject.setScheduledEventId(param.getScheduledEventId());
if (param.getScheduledTime() != null) {
newObject.setScheduledTime(ScheduleTimeHelper.convertStrToCalendar(param.getScheduledTime()));
}
if (param.getExecutionWindow() == null) {
newObject.setExecutionWindowId(null);
} else {
newObject.setExecutionWindowId(new NamedURI(param.getExecutionWindow(), "ExecutionWindow"));
}
}
updateObject(newObject, param);
return newObject;
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderCleanupHandler method execute.
@Override
protected void execute() {
// cleanup enginer monitor
getCoordinator().deletePath(ExecutionEngineMonitor.BASE_PATH);
log.info("Start processing inflight orders");
List<Order> orders = modelClient.orders().findByOrderStatus(OrderStatus.EXECUTING);
for (Order order : orders) {
String message = "Order processing terminated because of site failover, order was not completed. " + "You may see partial completion on storage arrays. Check with your administrator to do cleanup if necessary.";
order.setMessage(message);
modelClient.save(order);
monitor.killOrder(order.getId(), message);
}
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testErrorCreatingService.
@Test
public void testErrorCreatingService() {
ExecutionEngineImpl engine = new ExecutionEngineImpl();
engine.setModelClient(modelClient);
engine.setServiceFactory(new ExecutionServiceFactory() {
@Override
public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
throw new RuntimeException("Unexpected error");
}
});
Order order = executeOrder(engine, createOrder("ErrorCreatingService"));
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testClearSomeRollback.
@Test
public void testClearSomeRollback() {
final EmptyTask rollback1 = new EmptyTask("Rollback 1");
final EmptyTask rollback2 = new EmptyTask("Rollback 2");
ExecutionService rollbackService = new EmptyService() {
@Override
public void execute() throws Exception {
addRollback(rollback1);
clearRollback();
addRollback(rollback2);
throw new Exception("Trigger rollback");
}
};
Order order = executeOrder(rollbackService, "ClearSomeRollback");
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
Assert.assertEquals(false, rollback1.wasRun);
Assert.assertEquals(true, rollback2.wasRun);
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testRollback.
@Test
public void testRollback() {
final EmptyTask firstRollbackTask = new EmptyTask("First Rollback");
final EmptyTask secondRollbackTask = new EmptyTask("Second Rollback");
ExecutionService rollbackService = new EmptyService() {
@Param
protected boolean rollback;
@Override
public void execute() throws Exception {
addRollback(firstRollbackTask);
addRollback(secondRollbackTask);
if (rollback) {
throw new Exception("Trigger rollback");
}
}
};
Order noRollbackOrder = executeOrder(rollbackService, "NoRollback", "rollback=false");
Assert.assertEquals(OrderStatus.SUCCESS.name(), noRollbackOrder.getOrderStatus());
Assert.assertFalse(firstRollbackTask.wasRun);
Assert.assertFalse(secondRollbackTask.wasRun);
Order rollbackOrder = executeOrder(rollbackService, "Rollback", "rollback=true");
Assert.assertEquals(OrderStatus.ERROR.name(), rollbackOrder.getOrderStatus());
Assert.assertTrue(firstRollbackTask.wasRun);
Assert.assertTrue(secondRollbackTask.wasRun);
}
Aggregations