Package voldemort.client.rebalance.task

Examples of voldemort.client.rebalance.task.StealerBasedRebalanceTask


        RebalanceTaskInfo partitionsInfo = new RebalanceTaskInfo(stealerId,
                                                                 donorId,
                                                                 (HashMap<String, List<Integer>>) outerMap,
                                                                 zzCurrent);

        StealerBasedRebalanceTask sbTask = new StealerBasedRebalanceTask(0,
                                                                         0,
                                                                         partitionsInfo,
                                                                         donorPermit,
                                                                         adminClient,
                                                                         progressBar,
                                                                         mockedScheduler);
        sbTaskList.add(sbTask);
        sbTaskList.add(sbTask);
        sbTaskList.add(sbTask);
        sbTaskList.add(sbTask);
        sbTaskList.add(sbTask);

        mockedScheduler.initializeLatch(sbTaskList.size());
        mockedScheduler.populateTasksByStealer(sbTaskList);

        // In the beginning both stealer and donor are idle so scheduler should
        // return the scheduled
        // task
        StealerBasedRebalanceTask scheduledTask = mockedScheduler.scheduleNextTask(false);
        org.junit.Assert.assertNotNull(sbTask);
        org.junit.Assert.assertEquals(sbTask, scheduledTask);
        mockedScheduler.removeNodesFromWorkerList(Arrays.asList(stealerId, donorId));

        // Now lets remove the donor from the worker list so that the donor is
        // idle and add the
        // stealer to the worker list. The scheduler should return null as it
        // won't be able to
        // schedule the task.
        mockedScheduler.addNodesToWorkerList(Arrays.asList(stealerId));
        mockedScheduler.removeNodesFromWorkerList(Arrays.asList(donorId));
        org.junit.Assert.assertEquals(mockedScheduler.scheduleNextTask(false), null);

        // This time stealer doesn't have any work but donor does
        mockedScheduler.addNodesToWorkerList(Arrays.asList(donorId));
        mockedScheduler.removeNodesFromWorkerList(Arrays.asList(stealerId));
        org.junit.Assert.assertEquals(mockedScheduler.scheduleNextTask(false), null);

        // And now both stealer and donor have work to do
        mockedScheduler.addNodesToWorkerList(Arrays.asList(donorId));
        mockedScheduler.addNodesToWorkerList(Arrays.asList(stealerId));
        org.junit.Assert.assertEquals(mockedScheduler.scheduleNextTask(false), null);

        // And stealer and donor are idle again
        mockedScheduler.removeNodesFromWorkerList(Arrays.asList(stealerId, donorId));
        StealerBasedRebalanceTask nextscheduledTask = mockedScheduler.scheduleNextTask(false);
        org.junit.Assert.assertNotNull(sbTask);
        org.junit.Assert.assertEquals(sbTask, nextscheduledTask);

    }
View Full Code Here


        List<RebalanceTask> taskList = Lists.newArrayList();
        int taskId = 0;
        RebalanceScheduler scheduler = new RebalanceScheduler(service, maxParallelRebalancing);
        List<StealerBasedRebalanceTask> sbTaskList = Lists.newArrayList();
        for(RebalanceTaskInfo taskInfo: rebalanceTaskPlanList) {
            StealerBasedRebalanceTask rebalanceTask = new StealerBasedRebalanceTask(batchId,
                                                                                    taskId,
                                                                                    taskInfo,
                                                                                    donorPermits.get(taskInfo.getDonorId()),
                                                                                    adminClient,
                                                                                    progressBar,
View Full Code Here

TOP

Related Classes of voldemort.client.rebalance.task.StealerBasedRebalanceTask

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.