private static String getReduceFunctionDescription(final ReductionFunction reductionFunction) { return reductionFunction.accept(new ReduceFunctionVisitor<String>() { @Override public String visit(HighestSeverity function) { return function.getClass().getSimpleName(); } @Override public String visit(HighestSeverityAbove function) { return String.format("%s (%s)", function.getClass().getSimpleName(), function.getThreshold().getLabel()); } @Override public String visit(Threshold function) { return String.format("%s (%s)", function.getClass().getSimpleName(), Float.toString(function.getThreshold())); } @Override public String visit(ExponentialPropagation function) { return String.format("%s (%s)", function.getClass().getSimpleName(), Double.toString(function.getBase())); } }); }
public static Set<GraphEdge> calculateImpacting(BusinessServiceGraph graph, GraphVertex parent) { // Grab all of the child edges List<GraphEdge> childEdges = graph.getOutEdges(parent).stream() .collect(Collectors.toList()); // Weigh and reduce the statuses List<StatusWithIndex> statuses = DefaultBusinessServiceStateMachine.weighEdges(childEdges); Optional<StatusWithIndices> reducedStatus = parent.getReductionFunction().reduce(statuses); if (!reducedStatus.isPresent()) { return Collections.emptySet(); } else { return reducedStatus.get().getIndices().stream() .map(childEdges::get) .collect(Collectors.toSet()); } } }
public AbstractReductionFunctionEntity toPersistenceFunction(ReductionFunction reductionFunction) { AbstractReductionFunctionEntity functionEntity = reductionFunction.accept(serviceToPersistenceMapping); if (functionEntity == null) { throw new IllegalArgumentException("No mapping found"); } return functionEntity; } }
private void reduceUpdateAndPropagateVertex(BusinessServiceGraph graph, GraphVertex vertex) { if (vertex == null) { // Nothing to do here return; } // Calculate the weighed statuses from the child edges List<StatusWithIndex> statuses = weighEdges(graph.getOutEdges(vertex)); // Reduce Optional<StatusWithIndices> reducedStatus = vertex.getReductionFunction().reduce(statuses); Status newStatus; if (reducedStatus.isPresent()) { newStatus = reducedStatus.get().getStatus(); } else { newStatus = MIN_SEVERITY; } // Update and propagate updateAndPropagateVertex(graph, vertex, newStatus); }
private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect.getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } @Override public Void visit(ExponentialPropagation exponentialPropagation) { exponentialPropagation.setBase(Double.parseDouble(m_exponentialPropagationBaseTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } }));
private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect.getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } @Override public Void visit(ExponentialPropagation exponentialPropagation) { exponentialPropagation.setBase(Double.parseDouble(m_exponentialPropagationBaseTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } }));
businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {
m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {
m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {