@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, LSTDISPATCHED_COMPARATOR_NAME)) { return result; } // Note: an earlier date time indicates higher weight. return ((Long) stat2.getLastDispatchedTime()).compareTo(stat1.getLastDispatchedTime()); } });
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final Integer result = 0; if (statisticsObjectCheck(stat1, stat2, NUMOFASSIGNEDFLOW_COMPARATOR_NAME)) { return result; } return ((Integer) stat1.getRemainingFlowCapacity()) .compareTo(stat2.getRemainingFlowCapacity()); } });
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, CPUUSAGE_COMPARATOR_NAME)) { return result; } // CPU usage , the lesser the value is, the better. return ((Double) stat2.getCpuUsage()).compareTo(stat1.getCpuUsage()); } });
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, MEMORY_COMPARATOR_NAME)) { return result; } if (stat1.getRemainingMemoryInMB() != stat2.getRemainingMemoryInMB()) { return stat1.getRemainingMemoryInMB() > stat2.getRemainingMemoryInMB() ? 1 : -1; } return Double.compare(stat1.getRemainingMemoryPercent(), stat2.getRemainingMemoryPercent()); } });
/** * <pre> * function to register the static remaining flow size filter. * NOTE : this is a static filter which means the filter will be filtering based on the system * standard which is not * Coming for the passed flow. * Ideally this filter will make sure only the executor hasn't reached the Max allowed # * of * executing flows. * </pre> */ private static FactorFilter<Executor, ExecutableFlow> getStaticRemainingFlowSizeFilter() { return FactorFilter .create(STATICREMAININGFLOWSIZE_FILTER_NAME, (filteringTarget, referencingObject) -> { if (null == filteringTarget) { logger.debug(String.format("%s : filtering out the target as it is null.", STATICREMAININGFLOWSIZE_FILTER_NAME)); return false; } final ExecutorInfo stats = filteringTarget.getExecutorInfo(); if (null == stats) { logger.debug(String.format("%s : filtering out %s as it's stats is unavailable.", STATICREMAININGFLOWSIZE_FILTER_NAME, filteringTarget.toString())); return false; } return stats.getRemainingFlowCapacity() > 0; }); }
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final Integer result = 0; if (statisticsObjectCheck(stat1, stat2, NUMOFASSIGNEDFLOW_COMPARATOR_NAME)) { return result; } return ((Integer) stat1.getRemainingFlowCapacity()) .compareTo(stat2.getRemainingFlowCapacity()); } });
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, CPUUSAGE_COMPARATOR_NAME)) { return result; } // CPU usage , the lesser the value is, the better. return ((Double) stat2.getCpuUsage()).compareTo(stat1.getCpuUsage()); } });
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, LSTDISPATCHED_COMPARATOR_NAME)) { return result; } // Note: an earlier date time indicates higher weight. return ((Long) stat2.getLastDispatchedTime()).compareTo(stat1.getLastDispatchedTime()); } });
/** * <pre> * function to register the static remaining flow size filter. * NOTE : this is a static filter which means the filter will be filtering based on the system * standard which is not * Coming for the passed flow. * Ideally this filter will make sure only the executor hasn't reached the Max allowed # * of * executing flows. * </pre> */ private static FactorFilter<Executor, ExecutableFlow> getStaticRemainingFlowSizeFilter() { return FactorFilter .create(STATICREMAININGFLOWSIZE_FILTER_NAME, (filteringTarget, referencingObject) -> { if (null == filteringTarget) { logger.debug(String.format("%s : filtering out the target as it is null.", STATICREMAININGFLOWSIZE_FILTER_NAME)); return false; } final ExecutorInfo stats = filteringTarget.getExecutorInfo(); if (null == stats) { logger.debug(String.format("%s : filtering out %s as it's stats is unavailable.", STATICREMAININGFLOWSIZE_FILTER_NAME, filteringTarget.toString())); return false; } return stats.getRemainingFlowCapacity() > 0; }); }
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, MEMORY_COMPARATOR_NAME)) { return result; } if (stat1.getRemainingMemoryInMB() != stat2.getRemainingMemoryInMB()) { return stat1.getRemainingMemoryInMB() > stat2.getRemainingMemoryInMB() ? 1 : -1; } return Double.compare(stat1.getRemainingMemoryPercent(), stat2.getRemainingMemoryPercent()); } });