Search in sources :

Example 6 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImpl method executeOrder.

@Override
public void executeOrder(Order order) {
    LOG.info(String.format("Executing order: %s [%s]", order.getOrderNumber(), order.getId()));
    initContext(order);
    try {
        updateOrderStatus(order, OrderStatus.EXECUTING);
        ExecutionService service = createService(order);
        runService(service);
        orderCompleted(order, service.getCompletedOrderStatus());
    } catch (ExecutionException e) {
        orderFailed(order, e);
    } catch (RuntimeException e) {
        LOG.error("Unexpected error executing order: " + order.getId());
        orderFailed(order, new ExecutionException(e));
    } finally {
        destroyContext(order);
    }
}
Also used : ExecutionService(com.emc.sa.engine.service.ExecutionService)

Example 7 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testFailDuringRollback.

@Test
public void testFailDuringRollback() {
    final FailureTask rollbackTask = new FailureTask("Fail During Rollback", "Fail during rollback");
    final EmptyTask skippedTask = new EmptyTask("Skipped Rollback");
    ExecutionService rollbackService = new EmptyService() {

        @Override
        public void execute() throws Exception {
            addRollback(skippedTask);
            addRollback(rollbackTask);
            throw new Exception("Trigger rollback");
        }
    };
    Order order = executeOrder(rollbackService, "FailDuringRollback");
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
    Assert.assertEquals(true, rollbackTask.wasRun);
    Assert.assertEquals(false, skippedTask.wasRun);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Test(org.junit.Test)

Aggregations

ExecutionService (com.emc.sa.engine.service.ExecutionService)7 AbstractExecutionService (com.emc.sa.engine.service.AbstractExecutionService)6 ServiceNotFoundException (com.emc.sa.engine.service.ServiceNotFoundException)6 Order (com.emc.storageos.db.client.model.uimodels.Order)6 Test (org.junit.Test)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 ExecutionServiceFactory (com.emc.sa.engine.service.ExecutionServiceFactory)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1