Search in sources :

Example 6 with IInstanceConfig

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);
}
Also used : IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) File(org.apache.cassandra.io.util.File)

Example 7 with IInstanceConfig

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));
    }
}
Also used : IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) Cluster(org.apache.cassandra.distributed.Cluster)

Example 8 with IInstanceConfig

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();
    }
}
Also used : InetAddress(java.net.InetAddress) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) Test(org.junit.Test) Cluster(org.apache.cassandra.distributed.Cluster) UUID(java.util.UUID) MigrationCoordinator(org.apache.cassandra.schema.MigrationCoordinator) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology) NETWORK(org.apache.cassandra.distributed.api.Feature.NETWORK) Before(org.junit.Before) Schema(org.apache.cassandra.schema.Schema) GOSSIP(org.apache.cassandra.distributed.api.Feature.GOSSIP) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) Cluster(org.apache.cassandra.distributed.Cluster) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 9 with IInstanceConfig

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();
    }
}
Also used : InetAddress(java.net.InetAddress) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) Test(org.junit.Test) Cluster(org.apache.cassandra.distributed.Cluster) UUID(java.util.UUID) MigrationCoordinator(org.apache.cassandra.schema.MigrationCoordinator) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology) NETWORK(org.apache.cassandra.distributed.api.Feature.NETWORK) Before(org.junit.Before) Schema(org.apache.cassandra.schema.Schema) GOSSIP(org.apache.cassandra.distributed.api.Feature.GOSSIP) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) Cluster(org.apache.cassandra.distributed.Cluster) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 10 with IInstanceConfig

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);
    }
}
Also used : IntStream(java.util.stream.IntStream) ICluster(org.apache.cassandra.distributed.api.ICluster) Test(org.junit.Test) ConsistencyLevel(org.apache.cassandra.distributed.api.ConsistencyLevel) Collectors(java.util.stream.Collectors) GossipHelper.bootstrap(org.apache.cassandra.distributed.action.GossipHelper.bootstrap) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) GossipHelper.pullSchemaFrom(org.apache.cassandra.distributed.action.GossipHelper.pullSchemaFrom) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) TestBaseImpl(org.apache.cassandra.distributed.test.TestBaseImpl) Cluster(org.apache.cassandra.distributed.Cluster) GossipHelper.withProperty(org.apache.cassandra.distributed.action.GossipHelper.withProperty) Assert(org.junit.Assert) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) GossipHelper.statusToBootstrap(org.apache.cassandra.distributed.action.GossipHelper.statusToBootstrap) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology) NETWORK(org.apache.cassandra.distributed.api.Feature.NETWORK) GOSSIP(org.apache.cassandra.distributed.api.Feature.GOSSIP) IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) ICluster(org.apache.cassandra.distributed.api.ICluster) Cluster(org.apache.cassandra.distributed.Cluster) Test(org.junit.Test)

Aggregations

IInstanceConfig (org.apache.cassandra.distributed.api.IInstanceConfig)18 Cluster (org.apache.cassandra.distributed.Cluster)8 TokenSupplier (org.apache.cassandra.distributed.api.TokenSupplier)7 NetworkTopology (org.apache.cassandra.distributed.shared.NetworkTopology)7 Test (org.junit.Test)7 GOSSIP (org.apache.cassandra.distributed.api.Feature.GOSSIP)6 NETWORK (org.apache.cassandra.distributed.api.Feature.NETWORK)6 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)6 Map (java.util.Map)5 File (org.apache.cassandra.io.util.File)4 Assert (org.junit.Assert)4 InetAddress (java.net.InetAddress)3 InetSocketAddress (java.net.InetSocketAddress)3 UUID (java.util.UUID)3 GossipHelper.bootstrap (org.apache.cassandra.distributed.action.GossipHelper.bootstrap)3 GossipHelper.statusToBootstrap (org.apache.cassandra.distributed.action.GossipHelper.statusToBootstrap)3 GossipHelper.withProperty (org.apache.cassandra.distributed.action.GossipHelper.withProperty)3 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)3 TestBaseImpl (org.apache.cassandra.distributed.test.TestBaseImpl)3 Arrays.asList (java.util.Arrays.asList)2