Search in sources :

Example 1 with MasterInfo

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);
    }
}
Also used : MasterInfo(org.apache.mesos.v1.Protos.MasterInfo) MesosMasterStateObject(com.hubspot.mesos.json.MesosMasterStateObject)

Example 2 with MasterInfo

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);
}
Also used : MasterInfo(org.apache.mesos.v1.Protos.MasterInfo) Offer(org.apache.mesos.v1.Protos.Offer) RuntimeMXBean(java.lang.management.RuntimeMXBean)

Example 3 with MasterInfo

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);
}
Also used : MasterInfo(org.apache.mesos.v1.Protos.MasterInfo)

Aggregations

MasterInfo (org.apache.mesos.v1.Protos.MasterInfo)3 MesosMasterStateObject (com.hubspot.mesos.json.MesosMasterStateObject)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 Offer (org.apache.mesos.v1.Protos.Offer)1