Search in sources :

Example 1 with HighestSeverity

use of org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity in project opennms by OpenNMS.

the class BusinessServiceVertexInfoPanelItemProvider method createComponent.

private Component createComponent(AbstractBusinessServiceVertex ref, GraphContainer graphContainer) {
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    ref.accept(new BusinessServiceVertexVisitor<Void>() {

        @Override
        public Void visit(BusinessServiceVertex vertex) {
            final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
            formLayout.addComponent(createLabel("Reduce function", getReduceFunctionDescription(businessService.getReduceFunction())));
            // Apply Reduce Function specific details
            businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() {

                @Override
                public Void visit(HighestSeverity highestSeverity) {
                    return null;
                }

                @Override
                public Void visit(HighestSeverityAbove highestSeverityAbove) {
                    return null;
                }

                @Override
                public // Threshold is not very transparent, we add an Explain Button in these cases
                Void visit(Threshold threshold) {
                    final Button explainButton = createButton("Explain", "Explain the Threshold function", FontAwesome.TABLE, (Button.ClickListener) event -> {
                        ThresholdExplanationWindow explainWindow = new ThresholdExplanationWindow(SimulationAwareStateMachineFactory.createSimulatedStateMachine(businessServiceManager, graphContainer.getCriteria()).explain(businessService, (Threshold) businessService.getReduceFunction()));
                        UI.getCurrent().addWindow(explainWindow);
                    });
                    explainButton.setStyleName(BaseTheme.BUTTON_LINK);
                    formLayout.addComponent(explainButton);
                    return null;
                }

                @Override
                public Void visit(ExponentialPropagation exponentialPropagation) {
                    return null;
                }
            });
            return null;
        }

        @Override
        public Void visit(IpServiceVertex vertex) {
            IpService ipService = businessServiceManager.getIpServiceById(vertex.getIpServiceId());
            formLayout.addComponent(createLabel("Interface", ipService.getIpAddress()));
            formLayout.addComponent(createLabel("Service", ipService.getServiceName()));
            if (!ipService.getServiceName().equals(vertex.getLabel())) {
                formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
            }
            return null;
        }

        @Override
        public Void visit(ReductionKeyVertex vertex) {
            formLayout.addComponent(createLabel("Reduction Key", vertex.getReductionKey()));
            if (!vertex.getReductionKey().equals(vertex.getLabel())) {
                formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
            }
            return null;
        }
    });
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) GraphContainer(org.opennms.features.topology.api.GraphContainer) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) IpService(org.opennms.netmgt.bsm.service.model.IpService) BaseTheme(com.vaadin.ui.themes.BaseTheme) VerticalLayout(com.vaadin.ui.VerticalLayout) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold) UI(com.vaadin.ui.UI) BusinessServiceManager(org.opennms.netmgt.bsm.service.BusinessServiceManager) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) Window(com.vaadin.ui.Window) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceVertexVisitor(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertexVisitor) Strings(com.google.common.base.Strings) FontAwesome(com.vaadin.server.FontAwesome) GraphVertexToTopologyVertexConverter(org.opennms.features.topology.plugins.topo.bsm.GraphVertexToTopologyVertexConverter) VertexInfoPanelItemProvider(org.opennms.features.topology.api.info.VertexInfoPanelItemProvider) DefaultInfoPanelItem(org.opennms.features.topology.api.info.item.DefaultInfoPanelItem) ReductionFunction(org.opennms.netmgt.bsm.service.model.functions.reduce.ReductionFunction) Status(org.opennms.netmgt.bsm.service.model.Status) Label(com.vaadin.ui.Label) ShortcutAction(com.vaadin.event.ShortcutAction) Comparator.comparing(java.util.Comparator.comparing) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) BusinessServicesTopologyProvider(org.opennms.features.topology.plugins.topo.bsm.BusinessServicesTopologyProvider) ThresholdResultExplanation(org.opennms.netmgt.bsm.service.model.functions.reduce.ThresholdResultExplanation) InfoPanelItem(org.opennms.features.topology.api.info.item.InfoPanelItem) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) Collectors(java.util.stream.Collectors) Sizeable(com.vaadin.server.Sizeable) SimulationAwareStateMachineFactory(org.opennms.features.topology.plugins.topo.bsm.simulate.SimulationAwareStateMachineFactory) TransactionAwareBeanProxyFactory(org.opennms.netmgt.vaadin.core.TransactionAwareBeanProxyFactory) BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel(org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel) List(java.util.List) Button(com.vaadin.ui.Button) Table(com.vaadin.ui.Table) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) FormLayout(com.vaadin.ui.FormLayout) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) VertexRef(org.opennms.features.topology.api.topo.VertexRef) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) Component(com.vaadin.ui.Component) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) IpService(org.opennms.netmgt.bsm.service.model.IpService) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) Button(com.vaadin.ui.Button) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold)

