@Override public List<? extends Instance> getInstances(Object obj) { if (!(obj instanceof Agent)) { return null; } Agent agent = (Agent) obj; Host host = objectManager.findAny(Host.class, HOST.AGENT_ID, agent.getId(), HOST.REMOVED, null); if (host == null) { return null; } return serviceDao.getInstancesWithHealtcheckEnabled(host.getAccountId()); }
@Override public List<Long> getHostsSatisfyingHostAffinity( Long accountId, Map<String, String> labelConstraints) { List<? extends Host> hosts = allocatorDao.getActiveHosts(accountId); List<Constraint> hostAffinityConstraints = getHostAffinityConstraintsFromLabels(labelConstraints); List<Long> acceptableHostIds = new ArrayList<Long>(); for (Host host : hosts) { if (hostSatisfiesHostAffinity(host.getId(), hostAffinityConstraints)) { acceptableHostIds.add(host.getId()); } } return acceptableHostIds; }
protected List<Long> getHostsSatisfyingHostAffinityInternal( boolean includeRemoved, Long accountId, Map<String, String> labelConstraints) { List<? extends Host> hosts = includeRemoved ? allocatorDao.getNonPurgedHosts(accountId) : allocatorDao.getActiveHosts(accountId); List<Constraint> hostAffinityConstraints = getHostAffinityConstraintsFromLabels(labelConstraints); List<Long> acceptableHostIds = new ArrayList<Long>(); for (Host host : hosts) { if (hostSatisfiesHostAffinity(host.getId(), hostAffinityConstraints)) { acceptableHostIds.add(host.getId()); } } return acceptableHostIds; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { LoadBalancerHostMap map = (LoadBalancerHostMap) state.getResource(); LoadBalancer lb = loadResource(LoadBalancer.class, map.getLoadBalancerId()); Long hostId = map.getHostId(); boolean validHostState = false; if (hostId == null) { validHostState = true; } else { Host host = objectManager.loadResource(Host.class, hostId); if (host.getRemoved() == null && !(host.getState().equalsIgnoreCase(CommonStatesConstants.REMOVED) || host.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING))) { validHostState = true; } } if (validHostState) { removeLoadBalancerInstance(lb, map); removeLoadBalancerAgent(lb, map); } return null; }
@Override public List<? extends StoragePool> getAssociatedUnmanagedPools(Host host) { return create() .select(STORAGE_POOL.fields()) .from(STORAGE_POOL) .join(STORAGE_POOL_HOST_MAP) .on(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID.eq(STORAGE_POOL.ID)) .where( STORAGE_POOL_HOST_MAP .REMOVED .isNull() .and( STORAGE_POOL_HOST_MAP .HOST_ID .eq(host.getId()) .and(STORAGE_POOL.KIND.in(AllocatorUtils.UNMANGED_STORAGE_POOLS)))) .fetchInto(StoragePoolRecord.class); }
public HostEndpointsUpdateLock(Host host) { super("HOST." + host.getId() + "ENDPOINTS.UPDATE"); }