@Override public <T extends Enum<T>> Set<Operation<T>> operations(Class<T> outcome, String name, String... tags) { Set<OperationStatistic<T>> sources = findOperationStatistic(manager, queryBuilder().descendants().build(), outcome, name, new HashSet<String>(Arrays.asList(tags))); if (sources.isEmpty()) { return Collections.emptySet(); } else { Set<Operation<T>> operations = new HashSet(); for (OperationStatistic<T> source : sources) { CompoundOperationImpl<T> operation = (CompoundOperationImpl<T>) customOperations.get(source); if (operation == null) { operation = new CompoundOperationImpl<T>(source, source.type(), 1, SECONDS, executor, 0, 1, SECONDS); CompoundOperationImpl<T> racer = (CompoundOperationImpl<T>) customOperations.putIfAbsent(source, operation); if (racer != null) { operation = racer; } } operations.add(operation); } return operations; } }
/** * Gets the standard operation. * * @param statistic the statistic * @return the standard operation */ private Operation<?> getStandardOperation(StandardOperationStatistic statistic) { Operation<?> operation = standardOperations.get(statistic); if (operation instanceof NullCompoundOperation<?>) { OperationStatistic<?> discovered = findOperationStatistic(manager, statistic); if (discovered == null) { return operation; } else { Operation<?> newOperation = new CompoundOperationImpl(discovered, statistic.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, statistic.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS); if (standardOperations.replace(statistic, operation, newOperation)) { return newOperation; } else { return standardOperations.get(statistic); } } } else { return operation; } }
/** * Find operation statistic. * * @param manager the manager * @param statistic the statistic * @return the operation statistic */ private static OperationStatistic findOperationStatistic(StatisticsManager manager, StandardOperationStatistic statistic) { Set<? extends OperationStatistic<? extends Enum>> results = findOperationStatistic(manager, statistic.context(), statistic.type(), statistic.operationName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * Find standard operation statistics. */ private void findStandardOperationStatistics() { for (final StandardOperationStatistic t : StandardOperationStatistic.values()) { OperationStatistic statistic = findOperationStatistic(manager, t); if (statistic == null) { if (t.required()) { throw new IllegalStateException("Required statistic " + t + " not found"); } else { LOGGER.debug("Mocking Operation Statistic: {}", t); standardOperations.put(t, NullCompoundOperation.instance(t.type())); } } else { standardOperations.put(t, new CompoundOperationImpl(statistic, t.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, t.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS)); } } }
@Override public <T extends Enum<T>> Set<Operation<T>> operations(Class<T> outcome, String name, String... tags) { Set<OperationStatistic<T>> sources = findOperationStatistic(manager, queryBuilder().descendants().build(), outcome, name, new HashSet<String>(Arrays.asList(tags))); if (sources.isEmpty()) { return Collections.emptySet(); } else { Set<Operation<T>> operations = new HashSet(); for (OperationStatistic<T> source : sources) { CompoundOperationImpl<T> operation = (CompoundOperationImpl<T>) customOperations.get(source); if (operation == null) { operation = new CompoundOperationImpl<T>(source, source.type(), 1, SECONDS, executor, 0, 1, SECONDS); CompoundOperationImpl<T> racer = (CompoundOperationImpl<T>) customOperations.putIfAbsent(source, operation); if (racer != null) { operation = racer; } } operations.add(operation); } return operations; } }
/** * Find operation statistic. * * @param manager the manager * @param statistic the statistic * @return the operation statistic */ private static OperationStatistic findOperationStatistic(StatisticsManager manager, StandardOperationStatistic statistic) { Set<OperationStatistic<? extends Enum>> results = findOperationStatistic(manager, statistic.context(), statistic.type(), statistic.operationName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * Gets the standard operation. * * @param statistic the statistic * @return the standard operation */ private Operation<?> getStandardOperation(StandardOperationStatistic statistic) { Operation<?> operation = standardOperations.get(statistic); if (operation instanceof NullCompoundOperation<?>) { OperationStatistic<?> discovered = findOperationStatistic(manager, statistic); if (discovered == null) { return operation; } else { Operation<?> newOperation = new CompoundOperationImpl(discovered, statistic.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, statistic.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS); if (standardOperations.replace(statistic, operation, newOperation)) { return newOperation; } else { return standardOperations.get(statistic); } } } else { return operation; } }
@Override public <T extends Enum<T>> Set<Operation<T>> operations(Class<T> outcome, String name, String... tags) { Set<OperationStatistic<T>> sources = findOperationStatistic(manager, queryBuilder().descendants().build(), outcome, name, new HashSet<String>(Arrays.asList(tags))); if (sources.isEmpty()) { return Collections.emptySet(); } else { Set<Operation<T>> operations = new HashSet(); for (OperationStatistic<T> source : sources) { CompoundOperationImpl<T> operation = (CompoundOperationImpl<T>) customOperations.get(source); if (operation == null) { operation = new CompoundOperationImpl<T>(source, source.type(), 1, SECONDS, executor, 0, 1, SECONDS); CompoundOperationImpl<T> racer = (CompoundOperationImpl<T>) customOperations.putIfAbsent(source, operation); if (racer != null) { operation = racer; } } operations.add(operation); } return operations; } }
/** * Gets the standard operation. * * @param statistic the statistic * @return the standard operation */ private Operation<?> getStandardOperation(StandardOperationStatistic statistic) { Operation<?> operation = standardOperations.get(statistic); if (operation instanceof NullCompoundOperation<?>) { OperationStatistic<?> discovered = findOperationStatistic(manager, statistic); if (discovered == null) { return operation; } else { Operation<?> newOperation = new CompoundOperationImpl(discovered, statistic.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, statistic.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS); if (standardOperations.replace(statistic, operation, newOperation)) { return newOperation; } else { return standardOperations.get(statistic); } } } else { return operation; } }
/** * Find operation statistic. * * @param manager the manager * @param statistic the statistic * @return the operation statistic */ private static OperationStatistic findOperationStatistic(StatisticsManager manager, StandardOperationStatistic statistic) { Set<? extends OperationStatistic<? extends Enum>> results = findOperationStatistic(manager, statistic.context(), statistic.type(), statistic.operationName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * Find standard operation statistics. */ private void findStandardOperationStatistics() { for (final StandardOperationStatistic t : StandardOperationStatistic.values()) { OperationStatistic statistic = findOperationStatistic(manager, t); if (statistic == null) { if (t.required()) { throw new IllegalStateException("Required statistic " + t + " not found"); } else { LOGGER.debug("Mocking Operation Statistic: {}", t); standardOperations.put(t, NullCompoundOperation.instance(t.type())); } } else { standardOperations.put(t, new CompoundOperationImpl(statistic, t.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, t.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS)); } } }
/** * Find standard operation statistics. */ private void findStandardOperationStatistics() { for (final StandardOperationStatistic t : StandardOperationStatistic.values()) { OperationStatistic statistic = findOperationStatistic(manager, t); if (statistic == null) { if (t.required()) { throw new IllegalStateException("Required statistic " + t + " not found"); } else { LOGGER.debug("Mocking Operation Statistic: {}", t); standardOperations.put(t, NullCompoundOperation.instance(t.type())); } } else { standardOperations.put(t, new CompoundOperationImpl(statistic, t.type(), StatisticsGateway.DEFAULT_WINDOW_SIZE_SECS, SECONDS, executor, defaultHistorySize, t.isSearch() ? defaultSearchIntervalSeconds : defaultIntervalSeconds, SECONDS)); } } }