Search in sources :

Example 6 with ComponentLocator

use of com.cloud.utils.component.ComponentLocator in project CloudStack-archive by CloudStack-extras.

the class ConfigureSimulator method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
    SimulatorManager _simMgr = locator.getManager(SimulatorManager.class);
    boolean result = _simMgr.configureSimulator(zoneId, podId, clusterId, hostId, command, values);
    if (!result) {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure simulator");
    }
    SuccessResponse response = new SuccessResponse(getCommandName());
    this.setResponseObject(response);
}
Also used : ComponentLocator(com.cloud.utils.component.ComponentLocator) SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException) SimulatorManager(com.cloud.agent.manager.SimulatorManager)

Example 7 with ComponentLocator

use of com.cloud.utils.component.ComponentLocator in project CloudStack-archive by CloudStack-extras.

the class BaseCmd method setComponents.

static void setComponents(ResponseGenerator generator) {
    ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
    _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name);
    _accountService = locator.getManager(AccountService.class);
    _configService = locator.getManager(ConfigurationService.class);
    _userVmService = locator.getManager(UserVmService.class);
    _storageService = locator.getManager(StorageService.class);
    _resourceService = locator.getManager(ResourceService.class);
    _networkService = locator.getManager(NetworkService.class);
    _templateService = locator.getManager(TemplateService.class);
    _securityGroupService = locator.getManager(SecurityGroupService.class);
    _snapshotService = locator.getManager(SnapshotService.class);
    _consoleProxyService = locator.getManager(ConsoleProxyService.class);
    _routerService = locator.getManager(VirtualNetworkApplianceService.class);
    _entityMgr = locator.getManager(EntityManager.class);
    _rulesService = locator.getManager(RulesService.class);
    _lbService = locator.getManager(LoadBalancingRulesService.class);
    _ravService = locator.getManager(RemoteAccessVpnService.class);
    _responseGenerator = generator;
    _bareMetalVmService = locator.getManager(BareMetalVmService.class);
    _projectService = locator.getManager(ProjectService.class);
    _firewallService = locator.getManager(FirewallService.class);
    _domainService = locator.getManager(DomainService.class);
    _resourceLimitService = locator.getManager(ResourceLimitService.class);
    _identityService = locator.getManager(IdentityService.class);
    _storageNetworkService = locator.getManager(StorageNetworkService.class);
}
Also used : SnapshotService(com.cloud.storage.snapshot.SnapshotService) StorageNetworkService(com.cloud.network.StorageNetworkService) UserVmService(com.cloud.vm.UserVmService) DomainService(com.cloud.user.DomainService) ResourceService(com.cloud.resource.ResourceService) ProjectService(com.cloud.projects.ProjectService) ConsoleProxyService(com.cloud.consoleproxy.ConsoleProxyService) BareMetalVmService(com.cloud.vm.BareMetalVmService) SecurityGroupService(com.cloud.network.security.SecurityGroupService) StorageService(com.cloud.storage.StorageService) ComponentLocator(com.cloud.utils.component.ComponentLocator) EntityManager(com.cloud.dao.EntityManager) ResourceLimitService(com.cloud.user.ResourceLimitService) LoadBalancingRulesService(com.cloud.network.lb.LoadBalancingRulesService) RulesService(com.cloud.network.rules.RulesService) FirewallService(com.cloud.network.firewall.FirewallService) VirtualNetworkApplianceService(com.cloud.network.VirtualNetworkApplianceService) LoadBalancingRulesService(com.cloud.network.lb.LoadBalancingRulesService) NetworkService(com.cloud.network.NetworkService) StorageNetworkService(com.cloud.network.StorageNetworkService) ConfigurationService(com.cloud.configuration.ConfigurationService) AccountService(com.cloud.user.AccountService) TemplateService(com.cloud.template.TemplateService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService)

Example 8 with ComponentLocator

use of com.cloud.utils.component.ComponentLocator in project CloudStack-archive by CloudStack-extras.

the class CheckPointManagerTest method testSimulatedReboot.

