Examples of CloudBalance


Examples of org.optaplanner.examples.cloudbalancing.domain.CloudBalance

        updatePanel(solution);
    }

    @Override
    public void updatePanel(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        Set<CloudComputer> deadCloudComputerSet = new LinkedHashSet<CloudComputer>(computerToPanelMap.keySet());
        deadCloudComputerSet.remove(null);
        for (CloudComputer computer : cloudBalance.getComputerList()) {
            deadCloudComputerSet.remove(computer);
            CloudComputerPanel computerPanel = computerToPanelMap.get(computer);
            if (computerPanel == null) {
                computerPanel = new CloudComputerPanel(this, computer);
                computersPanel.add(computerPanel);
                computerToPanelMap.put(computer, computerPanel);
            }
            computerPanel.clearProcesses();
        }
        unassignedPanel.clearProcesses();
        for (CloudProcess process : cloudBalance.getProcessList()) {
            CloudComputer computer = process.getComputer();
            CloudComputerPanel computerPanel = computerToPanelMap.get(computer);
            computerPanel.addProcess(process);
        }
        for (CloudComputer deadComputer : deadCloudComputerSet) {
View Full Code Here

Examples of org.optaplanner.examples.cloudbalancing.domain.CloudBalance

    public void addComputer(final CloudComputer computer) {
        logger.info("Scheduling addition of computer ({}).", computer);
        doProblemFactChange(new ProblemFactChange() {
            public void doChange(ScoreDirector scoreDirector) {
                CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
                // Set a unique id on the new computer
                long nextComputerId = 0L;
                for (CloudComputer otherComputer : cloudBalance.getComputerList()) {
                    if (nextComputerId <= otherComputer.getId()) {
                        nextComputerId = otherComputer.getId() + 1L;
                    }
                }
                computer.setId(nextComputerId);
                // A SolutionCloner does not clone problem fact lists (such as computerList)
                // Shallow clone the computerList so only workingSolution is affected, not bestSolution or guiSolution
                cloudBalance.setComputerList(new ArrayList<CloudComputer>(cloudBalance.getComputerList()));
                // Add the planning fact itself
                scoreDirector.beforeProblemFactAdded(computer);
                cloudBalance.getComputerList().add(computer);
                scoreDirector.afterProblemFactAdded(computer);
            }
        });
    }
View Full Code Here

Examples of org.optaplanner.examples.cloudbalancing.domain.CloudBalance

    public void deleteComputer(final CloudComputer computer) {
        logger.info("Scheduling delete of computer ({}).", computer);
        doProblemFactChange(new ProblemFactChange() {
            public void doChange(ScoreDirector scoreDirector) {
                CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
                // First remove the planning fact from all planning entities that use it
                for (CloudProcess process : cloudBalance.getProcessList()) {
                    if (ObjectUtils.equals(process.getComputer(), computer)) {
                        scoreDirector.beforeVariableChanged(process, "computer");
                        process.setComputer(null);
                        scoreDirector.afterVariableChanged(process, "computer");
                    }
                }
                // A SolutionCloner does not clone problem fact lists (such as computerList)
                // Shallow clone the computerList so only workingSolution is affected, not bestSolution or guiSolution
                cloudBalance.setComputerList(new ArrayList<CloudComputer>(cloudBalance.getComputerList()));
                // Remove the planning fact itself
                for (Iterator<CloudComputer> it = cloudBalance.getComputerList().iterator(); it.hasNext(); ) {
                    CloudComputer workingComputer = it.next();
                    if (ObjectUtils.equals(workingComputer, computer)) {
                        scoreDirector.beforeProblemFactRemoved(workingComputer);
                        it.remove(); // remove from list
                        scoreDirector.beforeProblemFactRemoved(workingComputer);
View Full Code Here

Examples of org.optaplanner.examples.cloudbalancing.domain.CloudBalance

    public void addProcess(final CloudProcess process) {
        logger.info("Scheduling addition of process ({}).", process);
        doProblemFactChange(new ProblemFactChange() {
            public void doChange(ScoreDirector scoreDirector) {
                CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
                // Set a unique id on the new process
                long nextProcessId = 0L;
                for (CloudProcess otherProcess : cloudBalance.getProcessList()) {
                    if (nextProcessId <= otherProcess.getId()) {
                        nextProcessId = otherProcess.getId() + 1L;
                    }
                }
                process.setId(nextProcessId);
                // Add the planning entity itself
                scoreDirector.beforeEntityAdded(process);
                cloudBalance.getProcessList().add(process);
                scoreDirector.afterEntityAdded(process);
            }
        });
    }
View Full Code Here

Examples of org.optaplanner.examples.cloudbalancing.domain.CloudBalance

    public void deleteProcess(final CloudProcess process) {
        logger.info("Scheduling delete of process ({}).", process);
        doProblemFactChange(new ProblemFactChange() {
            public void doChange(ScoreDirector scoreDirector) {
                CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
                // Remove the planning entity itself
                for (Iterator<CloudProcess> it = cloudBalance.getProcessList().iterator(); it.hasNext(); ) {
                    CloudProcess workingProcess = it.next();
                    if (ObjectUtils.equals(workingProcess, process)) {
                        scoreDirector.beforeEntityRemoved(workingProcess);
                        it.remove(); // remove from list
                        scoreDirector.afterEntityRemoved(workingProcess);
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.