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);
}
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);
}
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");
}
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"));
}
}
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;
}
Aggregations