Search in sources :

Example 6 with StateStore

use of com.mesosphere.sdk.state.StateStore in project dcos-commons by mesosphere.

the class DefaultStepFactoryTest method getPodInstanceWithASingleTask.

private PodInstance getPodInstanceWithASingleTask() throws Exception {
    TaskSpec taskSpec0 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 0, TestConstants.RESOURCE_SET_ID);
    PodSpec podSpec = DefaultPodSpec.newBuilder(SCHEDULER_CONFIG.getExecutorURI()).type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec0)).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 7 with StateStore

use of com.mesosphere.sdk.state.StateStore in project dcos-commons by mesosphere.

the class DefaultRecoveryPlanManagerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    failureMonitor = spy(new TestingFailureMonitor());
    launchConstrainer = spy(new TestingLaunchConstrainer());
    offerAccepter = mock(OfferAccepter.class);
    Persister persister = new MemPersister();
    frameworkStore = new FrameworkStore(persister);
    stateStore = new StateStore(persister);
    File recoverySpecFile = new File(getClass().getClassLoader().getResource("recovery-plan-manager-test.yml").getPath());
    serviceSpec = DefaultServiceSpec.newGenerator(recoverySpecFile, SCHEDULER_CONFIG).build();
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    UUID configTarget = configStore.store(serviceSpec);
    configStore.setTargetConfig(configTarget);
    taskInfo = TaskInfo.newBuilder(taskInfo).setLabels(new TaskLabelWriter(taskInfo).setTargetConfiguration(configTarget).setIndex(0).toProto()).setName("test-task-type-0-test-task-name").setTaskId(CommonIdUtils.toTaskId(TestConstants.SERVICE_NAME, "test-task-type-0-test-task-name")).build();
    taskInfos = Collections.singletonList(taskInfo);
    recoveryManager = spy(new DefaultRecoveryPlanManager(stateStore, configStore, new HashSet<>(Arrays.asList(taskInfo.getName())), launchConstrainer, failureMonitor));
    mockDeployManager = mock(PlanManager.class);
    final Plan mockDeployPlan = mock(Plan.class);
    when(mockDeployManager.getPlan()).thenReturn(mockDeployPlan);
    planScheduler = new DefaultPlanScheduler(offerAccepter, new OfferEvaluator(frameworkStore, stateStore, new OfferOutcomeTracker(), serviceSpec.getName(), configTarget, ArtifactResource.getUrlFactory(TestConstants.SERVICE_NAME), SchedulerConfigTestUtils.getTestSchedulerConfig(), Optional.empty(), true), stateStore);
    planCoordinator = new DefaultPlanCoordinator(Arrays.asList(mockDeployManager, recoveryManager));
}
Also used : TestingLaunchConstrainer(com.mesosphere.sdk.scheduler.recovery.constrain.TestingLaunchConstrainer) OfferAccepter(com.mesosphere.sdk.offer.OfferAccepter) MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) OfferEvaluator(com.mesosphere.sdk.offer.evaluate.OfferEvaluator) OfferOutcomeTracker(com.mesosphere.sdk.offer.history.OfferOutcomeTracker) TaskLabelWriter(com.mesosphere.sdk.offer.taskdata.TaskLabelWriter) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) TestingFailureMonitor(com.mesosphere.sdk.scheduler.recovery.monitor.TestingFailureMonitor) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) File(java.io.File) Before(org.junit.Before)

Example 8 with StateStore

use of com.mesosphere.sdk.state.StateStore in project dcos-commons by mesosphere.

the class UninstallRecorderTest method testHandlingOfUnexpectedOfferRecommendation.

