Search in sources :

Example 1 with Component

use of com.yahoo.vespa.model.container.component.Component in project vespa by vespa-engine.

the class DocumentFactoryBuilder method buildDocumentFactories.

public static void buildDocumentFactories(ContainerCluster cluster, Element spec) {
    Map<String, String> types = new LinkedHashMap<>();
    for (Element e : XML.getChildren(spec, "document")) {
        String type = e.getAttribute("type");
        String clazz = e.getAttribute("class");
        // Empty pkg is forbidden in the documentgen Mojo.
        if (clazz.indexOf('.') < 0)
            throw new IllegalArgumentException("Malformed class for <document> binding, must be a full class with package: " + clazz);
        String pkg = clazz.substring(0, clazz.lastIndexOf('.'));
        String concDocFactory = pkg + "." + CONCRETE_DOC_FACTORY_CLASS;
        String bundle = e.getAttribute("bundle");
        Component<AbstractConfigProducer<?>, ComponentModel> component = new Component<>(new ComponentModel(BundleInstantiationSpecification.getFromStrings(concDocFactory, concDocFactory, bundle)));
        if (!cluster.getComponentsMap().containsKey(component.getComponentId()))
            cluster.addComponent(component);
        types.put(type, concDocFactory);
    }
    cluster.concreteDocumentTypes().putAll(types);
}
Also used : AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) Element(org.w3c.dom.Element) ComponentModel(com.yahoo.osgi.provider.model.ComponentModel) Component(com.yahoo.vespa.model.container.component.Component) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Component

use of com.yahoo.vespa.model.container.component.Component in project vespa by vespa-engine.

the class AdminTestCase method testContainerMetricsSnapshotInterval.

@Test
public void testContainerMetricsSnapshotInterval() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "metricconfig");
    ContainerCluster docprocCluster = vespaModel.getContainerClusters().get("cluster.music.indexing");
    HealthMonitorConfig.Builder builder = new HealthMonitorConfig.Builder();
    docprocCluster.getConfig(builder);
    HealthMonitorConfig docprocConfig = new HealthMonitorConfig(builder);
    assertEquals(60, (int) docprocConfig.snapshot_interval());
    ContainerCluster qrCluster = vespaModel.getContainerClusters().get("container");
    builder = new HealthMonitorConfig.Builder();
    qrCluster.getConfig(builder);
    HealthMonitorConfig qrClusterConfig = new HealthMonitorConfig(builder);
    assertEquals(60, (int) qrClusterConfig.snapshot_interval());
    StatisticsComponent stat = null;
    for (Component component : qrCluster.getAllComponents()) {
        if (component.getClassId().getName().contains("com.yahoo.statistics.StatisticsImpl")) {
            stat = (StatisticsComponent) component;
            break;
        }
    }
    assertNotNull(stat);
    StatisticsConfig.Builder sb = new StatisticsConfig.Builder();
    stat.getConfig(sb);
    StatisticsConfig sc = new StatisticsConfig(sb);
    assertEquals(60, (int) sc.collectionintervalsec());
    assertEquals(60, (int) sc.loggingintervalsec());
}
Also used : StatisticsComponent(com.yahoo.vespa.model.container.component.StatisticsComponent) StatisticsConfig(com.yahoo.container.StatisticsConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) HealthMonitorConfig(com.yahoo.container.jdisc.config.HealthMonitorConfig) StatisticsComponent(com.yahoo.vespa.model.container.component.StatisticsComponent) Component(com.yahoo.vespa.model.container.component.Component) Test(org.junit.Test)

Example 3 with Component

use of com.yahoo.vespa.model.container.component.Component in project vespa by vespa-engine.

the class AccessLogTest method access_log_can_be_configured.

@Test
public void access_log_can_be_configured() throws Exception {
    Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0'>", "  <accesslog type='yapache' ", "             fileNamePattern='pattern' rotationInterval='interval'", "             rotationScheme='date' />", "  <accesslog type='json' ", "             fileNamePattern='pattern' rotationInterval='interval'", "             rotationScheme='date' />", nodesXml, "</jdisc>");
    createModel(root, clusterElem);
    {
        // yapache
        Component<?, ?> accessLogComponent = getContainerComponent("default", YApacheAccessLog.class.getName());
        assertNotNull(accessLogComponent);
        assertEquals(YApacheAccessLog.class.getName(), accessLogComponent.getClassId().getName(), YApacheAccessLog.class.getName());
        AccessLogConfig config = root.getConfig(AccessLogConfig.class, "default/component/com.yahoo.container.logging.YApacheAccessLog");
        AccessLogConfig.FileHandler fileHandlerConfig = config.fileHandler();
        assertEquals("pattern", fileHandlerConfig.pattern());
        assertEquals("interval", fileHandlerConfig.rotation());
        assertEquals(AccessLogConfig.FileHandler.RotateScheme.DATE, fileHandlerConfig.rotateScheme());
    }
    {
        // json
        Component<?, ?> accessLogComponent = getContainerComponent("default", JSONAccessLog.class.getName());
        assertNotNull(accessLogComponent);
        assertEquals(JSONAccessLog.class.getName(), accessLogComponent.getClassId().getName(), JSONAccessLog.class.getName());
        AccessLogConfig config = root.getConfig(AccessLogConfig.class, "default/component/com.yahoo.container.logging.JSONAccessLog");
        AccessLogConfig.FileHandler fileHandlerConfig = config.fileHandler();
        assertEquals("pattern", fileHandlerConfig.pattern());
        assertEquals("interval", fileHandlerConfig.rotation());
        assertEquals(AccessLogConfig.FileHandler.RotateScheme.DATE, fileHandlerConfig.rotateScheme());
    }
}
Also used : AccessLogConfig(com.yahoo.container.core.AccessLogConfig) Element(org.w3c.dom.Element) Component(com.yahoo.vespa.model.container.component.Component) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 4 with Component

