use of org.apache.mesos.v1.Protos.MasterInfo in project Singularity by HubSpot.
the class SingularitySlaveReconciliationPoller method refereshSlavesAndRacks.
private void refereshSlavesAndRacks() {
try {
Optional<MasterInfo> maybeMasterInfo = mesosScheduler.getMaster();
if (maybeMasterInfo.isPresent()) {
final String uri = mesosClient.getMasterUri(MesosUtils.getMasterHostAndPort(maybeMasterInfo.get()));
MesosMasterStateObject state = mesosClient.getMasterState(uri);
slaveAndRackManager.loadSlavesAndRacksFromMaster(state, false);
}
} catch (Exception e) {
LOG.error("Could not refresh slave data", e);
}
}
use of org.apache.mesos.v1.Protos.MasterInfo in project Singularity by HubSpot.
the class SingularityLeaderController method getHostState.
private SingularityHostState getHostState() {
final boolean master = isMaster();
final RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
final long uptime = mxBean.getUptime();
final long now = System.currentTimeMillis();
final Optional<Long> lastOfferTimestamp = getLastOfferTimestamp();
final Optional<Long> millisSinceLastOfferTimestamp = lastOfferTimestamp.isPresent() ? Optional.of(now - lastOfferTimestamp.get()) : Optional.<Long>absent();
String mesosMaster = null;
Optional<MasterInfo> mesosMasterInfo = getMaster();
if (mesosMasterInfo.isPresent()) {
mesosMaster = MesosUtils.getMasterHostAndPort(mesosMasterInfo.get());
}
double cachedCpus = 0;
double cachedMemoryBytes = 0;
int numCachedOffers = 0;
for (Offer offer : offerCache.peekOffers()) {
cachedCpus += MesosUtils.getNumCpus(offer);
cachedMemoryBytes += MesosUtils.getMemory(offer);
numCachedOffers++;
}
return new SingularityHostState(master, uptime, scheduler.getState().name(), millisSinceLastOfferTimestamp, hostAndPort.getHostText(), hostAndPort.getHostText(), mesosMaster, scheduler.isRunning(), numCachedOffers, cachedCpus, cachedMemoryBytes);
}
use of org.apache.mesos.v1.Protos.MasterInfo in project Singularity by HubSpot.
the class SingularityMesosSchedulerImpl method subscribed.
@Override
public void subscribed(Subscribed subscribed) {
callWithStateLock(() -> {
Preconditions.checkState(state == SchedulerState.NOT_STARTED, "Asked to startup - but in invalid state: %s", state.name());
leaderCacheCoordinator.activateLeaderCache();
MasterInfo newMasterInfo = subscribed.getMasterInfo();
masterInfo.set(newMasterInfo);
startup.startup(newMasterInfo);
state = SchedulerState.SUBSCRIBED;
queuedUpdates.forEach(this::handleStatusUpdateAsync);
}, "subscribed", false);
}
Aggregations