use of org.apache.cassandra.distributed.api.IInstanceConfig in project cassandra by apache.
the class ClusterUtils method getHintsDirectory.
/**
* Get the hints directory for the given instance.
*
* @param instance to get the hints directory for
* @return hints directory
*/
public static File getHintsDirectory(IInstance instance) {
IInstanceConfig conf = instance.config();
// this isn't safe as it assumes the implementation of InstanceConfig
// might need to get smarter... some day...
String d = (String) conf.get("hints_directory");
return new File(d);
}
use of org.apache.cassandra.distributed.api.IInstanceConfig in project cassandra by apache.
the class AbstractNetstatsBootstrapStreaming method executeTest.
protected void executeTest(final boolean streamEntireSSTables, final boolean compressionEnabled, final int throughput) throws Exception {
final Cluster.Builder builder = builder().withNodes(1).withTokenSupplier(TokenSupplier.evenlyDistributedTokens(2)).withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(2, "dc0", "rack0")).withConfig(config -> config.with(NETWORK, GOSSIP, NATIVE_PROTOCOL).set(streamEntireSSTables ? "entire_sstable_stream_throughput_outbound" : "stream_throughput_outbound", throughput + "MiB/s").set("compaction_throughput", "1MiB/s").set("stream_entire_sstables", streamEntireSSTables));
try (final Cluster cluster = builder.withNodes(1).start()) {
// populate data only against 1 node first
createTable(cluster, 1, compressionEnabled);
cluster.get(1).nodetoolResult("disableautocompaction", "netstats_test").asserts().success();
populateData(compressionEnabled);
cluster.get(1).flush("netstats_test");
// then bootstrap the second one, upon joining,
// we should see that netstats shows how SSTables are being streamed on the first node
final IInstanceConfig config = cluster.newInstanceConfig();
config.set("auto_bootstrap", true);
IInvokableInstance secondNode = cluster.bootstrap(config);
final Future<?> startupRunnable = executorService.submit((Runnable) secondNode::startup);
final Future<AbstractNetstatsStreaming.NetstatResults> netstatsFuture = executorService.submit(new NetstatsCallable(cluster.get(1)));
startupRunnable.get(3, MINUTES);
// 1m is a bit much, but should be fine on slower environments. Node2 can't come up without streaming
// completing, so if node2 is up 1m is enough time for the nodetool watcher to yield
final AbstractNetstatsStreaming.NetstatResults results = netstatsFuture.get(1, MINUTES);
results.assertSuccessful();
AbstractNetstatsStreaming.NetstatsOutputParser.validate(AbstractNetstatsStreaming.NetstatsOutputParser.parse(results));
}
}
use of org.apache.cassandra.distributed.api.IInstanceConfig in project cassandra by apache.
the class MigrationCoordinatorTest method explicitEndpointIgnore.
@Test
public void explicitEndpointIgnore() throws Throwable {
try (Cluster cluster = Cluster.build(2).withTokenSupplier(TokenSupplier.evenlyDistributedTokens(3)).withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(3, "dc0", "rack0")).withConfig(config -> config.with(NETWORK, GOSSIP)).start()) {
cluster.schemaChange("CREATE KEYSPACE ks with replication={'class':'SimpleStrategy', 'replication_factor':2}");
InetAddress ignoredEndpoint = cluster.get(2).broadcastAddress().getAddress();
cluster.get(2).shutdown(false);
cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE ks.tbl (k int primary key, v int)");
IInstanceConfig config = cluster.newInstanceConfig();
config.set("auto_bootstrap", true);
System.setProperty(MigrationCoordinator.IGNORED_ENDPOINTS_PROP, ignoredEndpoint.getHostAddress());
System.setProperty("cassandra.consistent.rangemovement", "false");
cluster.bootstrap(config).startup();
}
}
use of org.apache.cassandra.distributed.api.IInstanceConfig in project cassandra by apache.
the class MigrationCoordinatorTest method replaceNode.
/**
* We shouldn't wait on versions only available from a node being replaced
* see CASSANDRA-
*/
@Test
public void replaceNode() throws Throwable {
try (Cluster cluster = Cluster.build(2).withTokenSupplier(TokenSupplier.evenlyDistributedTokens(3)).withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(3, "dc0", "rack0")).withConfig(config -> config.with(NETWORK, GOSSIP)).start()) {
cluster.schemaChange("CREATE KEYSPACE ks with replication={'class':'SimpleStrategy', 'replication_factor':2}");
InetAddress replacementAddress = cluster.get(2).broadcastAddress().getAddress();
cluster.get(2).shutdown(false);
cluster.schemaChangeIgnoringStoppedInstances("CREATE TABLE ks.tbl (k int primary key, v int)");
IInstanceConfig config = cluster.newInstanceConfig();
config.set("auto_bootstrap", true);
System.setProperty("cassandra.replace_address", replacementAddress.getHostAddress());
cluster.bootstrap(config).startup();
}
}
use of org.apache.cassandra.distributed.api.IInstanceConfig in project cassandra by apache.
the class BootstrapTest method readWriteDuringBootstrapTest.
@Test
public void readWriteDuringBootstrapTest() throws Throwable {
int originalNodeCount = 2;
int expandedNodeCount = originalNodeCount + 1;
try (Cluster cluster = builder().withNodes(originalNodeCount).withTokenSupplier(TokenSupplier.evenlyDistributedTokens(expandedNodeCount)).withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(expandedNodeCount, "dc0", "rack0")).withConfig(config -> config.with(NETWORK, GOSSIP)).start()) {
IInstanceConfig config = cluster.newInstanceConfig();
IInvokableInstance newInstance = cluster.bootstrap(config);
withProperty("cassandra.join_ring", false, () -> newInstance.startup(cluster));
cluster.forEach(statusToBootstrap(newInstance));
populate(cluster, 0, 100);
Assert.assertEquals(100, newInstance.executeInternal("SELECT *FROM " + KEYSPACE + ".tbl").length);
}
}
Aggregations