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 void
causeConnectionLoss(org.apache.solr.client.solrj.embedded.JettySolrRunner jetty)
static void
causeConnectionLoss(org.apache.zookeeper.ZooKeeper zooKeeper)
void
causeSomeChaos()
causes some randomly selected chaosvoid
expireRandomSession()
void
expireSession(org.apache.solr.client.solrj.embedded.JettySolrRunner jetty)
AbstractFullDistribZkTestBase.CloudJettyRunner
getRandomJetty(String slice, boolean aggressivelyKillLeaders)
org.apache.solr.client.solrj.embedded.JettySolrRunner
getShard(String slice, int index)
int
getStarts()
AbstractFullDistribZkTestBase.CloudJettyRunner
killRandomShard()
AbstractFullDistribZkTestBase.CloudJettyRunner
killRandomShard(String slice)
static void
monkeyLog(String msg)
static void
monkeyLog(String msg, Object... logParams)
void
randomConnectionLoss()
static void
start(List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys)
void
startAll()
void
startTheMonkey(boolean killLeaders, int roundPauseUpperLimit)
static void
stop(List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys)
void
stopAll(int pauseBetweenMs)
void
stopJetty(AbstractFullDistribZkTestBase.CloudJettyRunner cjetty)
AbstractFullDistribZkTestBase.CloudJettyRunner
stopRandomShard()
AbstractFullDistribZkTestBase.CloudJettyRunner
stopRandomShard(String slice)
void
stopShard(String slice)
AbstractFullDistribZkTestBase.CloudJettyRunner
stopShard(String slice, int index)
void
stopShardExcept(String slice, String shardName)
void
stopTheMonkey()
static void
wait(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(org.apache.solr.client.solrj.embedded.JettySolrRunner jetty)
-
expireRandomSession
public void expireRandomSession() throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
randomConnectionLoss
public void randomConnectionLoss() throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
causeConnectionLoss
public static void causeConnectionLoss(org.apache.solr.client.solrj.embedded.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 org.apache.solr.client.solrj.embedded.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.KeeperException
InterruptedException
-
startTheMonkey
public void startTheMonkey(boolean killLeaders, int roundPauseUpperLimit)
-
monkeyLog
public static void monkeyLog(String msg)
-
stopTheMonkey
public void stopTheMonkey()
-
causeSomeChaos
public void causeSomeChaos() throws Exception
causes some randomly selected chaos- Throws:
Exception
-
getStarts
public int getStarts()
-
stop
public static void stop(List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys) throws Exception
- Throws:
Exception
-
start
public static void start(List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys) throws Exception
- Throws:
Exception
-
wait
public static void wait(long runLength, String collectionName, org.apache.solr.common.cloud.ZkStateReader zkStateReader) throws InterruptedException
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- Parameters:
runLength
- The time in ms to waitcollectionName
- The main collection being used for the ChaosMonkeyzkStateReader
- current state reader- Throws:
InterruptedException
-
-