Package org.optaplanner.examples.cloudbalancing.domain

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


    public List<Move> createMoveList(CloudBalance cloudBalance) {
        List<CloudProcess> cloudProcessList = cloudBalance.getProcessList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<CloudProcess> leftIt = cloudProcessList.listIterator(); leftIt.hasNext();) {
            CloudProcess leftCloudProcess = leftIt.next();
            for (ListIterator<CloudProcess> rightIt = cloudProcessList.listIterator(leftIt.nextIndex()); rightIt.hasNext();) {
                CloudProcess rightCloudProcess = rightIt.next();
                moveList.add(new CloudProcessSwapMove(leftCloudProcess, rightCloudProcess));
            }
        }
        return moveList;
    }
View Full Code Here


        waitForNextStage();

        // Give the solver thread a chance to terminate and get into the daemon waiting state
        Thread.sleep(500);
        for (int i = 0; i < 8; i++) {
            CloudProcess process = notYetAddedProcessQueue.poll();
            solver.addProblemFactChange(new AddProcessChange(process));
        }
        // Wait until those AddProcessChanges are processed
        waitForNextStage();

        // Give the solver thread some time to solve, terminate and get into the daemon waiting state
        Thread.sleep(1000);
        while (!notYetAddedProcessQueue.isEmpty()) {
            CloudProcess process = notYetAddedProcessQueue.poll();
            solver.addProblemFactChange(new AddProcessChange(process));
        }
        // Wait until those AddProcessChanges are processed
        waitForNextStage();
View Full Code Here

    }

    private void createProcessList(CloudBalance cloudBalance, int processListSize) {
        List<CloudProcess> processList = new ArrayList<CloudProcess>(processListSize);
        for (int i = 0; i < processListSize; i++) {
            CloudProcess process = new CloudProcess();
            process.setId((long) i);
            int requiredCpuPower = generateRandom(MAXIMUM_REQUIRED_CPU_POWER);
            process.setRequiredCpuPower(requiredCpuPower);
            int requiredMemory = generateRandom(MAXIMUM_REQUIRED_MEMORY);
            process.setRequiredMemory(requiredMemory);
            int requiredNetworkBandwidth = generateRandom(MAXIMUM_REQUIRED_NETWORK_BANDWIDTH);
            process.setRequiredNetworkBandwidth(requiredNetworkBandwidth);
            logger.trace("Created CloudProcess with requiredCpuPower ({}), requiredMemory({}),"
                    + " requiredNetworkBandwidth({}).",
                    requiredCpuPower, requiredMemory, requiredNetworkBandwidth);
            // Notice that we leave the PlanningVariable properties on null
            processList.add(process);
View Full Code Here

        addComputerButton.setMargin(new Insets(0, 0, 0, 0));
        addPanel.add(addComputerButton);
        JButton addProcessButton = new JButton(addCloudProcessIcon);
        addProcessButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CloudProcess process = new CloudProcess();
                process.setRequiredCpuPower(3);
                process.setRequiredMemory(8);
                process.setRequiredNetworkBandwidth(3);
                addProcess(process);
            }
        });
        addProcessButton.setMargin(new Insets(0, 0, 0, 0));
        addPanel.add(addProcessButton);
View Full Code Here

        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);
                        break;
View Full Code Here

TOP

Related Classes of org.optaplanner.examples.cloudbalancing.domain.CloudProcess

Copyright © 2018 www.massapicom. 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.