use of com.hubspot.mesos.json.MesosMasterStateObject in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testLoadSlavesFromMasterDataOnStartup.
@Test
public void testLoadSlavesFromMasterDataOnStartup() {
MesosMasterStateObject state = getMasterState(3);
singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(state, true);
List<SingularitySlave> slaves = slaveManager.getObjects();
Assert.assertEquals(3, slaves.size());
for (SingularitySlave slave : slaves) {
Assert.assertEquals(MachineState.ACTIVE, slave.getCurrentState().getState());
}
}
use of com.hubspot.mesos.json.MesosMasterStateObject in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testReconcileSlaves.
@Test
public void testReconcileSlaves() {
// Load 3 slaves on startup
MesosMasterStateObject state = getMasterState(3);
singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(state, true);
// 2 slaves, third has died
MesosMasterStateObject newState = getMasterState(2);
singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(newState, false);
List<SingularitySlave> slaves = slaveManager.getObjects();
Assert.assertEquals(3, slaves.size());
for (SingularitySlave slave : slaves) {
if (slave.getId().equals("2")) {
Assert.assertEquals(MachineState.DEAD, slave.getCurrentState().getState());
} else {
Assert.assertEquals(MachineState.ACTIVE, slave.getCurrentState().getState());
}
}
}
use of com.hubspot.mesos.json.MesosMasterStateObject in project Singularity by HubSpot.
the class SingularityAgentReconciliationPoller method refereshAgentsAndRacks.
private void refereshAgentsAndRacks() {
try {
Optional<MasterInfo> maybeMasterInfo = mesosScheduler.getMaster();
if (maybeMasterInfo.isPresent()) {
final String uri = mesosClient.getMasterUri(MesosUtils.getMasterHostAndPort(maybeMasterInfo.get()));
MesosMasterStateObject state = mesosClient.getMasterState(uri);
agentAndRackManager.loadAgentsAndRacksFromMaster(state, false);
}
} catch (Exception e) {
LOG.error("Could not refresh agent data", e);
}
}
use of com.hubspot.mesos.json.MesosMasterStateObject in project Singularity by HubSpot.
the class SingularityStartup method startup.
public void startup(MasterInfo masterInfo) {
final long start = System.currentTimeMillis();
final String uri = mesosClient.getMasterUri(MesosUtils.getMasterHostAndPort(masterInfo));
LOG.info("Starting up... fetching state data from: " + uri);
MesosMasterStateObject state = mesosClient.getMasterState(uri);
agentAndRackManager.checkDecommissionedAgentsFromMaster(state, true);
agentAndRackManager.loadAgentsAndRacksFromMaster(state, true);
ExecutorService startupExecutor = Executors.newFixedThreadPool(configuration.getSchedulerStartupConcurrency(), new ThreadFactoryBuilder().setNameFormat("startup-%d").build());
List<CompletableFuture<Void>> checkFutures = checkSchedulerForInconsistentState(startupExecutor);
CompletableFutures.allOf(enqueueHealthAndNewTaskChecks(startupExecutor)).join();
CompletableFutures.allOf(checkFutures).join();
startupExecutor.shutdown();
if (!disasterManager.isDisabled(SingularityAction.STARTUP_TASK_RECONCILIATION)) {
taskReconciliation.startReconciliation();
}
LOG.info("Finished startup after {}", JavaUtils.duration(start));
}
use of com.hubspot.mesos.json.MesosMasterStateObject in project Singularity by HubSpot.
the class SingularityMachinesTest method testExpiringMachineState.
@Test
public void testExpiringMachineState() {
MesosMasterStateObject state = getMasterState(1);
singularityAgentAndRackManager.loadAgentsAndRacksFromMaster(state, true);
SingularityAgent agent = agentManager.getObjects().get(0);
agentResource.freezeAgent(singularityUser, agent.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.empty(), Optional.empty(), Optional.of(MachineState.ACTIVE), Optional.empty()));
Assertions.assertEquals(MachineState.FROZEN, agentManager.getObjects().get(0).getCurrentState().getState());
try {
Thread.sleep(10);
} catch (Exception e) {
// didn't see that
}
expiringUserActionPoller.runActionOnPoll();
Assertions.assertEquals(MachineState.ACTIVE, agentManager.getObjects().get(0).getCurrentState().getState());
}
Aggregations