use of com.netflix.fenzo.AutoScaleAction in project mantis by Netflix.
the class SchedulingService method setupTaskSchedulerAndAutoScaler.
private TaskScheduler setupTaskSchedulerAndAutoScaler(Observable<String> vmLeaseRescindedObservable, TaskScheduler.Builder schedulerBuilder) {
int minMinIdle = 4;
schedulerBuilder = schedulerBuilder.withAutoScaleDownBalancedByAttributeName(ConfigurationProvider.getConfig().getHostZoneAttributeName()).withAutoScalerMapHostnameAttributeName(ConfigurationProvider.getConfig().getAutoScalerMapHostnameAttributeName());
final AgentClustersAutoScaler agentClustersAutoScaler = AgentClustersAutoScaler.get();
try {
if (agentClustersAutoScaler != null) {
Set<AutoScaleRule> rules = agentClustersAutoScaler.getRules();
if (rules != null && !rules.isEmpty()) {
for (AutoScaleRule rule : rules) {
schedulerBuilder = schedulerBuilder.withAutoScaleRule(rule);
minMinIdle = Math.min(minMinIdle, rule.getMinIdleHostsToKeep());
}
} else
logger.warn("No auto scale rules setup");
}
} catch (IllegalStateException e) {
logger.warn("Ignoring: " + e.getMessage());
}
schedulerBuilder = schedulerBuilder.withMaxOffersToReject(Math.max(1, minMinIdle));
final TaskScheduler scheduler = schedulerBuilder.build();
vmLeaseRescindedObservable.doOnNext(new Action1<String>() {
@Override
public void call(String s) {
if (s.equals("ALL"))
scheduler.expireAllLeases();
else
scheduler.expireLease(s);
}
}).subscribe();
if (agentClustersAutoScaler != null) {
final Observer<AutoScaleAction> autoScaleActionObserver = agentClustersAutoScaler.getAutoScaleActionObserver();
scheduler.setAutoscalerCallback(new com.netflix.fenzo.functions.Action1<AutoScaleAction>() {
@Override
public void call(AutoScaleAction action) {
try {
switch(action.getType()) {
case Up:
numAutoScaleUpActions.increment();
break;
case Down:
numAutoScaleDownActions.increment();
break;
}
autoScaleActionObserver.onNext(action);
} catch (Exception e) {
logger.warn("Will continue after exception calling autoscale action observer: " + e.getMessage(), e);
}
}
});
}
return scheduler;
}
use of com.netflix.fenzo.AutoScaleAction in project mantis by Netflix.
the class MantisMasterAPI method setupDummyAgentClusterAutoScaler.
private static void setupDummyAgentClusterAutoScaler() {
final AutoScaleRule dummyAutoScaleRule = new AutoScaleRule() {
@Override
public String getRuleName() {
return "test";
}
@Override
public int getMinIdleHostsToKeep() {
return 1;
}
@Override
public int getMaxIdleHostsToKeep() {
return 10;
}
@Override
public long getCoolDownSecs() {
return 300;
}
@Override
public boolean idleMachineTooSmall(VirtualMachineLease lease) {
return false;
}
};
AgentClustersAutoScaler.initialize(() -> new HashSet<>(Collections.singletonList(dummyAutoScaleRule)), new Observer<AutoScaleAction>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(AutoScaleAction autoScaleAction) {
}
});
}
use of com.netflix.fenzo.AutoScaleAction in project mantis by Netflix.
the class MasterMain method setupDummyAgentClusterAutoScaler.
private static void setupDummyAgentClusterAutoScaler() {
final AutoScaleRule dummyAutoScaleRule = new AutoScaleRule() {
@Override
public String getRuleName() {
return "test";
}
@Override
public int getMinIdleHostsToKeep() {
return 1;
}
@Override
public int getMaxIdleHostsToKeep() {
return 10;
}
@Override
public long getCoolDownSecs() {
return 300;
}
@Override
public boolean idleMachineTooSmall(VirtualMachineLease lease) {
return false;
}
};
AgentClustersAutoScaler.initialize(() -> new HashSet<>(Collections.singletonList(dummyAutoScaleRule)), new Observer<AutoScaleAction>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(AutoScaleAction autoScaleAction) {
}
});
}
Aggregations