Example 2 with HighestSeverity

use of org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity in project opennms by OpenNMS.

the class BusinessServiceRequestDTOMarshalTest method data.

@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
    final SetTo setTo = new SetTo();
    setTo.setStatus(Status.CRITICAL);
    final MapFunctionDTO increaseDto = createMapFunctionDTO(new Increase());
    final MapFunctionDTO setToDto = createMapFunctionDTO(setTo);
    final BusinessServiceRequestDTO requestDTO = new BusinessServiceRequestDTO();
    requestDTO.setReduceFunction(createReduceFunctionDTO(new HighestSeverity()));
    requestDTO.setName("Web Servers");
    requestDTO.addAttribute("dc", "RDU");
    requestDTO.addAttribute("some-key", "some-value");
    requestDTO.addChildService(2L, increaseDto, 5);
    requestDTO.addChildService(3L, setToDto, 5);
    requestDTO.addReductionKey("myReductionKeyA", increaseDto, 7, "reduction-key-a-friendly-name");
    requestDTO.addReductionKey("myReductionKeyB", increaseDto, 7, "reduction-key-b-friendly-name");
    requestDTO.addIpService(1, increaseDto, 9, "ip-service-friendly-name");
    return Arrays.asList(new Object[][] { { BusinessServiceRequestDTO.class, requestDTO, "{" + "  \"name\" : \"Web Servers\"," + "  \"attributes\" : {" + "    \"attribute\" : [ {" + "      \"key\" : \"dc\"," + "      \"value\" : \"RDU\"" + "    }, {" + "      \"key\" : \"some-key\"," + "      \"value\" : \"some-value\"" + "    } ]" + "  }," + "  \"reduce-function\" : {" + "       \"type\" : \"HighestSeverity\"," + "       \"properties\" : { }" + "  }," + "  \"child-edges\" : [" + "       {" + "           \"map-function\" : {" + "               \"type\" : \"Increase\"," + "               \"properties\" : { }" + "           }," + "           \"weight\" : 5," + "           \"child-id\" : 2" + "       }," + "       {" + "           \"map-function\" : {" + "               \"type\" : \"SetTo\"," + "               \"properties\" : {" + "                   \"status\" : \"Critical\"" + "               }" + "           }," + "           \"weight\" : 5," + "           \"child-id\" : 3" + "       }," + "   ]," + "  \"ip-service-edges\" : [" + "       {" + "           \"map-function\" : {" + "               \"type\" : \"Increase\"," + "               \"properties\" : { }" + "           }," + "           \"weight\" : 9," + "           \"ip-service-id\" : 1," + "           \"friendly-name\" : \"ip-service-friendly-name\"" + "       }," + "   ]," + "  \"reduction-key-edges\" : [" + "       {" + "           \"map-function\" : {" + "               \"type\" : \"Increase\"," + "               \"properties\" : { }" + "           }," + "           \"weight\" : 7," + "           \"reduction-key\" : \"myReductionKeyA\"," + "           \"friendly-name\" : \"reduction-key-a-friendly-name\"" + "       }," + "       {" + "            \"map-function\" : {" + "               \"type\" : \"Increase\"," + "               \"properties\" : { }" + "           }," + "           \"weight\" : 7," + "           \"reduction-key\" : \"myReductionKeyB\"," + "           \"friendly-name\" : \"reduction-key-b-friendly-name\"" + "       }," + "   ]," + "}", "<business-service>\n" + "   <name>Web Servers</name>\n" + "   <attributes>\n" + "      <attribute>\n" + "         <key>dc</key>\n" + "         <value>RDU</value>\n" + "      </attribute>\n" + "      <attribute>\n" + "         <key>some-key</key>\n" + "         <value>some-value</value>\n" + "      </attribute>\n" + "   </attributes>\n" + "    <ip-service-edges>\n" + "      <ip-service-edge>\n" + "         <map-function>\n" + "            <type>Increase</type>\n" + "         </map-function>\n" + "         <weight>9</weight>\n" + "         <friendly-name>ip-service-friendly-name</friendly-name>\n" + "         <ip-service-id>1</ip-service-id>\n" + "      </ip-service-edge>\n" + "   </ip-service-edges>\n" + "   <child-edges>\n" + "      <child-edge>\n" + "         <map-function>\n" + "            <type>Increase</type>\n" + "         </map-function>\n" + "         <weight>5</weight>\n" + "         <child-id>2</child-id>\n" + "      </child-edge>\n" + "      <child-edge>\n" + "         <map-function>\n" + "            <type>SetTo</type>\n" + "            <properties>\n" + "               <entry>\n" + "                  <key>status</key>\n" + "                  <value>Critical</value>\n" + "               </entry>\n" + "            </properties>\n" + "         </map-function>\n" + "         <weight>5</weight>\n" + "         <child-id>3</child-id>\n" + "      </child-edge>\n" + "   </child-edges>\n" + "   <reduction-key-edges>\n" + "      <reduction-key-edge>\n" + "         <map-function>\n" + "            <type>Increase</type>\n" + "         </map-function>\n" + "         <weight>7</weight>\n" + "         <friendly-name>reduction-key-a-friendly-name</friendly-name>\n" + "         <reduction-key>myReductionKeyA</reduction-key>\n" + "      </reduction-key-edge>\n" + "      <reduction-key-edge>\n" + "         <map-function>\n" + "            <type>Increase</type>\n" + "         </map-function>\n" + "         <weight>7</weight>\n" + "         <friendly-name>reduction-key-b-friendly-name</friendly-name>\n" + "         <reduction-key>myReductionKeyB</reduction-key>\n" + "      </reduction-key-edge>\n" + "   </reduction-key-edges>\n" + "   <reduce-function>\n" + "      <type>HighestSeverity</type>\n" + "   </reduce-function>\n" + "</business-service>" } });
}
Also used : TestHelper.createMapFunctionDTO(org.opennms.web.rest.v2.bsm.model.TestHelper.createMapFunctionDTO) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) Increase(org.opennms.netmgt.bsm.service.model.functions.map.Increase) SetTo(org.opennms.netmgt.bsm.service.model.functions.map.SetTo)

Example 3 with HighestSeverity

use of org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity in project opennms by OpenNMS.

the class DefaultBusinessServiceStateMachineTest method canPerformRootCauseAndImpactAnalysis.

@Test
public void canPerformRootCauseAndImpactAnalysis() {
    // Create a hierarchy using all of the available reduction functions
    HighestSeverity highestSeverity = new HighestSeverity();
    Threshold threshold = new Threshold();
    threshold.setThreshold(0.5f);
    HighestSeverityAbove highestSeverityAbove = new HighestSeverityAbove();
    highestSeverityAbove.setThreshold(Status.MINOR);
    MockBusinessServiceHierarchy h = MockBusinessServiceHierarchy.builder().withBusinessService(1).withName("b1").withReductionFunction(highestSeverityAbove).withBusinessService(2).withName("b2").withReductionFunction(highestSeverity).withReductionKey(21, "a1").withReductionKey(22, "a2").withReductionKey(23, "a3").commit().withBusinessService(3).withName("b3").withReductionFunction(threshold).withReductionKey(34, "a4").withReductionKey(35, "a5").withReductionKey(36, "a6").withReductionKey(37, "a7").commit().commit().build();
    // Setup the state machine
    DefaultBusinessServiceStateMachine stateMachine = new DefaultBusinessServiceStateMachine();
    stateMachine.setBusinessServices(h.getBusinessServices());
    // Bump b2 to MINOR, caused by a1
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a1", Status.MINOR));
    // Bump b3 to MAJOR, caused by a4, a6 and a7
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a4", Status.MAJOR));
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a6", Status.CRITICAL));
    stateMachine.handleNewOrUpdatedAlarm(new MockAlarmWrapper("a7", Status.MAJOR));
    // Bumped b1 to MAJOR, caused by b3
    // Verify the state
    assertEquals(Status.MAJOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(1)));
    assertEquals(Status.MINOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(2)));
    assertEquals(Status.MAJOR, stateMachine.getOperationalStatus(h.getBusinessServiceById(3)));
    // Calculate and verify the root causes, b2 caused by a1
    List<GraphVertex> causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(2));
    assertEquals(1, causedby.size());
    assertEquals("a1", causedby.get(0).getReductionKey());
    // b3 caused by a4, a6 and a7
    causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(3));
    assertEquals(3, causedby.size());
    assertEquals("a4", causedby.get(0).getReductionKey());
    assertEquals("a6", causedby.get(1).getReductionKey());
    assertEquals("a7", causedby.get(2).getReductionKey());
    // b1 caused by b3, which was in turn caused by a4, a6 and a7
    causedby = stateMachine.calculateRootCause(h.getBusinessServiceById(1));
    assertEquals(4, causedby.size());
    assertEquals(Long.valueOf(3), causedby.get(0).getBusinessService().getId());
    assertEquals("a4", causedby.get(1).getReductionKey());
    assertEquals("a6", causedby.get(2).getReductionKey());
    assertEquals("a7", causedby.get(3).getReductionKey());
    // Now calculate the impact, a1 impacts b2
    List<GraphVertex> impacts = stateMachine.calculateImpact("a1");
    assertEquals(1, impacts.size());
    assertEquals("b2", impacts.get(0).getBusinessService().getName());
    // a4 impacts b3 which impacts b1
    impacts = stateMachine.calculateImpact("a4");
    assertEquals(2, impacts.size());
    assertEquals("b3", impacts.get(0).getBusinessService().getName());
    assertEquals("b1", impacts.get(1).getBusinessService().getName());
    // b3 impacts b1
    impacts = stateMachine.calculateImpact(h.getBusinessServiceById(3));
    assertEquals(1, impacts.size());
    assertEquals("b1", impacts.get(0).getBusinessService().getName());
}
Also used : HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) MockBusinessServiceHierarchy(org.opennms.netmgt.bsm.mock.MockBusinessServiceHierarchy) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) MockAlarmWrapper(org.opennms.netmgt.bsm.mock.MockAlarmWrapper) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold) Test(org.junit.Test)

