Examples of AutoScaleProfileStatus


Examples of io.fabric8.api.AutoScaleProfileStatus

                // lets check if we need to provision more
                List<Container> containers = Containers.aliveOrPendingContainersForProfile(profile, service);
                int count = containers.size();
                int delta = minimumInstances - count;
                try {
                    AutoScaleProfileStatus profileStatus = status.profileStatus(profile);
                    if (delta < 0) {
                        profileStatus.destroyingContainer();
                        autoScaler.destroyContainers(profile, -delta, containers);
                    } else if (delta > 0) {
                        if (AutoScalers.requirementsSatisfied(service, requirements, profileRequirement, status)) {
                            profileStatus.creatingContainer();
                            String requirementsVersion = requirements.getVersion();
                            final String version = Strings.isNotBlank(requirementsVersion) ? requirementsVersion : service.getDefaultVersionId();
                            final AutoScaleRequest command = new AutoScaleRequest(service, version, profile, delta, requirements, profileRequirement, status);
                            new Thread("Creating container for " + command.getProfile()) {
                                @Override
                                public void run() {
                                    try {
                                        autoScaler.createContainers(command);
                                    } catch (Exception e) {
                                        LOGGER.error("Failed to create container of profile: " + profile + ". Caught: " + e, e);
                                    }
                                }
                            }.start();
                        }
                    } else {
                        profileStatus.provisioned();
                    }
                } catch (Exception e) {
                    LOGGER.error("Failed to auto-scale " + profile + ". Caught: " + e, e);
                }
            }
View Full Code Here

Examples of io.fabric8.api.AutoScaleProfileStatus

        }
    }

    protected void stopContainers(List<Container> containers, ContainerAutoScaler autoScaler, FabricRequirements requirements, ProfileRequirements profileRequirement, AutoScaleStatus status, int delta) {
        final String profile = profileRequirement.getProfile();
        AutoScaleProfileStatus profileStatus = status.profileStatus(profile);

        // TODO sort the containers using some kind of requirements sorting order
        List<Container> sorted = new ArrayList<>(containers);

        // lets stop the ones at the end of the list by default
        Collections.reverse(sorted);

        List<String> stoppingContainerIds = new ArrayList<>();
        for (int i = 0; i < delta; i++) {
            if (i >= sorted.size()) {
                break;
            }
            Container container = sorted.get(i);
            stoppingContainerIds.add(container.getId());
            profileStatus.stoppingContainers(stoppingContainerIds);
            container.stop(true);

        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.