Search in sources :

Example 6 with CloudJettyRunner

use of org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner in project lucene-solr by apache.

the class ChaosMonkey method causeSomeChaos.

/**
   * causes some randomly selected chaos
   */
public void causeSomeChaos() throws Exception {
    if (chaosRandom.nextBoolean()) {
        if (!deadPool.isEmpty()) {
            int index = chaosRandom.nextInt(deadPool.size());
            JettySolrRunner jetty = deadPool.get(index).jetty;
            if (jetty.isStopped() && !ChaosMonkey.start(jetty)) {
                return;
            }
            deadPool.remove(index);
            starts.incrementAndGet();
            return;
        }
    }
    int rnd = chaosRandom.nextInt(10);
    if (expireSessions && rnd < EXPIRE_PERCENT) {
        expireRandomSession();
    }
    if (causeConnectionLoss && rnd < CONLOSS_PERCENT) {
        randomConnectionLoss();
    }
    CloudJettyRunner cjetty;
    if (chaosRandom.nextBoolean()) {
        cjetty = stopRandomShard();
    } else {
        cjetty = killRandomShard();
    }
    if (cjetty == null) {
    // we cannot kill
    } else {
        deadPool.add(cjetty);
    }
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) CloudJettyRunner(org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner)

Example 7 with CloudJettyRunner

use of org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner in project lucene-solr by apache.

the class ChaosMonkey method checkIfKillIsLegal.

private int checkIfKillIsLegal(String sliceName, int numActive) throws KeeperException, InterruptedException {
    for (CloudJettyRunner cloudJetty : shardToJetty.get(sliceName)) {
        // get latest cloud state
        zkStateReader.forceUpdateCollection(collection);
        DocCollection docCollection = zkStateReader.getClusterState().getCollection(collection);
        Slice slice = docCollection.getSlice(sliceName);
        ZkNodeProps props = slice.getReplicasMap().get(cloudJetty.coreNodeName);
        if (props == null) {
            throw new RuntimeException("shard name " + cloudJetty.coreNodeName + " not found in " + slice.getReplicasMap().keySet());
        }
        final Replica.State state = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP));
        final String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);
        if (cloudJetty.jetty.isRunning() && state == Replica.State.ACTIVE && zkStateReader.getClusterState().liveNodesContain(nodeName)) {
            numActive++;
        }
    }
    return numActive;
}
Also used : Slice(org.apache.solr.common.cloud.Slice) ZkNodeProps(org.apache.solr.common.cloud.ZkNodeProps) CloudJettyRunner(org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner) DocCollection(org.apache.solr.common.cloud.DocCollection) Replica(org.apache.solr.common.cloud.Replica)

Example 8 with CloudJettyRunner

use of org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner in project lucene-solr by apache.

the class ChaosMonkey method stopAll.

public void stopAll(int pauseBetweenMs) throws Exception {
    Set<String> keys = shardToJetty.keySet();
    List<Thread> jettyThreads = new ArrayList<>(keys.size());
    for (String key : keys) {
        List<CloudJettyRunner> jetties = shardToJetty.get(key);
        for (CloudJettyRunner jetty : jetties) {
            Thread.sleep(pauseBetweenMs);
            Thread thread = new Thread() {

                public void run() {
                    try {
                        stopJetty(jetty);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            };
            jettyThreads.add(thread);
            thread.start();
        }
    }
    for (Thread thread : jettyThreads) {
        thread.join();
    }
}
Also used : ArrayList(java.util.ArrayList) CloudJettyRunner(org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

CloudJettyRunner (org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner)8 ZkNodeProps (org.apache.solr.common.cloud.ZkNodeProps)3 DocCollection (org.apache.solr.common.cloud.DocCollection)2 Replica (org.apache.solr.common.cloud.Replica)2 Slice (org.apache.solr.common.cloud.Slice)2 ArrayList (java.util.ArrayList)1 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)1 Type (org.apache.solr.common.cloud.Replica.Type)1 CoreContainer (org.apache.solr.core.CoreContainer)1 SolrCore (org.apache.solr.core.SolrCore)1 KeeperException (org.apache.zookeeper.KeeperException)1