@Override public void run(Command<Serializable> command, AsyncCallback<Serializable> callback) { log.debug("Going send command {} to delegate coordinator", command); RemoteExecutor remoteExecutor = coordinator.getExecutor(node); remoteExecutor.run(command, Coordination.doNothing(), callback); } });
public Map<NodeId, MonitoringStatus> getStatus() { Map<NodeId, MonitoringStatus> result = Maps.newHashMap(); for (NodeId nodeId : capableNodes) { RemoteExecutor remote = coordinator.getExecutor(nodeId); Collection<String> processes = activeProcesses.get(nodeId); for (String processId : processes) { remote.runSyncWithTimeout(PollMonitoringStatus.create(sessionId, processId), Coordination.<Command>doNothing(), ttl * 2); } } return result; }
public void startMonitoring() { log.debug("Start of monitoring requested. Task id {}", taskId); // todo use nodes on start Collection<NodeId> agents = availableNodes.get(NodeType.AGENT); log.debug("Available agents {}", agents); Iterator<NodeId> iterator = capableNodes.iterator(); for (NodeId agent : agents) { if (!iterator.hasNext()) { iterator = capableNodes.iterator(); } NodeId kernel = iterator.next(); RemoteExecutor remote = coordinator.getExecutor(kernel); log.info("Agent {} will be monitored by kernel {}", agent, kernel); log.debug("Start monitoring command is sending"); String processId = remote.runSyncWithTimeout(StartMonitoring.create(sessionId, agent, taskId), Coordination.<StartMonitoring>doNothing(), ttl * 2); log.debug("Start monitoring command is sent. Process with id {} started", processId); activeProcesses.put(kernel, processId); agentMapping.put(processId, agent); } }
@Override public void startWorkload(Map<NodeId, Integer> poolSize) { Preconditions.checkState(progress == Progress.IDLE, "Workload should be idle to get started"); log.debug("Workload start requested"); for (NodeId nodeId : remotes.keySet()) { threads.put(nodeId, 0); delays.put(nodeId, 0); if (classesUrl != null) { RemoteExecutor executor = remotes.get(nodeId); AddUrlClassLoader addUrlClassLoaderCommand = AddUrlClassLoader.create(sessionId, classesUrl); log.info("Sending command to add a class loader with classes url {} to node {}", classesUrl, nodeId); executor.runSyncWithTimeout(addUrlClassLoaderCommand, Coordination.<Command>doNothing(), timeoutsConfiguration.getWorkloadStartTimeout()); log.info("Class loader with classes url {} has been added to node {}", classesUrl, nodeId); } } this.poolSize = poolSize; progress = Progress.STARTED; }
private void changeWorkload(NodeId node, WorkloadConfiguration newConfiguration) { String processId = processes.get(node); RemoteExecutor remote = remotes.get(node); remote.runSyncWithTimeout(ChangeWorkloadConfiguration.create(sessionId, processId, newConfiguration), Coordination.<Command>doNothing(), timeoutsConfiguration.getWorkloadPollingTimeout()); threads.put(node, newConfiguration.getThreads()); delays.put(node, newConfiguration.getDelay()); }
@Override public void stopWorkload() { Preconditions.checkState(progress == Progress.STARTED, "Workload should be started to stop processes"); log.debug("Workload stop requested"); for (Map.Entry<NodeId, String> entry : processes.entrySet()) { NodeId id = entry.getKey(); String processId = entry.getValue(); RemoteExecutor executor = remotes.get(id); StopWorkloadProcess stop = StopWorkloadProcess.create(sessionId, processId); log.debug("Going to stop process {} on node {}", processId, id); executor.runSyncWithTimeout(stop, Coordination.<Command>doNothing(), timeoutsConfiguration.getWorkloadStopTimeout()); log.debug("Process {} is stopped on node {}", processId, id); if (classesUrl != null) { RemoveUrlClassLoader removeUrlClassLoaderCommand = RemoveUrlClassLoader.create(sessionId); log.info("Sending command to remove a custom class loader to node {}", id); executor.runSyncWithTimeout(removeUrlClassLoaderCommand, Coordination.<Command>doNothing(), timeoutsConfiguration.getWorkloadStopTimeout()); log.info("A custom class loader has been removed from node {}", id); } } log.debug("Workload stopped"); progress = Progress.STOPPED; }
@Override public Void call() throws Exception { try { RemoteExecutor remote = coordinator.getExecutor(kernel); log.info("Going to send stop monitoring command to kernel {}", kernel); remote.runSyncWithTimeout(StopMonitoring.create(sessionId, processId), Coordination.doNothing(), 2*ttl); log.info("Command stop monitoring successfully sent"); NodeId agent = agentMapping.get(processId); log.info("Agent {} monitoring is stopped on kernel {}", agent, kernel); } catch (Throwable e) { log.error("Stop monitoring failed for kernel {}, process {}", kernel.getIdentifier(), processId); return null; } return null; } });
private void processAgentManagement(String sessionId, Map<ManageAgent.ActionProp, Serializable> agentManagementProps) { for (NodeId agent : coordinator.getAvailableNodes(NodeType.AGENT)) { // async run coordinator.getExecutor(agent).run(new ManageAgent(sessionId, agentManagementProps), Coordination.<ManageAgent>doNothing()); } }
public Map<NodeId,GeneralNodeInfo> getGeneralNodeInfo(String sessionId, Coordinator coordinator) { final String localSessionId = sessionId; Set<NodeId> nodes = new HashSet<NodeId>(); Map<NodeId,GeneralNodeInfo> result = new HashMap<NodeId, GeneralNodeInfo>(); nodes.addAll(coordinator.getAvailableNodes(NodeType.KERNEL)); nodes.addAll(coordinator.getAvailableNodes(NodeType.AGENT)); for (NodeId node : nodes) { try { final GeneralNodeInfo generalNodeInfo = coordinator.getExecutor(node).runSyncWithTimeout(new GetGeneralNodeInfo(sessionId), Coordination.<GetGeneralNodeInfo>doNothing(), nodeCollectInfoTime); generalNodeInfo.setNodeId(node.toString()); log.info("Got node info from node {}:\n {}", node, generalNodeInfo.toString()); getHibernateTemplate().execute(new HibernateCallback<Void>() { @Override public Void doInHibernate(Session session) throws HibernateException, SQLException { session.persist(new NodeInfoEntity(localSessionId,generalNodeInfo)); session.flush(); return null; } }); result.put(node,generalNodeInfo); } catch (Throwable e) { log.error("Get node info failed for node " + node + "\n" + Throwables.getStackTraceAsString(e)); } } return result; }
public void run() { try { VoidResult voidResult = remote.runSyncWithTimeout(new ManageCollectionProfileFromSuT(sessionId, ManageHotSpotMethodsFromSuT.START_POLLING, profilerPollingInterval), Coordination.<ManageCollectionProfileFromSuT>doNothing(), ttl); while (alive) { long startTime = System.currentTimeMillis(); log.debug("try getting GetSystemInfo on kernel {} from {}", nodeContext.getId(), agentId); try { ArrayList<SystemInfo> info = remote.runSyncWithTimeout(new GetSystemInfo(sessionId), Coordination.<GetSystemInfo>doNothing(), ttl); if (voidResult.hasException()) log.error("Remote exception raised during staring profiling from SuT", voidResult.getException()); profilerPollingInterval), Coordination.<ManageCollectionProfileFromSuT>doNothing(), ttl); log.debug("manage monitoring has done on agent {} from kernel {}", agentId, nodeContext.getId()); if (voidResult.hasException()) remote.runSyncWithTimeout(GetCollectedProfileFromSuT.create(sessionId), Coordination.<GetCollectedProfileFromSuT>doNothing(), ttl); if (profileDTO.getRuntimeGraphs().isEmpty()) { log.info("Profiler of {} turned off. There is no profiler data for recording", agentId);
if (processId != null) { status = remote.runSyncWithTimeout(PollWorkloadProcessStatus.create(sessionId, processId), Coordination.<Command<WorkloadStatus>>doNothing(), timeoutsConfiguration.getWorkloadPollingTimeout()); } else {
private void startWorkload(NodeId node, WorkloadConfiguration configuration) { ScenarioContext scenarioContext = new ScenarioContext(taskId, task.getName(), task.getVersion(), configuration); Integer nodePoolSize = poolSize.get(node); if (nodePoolSize == null) { nodePoolSize = 1; } StartWorkloadProcess start = StartWorkloadProcess.create(sessionId, scenarioContext, nodePoolSize); start.setScenarioFactory(task.getScenarioFactory()); start.setKernelInfo(new KernelInfo(nodeToIndex.get(node), nodeToIndex.size())); start.setCollectors(task.getCollectors()); start.setValidators(task.getValidators()); start.setListeners(task.getListeners()); log.debug("Going to start process {} on node {}", start, node); RemoteExecutor remote = remotes.get(node); String processId = remote.runSyncWithTimeout(start, Coordination.<StartWorkloadProcess>doNothing(), timeoutsConfiguration.getWorkloadStartTimeout()); log.debug("Process with id {} is started on node {}", processId, node); processes.put(node, processId); threads.put(node, configuration.getThreads()); delays.put(node, configuration.getDelay()); }