public void testSimulatedReboot() throws Exception {
    ComponentLocator locator = ComponentLocator.getCurrentLocator();
    CheckPointManagerImpl taskMgr = ComponentLocator.inject(CheckPointManagerImpl.class);
    assertTrue(taskMgr.configure("TaskManager", new HashMap<String, Object>()));
    assertTrue(taskMgr.start());
    MockMaid maid = new MockMaid();
    maid.setValue("first");
    long taskId = taskMgr.pushCheckPoint(maid);
    StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
    CheckPointVO task = maidDao.findById(taskId);
    assertEquals(task.getDelegate(), MockMaid.class.getName());
    MockMaid retrieved = (MockMaid) SerializerHelper.fromSerializedString(task.getContext());
    assertEquals(retrieved.getValue(), maid.getValue());
    taskMgr.stop();
    assertNotNull(MockMaid.map.get(maid.getSeq()));
    taskMgr = ComponentLocator.inject(CheckPointManagerImpl.class);
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put(Config.TaskCleanupRetryInterval.key(), "1");
    taskMgr.configure("TaskManager", params);
    taskMgr.start();
    int i = 0;
    while (MockMaid.map.get(maid.getSeq()) != null && i++ < 5) {
        Thread.sleep(1000);
    }
    assertNull(MockMaid.map.get(maid.getSeq()));
}
Also used : ComponentLocator(com.cloud.utils.component.ComponentLocator) MockComponentLocator(com.cloud.utils.component.MockComponentLocator) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StackMaidDao(com.cloud.cluster.dao.StackMaidDao)

Example 9 with ComponentLocator

use of com.cloud.utils.component.ComponentLocator in project CloudStack-archive by CloudStack-extras.

the class CheckPointManagerTest method testTakeover.

public void testTakeover() throws Exception {
    ComponentLocator locator = ComponentLocator.getCurrentLocator();
    CheckPointManagerImpl taskMgr = ComponentLocator.inject(CheckPointManagerImpl.class);
    assertTrue(taskMgr.configure("TaskManager", new HashMap<String, Object>()));
    assertTrue(taskMgr.start());
    MockMaid delegate = new MockMaid();
    delegate.setValue("first");
    long taskId = taskMgr.pushCheckPoint(delegate);
    StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
    CheckPointVO task = maidDao.findById(taskId);
    assertEquals(task.getDelegate(), MockMaid.class.getName());
    MockMaid retrieved = (MockMaid) SerializerHelper.fromSerializedString(task.getContext());
    assertEquals(retrieved.getValue(), delegate.getValue());
    Connection conn = Transaction.getStandaloneConnection();
    try {
        conn.setAutoCommit(true);
        PreparedStatement stmt = conn.prepareStatement("update stack_maid set msid=? where msid=?");
        stmt.setLong(1, 1234);
        stmt.setLong(2, ManagementServerNode.getManagementServerId());
        stmt.executeUpdate();
        stmt.close();
    } finally {
        conn.close();
    }
    MockClusterManager clusterMgr = (MockClusterManager) locator.getManager(ClusterManager.class);
    clusterMgr.triggerTakeover(1234);
    int i = 0;
    while (MockMaid.map.get(delegate.getSeq()) != null && i++ < 500) {
        Thread.sleep(1000);
    }
    assertNull(MockMaid.map.get(delegate.getSeq()));
}
Also used : ComponentLocator(com.cloud.utils.component.ComponentLocator) MockComponentLocator(com.cloud.utils.component.MockComponentLocator) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StackMaidDao(com.cloud.cluster.dao.StackMaidDao) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Aggregations

ComponentLocator (com.cloud.utils.component.ComponentLocator)9 HashMap (java.util.HashMap)4 StackMaidDao (com.cloud.cluster.dao.StackMaidDao)3 MockComponentLocator (com.cloud.utils.component.MockComponentLocator)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConfigurationDao (com.cloud.configuration.dao.ConfigurationDao)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 StorageComponent (com.cloud.agent.dao.StorageComponent)1 PropertiesStorage (com.cloud.agent.dao.impl.PropertiesStorage)1 SimulatorManager (com.cloud.agent.manager.SimulatorManager)1 AlertDao (com.cloud.alert.dao.AlertDao)1 ServerApiException (com.cloud.api.ServerApiException)1 SuccessResponse (com.cloud.api.response.SuccessResponse)1 ConfigurationService (com.cloud.configuration.ConfigurationService)1 ConsoleProxyService (com.cloud.consoleproxy.ConsoleProxyService)1 EntityManager (com.cloud.dao.EntityManager)1 NetworkService (com.cloud.network.NetworkService)1 StorageNetworkService (com.cloud.network.StorageNetworkService)1 VirtualNetworkApplianceService (com.cloud.network.VirtualNetworkApplianceService)1 FirewallService (com.cloud.network.firewall.FirewallService)1