Class CassandraCluster<I extends org.apache.cassandra.distributed.api.IInstance>
- java.lang.Object
-
- org.apache.cassandra.distributed.impl.CassandraCluster<I>
-
- Type Parameters:
I- the type of the cluster instance
- All Implemented Interfaces:
java.lang.AutoCloseable,java.lang.Iterable<I>,org.apache.cassandra.distributed.api.ICluster<I>,IClusterExtension<I>
public class CassandraCluster<I extends org.apache.cassandra.distributed.api.IInstance> extends java.lang.Object implements IClusterExtension<I>
Implements theIClusterExtensioninterface, delegating the functionality to thedelegate. This class is meant to be loaded in a different classloader.
-
-
Constructor Summary
Constructors Constructor Description CassandraCluster(java.lang.String versionString, ClusterBuilderConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IaddInstance(java.lang.String dc, java.lang.String rack, java.util.function.Consumer<org.apache.cassandra.distributed.api.IInstanceConfig> fn)Create a new instance and add it to the cluster, without starting it.voidawaitGossipStatus(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInGossip, java.lang.String targetStatus)Waits for the target instance to have the desired status.voidawaitRingState(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInRing, java.lang.String state)Waits for the ring to have the target instance with the provided state.voidawaitRingStatus(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInRing, java.lang.String status)Wait for the ring to have the target instance with the provided status.Ibootstrap(org.apache.cassandra.distributed.api.IInstanceConfig iInstanceConfig)voidcheckAndResetUncaughtExceptions()voidclose()org.apache.cassandra.distributed.api.ICoordinatorcoordinator(int i)org.apache.cassandra.distributed.api.ICluster<I>delegate()voiddeliverMessage(java.net.InetSocketAddress to, org.apache.cassandra.distributed.api.IMessage msg)org.apache.cassandra.distributed.api.IMessageFiltersfilters()voidforEach(java.util.function.Consumer<? super I> action)Iget(int i)Iget(java.net.InetSocketAddress inetSocketAddress)IgetFirstRunningInstance()org.apache.cassandra.distributed.impl.AbstractCluster<I>initializeCluster(java.lang.String versionString, ClusterBuilderConfiguration configuration)java.util.Iterator<I>iterator()org.apache.cassandra.distributed.api.IInstanceConfignewInstanceConfig()voidschemaChange(java.lang.String s)voidschemaChange(java.lang.String s, int i)voidschemaChangeIgnoringStoppedInstances(java.lang.String query)Change the schema of the cluster, tolerating stopped nodes.voidsetMessageSink(org.apache.cassandra.distributed.api.IMessageSink messageSink)voidsetUncaughtExceptionsFilter(java.util.function.BiPredicate<java.lang.Integer,java.lang.Throwable> ignoreThrowable)voidsetUncaughtExceptionsFilter(java.util.function.Predicate<java.lang.Throwable> ignoreThrowable)intsize()java.util.Spliterator<I>spliterator()voidstartup()voidstopUnchecked(org.apache.cassandra.distributed.api.IInstance instance)Stop an instance in a blocking manner.java.util.stream.Stream<I>stream()java.util.stream.Stream<I>stream(java.lang.String s)java.util.stream.Stream<I>stream(java.lang.String s, java.lang.String s1)
-
-
-
Constructor Detail
-
CassandraCluster
public CassandraCluster(java.lang.String versionString, ClusterBuilderConfiguration configuration) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
initializeCluster
public org.apache.cassandra.distributed.impl.AbstractCluster<I> initializeCluster(java.lang.String versionString, ClusterBuilderConfiguration configuration) throws java.io.IOException
- Throws:
java.io.IOException
-
schemaChangeIgnoringStoppedInstances
public void schemaChangeIgnoringStoppedInstances(java.lang.String query)
Description copied from interface:IClusterExtensionChange the schema of the cluster, tolerating stopped nodes. N.B. the schema will not automatically be updated when stopped nodes are restarted, individual tests need to re-synchronize somehow (by gossip or some other mechanism).- Specified by:
schemaChangeIgnoringStoppedInstancesin interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
query- Schema altering statement
-
addInstance
public I addInstance(java.lang.String dc, java.lang.String rack, java.util.function.Consumer<org.apache.cassandra.distributed.api.IInstanceConfig> fn)
Description copied from interface:IClusterExtensionCreate a new instance and add it to the cluster, without starting it.- Specified by:
addInstancein interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
dc- the instance should be inrack- the instance should be infn- function to add to the config before starting- Returns:
- the instance added
-
getFirstRunningInstance
public I getFirstRunningInstance()
- Specified by:
getFirstRunningInstancein interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Returns:
- the first instance with running state
-
newInstanceConfig
public org.apache.cassandra.distributed.api.IInstanceConfig newInstanceConfig()
- Specified by:
newInstanceConfigin interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Returns:
- a newly created instance configuration
-
delegate
public org.apache.cassandra.distributed.api.ICluster<I> delegate()
- Specified by:
delegatein interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Returns:
- a reference to the delegated
IClusterinstance
-
awaitRingState
public void awaitRingState(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInRing, java.lang.String state)Description copied from interface:IClusterExtensionWaits for the ring to have the target instance with the provided state.- Specified by:
awaitRingStatein interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
instance- instance to check onexpectedInRing- to look forstate- expected
-
awaitRingStatus
public void awaitRingStatus(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInRing, java.lang.String status)Description copied from interface:IClusterExtensionWait for the ring to have the target instance with the provided status.- Specified by:
awaitRingStatusin interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
instance- instance to check onexpectedInRing- to look forstatus- expected
-
awaitGossipStatus
public void awaitGossipStatus(org.apache.cassandra.distributed.api.IInstance instance, org.apache.cassandra.distributed.api.IInstance expectedInGossip, java.lang.String targetStatus)Description copied from interface:IClusterExtensionWaits for the target instance to have the desired status. Target status is checked via string contains so works with 'NORMAL' but also can check tokens or full state.- Specified by:
awaitGossipStatusin interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
instance- instance to check onexpectedInGossip- instance to wait fortargetStatus- for the instance
-
stopUnchecked
public void stopUnchecked(org.apache.cassandra.distributed.api.IInstance instance)
Description copied from interface:IClusterExtensionStop an instance in a blocking manner.The main difference between this and
IInstance.shutdown()is that the wait on the future will catch the exceptions and throw as runtime.- Specified by:
stopUncheckedin interfaceIClusterExtension<I extends org.apache.cassandra.distributed.api.IInstance>- Parameters:
instance- instance to stop
-
startup
public void startup()
- Specified by:
startupin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
bootstrap
public I bootstrap(org.apache.cassandra.distributed.api.IInstanceConfig iInstanceConfig)
- Specified by:
bootstrapin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
get
public I get(int i)
- Specified by:
getin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
get
public I get(java.net.InetSocketAddress inetSocketAddress)
- Specified by:
getin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
coordinator
public org.apache.cassandra.distributed.api.ICoordinator coordinator(int i)
- Specified by:
coordinatorin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
schemaChange
public void schemaChange(java.lang.String s)
- Specified by:
schemaChangein interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
schemaChange
public void schemaChange(java.lang.String s, int i)- Specified by:
schemaChangein interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
size
public int size()
- Specified by:
sizein interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
stream
public java.util.stream.Stream<I> stream()
- Specified by:
streamin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
stream
public java.util.stream.Stream<I> stream(java.lang.String s)
- Specified by:
streamin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
stream
public java.util.stream.Stream<I> stream(java.lang.String s, java.lang.String s1)
- Specified by:
streamin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
iterator
@NotNull public java.util.Iterator<I> iterator()
-
filters
public org.apache.cassandra.distributed.api.IMessageFilters filters()
- Specified by:
filtersin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
setMessageSink
public void setMessageSink(org.apache.cassandra.distributed.api.IMessageSink messageSink)
- Specified by:
setMessageSinkin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
deliverMessage
public void deliverMessage(java.net.InetSocketAddress to, org.apache.cassandra.distributed.api.IMessage msg)- Specified by:
deliverMessagein interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
setUncaughtExceptionsFilter
public void setUncaughtExceptionsFilter(java.util.function.BiPredicate<java.lang.Integer,java.lang.Throwable> ignoreThrowable)
- Specified by:
setUncaughtExceptionsFilterin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
setUncaughtExceptionsFilter
public void setUncaughtExceptionsFilter(java.util.function.Predicate<java.lang.Throwable> ignoreThrowable)
- Specified by:
setUncaughtExceptionsFilterin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
checkAndResetUncaughtExceptions
public void checkAndResetUncaughtExceptions()
- Specified by:
checkAndResetUncaughtExceptionsin interfaceorg.apache.cassandra.distributed.api.ICluster<I extends org.apache.cassandra.distributed.api.IInstance>
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
forEach
public void forEach(java.util.function.Consumer<? super I> action)
- Specified by:
forEachin interfacejava.lang.Iterable<I extends org.apache.cassandra.distributed.api.IInstance>
-
-