use of io.fabric8.api.AutoScaleStatus in project fabric8 by jboss-fuse.
the class AutoScaleStatusListAction method doExecute.
@Override
protected Object doExecute() throws Exception {
PrintStream out = System.out;
AutoScaleStatus status = getFabricService().getAutoScaleStatus();
printStatus(out, status);
return null;
}
use of io.fabric8.api.AutoScaleStatus in project fabric8 by jboss-fuse.
the class AutoScaleStatusListAction method printStatus.
protected void printStatus(PrintStream out, AutoScaleStatus status) {
TablePrinter table = new TablePrinter();
table.columns("auto scale profile", "status", "message");
List<AutoScaleProfileStatus> profileStatuses = status.getProfileStatuses();
for (AutoScaleProfileStatus profile : profileStatuses) {
table.row(getStringOrBlank(profile.getProfile()), getStringOrBlank(profile.getStatus()), getStringOrBlank(profile.getMessage()));
}
table.print();
}
use of io.fabric8.api.AutoScaleStatus in project fabric8 by jboss-fuse.
the class AutoScalers method requirementsSatisfied.
/**
* Returns true if the requirements are satisfied for the given profile requirements; updating the auto scale status
* accordingly
*/
public static boolean requirementsSatisfied(FabricService service, String version, FabricRequirements requirements, ProfileRequirements profileRequirement, AutoScaleStatus status) {
String profile = profileRequirement.getProfile();
List<String> dependentProfiles = profileRequirement.getDependentProfiles();
if (dependentProfiles != null) {
for (String dependentProfile : dependentProfiles) {
ProfileRequirements dependentProfileRequirements = requirements.getOrCreateProfileRequirement(dependentProfile);
Integer minimumInstances = dependentProfileRequirements.getMinimumInstances();
if (minimumInstances != null) {
List<Container> containers = Containers.aliveAndSuccessfulContainersForProfile(version, dependentProfile, service);
int dependentSize = containers.size();
if (minimumInstances > dependentSize) {
status.profileStatus(profile).missingDependency(dependentProfile, dependentSize, minimumInstances);
return false;
}
}
}
}
return true;
}
use of io.fabric8.api.AutoScaleStatus in project fabric8 by jboss-fuse.
the class SshAutoScalerTest method assertSshAutoScale.
public static HostProfileCounter assertSshAutoScale(FabricRequirements requirements, AutoScaleStatus status) {
HostProfileCounter hostProfileCounter = new HostProfileCounter();
String version = requirements.getVersion();
if (Strings.isEmpty(version)) {
version = "1.0";
}
List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
for (ProfileRequirements profileRequirement : profileRequirements) {
Integer minimumInstances = profileRequirement.getMinimumInstances();
if (minimumInstances != null) {
for (int i = 0; i < minimumInstances; i++) {
String profileId = profileRequirement.getProfile();
AutoScaleRequest request = new AutoScaleRequest(null, version, profileId, 1, requirements, profileRequirement, status);
CreateSshContainerOptions.Builder builder = chooseHostContainerOptions(request, hostProfileCounter);
assertNotNull("Should have found a builder for " + profileId, builder);
String host = builder.getHost();
hostProfileCounter.incrementContainers(host);
hostProfileCounter.incrementProfileCount(host, profileId);
}
}
}
Map<String, CountingMap> hostToProfileCounts = hostProfileCounter.getHostToProfileCounts();
assertProfilesUseSeparateHost(requirements, hostToProfileCounts);
assertMaximumContainerCountNotExceeded(requirements, hostToProfileCounts);
return hostProfileCounter;
}
use of io.fabric8.api.AutoScaleStatus in project fabric8 by jboss-fuse.
the class ZkDataStoreImpl method getAutoScaleStatus.
@Override
public AutoScaleStatus getAutoScaleStatus() {
assertValid();
try {
AutoScaleStatus answer = null;
String zkPath = ZkPath.AUTO_SCALE_STATUS.getPath();
if (configCache.getCurrentData(zkPath) != null) {
String json = getStringData(configCache, zkPath);
answer = RequirementsJson.autoScaleStatusFromJSON(json);
}
if (answer == null) {
answer = new AutoScaleStatus();
}
return answer;
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
Aggregations