Search in sources :

Example 6 with InMemoryState

use of org.apache.mesos.state.InMemoryState in project cassandra-mesos-deprecated by mesosphere.

the class PersistedCassandraFrameworkConfigurationTest method testGetDefaultRackDc.

@Test
public void testGetDefaultRackDc() {
    InMemoryState state = new InMemoryState();
    PersistedCassandraFrameworkConfiguration config = new PersistedCassandraFrameworkConfiguration(state, "name", 60, 30, "2.1", 0.5, 1024, 1024, 512, 1, 1, "role", "./backup", ".", false, true, "RACK5", "DC5", Lists.<ExternalDc>newArrayList(), "clusterName");
    CassandraFrameworkProtos.RackDc rackDc = config.getDefaultRackDc();
    assertEquals("RACK5", rackDc.getRack());
    assertEquals("DC5", rackDc.getDc());
    // backward compatibility: if rackDc is not defined - use defaults
    CassandraFrameworkConfiguration.Builder builder = CassandraFrameworkConfiguration.newBuilder(config.get());
    builder.setDefaultConfigRole(CassandraConfigRole.newBuilder(builder.getDefaultConfigRole()).clearRackDc());
    config.setValue(builder.build());
    rackDc = config.getDefaultRackDc();
    assertEquals("RAC1", rackDc.getRack());
    assertEquals("DC1", rackDc.getDc());
}
Also used : CassandraFrameworkProtos(io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos) CassandraFrameworkConfiguration(io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraFrameworkConfiguration) InMemoryState(org.apache.mesos.state.InMemoryState) Test(org.junit.Test)

Example 7 with InMemoryState

use of org.apache.mesos.state.InMemoryState in project cassandra-mesos-deprecated by mesosphere.

the class SeedManagerTest method before.

@Before
public void before() {
    InMemoryState state = new InMemoryState();
    PersistedCassandraFrameworkConfiguration config = new PersistedCassandraFrameworkConfiguration(state, "name", 60, 30, "2.1", 0.5, 1024, 1024, 512, 1, 1, "role", "./backup", ".", false, true, "RACK1", "DC1", Arrays.asList(ExternalDc.newBuilder().setName("dc").setUrl("http://dc").build()), "name");
    seedManager = new SeedManager(config, new ObjectMapper(), new SystemClock()) {

        @Override
        @Nullable
        protected JsonNode fetchJson(@NotNull final String url) {
            try {
                return new ObjectMapper().readTree(jsonResponse);
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    };
}
Also used : SystemClock(io.mesosphere.mesos.util.SystemClock) InMemoryState(org.apache.mesos.state.InMemoryState) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Nullable(org.jetbrains.annotations.Nullable) Before(org.junit.Before)

Example 8 with InMemoryState

use of org.apache.mesos.state.InMemoryState in project cassandra-mesos-deprecated by mesosphere.

the class PersistedCassandraFrameworkConfigurationTest method generatingNewConfigAllowsFrameworkNameAndClusterNameToBeDifferent.

@Test
public void generatingNewConfigAllowsFrameworkNameAndClusterNameToBeDifferent() throws Exception {
    final State state = new InMemoryState();
    final PersistedCassandraFrameworkConfiguration configuration = new PersistedCassandraFrameworkConfiguration(state, "cassandra.frameworkName", 15, 15, "2.1.4", 1.0, 2048, 2048, 1024, 1, 1, "*", "./backup", ".", true, true, "rack1", "dc1", Collections.<ExternalDc>emptyList(), "clusterName");
    assertThat(configuration.frameworkName()).isEqualTo("cassandra.frameworkName");
    assertThat(configuration.clusterName()).isEqualTo("clusterName");
}
Also used : InMemoryState(org.apache.mesos.state.InMemoryState) State(org.apache.mesos.state.State) InMemoryState(org.apache.mesos.state.InMemoryState) Test(org.junit.Test)

Aggregations

InMemoryState (org.apache.mesos.state.InMemoryState)8 Test (org.junit.Test)5 CassandraFrameworkProtos (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos)4 State (org.apache.mesos.state.State)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 SystemClock (io.mesosphere.mesos.util.SystemClock)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Predicate (com.google.common.base.Predicate)1 CassandraFrameworkConfiguration (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraFrameworkConfiguration)1 CassandraNode (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraNode)1 CassandraNodeExecutor (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraNodeExecutor)1 FileDownload (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.FileDownload)1 Clock (io.mesosphere.mesos.util.Clock)1 IOException (java.io.IOException)1 NotNull (javax.validation.constraints.NotNull)1 Variable (org.apache.mesos.state.Variable)1 Nullable (org.jetbrains.annotations.Nullable)1 Before (org.junit.Before)1