@Test
public void testHandlingOfUnexpectedOfferRecommendation() throws Exception {
    Protos.Resource resource = ResourceTestUtils.getUnreservedCpus(1.0);
    OfferRecommendation unsupportedOfferRecommendation = new CreateOfferRecommendation(null, resource);
    StateStore mockStateStore = mock(StateStore.class);
    OperationRecorder operationRecorder = new UninstallRecorder(mockStateStore, null);
    // should just return without error
    operationRecorder.record(unsupportedOfferRecommendation);
}
Also used : Protos(org.apache.mesos.Protos) StateStore(com.mesosphere.sdk.state.StateStore) OperationRecorder(com.mesosphere.sdk.offer.OperationRecorder) CreateOfferRecommendation(com.mesosphere.sdk.offer.CreateOfferRecommendation) OfferRecommendation(com.mesosphere.sdk.offer.OfferRecommendation) CreateOfferRecommendation(com.mesosphere.sdk.offer.CreateOfferRecommendation) Test(org.junit.Test)

Example 9 with StateStore

use of com.mesosphere.sdk.state.StateStore in project dcos-commons by mesosphere.

the class UninstallSchedulerTest method testAllButDeregisteredPlanCompletes.

@Test
public void testAllButDeregisteredPlanCompletes() throws Exception {
    // New empty state store: No framework ID is set yet, and there are no tasks, and no SchedulerDriver
    Persister persister = new MemPersister();
    UninstallScheduler uninstallScheduler = new UninstallScheduler(getServiceSpec(), new FrameworkStore(persister), new StateStore(persister), mockConfigStore, FrameworkConfig.fromServiceSpec(getServiceSpec()), SchedulerConfigTestUtils.getTestSchedulerConfig(), Optional.empty(), Optional.of(mockSecretsClient));
    // Returns a simple placeholder plan with status COMPLETE
    PlanCoordinator planCoordinator = uninstallScheduler.getPlanCoordinator();
    Plan plan = planCoordinator.getPlanManagers().stream().findFirst().get().getPlan();
    Assert.assertTrue(plan.toString(), plan.isComplete());
    Assert.assertTrue(plan.getChildren().isEmpty());
    // Doesn't want to register with Mesos:
    Assert.assertFalse(uninstallScheduler.getMesosScheduler().isPresent());
}
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) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) Test(org.junit.Test)

Example 10 with StateStore

use of com.mesosphere.sdk.state.StateStore in project dcos-commons by mesosphere.

the class DefaultStepFactoryTest method getPodInstanceWithSameResourceSets.

private PodInstance getPodInstanceWithSameResourceSets() throws Exception {
    TaskSpec taskSpec0 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 0, TestConstants.RESOURCE_SET_ID);
    TaskSpec taskSpec1 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 1, TestConstants.RESOURCE_SET_ID);
    PodSpec podSpec = DefaultPodSpec.newBuilder(SCHEDULER_CONFIG.getExecutorURI()).type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec0, taskSpec1)).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)

Aggregations

StateStore (com.mesosphere.sdk.state.StateStore)18 MemPersister (com.mesosphere.sdk.storage.MemPersister)12 Persister (com.mesosphere.sdk.storage.Persister)10 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)6 Before (org.junit.Before)6 UUID (java.util.UUID)5 Protos (org.apache.mesos.Protos)5 OfferOutcomeTracker (com.mesosphere.sdk.offer.history.OfferOutcomeTracker)3 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)3 Test (org.junit.Test)3 OfferAccepter (com.mesosphere.sdk.offer.OfferAccepter)2 OfferEvaluator (com.mesosphere.sdk.offer.evaluate.OfferEvaluator)2 RecoveryPlanOverrider (com.mesosphere.sdk.scheduler.recovery.RecoveryPlanOverrider)2 RecoveryStep (com.mesosphere.sdk.scheduler.recovery.RecoveryStep)2 UnconstrainedLaunchConstrainer (com.mesosphere.sdk.scheduler.recovery.constrain.UnconstrainedLaunchConstrainer)2 ConfigStore (com.mesosphere.sdk.state.ConfigStore)2 File (java.io.File)2 SchedulerDriver (org.apache.mesos.SchedulerDriver)2 CreateOfferRecommendation (com.mesosphere.sdk.offer.CreateOfferRecommendation)1 OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)1