private static void updateVmUsageData(Map<String, Pair<String, Long>> usageDataMap, String key, String vmName, long duration) { Pair<String, Long> vmUsageInfo = usageDataMap.get(key); if (vmUsageInfo == null) { vmUsageInfo = new Pair<String, Long>(vmName, new Long(duration)); } else { Long runningTime = vmUsageInfo.second(); runningTime = new Long(runningTime.longValue() + duration); vmUsageInfo = new Pair<String, Long>(vmUsageInfo.first(), runningTime); } usageDataMap.put(key, vmUsageInfo); }
final private void log(String msg, Object... params) { Pair<String, Object[]> entry = new Pair<String, Object[]>(msg, params); assert msg != null : "Message can not be null or else it's useless!"; _entries.add(entry); }
/** * This method should reorder the given list of Pod Ids by applying any necessary heuristic * for this planner * For FirstFitPlanner there is no specific heuristic to be applied * other than the capacity based ordering which is done by default. * @return List<Long> ordered list of Pod Ids */ protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>> podCapacityInfo, VirtualMachineProfile vmProfile, DeploymentPlan plan) { List<Long> podIdsByCapacity = podCapacityInfo.first(); return podIdsByCapacity; }
@Override public void notifyMonitorsOfHostAboutToBeRemoved(long hostId) { for (final Pair<Integer, Listener> monitor : _hostMonitors) { if (s_logger.isDebugEnabled()) { s_logger.debug("Sending host about to be removed to listener: " + monitor.second().getClass().getSimpleName()); } monitor.second().processHostAboutToBeRemoved(hostId); } }
public Pair<String, ArrayList<Object>> toSql() { StringBuilder sql = new StringBuilder(); return new Pair<String, ArrayList<Object>>(sql.toString(), null); } }
/** * Return the list of first elements on the list of pairs */ protected static List<String> getListOfFirstElements(List<Pair<String, Integer>> priorityList) { List<String> values = new ArrayList<>(); for (Pair<String, Integer> pair : priorityList) { values.add(pair.first()); } return values; }
@Override public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) { for (final Pair<Integer, Listener> monitor : _hostMonitors) { if (s_logger.isDebugEnabled()) { s_logger.debug("Sending host removed to listener: " + monitor.second().getClass().getSimpleName()); } monitor.second().processHostRemoved(hostId, clusterId); } }
private static void updateVUUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long userId, long duration) { Pair<Long, Long> vuUsageInfo = usageDataMap.get(key); if (vuUsageInfo == null) { vuUsageInfo = new Pair<Long, Long>(new Long(userId), new Long(duration)); } else { Long runningTime = vuUsageInfo.second(); runningTime = new Long(runningTime.longValue() + duration); vuUsageInfo = new Pair<Long, Long>(vuUsageInfo.first(), runningTime); } usageDataMap.put(key, vuUsageInfo); }
@Override /** * The basic implementation assumes that the initial "host" defined to execute the command is the host that is in fact going to execute it. * However, subclasses can extend this behavior, changing the host that is going to execute the command in runtime. * The first element of the 'Pair' indicates if the hostId has been changed; this means, if you change the hostId, but you do not inform this action in the return 'Pair' object, we will use the original "hostId". * * Side note: it seems that the 'hostId' received here is normally the ID of the SSVM that has an entry at the host table. Therefore, this methods gives the opportunity to change from the SSVM to a real host to execute a command. */ public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) { return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId)); }
protected Pair<List<Long>, Map<Long, Double>> listPodsByUserDispersion(long dataCenterId, long accountId) { if (s_logger.isDebugEnabled()) { s_logger.debug("Applying Userdispersion heuristic to pods for account: " + accountId); } Pair<List<Long>, Map<Long, Double>> podIdsVmCountInfo = vmInstanceDao.listPodIdsInZoneByVmCount(dataCenterId, accountId); if (s_logger.isTraceEnabled()) { s_logger.trace("List of pods in ascending order of number of VMs: " + podIdsVmCountInfo.first()); } return podIdsVmCountInfo; }
public void notifyAnswersToMonitors(final long agentId, final long seq, final Answer[] answers) { for (final Pair<Integer, Listener> listener : _cmdMonitors) { listener.second().processAnswers(agentId, seq, answers); } }
private static void updateStorageUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long storageId, long duration) { Pair<Long, Long> volUsageInfo = usageDataMap.get(key); if (volUsageInfo == null) { volUsageInfo = new Pair<Long, Long>(new Long(storageId), new Long(duration)); } else { Long runningTime = volUsageInfo.second(); runningTime = new Long(runningTime.longValue() + duration); volUsageInfo = new Pair<Long, Long>(volUsageInfo.first(), runningTime); } usageDataMap.put(key, volUsageInfo); }
@Override public List<Pair<String, String>> getCounterParams() { List<Pair<String, String>> paramsList = new ArrayList<Pair<String, String>>(); if (counterParams != null) { String[] params = counterParams.split("[=&]"); for (int i = 0; i < (params.length - 1); i = i + 2) { paramsList.add(new Pair<String, String>(params[i], params[i + 1])); } } return paramsList; }
@DB() protected StringBuilder createPartialSelectSql(SearchCriteria<?> sc, final boolean whereClause, final boolean enableQueryCache) { StringBuilder sql = new StringBuilder(enableQueryCache ? _partialQueryCacheSelectSql.first() : _partialSelectSql.first()); if (sc != null && !sc.isSelectAll()) { sql.delete(7, sql.indexOf(" FROM")); sc.getSelect(sql, 7); } if (!whereClause) { sql.delete(sql.length() - (_discriminatorClause == null ? 6 : 4), sql.length()); } return sql; }
public void handleCommands(final AgentAttache attache, final long sequence, final Command[] cmds) { for (final Pair<Integer, Listener> listener : _cmdMonitors) { final boolean processed = listener.second().processCommands(attache.getId(), sequence, cmds); if (s_logger.isTraceEnabled()) { s_logger.trace("SeqA " + attache.getId() + "-" + sequence + ": " + (processed ? "processed" : "not processed") + " by " + listener.getClass()); } } }
private static void updateNOUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long vmId, long duration) { Pair<Long, Long> noUsageInfo = usageDataMap.get(key); if (noUsageInfo == null) { noUsageInfo = new Pair<Long, Long>(new Long(vmId), new Long(duration)); } else { Long runningTime = noUsageInfo.second(); runningTime = new Long(runningTime.longValue() + duration); noUsageInfo = new Pair<Long, Long>(noUsageInfo.first(), runningTime); } usageDataMap.put(key, noUsageInfo); }