@Test public void testAboveThresholds() { ImmutableMap<String, String> config = ImmutableMap.<String, String>builder() .put("root.cellA.runtimeThresholdInSeconds", "60") .put("root.cellA.sigmaThreshold", "10") .put("root.cellB.runtimeThresholdInSeconds", "6") .put("root.cellB.sigmaThreshold", "1") .build(); Map<String, JobRuntimePredictionSelector> selectors = aboveThresholds(new MapConfig(config).getPrefixedView("root"), METADATA); checkSelection(selectors.get("cellA").apply(JOB_DESCRIPTOR, JOB_PREDICTIONS), HIGH_QUANTILE); assertThat(selectors.get("cellB").apply(JOB_DESCRIPTOR, JOB_PREDICTIONS)).isEmpty(); }
public static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata) { String[] keys = Iterators.toArray(config.getKeys(), String.class); Set<String> cellNames = PropertiesExt.getRootNames(Arrays.asList(keys), 1); Map<String, Config> subConfigs = new HashMap<>(); cellNames.forEach(cell -> subConfigs.put(cell, config.getPrefixedView(cell))); Map<String, String> allMetadata = appendSelectorInfoIfMissing( selectionMetadata, () -> String.format("aboveThresholds[%s], createdAt: %s", new TreeSet<>(subConfigs.keySet()).stream().map(k -> k + '=' + Archaius2Ext.toString(subConfigs.get(k))).collect(Collectors.joining(", ")) + ']', DateTimeExt.toLocalDateTimeString(System.currentTimeMillis()) ) ); return CollectionsExt.mapValues(subConfigs, cell -> aboveThreshold(cell, allMetadata), HashMap::new); }
JobRuntimePredictionSelectors { public static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata) { String[] keys = Iterators.toArray(config.getKeys(), String.class); Set<String> cellNames = PropertiesExt.getRootNames(Arrays.asList(keys), 1); Map<String, Config> subConfigs = new HashMap<>(); cellNames.forEach(cell -> subConfigs.put(cell, config.getPrefixedView(cell))); Map<String, String> allMetadata = appendSelectorInfoIfMissing( selectionMetadata, () -> String.format("aboveThresholds[%s], createdAt: %s", new TreeSet<>(subConfigs.keySet()).stream().map(k -> k + '=' + Archaius2Ext.toString(subConfigs.get(k))).collect(Collectors.joining(", ")) + ']', DateTimeExt.toLocalDateTimeString(System.currentTimeMillis()) ) ); return CollectionsExt.mapValues(subConfigs, cell -> aboveThreshold(cell, allMetadata), HashMap::new); } }
JobRuntimePredictionSelectors { public static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata) { String[] keys = Iterators.toArray(config.getKeys(), String.class); Set<String> cellNames = PropertiesExt.getRootNames(Arrays.asList(keys), 1); Map<String, Config> subConfigs = new HashMap<>(); cellNames.forEach(cell -> subConfigs.put(cell, config.getPrefixedView(cell))); Map<String, String> allMetadata = appendSelectorInfoIfMissing( selectionMetadata, () -> String.format("aboveThresholds[%s], createdAt: %s", new TreeSet<>(subConfigs.keySet()).stream().map(k -> k + '=' + Archaius2Ext.toString(subConfigs.get(k))).collect(Collectors.joining(", ")) + ']', DateTimeExt.toLocalDateTimeString(System.currentTimeMillis()) ) ); return CollectionsExt.mapValues(subConfigs, cell -> aboveThreshold(cell, allMetadata), HashMap::new); } private  JobRuntimePredictionSelectors(); }
JobRuntimePredictionSelectors { public static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata) { String[] keys = Iterators.toArray(config.getKeys(), String.class); Set<String> cellNames = PropertiesExt.getRootNames(Arrays.asList(keys), 1); Map<String, Config> subConfigs = new HashMap<>(); cellNames.forEach(cell -> subConfigs.put(cell, config.getPrefixedView(cell))); Map<String, String> allMetadata = appendSelectorInfoIfMissing( selectionMetadata, () -> String.format("aboveThresholds[%s], createdAt: %s", new TreeSet<>(subConfigs.keySet()).stream().map(k -> k + '=' + Archaius2Ext.toString(subConfigs.get(k))).collect(Collectors.joining(", ")) + ']', DateTimeExt.toLocalDateTimeString(System.currentTimeMillis()) ) ); return CollectionsExt.mapValues(subConfigs, cell -> aboveThreshold(cell, allMetadata), HashMap::new); } private  JobRuntimePredictionSelectors(); static JobRuntimePredictionSelector never(); static JobRuntimePredictionSelector best(); static JobRuntimePredictionSelector best(Map<String, String> selectionMetadata); static JobRuntimePredictionSelector aboveThreshold(double runtimeThresholdInSeconds,
                                                              double sigmaThreshold,
                                                              double quantile,
                                                              Map<String, String> selectionMetadata); static JobRuntimePredictionSelector aboveThreshold(Config config, Map<String, String> selectionMetadata); static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata); static CloseableReference<JobRuntimePredictionSelector> reloadedOnConfigurationUpdate(Config config, Function<Config, JobRuntimePredictionSelector> factory); static JobRuntimePredictionSelector abTestRandom(Map<String, JobRuntimePredictionSelector> selectors); }
JobRuntimePredictionSelectors { public static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata) { String[] keys = Iterators.toArray(config.getKeys(), String.class); Set<String> cellNames = PropertiesExt.getRootNames(Arrays.asList(keys), 1); Map<String, Config> subConfigs = new HashMap<>(); cellNames.forEach(cell -> subConfigs.put(cell, config.getPrefixedView(cell))); Map<String, String> allMetadata = appendSelectorInfoIfMissing( selectionMetadata, () -> String.format("aboveThresholds[%s], createdAt: %s", new TreeSet<>(subConfigs.keySet()).stream().map(k -> k + '=' + Archaius2Ext.toString(subConfigs.get(k))).collect(Collectors.joining(", ")) + ']', DateTimeExt.toLocalDateTimeString(System.currentTimeMillis()) ) ); return CollectionsExt.mapValues(subConfigs, cell -> aboveThreshold(cell, allMetadata), HashMap::new); } private  JobRuntimePredictionSelectors(); static JobRuntimePredictionSelector never(); static JobRuntimePredictionSelector best(); static JobRuntimePredictionSelector best(Map<String, String> selectionMetadata); static JobRuntimePredictionSelector aboveThreshold(double runtimeThresholdInSeconds,
                                                              double sigmaThreshold,
                                                              double quantile,
                                                              Map<String, String> selectionMetadata); static JobRuntimePredictionSelector aboveThreshold(Config config, Map<String, String> selectionMetadata); static Map<String, JobRuntimePredictionSelector> aboveThresholds(Config config, Map<String, String> selectionMetadata); static CloseableReference<JobRuntimePredictionSelector> reloadedOnConfigurationUpdate(Config config, Function<Config, JobRuntimePredictionSelector> factory); static JobRuntimePredictionSelector abTestRandom(Map<String, JobRuntimePredictionSelector> selectors);  }