Example 4 with HighestSeverity

use of org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity in project opennms by OpenNMS.

the class BusinessServiceResponseDTOMarshalTest method data.

@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
    final MapFunctionDTO ignoreDto = createMapFunctionDTO(new Ignore());
    final BusinessServiceResponseDTO bs = new BusinessServiceResponseDTO();
    bs.setId(1L);
    bs.setName("Web Servers");
    bs.addAttribute("dc", "RDU");
    bs.setLocation(new ResourceLocation(ApiVersion.Version2, "business-services", "1"));
    bs.setOperationalStatus(Status.CRITICAL);
    bs.setReduceFunction(createReduceFunctionDTO(new HighestSeverity()));
    bs.getReductionKeys().add(createReductionKeyEdgeResponse(1L, "myReductionKeyA", ignoreDto, Status.CRITICAL, new ResourceLocation(ApiVersion.Version2, "test/1"), "reduction-key-a-friendly-name"));
    bs.getReductionKeys().add(createReductionKeyEdgeResponse(2L, "myReductionKeyB", ignoreDto, Status.NORMAL, new ResourceLocation(ApiVersion.Version2, "test/2"), "reduction-key-b-friendly-name"));
    bs.getChildren().add(createChildEdgeResponse(3L, 2L, ignoreDto, Status.MAJOR, new ResourceLocation(ApiVersion.Version2, "test/3")));
    bs.getChildren().add(createChildEdgeResponse(4L, 3L, ignoreDto, Status.MAJOR, new ResourceLocation(ApiVersion.Version2, "test/4")));
    bs.getIpServices().add(createIpServiceEdgeResponse(5L, createIpServiceResponse(), ignoreDto, Status.MINOR, new ResourceLocation(ApiVersion.Version2, "test/5"), "ip-service-friendly-name"));
    bs.getParentServices().add(11L);
    bs.getParentServices().add(12L);
    return Arrays.asList(new Object[][] { { BusinessServiceResponseDTO.class, bs, "{" + "  \"location\" : \"/api/v2/business-services/1\"," + "  \"name\" : \"Web Servers\"," + "  \"id\" : 1," + "  \"attributes\" : {" + "    \"attribute\" : [ {" + "      \"key\" : \"dc\"," + "      \"value\" : \"RDU\"" + "    } ]" + "  }," + "  \"operational-status\" : \"CRITICAL\"," + "  \"reduce-function\" : {" + "    \"type\" : \"HighestSeverity\"," + "    \"properties\" : { }" + "  }," + "  \"reduction-key-edges\" : [ {" + "    \"id\" : 1," + "    \"operational-status\" : \"CRITICAL\"," + "    \"map-function\" : {" + "      \"type\" : \"Ignore\"," + "      \"properties\" : { }" + "    }," + "    \"weight\" : 9," + "    \"location\" : \"/api/v2/test/1\"," + "    \"reduction-keys\" : [ \"myReductionKeyA\" ]," + "    \"friendly-name\" : \"reduction-key-a-friendly-name\"" + "  }, {" + "    \"id\" : 2," + "    \"operational-status\" : \"NORMAL\"," + "    \"map-function\" : {" + "      \"type\" : \"Ignore\"," + "      \"properties\" : { }" + "    }," + "    \"weight\" : 9," + "    \"location\" : \"/api/v2/test/2\"," + "    \"reduction-keys\" : [ \"myReductionKeyB\" ]," + "    \"friendly-name\" : \"reduction-key-b-friendly-name\"" + "  } ]," + "  \"child-edges\" : [ {" + "    \"id\" : 3," + "    \"operational-status\" : \"MAJOR\"," + "    \"map-function\" : {" + "      \"type\" : \"Ignore\"," + "      \"properties\" : { }" + "    }," + "    \"weight\" : 7," + "    \"location\" : \"/api/v2/test/3\"," + "    \"reduction-keys\" : [ ]," + "    \"child-id\" : 2" + "  }, {" + "    \"id\" : 4," + "    \"operational-status\" : \"MAJOR\"," + "    \"map-function\" : {" + "      \"type\" : \"Ignore\"," + "      \"properties\" : { }" + "    }," + "    \"weight\" : 7," + "    \"location\" : \"/api/v2/test/4\"," + "    \"reduction-keys\" : [ ]," + "    \"child-id\" : 3" + "  } ]," + "  \"ip-service-edges\" : [ {" + "    \"id\" : 5," + "    \"operational-status\" : \"MINOR\"," + "    \"map-function\" : {" + "      \"type\" : \"Ignore\"," + "      \"properties\" : { }" + "    }," + "    \"weight\" : 5," + "    \"location\" : \"/api/v2/test/5\"," + "    \"reduction-keys\" : [ \"key1\", \"key2\" ]," + "    \"ip-service\" : {" + "      \"location\" : \"/api/v2/business-services/ip-services/17\"," + "      \"id\" : 17," + "      \"node-label\" : \"dummy\"," + "      \"service-name\" : \"ICMP\"," + "      \"ip-address\" : \"1.1.1.1\"" + "    }," + "    \"friendly-name\" : \"ip-service-friendly-name\"" + "  } ]," + "  \"parent-services\" : [ 11, 12 ]" + "}", "<business-service>\n" + "   <id>1</id>\n" + "   <name>Web Servers</name>\n" + "   <attributes>\n" + "      <attribute>\n" + "         <key>dc</key>\n" + "         <value>RDU</value>\n" + "      </attribute>\n" + "   </attributes>\n" + "   <ip-service-edges>\n" + "      <ip-service-edge>\n" + "         <id>5</id>\n" + "         <operational-status>MINOR</operational-status>\n" + "         <map-function>\n" + "            <type>Ignore</type>\n" + "         </map-function>\n" + "         <location>/api/v2/test/5</location>\n" + "         <reduction-keys>\n" + "            <reduction-key>key1</reduction-key>\n" + "            <reduction-key>key2</reduction-key>\n" + "         </reduction-keys>\n" + "         <weight>5</weight>\n" + "         <ip-service>\n" + "            <id>17</id>\n" + "            <service-name>ICMP</service-name>\n" + "            <node-label>dummy</node-label>\n" + "            <ip-address>1.1.1.1</ip-address>\n" + "            <location>/api/v2/business-services/ip-services/17</location>\n" + "         </ip-service>\n" + "         <friendly-name>ip-service-friendly-name</friendly-name>\n" + "      </ip-service-edge>\n" + "   </ip-service-edges>\n" + "   <reduction-key-edges>\n" + "      <reduction-key-edge>\n" + "         <id>1</id>\n" + "         <operational-status>CRITICAL</operational-status>\n" + "         <map-function>\n" + "            <type>Ignore</type>\n" + "         </map-function>\n" + "         <location>/api/v2/test/1</location>\n" + "         <reduction-keys>\n" + "            <reduction-key>myReductionKeyA</reduction-key>\n" + "         </reduction-keys>\n" + "         <weight>9</weight>\n" + "         <friendly-name>reduction-key-a-friendly-name</friendly-name>\n" + "      </reduction-key-edge>\n" + "      <reduction-key-edge>\n" + "         <id>2</id>\n" + "         <operational-status>NORMAL</operational-status>\n" + "         <map-function>\n" + "            <type>Ignore</type>\n" + "         </map-function>\n" + "         <location>/api/v2/test/2</location>\n" + "         <reduction-keys>\n" + "            <reduction-key>myReductionKeyB</reduction-key>\n" + "         </reduction-keys>\n" + "         <weight>9</weight>\n" + "         <friendly-name>reduction-key-b-friendly-name</friendly-name>\n" + "      </reduction-key-edge>\n" + "   </reduction-key-edges>\n" + "   <child-edges>\n" + "      <child-edge>\n" + "         <id>3</id>\n" + "         <operational-status>MAJOR</operational-status>\n" + "         <map-function>\n" + "            <type>Ignore</type>\n" + "         </map-function>\n" + "         <location>/api/v2/test/3</location>\n" + "         <reduction-keys/>\n" + "         <weight>7</weight>\n" + "         <child-id>2</child-id>\n" + "      </child-edge>\n" + "      <child-edge>\n" + "         <id>4</id>\n" + "         <operational-status>MAJOR</operational-status>\n" + "         <map-function>\n" + "            <type>Ignore</type>\n" + "         </map-function>\n" + "         <location>/api/v2/test/4</location>\n" + "         <reduction-keys/>\n" + "         <weight>7</weight>\n" + "         <child-id>3</child-id>\n" + "      </child-edge>\n" + "   </child-edges>\n" + "   <parent-services>\n" + "      <parent-service>11</parent-service>\n" + "      <parent-service>12</parent-service>\n" + "   </parent-services>\n" + "   <reduce-function>\n" + "      <type>HighestSeverity</type>\n" + "   </reduce-function>\n" + "   <operational-status>CRITICAL</operational-status>\n" + "   <location>/api/v2/business-services/1</location>\n" + "</business-service>" } });
}
Also used : Ignore(org.opennms.netmgt.bsm.service.model.functions.map.Ignore) TestHelper.createMapFunctionDTO(org.opennms.web.rest.v2.bsm.model.TestHelper.createMapFunctionDTO) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) ResourceLocation(org.opennms.web.rest.api.ResourceLocation)

