@@ -0,0 +1,3497 @@
+/* This file is part of VoltDB.%0A * Copyright (C) 2008-2013 VoltDB Inc.%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as%0A * published by the Free Software Foundation, either version 3 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with VoltDB.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage org.voltdb.sysprocs;%0A%0Aimport com.google_voltpatches.common.collect.ImmutableList;%0Aimport org.json_voltpatches.JSONArray;%0Aimport org.json_voltpatches.JSONException;%0Aimport org.json_voltpatches.JSONObject;%0Aimport org.json_voltpatches.JSONString;%0Aimport org.json_voltpatches.JSONStringer;%0A%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0Apublic class BalancePartitionsRequest implements JSONString %7B%0A    public static class PartitionPair %7B%0A        public final int srcPartition;%0A        public final int destPartition;%0A        public final int rangeStart;%0A        public final int rangeEnd;%0A%0A        public PartitionPair(int srcPartition, int destPartition, int rangeStart, int rangeEnd)%0A        %7B%0A            this.srcPartition = srcPartition;%0A            this.destPartition = destPartition;%0A            this.rangeStart = rangeStart;%0A            this.rangeEnd = rangeEnd;%0A        %7D%0A    %7D%0A%0A    public final List%3CPartitionPair%3E partitionPairs;%0A%0A    public BalancePartitionsRequest(Collection%3CPartitionPair%3E partitionPairs)%0A    %7B%0A        this.partitionPairs = ImmutableList.copyOf(partitionPairs);%0A    %7D%0A%0A    public BalancePartitionsRequest(JSONObject jsObj) throws JSONException%0A    %7B%0A        partitionPairs = parseRanges(jsObj);%0A    %7D%0A%0A    private List%3CPartitionPair%3E parseRanges(JSONObject jsObj) throws JSONException%0A    %7B%0A        ImmutableList.Builder%3CPartitionPair%3E builder = ImmutableList.builder();%0A        JSONArray pairsArray = jsObj.getJSONArray(%22partitionPairs%22);%0A%0A        for (int i = 0; i %3C pairsArray.length(); i++) %7B%0A            JSONObject pairObj = pairsArray.getJSONObject(i);%0A%0A            builder.add(new PartitionPair(pairObj.getInt(%22srcPartition%22),%0A                                          pairObj.getInt(%22destPartition%22),%0A                                          pairObj.getInt(%22rangeStart%22),%0A                                          pairObj.getInt(%22rangeEnd%22)));%0A        %7D%0A%0A        return builder.build();%0A    %7D%0A%0A    @Override%0A    public String toJSONString()%0A    %7B%0A        JSONStringer stringer = new JSONStringer();%0A%0A        try %7B%0A            stringer.object();%0A            stringer.key(%22partitionPairs%22).array();%0A%0A            for (PartitionPair pair : partitionPairs) %7B%0A                stringer.object();%0A%0A                stringer.key(%22srcPartition%22).value(pair.srcPartition);%0A                stringer.key(%22destPartition%22).value(pair.destPartition);%0A                stringer.key(%22rangeStart%22).value(pair.rangeStart);%0A                stringer.key(%22rangeEnd%22).value(pair.rangeEnd);%0A%0A                stringer.endObject();%0A            %7D%0A%0A            stringer.endArray();%0A            stringer.endObject();%0A%0A            return stringer.toString();%0A        %7D catch (JSONException e) %7B%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Move BalancePartitionsRequest to eng so that the MpScheduler can peak into the parameters to figure out the partitions involved.