Search in sources :

Example 1 with TISZkStateReader

use of org.apache.solr.common.cloud.TISZkStateReader 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)

Example 2 with TISZkStateReader

use of org.apache.solr.common.cloud.TISZkStateReader in project tis by qlangtech.

the class TestCollectionAction method buildZkStateReaderMock.

private void buildZkStateReaderMock() throws Exception {
    TISZkStateReader tisZkStateReader = buildTisZkStateReaderMock();
    DocCollection docCollection = buildDocCollectionMock(true, true, COLLECTION_NAME, tisZkStateReader);
}
Also used : DocCollection(org.apache.solr.common.cloud.DocCollection) TISZkStateReader(org.apache.solr.common.cloud.TISZkStateReader)

Example 3 with TISZkStateReader

use of org.apache.solr.common.cloud.TISZkStateReader in project tis by qlangtech.

the class TestCollectionAction method buildTisZkStateReaderMock.

private TISZkStateReader buildTisZkStateReaderMock() {
    TISZkStateReader tisZkStateReader = this.mock("tisZkStateReader", TISZkStateReader.class);
    MockClusterStateReader.mockStateReader = tisZkStateReader;
    return tisZkStateReader;
}
Also used : TISZkStateReader(org.apache.solr.common.cloud.TISZkStateReader)

Example 4 with TISZkStateReader

use of org.apache.solr.common.cloud.TISZkStateReader in project tis by qlangtech.

the class SolrCloudQueryResutStrategy method query.

// @Override
// public int getServicePort() {
// return 7001;
// }
@Override
public List<ServerJoinGroup> query() {
    List<ServerJoinGroup> result = new ArrayList<ServerJoinGroup>();
    ServerJoinGroup groupServer = null;
    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");
    }
    Map<String, Slice> groups = docCollection.getSlicesMap();
    short shard;
    for (Map.Entry<String, Slice> entry : groups.entrySet()) {
        for (Replica replic : entry.getValue().getReplicas()) {
            groupServer = new ServerJoinGroup();
            groupServer.setLeader(replic.getBool("leader", false));
            groupServer.setIpAddress(replic.getCoreUrl());
            groupServer.setReplicBaseUrl(replic.getBaseUrl());
            shard = (Short.parseShort(StringUtils.substringAfter(entry.getKey(), SHARD_PREIX)));
            groupServer.setGroupIndex(--shard);
            result.add(groupServer);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Replica(org.apache.solr.common.cloud.Replica) TISZkStateReader(org.apache.solr.common.cloud.TISZkStateReader) Slice(org.apache.solr.common.cloud.Slice) DocCollection(org.apache.solr.common.cloud.DocCollection) Map(java.util.Map)

Example 5 with TISZkStateReader

use of org.apache.solr.common.cloud.TISZkStateReader in project tis by qlangtech.

the class ClusterStateReader method createSerivce.

@Override
protected TISZkStateReader createSerivce(RunEnvironment runtime) {
    try {
        TisZkClient zkClinet = (TisZkClient) zooKeeperGetter.getInstance(runtime);
        final TISZkStateReader zkStateReader = new TISZkStateReader(zkClinet.getZK());
        zkClinet.addOnReconnect(() -> {
            try {
                zkStateReader.createClusterStateWatchersAndUpdate();
            } catch (KeeperException e) {
                LOG.error("A ZK error has occurred", e);
                throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "A ZK error has occurred", e);
            } catch (InterruptedException e) {
                // Restore the interrupted status
                Thread.currentThread().interrupt();
                LOG.error("Interrupted", e);
                throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "Interrupted", e);
            }
        });
        zkStateReader.createClusterStateWatchersAndUpdate();
        return zkStateReader;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : ZooKeeperException(org.apache.solr.common.cloud.ZooKeeperException) TisZkClient(com.qlangtech.tis.TisZkClient) KeeperException(org.apache.zookeeper.KeeperException) ZooKeeperException(org.apache.solr.common.cloud.ZooKeeperException) SolrException(org.apache.solr.common.SolrException) KeeperException(org.apache.zookeeper.KeeperException) ZooKeeperException(org.apache.solr.common.cloud.ZooKeeperException) TISZkStateReader(org.apache.solr.common.cloud.TISZkStateReader)

Aggregations

TISZkStateReader (org.apache.solr.common.cloud.TISZkStateReader)6 DocCollection (org.apache.solr.common.cloud.DocCollection)4 Map (java.util.Map)3 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 Maps (com.google.common.collect.Maps)1 ActionProxy (com.opensymphony.xwork2.ActionProxy)1 BasicActionTestCase (com.qlangtech.tis.BasicActionTestCase)1 TisZkClient (com.qlangtech.tis.TisZkClient)1 ITISCoordinator (com.qlangtech.tis.cloud.ITISCoordinator)1 MockZKUtils (com.qlangtech.tis.cloud.MockZKUtils)1 CollectionTopology (com.qlangtech.tis.coredefine.module.action.CollectionTopology)1 CoreAction (com.qlangtech.tis.coredefine.module.action.CoreAction)1 ExtendWorkFlowBuildHistory (com.qlangtech.tis.coredefine.module.action.ExtendWorkFlowBuildHistory)1 SelectableServer (com.qlangtech.tis.coredefine.module.control.SelectableServer)1 ISnapshotViewDAO (com.qlangtech.tis.manage.biz.dal.dao.ISnapshotViewDAO)1 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)1 ServerGroupCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)1 com.qlangtech.tis.manage.common (com.qlangtech.tis.manage.common)1