private AgentInstance[] getAgentInstancesForStmt( String statementId, ContextPartitionSelector selector) { Collection<Integer> agentInstanceIds = getAgentInstanceIds(selector); if (agentInstanceIds == null || agentInstanceIds.isEmpty()) { return new AgentInstance[0]; } List<AgentInstance> instances = new ArrayList<AgentInstance>(agentInstanceIds.size()); for (Integer agentInstanceId : agentInstanceIds) { ContextControllerTreeAgentInstanceList instancesList = agentInstances.get(agentInstanceId); if (instancesList != null) { Iterator<AgentInstance> instanceIt = instancesList.getAgentInstances().iterator(); for (; instanceIt.hasNext(); ) { AgentInstance instance = instanceIt.next(); if (instance .getAgentInstanceContext() .getStatementContext() .getStatementId() .equals(statementId)) { instances.add(instance); } } } } return instances.toArray(new AgentInstance[instances.size()]); }
public void deactivateContextPartitions(Set<Integer> agentInstanceIds) { for (Integer agentInstanceId : agentInstanceIds) { ContextControllerTreeAgentInstanceList list = agentInstances.get(agentInstanceId); StatementAgentInstanceUtil.stopAgentInstances( list.getAgentInstances(), null, servicesContext, false); } }
public synchronized void contextPartitionTerminate( ContextControllerInstanceHandle contextNestedHandle, Map<String, Object> terminationProperties) { ContextNestedHandleImpl handle = (ContextNestedHandleImpl) contextNestedHandle; ContextControllerTreeAgentInstanceList entry = agentInstances.remove(handle.getContextPartitionOrPathId()); if (entry != null) { StatementAgentInstanceUtil.stopAgentInstances( entry.getAgentInstances(), terminationProperties, servicesContext, false); entry.getAgentInstances().clear(); contextPartitionIdManager.removeId(contextNestedHandle.getContextPartitionOrPathId()); } }