
com.hubspot.singularity.mesos.SingularityMesosModule Maven / Gradle / Ivy
package com.hubspot.singularity.mesos;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.mesos.Protos.TaskStatus.Reason;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
public class SingularityMesosModule extends AbstractModule {
public static final String SCHEDULER_LOCK_NAME = "scheduler-lock";
public static final String TASK_LOST_REASONS_COUNTER = "task-lost-reasons";
public static final String ACTIVE_SLAVES_LOST_COUNTER = "active-slaves-lost";
@Override
public void configure() {
bind(SingularityDriver.class).in(Scopes.SINGLETON);
bind(SingularityMesosExecutorInfoSupport.class).in(Scopes.SINGLETON);
bind(SingularityMesosScheduler.class).in(Scopes.SINGLETON);
bind(SingularityMesosFrameworkMessageHandler.class).in(Scopes.SINGLETON);
bind(SingularityMesosSchedulerDelegator.class).in(Scopes.SINGLETON);
bind(SingularityMesosTaskBuilder.class).in(Scopes.SINGLETON);
bind(SingularityTaskSizeOptimizer.class).in(Scopes.SINGLETON);
bind(SingularitySlaveAndRackManager.class).in(Scopes.SINGLETON);
bind(SingularitySlaveAndRackHelper.class).in(Scopes.SINGLETON);
bind(SingularityStartup.class).in(Scopes.SINGLETON);
bind(SchedulerDriverSupplier.class).in(Scopes.SINGLETON);
}
@Provides
@Named(SCHEDULER_LOCK_NAME)
@Singleton
public Lock getSchedulerLock() {
return new ReentrantLock();
}
@Provides
@Named(TASK_LOST_REASONS_COUNTER)
@Singleton
public Multiset provideTaskLostReasonsCounter() {
return HashMultiset.create(Reason.getDescriptor().getValues().size());
}
@Provides
@Named(ACTIVE_SLAVES_LOST_COUNTER)
@Singleton
public AtomicInteger provideActiveSlavesLostCounter() {
return new AtomicInteger();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy