Search in sources :

Example 16 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class DefaultStepFactoryTest method getPodInstanceWithGoalState.

private PodInstance getPodInstanceWithGoalState(GoalState goalState) throws Exception {
    TaskSpec taskSpec = TestPodFactory.getTaskSpecWithGoalState(TestConstants.TASK_NAME, TestConstants.RESOURCE_SET_ID, goalState);
    PodSpec podSpec = DefaultPodSpec.newBuilder(SCHEDULER_CONFIG.getExecutorURI()).type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec)).build();
    ServiceSpec serviceSpec = DefaultServiceSpec.newBuilder().name(TestConstants.SERVICE_NAME).role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).zookeeperConnection("foo.bar.com").pods(Arrays.asList(podSpec)).build();
    Persister persister = new MemPersister();
    stateStore = new StateStore(persister);
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    UUID configId = configStore.store(serviceSpec);
    configStore.setTargetConfig(configId);
    stepFactory = new DefaultStepFactory(configStore, stateStore);
    return new DefaultPodInstance(podSpec, 0);
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) UUID(java.util.UUID)

Example 17 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class StateStoreTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    persister = new MemPersister();
    store = new StateStore(persister);
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister)

Example 18 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class ConfigStoreTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    persister = new MemPersister();
    store = new ConfigStore<StringConfiguration>(new StringConfiguration.Factory(), persister);
    testConfig = new StringConfiguration("test-config");
}
Also used : StringConfiguration(com.mesosphere.sdk.config.StringConfiguration) MemPersister(com.mesosphere.sdk.storage.MemPersister) Before(org.junit.Before)

Example 19 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class CuratorUtilsTest method testServiceNameCollision.

@Test
public void testServiceNameCollision() {
    Persister persister = new MemPersister();
    CuratorUtils.initServiceName(persister, "/path/to/myservice");
    try {
        CuratorUtils.initServiceName(persister, "/path/to__myservice");
        fail("expected exception");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Collision"));
    }
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) Test(org.junit.Test)

Example 20 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class TaskUtilsTest method buildPodLayout.

private static ConfigStore<ServiceSpec> buildPodLayout(int essentialTasks, int nonessentialTasks) {
    DefaultPodSpec.Builder podBuilder = DefaultPodSpec.newBuilder("executor-uri").type("server").count(3);
    for (int i = 0; i < essentialTasks; ++i) {
        podBuilder.addTask(buildTaskTemplate(String.format("essential%d", i)).goalState(GoalState.RUNNING).build());
    }
    for (int i = 0; i < nonessentialTasks; ++i) {
        podBuilder.addTask(buildTaskTemplate(String.format("nonessential%d", i)).goalState(GoalState.RUNNING).essential(false).build());
    }
    // should be ignored for recovery purposes:
    podBuilder.addTask(buildTaskTemplate("once").goalState(GoalState.ONCE).build());
    ServiceSpec serviceSpec = DefaultServiceSpec.newBuilder().name("svc").addPod(podBuilder.build()).build();
    ConfigStore<ServiceSpec> configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), new MemPersister());
    try {
        configStore.setTargetConfig(configStore.store(serviceSpec));
    } catch (ConfigStoreException e) {
        throw new IllegalStateException(e);
    }
    return configStore;
}
Also used : ConfigStore(com.mesosphere.sdk.state.ConfigStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) ConfigStoreException(com.mesosphere.sdk.state.ConfigStoreException)

Aggregations

MemPersister (com.mesosphere.sdk.storage.MemPersister)31 Persister (com.mesosphere.sdk.storage.Persister)14 Test (org.junit.Test)13 StateStore (com.mesosphere.sdk.state.StateStore)12 Before (org.junit.Before)9 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)7 ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)7 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)5 UUID (java.util.UUID)5 File (java.io.File)4 OfferOutcomeTracker (com.mesosphere.sdk.offer.history.OfferOutcomeTracker)3 Plan (com.mesosphere.sdk.scheduler.plan.Plan)3 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)3 OfferAccepter (com.mesosphere.sdk.offer.OfferAccepter)2 OfferEvaluator (com.mesosphere.sdk.offer.evaluate.OfferEvaluator)2 DefaultPlan (com.mesosphere.sdk.scheduler.plan.DefaultPlan)2 ConfigStore (com.mesosphere.sdk.state.ConfigStore)2 StringConfiguration (com.mesosphere.sdk.config.StringConfiguration)1 Capabilities (com.mesosphere.sdk.dcos.Capabilities)1 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)1