use of org.opennms.netmgt.bsm.service.BusinessServiceStateMachine in project opennms by OpenNMS.
the class DefaultBusinessServiceStateMachine method clone.
@Override
public BusinessServiceStateMachine clone(boolean preserveState) {
m_rwLock.readLock().lock();
try {
final BusinessServiceStateMachine sm = new DefaultBusinessServiceStateMachine();
// Rebuild the graph using the business services from the existing state machine
final BusinessServiceGraph graph = getGraph();
sm.setBusinessServices(graph.getVertices().stream().filter(v -> v.getBusinessService() != null).map(v -> v.getBusinessService()).collect(Collectors.toList()));
// Prime the state
if (preserveState) {
for (String reductionKey : graph.getReductionKeys()) {
GraphVertex reductionKeyVertex = graph.getVertexByReductionKey(reductionKey);
sm.handleNewOrUpdatedAlarm(new AlarmWrapper() {
@Override
public String getReductionKey() {
return reductionKey;
}
@Override
public Status getStatus() {
return reductionKeyVertex.getStatus();
}
});
}
}
return sm;
} finally {
m_rwLock.readLock().unlock();
}
}
use of org.opennms.netmgt.bsm.service.BusinessServiceStateMachine in project opennms by OpenNMS.
the class BusinessServiceEdgeStatusInfoPanelItemProvider method createComponent.
private Component createComponent(BusinessServiceEdge ref, GraphContainer container) {
FormLayout formLayout = new FormLayout();
formLayout.setMargin(false);
formLayout.setSpacing(false);
formLayout.addStyleName("severity");
final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
final Status outgoingStatus = BusinessServicesStatusProvider.getStatus(stateMachine, ref);
final Status incomingStatus = BusinessServicesStatusProvider.getStatus(stateMachine, ((AbstractBusinessServiceVertex) ref.getTarget().getVertex()));
formLayout.addComponent(createStatusLabel("Outgoing Severity", outgoingStatus));
formLayout.addComponent(createStatusLabel("Incoming Severity", incomingStatus));
return formLayout;
}
use of org.opennms.netmgt.bsm.service.BusinessServiceStateMachine in project opennms by OpenNMS.
the class SimulationAwareStateMachineFactory method createSimulatedStateMachine.
public static BusinessServiceStateMachine createSimulatedStateMachine(BusinessServiceManager manager, Criteria[] criteria) {
// Gather the statuses and group them by reduction key
final Map<String, Status> statusByReductionKey = Arrays.stream(criteria).filter(c -> c instanceof SetStatusToCriteria).map(c -> (SetStatusToCriteria) c).filter(c -> c.getStatus() != null).collect(Collectors.toMap(SetStatusToCriteria::getReductionKey, SetStatusToCriteria::getStatus));
// Determine whether or not we should inherit the existing state
final boolean shouldInheritState = Arrays.stream(criteria).anyMatch(c -> c instanceof InheritStateCriteria);
// Grab a copy of the state machine, and update push alarms
// that reflect the simulated state of the reduction keys
final BusinessServiceStateMachine stateMachine = manager.getStateMachine().clone(shouldInheritState);
for (Entry<String, Status> entry : statusByReductionKey.entrySet()) {
stateMachine.handleNewOrUpdatedAlarm(new AlarmWrapper() {
@Override
public String getReductionKey() {
return entry.getKey();
}
@Override
public Status getStatus() {
return entry.getValue();
}
});
}
return stateMachine;
}
use of org.opennms.netmgt.bsm.service.BusinessServiceStateMachine in project opennms by OpenNMS.
the class BusinessServiceVertexStatusInfoPanelItemProvider method createComponent.
private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) {
final FormLayout rootLayout = new FormLayout();
rootLayout.setSizeFull();
rootLayout.setSpacing(false);
rootLayout.setMargin(false);
rootLayout.addStyleName("severity");
final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex);
rootLayout.addComponent(createStatusLabel("Overall", overallStatus));
rootLayout.addComponent(new Label());
final BusinessServiceGraph graph = stateMachine.getGraph();
final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService);
for (final Edge edge : businessService.getEdges()) {
// Get the topology vertex for the child to determine the display label
final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() {
@Override
public VertexRef visit(final IpServiceEdge edge) {
return new IpServiceVertex(edge.getIpService(), 0);
}
@Override
public VertexRef visit(final ReductionKeyEdge edge) {
return new ReductionKeyVertex(edge.getReductionKey(), 0);
}
@Override
public VertexRef visit(final ChildEdge edge) {
return new BusinessServiceVertex(edge.getChild(), 0);
}
}));
final Status edgeStatus = stateMachine.getOperationalStatus(edge);
rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format("%s × %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
}
return rootLayout;
}
use of org.opennms.netmgt.bsm.service.BusinessServiceStateMachine in project opennms by OpenNMS.
the class AbstractAnalysisOperation method execute.
@Override
public void execute(List<VertexRef> targets, OperationContext operationContext) {
final List<AbstractBusinessServiceVertex> vertices = getVertices(targets);
final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, operationContext.getGraphContainer().getCriteria());
final Set<GraphVertex> graphVerticesToFocus = Sets.newHashSet();
final BusinessServiceVertexVisitor<Collection<GraphVertex>> visitor = getVisitorForVerticesToFocus(stateMachine);
for (AbstractBusinessServiceVertex vertex : vertices) {
graphVerticesToFocus.addAll(vertex.accept(visitor));
}
LOG.debug("Found {} business services.", graphVerticesToFocus.size());
if (graphVerticesToFocus.isEmpty()) {
new InfoDialog("No result", getMessageForNoResultDialog()).open();
} else {
focusOnVertices(targets.get(0), graphVerticesToFocus, operationContext.getGraphContainer());
}
}
Aggregations