Search in sources :

Example 11 with Order

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;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) NamedURI(com.emc.storageos.db.client.model.NamedURI)

Example 12 with Order

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);
    }
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order)

Example 13 with Order

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());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionServiceFactory(com.emc.sa.engine.service.ExecutionServiceFactory) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) Test(org.junit.Test)

Example 14 with Order

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);
}
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)

Example 15 with Order

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);
}
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

Order (com.emc.storageos.db.client.model.uimodels.Order)53 Test (org.junit.Test)15 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)12 URI (java.net.URI)12 Path (javax.ws.rs.Path)11 Produces (javax.ws.rs.Produces)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)8 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)7 GET (javax.ws.rs.GET)7 AbstractExecutionService (com.emc.sa.engine.service.AbstractExecutionService)6 ExecutionService (com.emc.sa.engine.service.ExecutionService)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 ServiceNotFoundException (com.emc.sa.engine.service.ServiceNotFoundException)5 Date (java.util.Date)5 ModelClient (com.emc.sa.model.dao.ModelClient)4 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)4 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)4 Consumes (javax.ws.rs.Consumes)4 BaseModelTest (com.emc.sa.model.BaseModelTest)3 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)3