Package org.apache.solr.cloud
Class ChaosMonkey
- java.lang.Object
-
- org.apache.solr.cloud.ChaosMonkey
-
public class ChaosMonkey extends Object
The monkey can stop random or specific jetties used with SolrCloud.It can also run in a background thread and start and stop jetties randomly.
TODO: expire multiple sessions / connectionloss at once
TODO: kill multiple jetties at once
TODO: ? add random headhunter mode that always kills the leader
TODO: chaosmonkey should be able to do cluster stop/start tests
-
-
Constructor Summary
Constructors Constructor Description ChaosMonkey(ZkTestServer zkServer, org.apache.solr.common.cloud.ZkStateReader zkStateReader, String collection, Map<String,List<AbstractFullDistribZkTestBase.CloudJettyRunner>> shardToJetty, Map<String,AbstractFullDistribZkTestBase.CloudJettyRunner> shardToLeaderJetty)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcauseConnectionLoss(JettySolrRunner jetty)static voidcauseConnectionLoss(org.apache.zookeeper.ZooKeeper zooKeeper)voidcauseSomeChaos()causes some randomly selected chaosvoidexpireRandomSession()voidexpireSession(JettySolrRunner jetty)AbstractFullDistribZkTestBase.CloudJettyRunnergetRandomJetty(String slice, boolean aggressivelyKillLeaders)JettySolrRunnergetShard(String slice, int index)intgetStarts()AbstractFullDistribZkTestBase.CloudJettyRunnerkillRandomShard()AbstractFullDistribZkTestBase.CloudJettyRunnerkillRandomShard(String slice)static voidmonkeyLog(String msg)static voidmonkeyLog(String msg, Object... logParams)voidrandomConnectionLoss()static voidstart(List<JettySolrRunner> jettys)voidstartAll()voidstartTheMonkey(boolean killLeaders, int roundPauseUpperLimit)static voidstop(List<JettySolrRunner> jettys)voidstopAll(int pauseBetweenMs)voidstopJetty(AbstractFullDistribZkTestBase.CloudJettyRunner cjetty)AbstractFullDistribZkTestBase.CloudJettyRunnerstopRandomShard()AbstractFullDistribZkTestBase.CloudJettyRunnerstopRandomShard(String slice)voidstopShard(String slice)AbstractFullDistribZkTestBase.CloudJettyRunnerstopShard(String slice, int index)voidstopShardExcept(String slice, String shardName)voidstopTheMonkey()static voidwait(long runLength, String collectionName, org.apache.solr.common.cloud.ZkStateReader zkStateReader)You can call this method to wait while the ChaosMonkey is running, it waits approximately the specified time, and periodically logs the status of the collection
-
-
-
Constructor Detail
-
ChaosMonkey
public ChaosMonkey(ZkTestServer zkServer, org.apache.solr.common.cloud.ZkStateReader zkStateReader, String collection, Map<String,List<AbstractFullDistribZkTestBase.CloudJettyRunner>> shardToJetty, Map<String,AbstractFullDistribZkTestBase.CloudJettyRunner> shardToLeaderJetty)
-
-
Method Detail
-
expireSession
public void expireSession(JettySolrRunner jetty)
-
expireRandomSession
public void expireRandomSession() throws org.apache.zookeeper.KeeperException, InterruptedException- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
randomConnectionLoss
public void randomConnectionLoss() throws org.apache.zookeeper.KeeperException, InterruptedException- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
causeConnectionLoss
public static void causeConnectionLoss(JettySolrRunner jetty)
-
causeConnectionLoss
public static void causeConnectionLoss(org.apache.zookeeper.ZooKeeper zooKeeper)
-
stopShard
public AbstractFullDistribZkTestBase.CloudJettyRunner stopShard(String slice, int index) throws Exception
- Throws:
Exception
-
stopJetty
public void stopJetty(AbstractFullDistribZkTestBase.CloudJettyRunner cjetty) throws Exception
- Throws:
Exception
-
stopShardExcept
public void stopShardExcept(String slice, String shardName) throws Exception
- Throws:
Exception
-
getShard
public JettySolrRunner getShard(String slice, int index) throws Exception
- Throws:
Exception
-
stopRandomShard
public AbstractFullDistribZkTestBase.CloudJettyRunner stopRandomShard() throws Exception
- Throws:
Exception
-
stopRandomShard
public AbstractFullDistribZkTestBase.CloudJettyRunner stopRandomShard(String slice) throws Exception
- Throws:
Exception
-
killRandomShard
public AbstractFullDistribZkTestBase.CloudJettyRunner killRandomShard() throws Exception
- Throws:
Exception
-
killRandomShard
public AbstractFullDistribZkTestBase.CloudJettyRunner killRandomShard(String slice) throws Exception
- Throws:
Exception
-
getRandomJetty
public AbstractFullDistribZkTestBase.CloudJettyRunner getRandomJetty(String slice, boolean aggressivelyKillLeaders) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
startTheMonkey
public void startTheMonkey(boolean killLeaders, int roundPauseUpperLimit)
-
monkeyLog
public static void monkeyLog(String msg)
-
stopTheMonkey
public void stopTheMonkey()
-
causeSomeChaos
public void causeSomeChaos() throws Exceptioncauses some randomly selected chaos- Throws:
Exception
-
getStarts
public int getStarts()
-
stop
public static void stop(List<JettySolrRunner> jettys) throws Exception
- Throws:
Exception
-
start
public static void start(List<JettySolrRunner> jettys) throws Exception
- Throws:
Exception
-
wait
public static void wait(long runLength, String collectionName, org.apache.solr.common.cloud.ZkStateReader zkStateReader) throws InterruptedExceptionYou can call this method to wait while the ChaosMonkey is running, it waits approximately the specified time, and periodically logs the status of the collection- Parameters:
runLength- The time in ms to waitcollectionName- The main collection being used for the ChaosMonkeyzkStateReader- current state reader- Throws:
InterruptedException
-
-