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