Search in sources :

Example 1 with ListMap

use of com.yahoo.collections.ListMap in project vespa by vespa-engine.

the class Dispatcher method hitsByNode.

/**
 * Return a map of hits by their search node (partition) id
 */
private static ListMap<Integer, FastHit> hitsByNode(Result result) {
    ListMap<Integer, FastHit> hitsByPartition = new ListMap<>();
    for (Iterator<Hit> i = result.hits().unorderedDeepIterator(); i.hasNext(); ) {
        Hit h = i.next();
        if (!(h instanceof FastHit))
            continue;
        FastHit hit = (FastHit) h;
        hitsByPartition.put(hit.getDistributionKey(), hit);
    }
    return hitsByPartition;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) ListMap(com.yahoo.collections.ListMap)

Example 2 with ListMap

use of com.yahoo.collections.ListMap in project vespa by vespa-engine.

the class VersionStatus method findConfigServerVersions.

private static ListMap<Version, String> findConfigServerVersions(Controller controller) {
    List<URI> configServers = controller.zoneRegistry().zones().controllerManaged().not().among(ZoneId.from("prod.cd-us-east-1a"), ZoneId.from("prod.aws-us-east-1a")).ids().stream().flatMap(zoneId -> controller.zoneRegistry().getConfigServerUris(zoneId).stream()).collect(Collectors.toList());
    ListMap<Version, String> versions = new ListMap<>();
    for (URI configServer : configServers) versions.put(controller.applications().configServer().version(configServer), configServer.getHost());
    return versions;
}
Also used : JobError.outOfCapacity(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError.outOfCapacity) Version(com.yahoo.component.Version) Vtag(com.yahoo.component.Vtag) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) HashSet(java.util.HashSet) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ImmutableList(com.google.common.collect.ImmutableList) JobList(com.yahoo.vespa.hosted.controller.application.JobList) Map(java.util.Map) URI(java.net.URI) Application(com.yahoo.vespa.hosted.controller.Application) Collection(java.util.Collection) Set(java.util.Set) Instant(java.time.Instant) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) GitSha(com.yahoo.vespa.hosted.controller.api.integration.github.GitSha) List(java.util.List) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) Collections(java.util.Collections) ListMap(com.yahoo.collections.ListMap) Controller(com.yahoo.vespa.hosted.controller.Controller) Version(com.yahoo.component.Version) URI(java.net.URI) ListMap(com.yahoo.collections.ListMap)

Example 3 with ListMap

use of com.yahoo.collections.ListMap in project vespa by vespa-engine.

the class NodeRepository method performOn.

/**
 * Performs an operation requiring locking on all nodes matching some filter.
 *
 * @param filter the filter determining the set of nodes where the operation will be performed
 * @param action the action to perform
 * @return the set of nodes on which the action was performed, as they became as a result of the operation
 */
private List<Node> performOn(NodeFilter filter, UnaryOperator<Node> action) {
    List<Node> unallocatedNodes = new ArrayList<>();
    ListMap<ApplicationId, Node> allocatedNodes = new ListMap<>();
    // Group matching nodes by the lock needed
    for (Node node : db.getNodes()) {
        if (!filter.matches(node))
            continue;
        if (node.allocation().isPresent())
            allocatedNodes.put(node.allocation().get().owner(), node);
        else
            unallocatedNodes.add(node);
    }
    // perform operation while holding locks
    List<Node> resultingNodes = new ArrayList<>();
    try (Mutex lock = lockUnallocated()) {
        for (Node node : unallocatedNodes) resultingNodes.add(action.apply(node));
    }
    for (Map.Entry<ApplicationId, List<Node>> applicationNodes : allocatedNodes.entrySet()) {
        try (Mutex lock = lock(applicationNodes.getKey())) {
            for (Node node : applicationNodes.getValue()) resultingNodes.add(action.apply(node));
        }
    }
    return resultingNodes;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Mutex(com.yahoo.transaction.Mutex) ApplicationId(com.yahoo.config.provision.ApplicationId) Map(java.util.Map) ListMap(com.yahoo.collections.ListMap) ListMap(com.yahoo.collections.ListMap)

Aggregations

ListMap (com.yahoo.collections.ListMap)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ImmutableList (com.google.common.collect.ImmutableList)1 Version (com.yahoo.component.Version)1 Vtag (com.yahoo.component.Vtag)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 Hit (com.yahoo.search.result.Hit)1 Mutex (com.yahoo.transaction.Mutex)1 Application (com.yahoo.vespa.hosted.controller.Application)1 Controller (com.yahoo.vespa.hosted.controller.Controller)1 GitSha (com.yahoo.vespa.hosted.controller.api.integration.github.GitSha)1 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)1 ApplicationList (com.yahoo.vespa.hosted.controller.application.ApplicationList)1 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)1 JobError.outOfCapacity (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError.outOfCapacity)1 JobList (com.yahoo.vespa.hosted.controller.application.JobList)1 URI (java.net.URI)1