public ComponentId nestInNamespace(ComponentId namespace) { if (namespace == null) { return this; } else { ComponentId newNamespace = getNamespace() == null ? namespace : getNamespace().nestInNamespace(namespace); return new ComponentId(getName(), getVersion(), newNamespace); } }
/** * Registers a component unless this registry is frozen. * This will succeed even if this component name and version is already registered. * * @throws IllegalStateException if this chain is frozen */ public void register(ComponentId id, COMPONENT component) { if (frozen) throw new IllegalStateException("Cannot modify a frozen component registry"); Map<String, Map<Version, COMPONENT>> componentVersionsByName = componentsByNameByNamespace.get(id.getNamespace()); if (componentVersionsByName == null) { componentVersionsByName = new LinkedHashMap<>(); componentsByNameByNamespace.put(id.getNamespace(), componentVersionsByName); } Map<Version, COMPONENT> componentVersions = componentVersionsByName.get(id.getName()); if (componentVersions == null) { componentVersions = new LinkedHashMap<>(); componentVersionsByName.put(id.getName(), componentVersions); } componentVersions.put(id.getVersion(), component); componentsById.put(id, component); }
/** * Unregisters a component unless this registry is frozen. * Note that the component is not deconstructed or otherwise modified in any way, this * is the responsiblity of the caller. * * @param id the id of the component to be unregistered * @return the component that was unregistered, or null if no such component was already registered */ public COMPONENT unregister(ComponentId id) { if (frozen) throw new IllegalStateException("Cannot modify a frozen component registry"); COMPONENT removed = componentsById.remove(id); if (removed != null) { //removed is non-null, so it must be present here as well: Map<String, Map<Version, COMPONENT>> componentVersionsByName = componentsByNameByNamespace.get(id.getNamespace()); Map<Version, COMPONENT> componentVersions = componentVersionsByName.get(id.getName()); COMPONENT removedInner = componentVersions.remove(id.getVersion()); assert (removedInner == removed); //clean up if (componentVersions.isEmpty()) { componentVersionsByName.remove(id.getName()); } if (componentVersionsByName.isEmpty()) { componentsByNameByNamespace.remove(id.getNamespace()); } } return removed; }
public String idAndType() { String className = instanceType().getName(); if (className.equals(componentId.getName())) { return "'" + componentId + "'"; } else { return "'" + componentId + "' of type '" + className + "'"; } }
public ComponentSpecification toSpecification() { if (isAnonymous()) throw new RuntimeException("Can't generate a specification for an anonymous component id."); return new ComponentSpecification(getName(), getVersion().toSpecification(), getNamespace()); }
public TimingSearcher(ComponentId id, TimingSearcherConfig config, Statistics manager) { this(id, buildParameters(config, id.getName()), manager); }
/** * Checks if a componentId matches a given spec */ public boolean matches(ComponentId id) { boolean versionMatch = getVersionSpecification().matches(id.getVersion()); return getName().equals(id.getName()) && versionMatch && namespaceMatch(id.getNamespace()); }
@Override public String stringValue() { return "query-profile" + (type!=null ? ":" + type.getId().getName() : ""); }
private Query createFederationQuery(Query query, Query outgoing, Window window, long timeout, Target target) { ComponentId chainId = target.getChain().getId(); String sourceName = chainId.getName(); outgoing.properties().set(SOURCENAME, sourceName); String providerName = chainId.getName(); if (chainId.getNamespace() != null) providerName = chainId.getNamespace().getName(); outgoing.properties().set(PROVIDERNAME, providerName); outgoing.setTimeout(timeout); switch (propagateSourceProperties) { case ALL: propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, Query.nativeProperties); break; case OFFSET_HITS: propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, queryAndHits); break; } //TODO: FederationTarget //TODO: only for target produced by this, not others target.modifyTargetQuery(outgoing); return outgoing; }
@Override public String toInstanceDescription() { return "reference to a query profile" + (type!=null ? " of type '" + type.getId().getName() + "'" : ""); }
public QueryProfileType(ComponentId id) { super(id); QueryProfile.validateName(id.getName()); }
/** * Creates a new query profile from an id. * The query profile can be modified freely (but not accessed) until it is {@link #freeze frozen}. * At that point it becomes readable but unmodifiable, which it stays until it goes out of reference. */ public QueryProfile(ComponentId id) { super(id); if ( ! id.isAnonymous()) validateName(id.getName()); }
/** Returns a copy of this id with namespace set to null **/ public ComponentId withoutNamespace() { return new ComponentId(getName(), getVersion(), null); }
/** * Creates a new query profile from an id. */ public CompiledQueryProfile(ComponentId id, QueryProfileType type, DimensionalMap<CompoundName, Object> entries, DimensionalMap<CompoundName, QueryProfileType> types, DimensionalMap<CompoundName, Object> references, DimensionalMap<CompoundName, Object> unoverridables, CompiledQueryProfileRegistry registry) { super(id); this.registry = registry; if (type != null) type.freeze(); this.type = type; this.entries = entries; this.types = types; this.references = references; this.unoverridables = unoverridables; if ( ! id.isAnonymous()) validateName(id.getName()); }
+ " exception in " + getId().getName() + " ping" + (trace == null ? ", no stack trace available." : traceAsString));
TimingSearcher(ComponentId id, Parameters setUp, Statistics manager) { super(id); if (setUp == null) { setUp = defaultParameters; } String eventName = setUp.eventName; if (eventName == null || "".equals(eventName)) { eventName = id.getName(); } measurements = new Value(eventName, manager, new Value.Parameters() .setNameExtension(true).setLogMax(true).setLogMin(true) .setLogMean(true).setLogSum(true).setLogInsertions(true) .setAppendChar('_')); measurePing = setUp.pathToSample == Activity.PING; measureSearch = setUp.pathToSample == Activity.SEARCH; measureFill = setUp.pathToSample == Activity.FILL; }
public PeakQpsSearcher(MeasureQpsConfig config, Statistics manager) { directory = createDirectory(); MeasureQpsConfig.Outputmethod.Enum method = config.outputmethod(); if (method == MeasureQpsConfig.Outputmethod.METAHIT) { useMetaHit = true; propertyName = new CompoundName(config.queryproperty()); qpsStatistics = null; } else if (method == MeasureQpsConfig.Outputmethod.STATISTICS) { String event = config.eventname(); if (event == null || event.isEmpty()) { event = getId().getName(); event = event.replace('.', '_'); } qpsStatistics = new Value(event, manager, new Value.Parameters() .setAppendChar('_').setLogMax(true).setLogMean(true) .setLogMin(false).setLogRaw(false).setNameExtension(true) .setCallback(new Fetcher())); useMetaHit = false; propertyName = null; } else { throw new IllegalArgumentException( "Config definition out of sync with implementation." + " No way to create output for method " + method + "."); } }