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);
}
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());
}
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());
}
}
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"));
}
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()));
}
Aggregations