Search in sources :

Example 1 with CollectionTopology

use of com.qlangtech.tis.coredefine.module.action.CollectionTopology in project tis by qlangtech.

the class SolrCloudQueryResutStrategy method createCollectionTopology.

public CollectionTopology createCollectionTopology() {
    CollectionTopology topology = new CollectionTopology();
    TISZkStateReader clusterReader = runContext.getZkStateReader();
    DocCollection docCollection = TISZkStateReader.getCollectionLive(clusterReader, domain.getAppName());
    if (docCollection == null) {
        throw new IllegalStateException("collection:" + domain.getAppName() + " relevant docCollection can not be null");
    }
    CollectionTopology.Shared shared = null;
    Map<String, Slice> groups = docCollection.getSlicesMap();
    short shard;
    for (Map.Entry<String, Slice> entry : groups.entrySet()) {
        shared = new CollectionTopology.Shared(entry.getKey());
        topology.addShard(shared);
        // shardName = entry.getKey();
        for (Replica replic : entry.getValue().getReplicas()) {
            shared.addReplic(replic);
        // groupServer = new ServerJoinGroup();
        // groupServer.setLeader(replic.getBool("leader", false));
        // groupServer.setIpAddress(replic.getCoreUrl());
        // shard = (Short.parseShort(StringUtils.substringAfter(entry.getKey(), SHARD_PREIX)));
        // groupServer.setGroupIndex(--shard);
        // result.add(groupServer);
        }
    }
    return topology;
}
Also used : CollectionTopology(com.qlangtech.tis.coredefine.module.action.CollectionTopology) Slice(org.apache.solr.common.cloud.Slice) DocCollection(org.apache.solr.common.cloud.DocCollection) Map(java.util.Map) Replica(org.apache.solr.common.cloud.Replica) TISZkStateReader(org.apache.solr.common.cloud.TISZkStateReader)

Aggregations

CollectionTopology (com.qlangtech.tis.coredefine.module.action.CollectionTopology)1 Map (java.util.Map)1 DocCollection (org.apache.solr.common.cloud.DocCollection)1 Replica (org.apache.solr.common.cloud.Replica)1 Slice (org.apache.solr.common.cloud.Slice)1 TISZkStateReader (org.apache.solr.common.cloud.TISZkStateReader)1