use of com.yahoo.vespa.model.container.component.Component in project vespa by vespa-engine.

the class ContainerModelBuilderTest method component_includes_are_added.

@Test
public void component_includes_are_added() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/application/include_dirs");
    VespaModel model = creator.create(true);
    ContainerCluster cluster = model.getContainerClusters().get("default");
    Map<ComponentId, Component<?, ?>> componentsMap = cluster.getComponentsMap();
    Component<?, ?> example = componentsMap.get(ComponentId.fromString("test.Exampledocproc"));
    assertThat(example.getComponentId().getName(), is("test.Exampledocproc"));
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 5 with Component

use of com.yahoo.vespa.model.container.component.Component in project vespa by vespa-engine.

the class RestApiTest method all_non_restApi_components_are_injected_to_RestApiContext.

@Test
public void all_non_restApi_components_are_injected_to_RestApiContext() throws Exception {
    setup();
    ComponentsConfig componentsConfig = root.getConfig(ComponentsConfig.class, ClusterId);
    Set<ComponentId> clusterChildrenComponentIds = getContainerCluster(ClusterId).getAllComponents().stream().map(Component::getComponentId).collect(Collectors.toSet());
    Set<ComponentId> restApiChildrenComponentIds = restApi.getChildren().values().stream().map(child -> ((Component<?, ?>) child).getComponentId()).collect(Collectors.toSet());
    // TODO: Review: replace with filtering against RestApiContext.isCycleGeneratingComponent
    ComponentId cycleInducingComponents = ComponentId.fromString("com.yahoo.container.handler.observability.ApplicationStatusHandler");
    Set<ComponentId> expectedInjectedConfigIds = new HashSet<>(clusterChildrenComponentIds);
    expectedInjectedConfigIds.removeAll(restApiChildrenComponentIds);
    expectedInjectedConfigIds.remove(cycleInducingComponents);
    Set<ComponentId> injectedConfigIds = restApiContextConfig(componentsConfig).inject().stream().map(inject -> ComponentId.fromString(inject.id())).collect(Collectors.toSet());
    // Verify that the two sets are equal. Split in two asserts to get decent failure messages.
    assertThat("Not all required components are injected", injectedConfigIds, containsInAnyOrder(expectedInjectedConfigIds.toArray()));
    assertThat("We inject some components that should not be injected", expectedInjectedConfigIds, containsInAnyOrder(injectedConfigIds.toArray()));
}
Also used : ComponentsConfig(com.yahoo.container.ComponentsConfig) CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Handler(com.yahoo.vespa.model.container.component.Handler) ComponentId(com.yahoo.component.ComponentId) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashSet(java.util.HashSet) RestApiContext(com.yahoo.vespa.model.container.jersey.RestApiContext) JerseyBundlesConfig(com.yahoo.container.di.config.JerseyBundlesConfig) RestApi(com.yahoo.vespa.model.container.jersey.RestApi) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) JerseyInitConfig(com.yahoo.container.config.jersey.JerseyInitConfig) Component(com.yahoo.vespa.model.container.component.Component) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) Set(java.util.Set) Test(org.junit.Test) ContainerModelBuilderTestBase(com.yahoo.vespa.model.container.xml.ContainerModelBuilderTestBase) Collectors(java.util.stream.Collectors) JerseyInjectionConfig(com.yahoo.container.di.config.JerseyInjectionConfig) Ignore(org.junit.Ignore) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ComponentsConfig(com.yahoo.container.ComponentsConfig) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) HashSet(java.util.HashSet) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Aggregations

Component (com.yahoo.vespa.model.container.component.Component)9 Test (org.junit.Test)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)5 ComponentId (com.yahoo.component.ComponentId)4 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)4 VespaModel (com.yahoo.vespa.model.VespaModel)2 Element (org.w3c.dom.Element)2 AbstractConfigProducer (com.yahoo.config.model.producer.AbstractConfigProducer)1 ComponentsConfig (com.yahoo.container.ComponentsConfig)1 StatisticsConfig (com.yahoo.container.StatisticsConfig)1 JerseyInitConfig (com.yahoo.container.config.jersey.JerseyInitConfig)1 AccessLogConfig (com.yahoo.container.core.AccessLogConfig)1 JerseyBundlesConfig (com.yahoo.container.di.config.JerseyBundlesConfig)1 JerseyInjectionConfig (com.yahoo.container.di.config.JerseyInjectionConfig)1 JdiscBindingsConfig (com.yahoo.container.jdisc.JdiscBindingsConfig)1 HealthMonitorConfig (com.yahoo.container.jdisc.config.HealthMonitorConfig)1 ComponentModel (com.yahoo.osgi.provider.model.ComponentModel)1 FederationSearcherModel (com.yahoo.search.searchchain.model.federation.FederationSearcherModel)1 Handler (com.yahoo.vespa.model.container.component.Handler)1 StatisticsComponent (com.yahoo.vespa.model.container.component.StatisticsComponent)1