Example 5 with HighestSeverity

use of org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity in project opennms by OpenNMS.

the class BusinessServiceManagerImplIT method ensureNoDanglingReductionFunctions.

@Test
@Transactional
public void ensureNoDanglingReductionFunctions() {
    // Create a business service
    final BusinessService bs = this.createBusinessService("bs1");
    bs.save();
    // Ensure there is an associated reduction function
    assertEquals(1, reductionFunctionDao.countAll());
    bs.setReduceFunction(new HighestSeverity());
    bs.save();
    // Ensure there is still only one associated reduction function
    assertEquals(1, reductionFunctionDao.countAll());
    // Delete
    bs.delete();
    // There should be no reduction function left
    assertEquals(0, reductionFunctionDao.countAll());
}
Also used : BsmTestUtils.createDummyBusinessService(org.opennms.netmgt.bsm.test.BsmTestUtils.createDummyBusinessService) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

HighestSeverity (org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity)8 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)4 Test (org.junit.Test)3 Collectors (java.util.stream.Collectors)2 MockAlarmWrapper (org.opennms.netmgt.bsm.mock.MockAlarmWrapper)2 MockBusinessServiceHierarchy (org.opennms.netmgt.bsm.mock.MockBusinessServiceHierarchy)2 BusinessServiceManager (org.opennms.netmgt.bsm.service.BusinessServiceManager)2 Identity (org.opennms.netmgt.bsm.service.model.functions.map.Identity)2 HighestSeverityAbove (org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove)2 Threshold (org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold)2 Strings (com.google.common.base.Strings)1 ShortcutAction (com.vaadin.event.ShortcutAction)1 FontAwesome (com.vaadin.server.FontAwesome)1 Sizeable (com.vaadin.server.Sizeable)1 Button (com.vaadin.ui.Button)1 Component (com.vaadin.ui.Component)1 FormLayout (com.vaadin.ui.FormLayout)1 Label (com.vaadin.ui.Label)1 Table (com.vaadin.ui.Table)1 UI (com.vaadin.ui.UI)1