Search in sources :

Example 1 with AutoScaleStatus

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;
}
Also used : PrintStream(java.io.PrintStream) AutoScaleStatus(io.fabric8.api.AutoScaleStatus)

Example 2 with AutoScaleStatus

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();
}
Also used : TablePrinter(io.fabric8.utils.TablePrinter) AutoScaleProfileStatus(io.fabric8.api.AutoScaleProfileStatus)

Example 3 with AutoScaleStatus

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;
}
Also used : Container(io.fabric8.api.Container) ProfileRequirements(io.fabric8.api.ProfileRequirements)

Example 4 with AutoScaleStatus

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;
}
Also used : CountingMap(io.fabric8.utils.CountingMap) ProfileRequirements(io.fabric8.api.ProfileRequirements) AutoScaleRequest(io.fabric8.api.AutoScaleRequest) HostProfileCounter(io.fabric8.internal.autoscale.HostProfileCounter)

Example 5 with AutoScaleStatus

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);
    }
}
Also used : AutoScaleStatus(io.fabric8.api.AutoScaleStatus) FabricException(io.fabric8.api.FabricException) InvalidClassException(java.io.InvalidClassException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Aggregations

AutoScaleProfileStatus (io.fabric8.api.AutoScaleProfileStatus)3 AutoScaleStatus (io.fabric8.api.AutoScaleStatus)3 Container (io.fabric8.api.Container)3 ProfileRequirements (io.fabric8.api.ProfileRequirements)3 AutoScaleRequest (io.fabric8.api.AutoScaleRequest)2 FabricService (io.fabric8.api.FabricService)2 ContainerAutoScaler (io.fabric8.api.ContainerAutoScaler)1 FabricException (io.fabric8.api.FabricException)1 FabricRequirements (io.fabric8.api.FabricRequirements)1 HostProfileCounter (io.fabric8.internal.autoscale.HostProfileCounter)1 CountingMap (io.fabric8.utils.CountingMap)1 TablePrinter (io.fabric8.utils.TablePrinter)1 IOException (java.io.IOException)1 InvalidClassException (java.io.InvalidClassException)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 KeeperException (org.apache.zookeeper.KeeperException)1