statsEntryIdentifier += ", public IP: " + publicIp; if (host.getType().equals(Host.Type.ExternalLoadBalancer) && inline) { userStats = _userStatsDao.lock(accountId, zoneId, networkId, publicIp, hostId, host.getType().toString()); } catch (Exception e) { s_logger.warn("Unable to find user stats entry for " + statsEntryIdentifier);
protected Status investigate(final AgentAttache agent) { final Long hostId = agent.getId(); final HostVO host = _hostDao.findById(hostId); if (host != null && host.getType() != null && !host.getType().isVirtual()) { if (s_logger.isDebugEnabled()) { s_logger.debug("checking if agent (" + hostId + ") is alive"); } final Answer answer = easySend(hostId, new CheckHealthCommand()); if (answer != null && answer.getResult()) { final Status status = Status.Up; if (s_logger.isDebugEnabled()) { s_logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status); } return status; } return _haMgr.investigate(hostId); } return Status.Alert; }
@Override public boolean configure(String name, Map<String, Object> params) { _name = name; String value = (String)params.get("type"); _type = Host.Type.valueOf(value); value = (String)params.get("negative.reply"); _negative = Boolean.parseBoolean(value); setParams(params); return true; }
List<HostVO> hosts = listAllHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId()); for (final HostVO host : hosts) { if (host.getType().equals(Host.Type.Routing) && !host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected) && !host.getStatus().equals(Status.Up) && !host.getStatus().equals(Status.Alert)) { final String msg = "host " + host.getPrivateIpAddress() + " should not be in " + host.getStatus().toString() + " status";
} else if (cmd instanceof SetupCertificateCommand && ((SetupCertificateCommand) cmd).isHandleByAgent()) { answer = setupAgentCertificate((SetupCertificateCommand) cmd); if (Host.Type.Routing.equals(_resource.getType())) { scheduleServicesRestartTask();
statsEntryIdentifier += ", public IP: " + publicIp; boolean inline = _networkModel.isNetworkInlineMode(network); if (externalLoadBalancer.getType().equals(Host.Type.ExternalLoadBalancer) && inline) {
if (ncc.getType().equals(Host.Type.NetScalerControlCenter)) { try {
@Override public void doInTransactionWithoutResult(TransactionStatus status) { UserStatisticsVO userStats; userStats = _userStatsDao.lock(accountId, zone.getId(), networkId, publicIp, externalLoadBalancer.getId(), externalLoadBalancer.getType().toString());
@Override public List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ); SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder(); EngineHostVO entity = hostSearch.entity(); hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ); hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ); hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ); hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ); hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ); hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ); hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<EngineHostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); sc.setParameters("type", type.toString()); if (podId != null) { sc.setParameters("pod", podId); } if (clusterId != null) { sc.setParameters("cluster", clusterId); } sc.setParameters("dc", dcId); sc.setParameters("status", Status.Up.toString()); sc.setParameters("resourceState", ResourceState.Enabled.toString()); return listBy(sc); }
@Override public List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ); SearchBuilder<HostVO> hostSearch = createSearchBuilder(); HostVO entity = hostSearch.entity(); hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ); hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ); hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ); hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ); hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ); hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ); hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<HostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); sc.setParameters("type", type.toString()); if (podId != null) { sc.setParameters("pod", podId); } if (clusterId != null) { sc.setParameters("cluster", clusterId); } sc.setParameters("dc", dcId); sc.setParameters("status", Status.Up.toString()); sc.setParameters("resourceState", ResourceState.Enabled.toString()); return listBy(sc); }
private void reorderClustersBasedOnImplicitTags(List<Long> clusterList, int requiredCpu, long requiredRam) { final HashMap<Long, Long> UniqueTagsInClusterMap = new HashMap<Long, Long>(); Long uniqueTags; for (Long clusterId : clusterList) { uniqueTags = (long) 0; List<Long> hostList = capacityDao.listHostsWithEnoughCapacity(requiredCpu, requiredRam, clusterId, Host.Type.Routing.toString()); if (!hostList.isEmpty() && implicitHostTags.length > 0) { uniqueTags = new Long(hostTagsDao.getDistinctImplicitHostTags(hostList, implicitHostTags).size()); } UniqueTagsInClusterMap.put(clusterId, uniqueTags); } Collections.sort(clusterList, new Comparator<Long>() { @Override public int compare(Long o1, Long o2) { Long t1 = UniqueTagsInClusterMap.get(o1); Long t2 = UniqueTagsInClusterMap.get(o2); return t1.compareTo(t2); } }); }
/** * Creates a HostVO SearchCriteria where: * <ul> * <li>"status" is Up;</li> * <li>"resourceState" is not in Maintenance, PrepareForMaintenance, or ErrorInMaintenance; and</li> * <li>"type" is Routing.</li> * </ul> */ private SearchCriteria<HostVO> createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance() { SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria(); sc.addAnd("status", SearchCriteria.Op.EQ, Status.Up.toString()); sc.addAnd("resourceState", SearchCriteria.Op.NIN, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance); sc.addAnd("type", SearchCriteria.Op.EQ, Host.Type.Routing.toString()); return sc; }
/** * Get running host IDs within the same hypervisor, cluster and datacenter than hostId. ID hostId is not included on the returned list */ protected List<Long> getRunningHostIdsInTheSameCluster(Long clusterId, long dataCenterId, HypervisorType hypervisorType, long hostId) { List<Long> list = hostDao.listByDataCenterIdAndHypervisorType(dataCenterId, hypervisorType) .stream() .filter(x -> x.getHypervisorType().equals(hypervisorType) && x.getStatus().equals(Status.Up) && x.getType().equals(Host.Type.Routing) && x.getClusterId().equals(clusterId) && x.getId() != hostId) .map(x -> x.getId()) .collect(Collectors.toList()); Collections.shuffle(list); return list; }
@Override public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) { if (host.getType().equals(Host.Type.TrafficMonitor) || host.getType().equals(Host.Type.SecondaryStorage)) { return; } // NOTE: We don't use pingBy here because we're initiating. _pingMap.put(host.getId(), InaccurateClock.getTimeInSeconds()); }
@Override public void execute() { setType(Host.Type.Routing.toString()); final List<HostMetricsResponse> metricsResponses = metricsService.listHostMetrics(getHostResponses().getResponses()); ListResponse<HostMetricsResponse> response = new ListResponse<>(); response.setResponses(metricsResponses, metricsResponses.size()); response.setResponseName(getCommandName()); setResponseObject(response); } }
@Override public boolean configure(String name, Map<String, Object> params) { String value = (String)params.get(Host.Type.Routing.toString()); _routingHost = (value != null) ? Long.parseLong(value) : null; value = (String)params.get(Host.Type.Storage.toString()); _storageHost = (value != null) ? Long.parseLong(value) : null; return true; } }
private boolean createStatsEntry(long accountId, long zoneId, long networkId, String publicIp, long hostId) { HostVO host = _hostDao.findById(hostId); UserStatisticsVO userStats = _userStatsDao.findBy(accountId, zoneId, networkId, publicIp, hostId, host.getType().toString()); if (userStats == null) { return (_userStatsDao.persist(new UserStatisticsVO(accountId, zoneId, publicIp, hostId, host.getType().toString(), networkId)) != null); } else { return true; } }
public static String[] toStrings(Host.Type... types) { String[] strs = new String[types.length]; for (int i = 0; i < types.length; i++) { strs[i] = types[i].toString(); } return strs; } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (hostType != null ? hostType.hashCode() : 0); result = 31 * result + (int) (hostId ^ (hostId >>> 32)); return result; } }