Search in sources :

Example 11 with ComponentSpecification

use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.

the class ChainSpecification method flatten.

/**
 * @param allChainSpecifications resolves ChainSpecifications from ComponentSpecifications
 *                               as given in the inheritance fields.
 * @param path tracks which chains are used in each recursive invocation of flatten, used for detecting cycles.
 * @return ChainSpecification directly containing all the component references and phases of the inherited chains.
 */
private ChainSpecification flatten(Resolver<ChainSpecification> allChainSpecifications, Deque<ComponentId> path) {
    path.push(componentId);
    // if this turns out to be a bottleneck(which I seriously doubt), please add memoization
    Map<String, ComponentSpecification> resultingComponents = componentsByName(componentReferences);
    Map<String, Phase> resultingPhases = new LinkedHashMap<>(phases);
    for (ComponentSpecification inheritedChainSpecification : inheritance.chainSpecifications) {
        ChainSpecification inheritedChain = resolveChain(path, allChainSpecifications, inheritedChainSpecification).flatten(allChainSpecifications, path);
        mergeInto(resultingComponents, filterByComponentSpecification(filterByName(inheritedChain.componentReferences, names(componentReferences)), inheritance.excludedComponents));
        mergeInto(resultingPhases, inheritedChain.phases);
    }
    path.pop();
    return new ChainSpecification(componentId, inheritance.flattened(), resultingPhases.values(), new LinkedHashSet<>(resultingComponents.values()));
}
Also used : Phase(com.yahoo.component.chain.Phase) ComponentSpecification(com.yahoo.component.ComponentSpecification)

Example 12 with ComponentSpecification

use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.

the class BundleInstantiationSpecificationBuilder method build.

public static BundleInstantiationSpecification build(Element spec, boolean legacyMode) {
    ComponentSpecification id = XmlHelper.getIdRef(spec);
    ComponentSpecification classId = getComponentSpecification(spec, "class");
    ComponentSpecification bundle = getComponentSpecification(spec, "bundle");
    BundleInstantiationSpecification instSpec = new BundleInstantiationSpecification(id, classId, bundle);
    if (// TODO: Remove?
    !legacyMode)
        validate(instSpec);
    return bundle == null ? setBundleForKnownClass(instSpec) : instSpec;
}
Also used : ComponentSpecification(com.yahoo.component.ComponentSpecification) BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification)

Example 13 with ComponentSpecification

use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.

the class ContainerServiceBuilder method readServerPortOverrides.

private List<Container.PortOverride> readServerPortOverrides(Element spec) {
    List<Container.PortOverride> portOverrides = new ArrayList<>();
    for (Element serverPort : XML.getChildren(spec, "server-port")) {
        ComponentSpecification serverId = XmlHelper.getIdRef(serverPort);
        int port = Integer.parseInt(serverPort.getAttribute("port"));
        portOverrides.add(new Container.PortOverride(serverId, port));
    }
    return portOverrides;
}
Also used : Container(com.yahoo.vespa.model.container.Container) ComponentSpecification(com.yahoo.component.ComponentSpecification) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 14 with ComponentSpecification

use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.

the class ContainerTestBase method complete.

public void complete() {
    try {
        Container container = new Container(new CloudSubscriberFactory(dirConfigSource().configSource()), dirConfigSource().configId(), new ContainerTest.TestDeconstructor(), new Osgi() {

            @SuppressWarnings("unchecked")
            @Override
            public Class<Object> resolveClass(BundleInstantiationSpecification spec) {
                try {
                    return (Class<Object>) Class.forName(spec.classId.getName());
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public BundleClasses getBundleClasses(ComponentSpecification bundle, Set<String> packagesToScan) {
                throw new UnsupportedOperationException("getBundleClasses not supported");
            }

            @Override
            public void useBundles(Collection<FileReference> bundles) {
            }

            @Override
            public Bundle getBundle(ComponentSpecification spec) {
                throw new UnsupportedOperationException("getBundle not supported.");
            }
        });
        componentGraph = container.runOnce(componentGraph, Guice.createInjector());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Osgi(com.yahoo.container.di.Osgi) ComponentSpecification(com.yahoo.component.ComponentSpecification) Bundle(org.osgi.framework.Bundle) CloudSubscriberFactory(com.yahoo.container.di.CloudSubscriberFactory) BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification) ContainerTest(com.yahoo.container.di.ContainerTest) Container(com.yahoo.container.di.Container) FileReference(com.yahoo.config.FileReference)

Example 15 with ComponentSpecification

use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.

the class CompiledQueryProfileRegistry method findQueryProfile.

/**
 * <p>Returns a query profile for the given request string, or null if a suitable one is not found.</p>
 *
 * The request string must be a valid {@link com.yahoo.component.ComponentId} or null.<br>
 * If the string is null, the profile named "default" is returned, or null if that does not exists.
 *
 * <p>
 * The version part (if any) is matched used the usual component version patching rules.
 * If the name part matches a query profile name perfectly, that profile is returned.
 * If not, and the name is a slash-separated path, the profile with the longest matching left sub-path
 * which has a type which allows path matching is used. If there is no such profile, null is returned.
 */
public CompiledQueryProfile findQueryProfile(String idString) {
    if (idString == null || idString.isEmpty())
        return getComponent("default");
    ComponentSpecification id = new ComponentSpecification(idString);
    CompiledQueryProfile profile = getComponent(id);
    if (profile != null)
        return profile;
    return findPathParentQueryProfile(new ComponentSpecification(idString));
}
Also used : ComponentSpecification(com.yahoo.component.ComponentSpecification)

Aggregations

ComponentSpecification (com.yahoo.component.ComponentSpecification)17 ArrayList (java.util.ArrayList)4 Element (org.w3c.dom.Element)4 ComponentId (com.yahoo.component.ComponentId)2 BundleInstantiationSpecification (com.yahoo.container.bundle.BundleInstantiationSpecification)2 QueryProfile (com.yahoo.search.query.profile.QueryProfile)2 Phase (com.yahoo.component.chain.Phase)1 ChainSpecification (com.yahoo.component.chain.model.ChainSpecification)1 FileReference (com.yahoo.config.FileReference)1 CloudSubscriberFactory (com.yahoo.container.di.CloudSubscriberFactory)1 Container (com.yahoo.container.di.Container)1 ContainerTest (com.yahoo.container.di.ContainerTest)1 Osgi (com.yahoo.container.di.Osgi)1 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 DimensionValues (com.yahoo.search.query.profile.DimensionValues)1 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)1 FederationOptions (com.yahoo.search.searchchain.model.federation.FederationOptions)1 TargetSpec (com.yahoo.search.searchchain.model.federation.FederationSearcherModel.TargetSpec)1 Container (com.yahoo.vespa.model.container.Container)1