Repository: incubator-ignite Updated Branches: refs/heads/master 12837f35b -> 8c20bddb3
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpi.java new file mode 100644 index 0000000..243e20a --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpi.java @@ -0,0 +1,319 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.loadbalancing.roundrobin; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.events.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.resources.*; +import org.apache.ignite.spi.*; +import org.gridgain.grid.*; +import org.gridgain.grid.kernal.managers.eventstorage.*; +import org.gridgain.grid.spi.loadbalancing.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.jdk8.backport.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +import static org.apache.ignite.events.IgniteEventType.*; + +/** + * This SPI iterates through nodes in round-robin fashion and pick the next + * sequential node. Two modes of operation are supported: per-task and global + * (see {@link #setPerTask(boolean)} configuration). + * <p> + * When configured in per-task mode, implementation will pick a random starting + * node at the beginning of every task execution and then sequentially iterate through all + * nodes in topology starting from the picked node. This is the default configuration + * and should fit most of the use cases as it provides a fairly well-distributed + * split and also ensures that jobs within a single task are spread out across + * nodes to the maximum. For cases when split size is equal to the number of nodes, + * this mode guarantees that all nodes will participate in the split. + * <p> + * When configured in global mode, a single sequential queue of nodes is maintained for + * all tasks and the next node in the queue is picked every time. In this mode (unlike in + * {@code per-task} mode) it is possible that even if split size may be equal to the + * number of nodes, some jobs within the same task will be assigned to the same node if + * multiple tasks are executing concurrently. + * <h1 class="header">Coding Example</h1> + * If you are using {@link org.apache.ignite.compute.ComputeTaskSplitAdapter} then load balancing logic + * is transparent to your code and is handled automatically by the adapter. + * Here is an example of how your task will look: + * <pre name="code" class="java"> + * public class MyFooBarTask extends GridComputeTaskSplitAdapter<Object, Object> { + * @Override + * protected Collection<? extends GridComputeJob> split(int gridSize, Object arg) throws GridException { + * List<MyFooBarJob> jobs = new ArrayList<MyFooBarJob>(gridSize); + * + * for (int i = 0; i < gridSize; i++) { + * jobs.add(new MyFooBarJob(arg)); + * } + * + * // Node assignment via load balancer + * // happens automatically. + * return jobs; + * } + * ... + * } + * </pre> + * If you need more fine-grained control over how some jobs within task get mapped to a node + * and use affinity load balancing for some other jobs within task, then you should use + * {@link org.apache.ignite.compute.ComputeTaskAdapter}. Here is an example of how your task will look. Note that in this + * case we manually inject load balancer and use it to pick the best node. Doing it in + * such way would allow user to map some jobs manually and for others use load balancer. + * <pre name="code" class="java"> + * public class MyFooBarTask extends GridComputeTaskAdapter<String, String> { + * // Inject load balancer. + * @GridLoadBalancerResource + * GridComputeLoadBalancer balancer; + * + * // Map jobs to grid nodes. + * public Map<? extends GridComputeJob, GridNode> map(List<GridNode> subgrid, String arg) throws GridException { + * Map<MyFooBarJob, GridNode> jobs = new HashMap<MyFooBarJob, GridNode>(subgrid.size()); + * + * // In more complex cases, you can actually do + * // more complicated assignments of jobs to nodes. + * for (int i = 0; i < subgrid.size(); i++) { + * // Pick the next best balanced node for the job. + * jobs.put(new MyFooBarJob(arg), balancer.getBalancedNode()) + * } + * + * return jobs; + * } + * + * // Aggregate results into one compound result. + * public String reduce(List<GridComputeJobResult> results) throws GridException { + * // For the purpose of this example we simply + * // concatenate string representation of every + * // job result + * StringBuilder buf = new StringBuilder(); + * + * for (GridComputeJobResult res : results) { + * // Append string representation of result + * // returned by every job. + * buf.append(res.getData().string()); + * } + * + * return buf.string(); + * } + * } + * </pre> + * <p> + * <h1 class="header">Configuration</h1> + * In order to use this load balancer, you should configure your grid instance + * to use {@code GridRoundRobinLoadBalancingSpi} either from Spring XML file or + * directly. The following configuration parameters are supported: + * <h2 class="header">Mandatory</h2> + * This SPI has no mandatory configuration parameters. + * <h2 class="header">Optional</h2> + * The following configuration parameters are optional: + * <ul> + * <li> + * Flag that indicates whether to use {@code per-task} or global + * round-robin modes described above (see {@link #setPerTask(boolean)}). + * </li> + * </ul> + * Below is Java configuration example: + * <pre name="code" class="java"> + * GridRandomLoadBalancingSpi = new GridRandomLoadBalancingSpi(); + * + * // Configure SPI to use global round-robin mode. + * spi.setPerTask(false); + * + * GridConfiguration cfg = new GridConfiguration(); + * + * // Override default load balancing SPI. + * cfg.setLoadBalancingSpi(spi); + * + * // Starts grid. + * G.start(cfg); + * </pre> + * Here is how you can configure {@code GridRandomLoadBalancingSpi} using Spring XML configuration: + * <pre name="code" class="xml"> + * <property name="loadBalancingSpi"> + * <bean class="org.gridgain.grid.spi.loadBalancing.roundrobin.GridRoundRobinLoadBalancingSpi"> + * <!-- Set to global round-robin mode. --> + * <property name="perTask" value="false"/> + * </bean> + * </property> + * </pre> + * <p> + * <img src="http://www.gridgain.com/images/spring-small.png"> + * <br> + * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a> + */ +@IgniteSpiMultipleInstancesSupport(true) +public class RoundRobinLoadBalancingSpi extends IgniteSpiAdapter implements LoadBalancingSpi, + RoundRobinLoadBalancingSpiMBean { + /** Grid logger. */ + @IgniteLoggerResource + private IgniteLogger log; + + /** */ + private RoundRobinGlobalLoadBalancer balancer; + + /** */ + private boolean isPerTask; + + /** */ + private final Map<IgniteUuid, RoundRobinPerTaskLoadBalancer> perTaskBalancers = + new ConcurrentHashMap8<>(); + + /** Event listener. */ + private final GridLocalEventListener lsnr = new GridLocalEventListener() { + @Override public void onEvent(IgniteEvent evt) { + if (evt.type() == EVT_TASK_FAILED || + evt.type() == EVT_TASK_FINISHED) + perTaskBalancers.remove(((IgniteTaskEvent)evt).taskSessionId()); + else if (evt.type() == EVT_JOB_MAPPED) { + RoundRobinPerTaskLoadBalancer balancer = + perTaskBalancers.get(((IgniteJobEvent)evt).taskSessionId()); + + if (balancer != null) + balancer.onMapped(); + } + } + }; + + /** {@inheritDoc} */ + @Override public boolean isPerTask() { + return isPerTask; + } + + /** + * Configuration parameter indicating whether a new round robin order should be + * created for every task. If {@code true} then load balancer is guaranteed + * to iterate through nodes sequentially for every task - so as long as number + * of jobs is less than or equal to the number of nodes, jobs are guaranteed to + * be assigned to unique nodes. If {@code false} then one round-robin order + * will be maintained for all tasks, so when tasks execute concurrently, it + * is possible for more than one job within task to be assigned to the same + * node. + * <p> + * Default is {@code false}. + * + * @param isPerTask Configuration parameter indicating whether a new round robin order should + * be created for every task. Default is {@code false}. + */ + @IgniteSpiConfiguration(optional = true) + public void setPerTask(boolean isPerTask) { + this.isPerTask = isPerTask; + } + + /** {@inheritDoc} */ + @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException { + startStopwatch(); + + if (log.isDebugEnabled()) + log.debug(configInfo("isPerTask", isPerTask)); + + registerMBean(gridName, this, RoundRobinLoadBalancingSpiMBean.class); + + balancer = new RoundRobinGlobalLoadBalancer(log); + + // Ack ok start. + if (log.isDebugEnabled()) + log.debug(startInfo()); + } + + /** {@inheritDoc} */ + @Override public void spiStop() throws IgniteSpiException { + balancer = null; + + perTaskBalancers.clear(); + + unregisterMBean(); + + // Ack ok stop. + if (log.isDebugEnabled()) + log.debug(stopInfo()); + } + + /** {@inheritDoc} */ + @Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException { + if (!isPerTask) + balancer.onContextInitialized(spiCtx); + else { + if (!getSpiContext().isEventRecordable(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED)) + throw new IgniteSpiException("Required event types are disabled: " + + U.gridEventName(EVT_TASK_FAILED) + ", " + + U.gridEventName(EVT_TASK_FINISHED) + ", " + + U.gridEventName(EVT_JOB_MAPPED)); + + getSpiContext().addLocalEventListener(lsnr, EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); + } + } + + /** {@inheritDoc} */ + @Override protected void onContextDestroyed0() { + if (!isPerTask) { + if (balancer != null) + balancer.onContextDestroyed(); + } + else { + IgniteSpiContext spiCtx = getSpiContext(); + + if (spiCtx != null) + spiCtx.removeLocalEventListener(lsnr); + } + } + + /** {@inheritDoc} */ + @Override public ClusterNode getBalancedNode(ComputeTaskSession ses, List<ClusterNode> top, ComputeJob job) + throws GridException { + A.notNull(ses, "ses", top, "top"); + + if (isPerTask) { + // Note that every session operates from single thread which + // allows us to use concurrent map and avoid synchronization. + RoundRobinPerTaskLoadBalancer taskBalancer = perTaskBalancers.get(ses.getId()); + + if (taskBalancer == null) + perTaskBalancers.put(ses.getId(), taskBalancer = new RoundRobinPerTaskLoadBalancer()); + + return taskBalancer.getBalancedNode(top); + } + + return balancer.getBalancedNode(top); + } + + /** + * THIS METHOD IS USED ONLY FOR TESTING. + * + * @param ses Task session. + * @return Internal list of nodes. + */ + List<UUID> getNodeIds(ComputeTaskSession ses) { + if (isPerTask) { + RoundRobinPerTaskLoadBalancer balancer = perTaskBalancers.get(ses.getId()); + + if (balancer == null) + return Collections.emptyList(); + + List<UUID> ids = new ArrayList<>(); + + for (ClusterNode node : balancer.getNodes()) { + ids.add(node.id()); + } + + return ids; + } + + return balancer.getNodeIds(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(RoundRobinLoadBalancingSpi.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpiMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpiMBean.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpiMBean.java new file mode 100644 index 0000000..1189677 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinLoadBalancingSpiMBean.java @@ -0,0 +1,37 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.loadbalancing.roundrobin; + +import org.apache.ignite.mbean.*; +import org.apache.ignite.spi.*; + +/** + * Management bean for {@link RoundRobinLoadBalancingSpi} SPI. + */ +@IgniteMBeanDescription("MBean that provides access to round robin load balancing SPI configuration.") +public interface RoundRobinLoadBalancingSpiMBean extends IgniteSpiManagementMBean { + /** + * Configuration parameter indicating whether a new round robin order should be + * created for every task. If {@code true} then load balancer is guaranteed + * to iterate through nodes sequentially for every task - so as long as number + * of jobs is less than or equal to the number of nodes, jobs are guaranteed to + * be assigned to unique nodes. If {@code false} then one round-robin order + * will be maintained for all tasks, so when tasks execute concurrently, it + * is possible for more than one job within task to be assigned to the same + * node. + * <p> + * Default is {@code true}. + * + * @return Configuration parameter indicating whether a new round robin order should + * be created for every task. Default is {@code true}. + */ + @IgniteMBeanDescription("Configuration parameter indicating whether a new round robin order should be created for every task.") + public boolean isPerTask(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinPerTaskLoadBalancer.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinPerTaskLoadBalancer.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinPerTaskLoadBalancer.java new file mode 100644 index 0000000..bf626b4 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/roundrobin/RoundRobinPerTaskLoadBalancer.java @@ -0,0 +1,96 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.loadbalancing.roundrobin; + +import org.apache.ignite.cluster.*; + +import java.util.*; + +/** + * Load balancer for per-task configuration. + */ +class RoundRobinPerTaskLoadBalancer { + /** Balancing nodes. */ + private ArrayDeque<ClusterNode> nodeQueue; + + /** Jobs mapped flag. */ + private volatile boolean isMapped; + + /** Mutex. */ + private final Object mux = new Object(); + + /** + * Call back for job mapped event. + */ + void onMapped() { + isMapped = true; + } + + /** + * Gets balanced node for given topology. This implementation + * is to be used only from {@link org.apache.ignite.compute.ComputeTask#map(List, Object)} method + * and, therefore, does not need to be thread-safe. + * + * @param top Topology to pick from. + * @return Best balanced node. + */ + ClusterNode getBalancedNode(List<ClusterNode> top) { + assert top != null; + assert !top.isEmpty(); + + boolean readjust = isMapped; + + synchronized (mux) { + // Populate first time. + if (nodeQueue == null) + nodeQueue = new ArrayDeque<>(top); + + // If job has been mapped, then it means + // that it is most likely being failed over. + // In this case topology might have changed + // and we need to readjust with every apply. + if (readjust) + // Add missing nodes. + for (ClusterNode node : top) + if (!nodeQueue.contains(node)) + nodeQueue.offer(node); + + ClusterNode next = nodeQueue.poll(); + + // If jobs have been mapped, we need to make sure + // that queued node is still in topology. + if (readjust && next != null) { + while (!top.contains(next) && !nodeQueue.isEmpty()) + next = nodeQueue.poll(); + + // No nodes found and queue is empty. + if (next != null && !top.contains(next)) + return null; + } + + if (next != null) + // Add to the end. + nodeQueue.offer(next); + + return next; + } + } + + /** + * THIS METHOD IS USED ONLY FOR TESTING. + * + * @return Internal list of nodes. + */ + List<ClusterNode> getNodes() { + synchronized (mux) { + return Collections.unmodifiableList(new ArrayList<>(nodeQueue)); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpi.java deleted file mode 100644 index f166da4..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpi.java +++ /dev/null @@ -1,394 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.loadbalancing.weightedrandom; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.spi.*; -import org.gridgain.grid.kernal.managers.eventstorage.*; -import org.gridgain.grid.spi.loadbalancing.*; -import org.gridgain.grid.util.typedef.*; -import org.gridgain.grid.util.typedef.internal.*; -import org.jdk8.backport.*; -import org.jetbrains.annotations.*; - -import java.util.*; -import java.util.concurrent.*; - -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * Load balancing SPI that picks a random node for job execution. Note that you can - * optionally assign weights to nodes, so nodes with larger weights will end up getting - * proportionally more jobs routed to them (see {@link #setNodeWeight(int)} - * configuration property). By default all nodes get equal weight defined by - * {@link #DFLT_NODE_WEIGHT} (value is {@code 10}). - * <h1 class="header">Coding Example</h1> - * If you are using {@link org.apache.ignite.compute.ComputeTaskSplitAdapter} then load balancing logic - * is transparent to your code and is handled automatically by the adapter. - * Here is an example of how your task could look: - * <pre name="code" class="java"> - * public class MyFooBarTask extends GridComputeTaskSplitAdapter<Object, Object> { - * @Override - * protected Collection<? extends GridComputeJob> split(int gridSize, Object arg) throws GridException { - * List<MyFooBarJob> jobs = new ArrayList<MyFooBarJob>(gridSize); - * - * for (int i = 0; i < gridSize; i++) { - * jobs.add(new MyFooBarJob(arg)); - * } - * - * // Node assignment via load balancer - * // happens automatically. - * return jobs; - * } - * ... - * } - * </pre> - * If you need more fine-grained control over how some jobs within task get mapped to a node - * and use affinity load balancing for some other jobs within task, then you should use - * {@link org.apache.ignite.compute.ComputeTaskAdapter}. Here is an example of how your task will look. Note that in this - * case we manually inject load balancer and use it to pick the best node. Doing it in - * such way would allow user to map some jobs manually and for others use load balancer. - * <pre name="code" class="java"> - * public class MyFooBarTask extends GridComputeTaskAdapter<String, String> { - * // Inject load balancer. - * @GridLoadBalancerResource - * GridComputeLoadBalancer balancer; - * - * // Map jobs to grid nodes. - * public Map<? extends GridComputeJob, GridNode> map(List<GridNode> subgrid, String arg) throws GridException { - * Map<MyFooBarJob, GridNode> jobs = new HashMap<MyFooBarJob, GridNode>(subgrid.size()); - * - * // In more complex cases, you can actually do - * // more complicated assignments of jobs to nodes. - * for (int i = 0; i < subgrid.size(); i++) { - * // Pick the next best balanced node for the job. - * jobs.put(new MyFooBarJob(arg), balancer.getBalancedNode()) - * } - * - * return jobs; - * } - * - * // Aggregate results into one compound result. - * public String reduce(List<GridComputeJobResult> results) throws GridException { - * // For the purpose of this example we simply - * // concatenate string representation of every - * // job result - * StringBuilder buf = new StringBuilder(); - * - * for (GridComputeJobResult res : results) { - * // Append string representation of result - * // returned by every job. - * buf.append(res.getData().string()); - * } - * - * return buf.string(); - * } - * } - * </pre> - * <p> - * <h1 class="header">Configuration</h1> - * In order to use this load balancer, you should configure your grid instance - * to use {@code GridRandomLoadBalancingSpi} either from Spring XML file or - * directly. The following configuration parameters are supported: - * <h2 class="header">Mandatory</h2> - * This SPI has no mandatory configuration parameters. - * <h2 class="header">Optional</h2> - * The following configuration parameters are optional: - * <ul> - * <li> - * Flag that indicates whether to use weight policy or simple random policy - * (see {@link #setUseWeights(boolean)}) - * </li> - * <li> - * Weight of this node (see {@link #setNodeWeight(int)}). This parameter is ignored - * if {@link #setUseWeights(boolean)} is set to {@code false}. - * </li> - * </ul> - * Below is Java configuration example: - * <pre name="code" class="java"> - * GridWeightedRandomLoadBalancingSpi = new GridWeightedLoadBalancingSpi(); - * - * // Configure SPI to used weighted - * // random load balancing. - * spi.setUseWeights(true); - * - * // Set weight for the local node. - * spi.setWeight( *); - * - * GridConfiguration cfg = new GridConfiguration(); - * - * // Override default load balancing SPI. - * cfg.setLoadBalancingSpi(spi); - * - * // Starts grid. - * G.start(cfg); - * </pre> - * Here is how you can configure {@code GridRandomLoadBalancingSpi} using Spring XML configuration: - * <pre name="code" class="xml"> - * <property name="loadBalancingSpi"> - * <bean class="org.gridgain.grid.spi.loadBalancing.weightedrandom.GridWeightedRandomLoadBalancingSpi"> - * <property name="useWeights" value="true"/> - * <property name="nodeWeight" value="10"/> - * </bean> - * </property> - * </pre> - * <p> - * <img src="http://www.gridgain.com/images/spring-small.png"> - * <br> - * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a> - */ -@IgniteSpiMultipleInstancesSupport(true) -@IgniteSpiConsistencyChecked(optional = true) -public class GridWeightedRandomLoadBalancingSpi extends IgniteSpiAdapter implements GridLoadBalancingSpi, - GridWeightedRandomLoadBalancingSpiMBean { - /** Random number generator. */ - private static final Random RAND = new Random(); - - /** - * Name of node attribute used to indicate load weight of a node - * (value is {@code "gridgain.node.weight.attr.name"}). - * - * @see org.apache.ignite.cluster.ClusterNode#attributes() - */ - public static final String NODE_WEIGHT_ATTR_NAME = "gridgain.node.weight.attr.name"; - - /** Default weight assigned to every node if explicit one is not provided (value is {@code 10}). */ - public static final int DFLT_NODE_WEIGHT = 10; - - /** Grid logger. */ - @IgniteLoggerResource - private IgniteLogger log; - - /** */ - private boolean isUseWeights; - - /** Local event listener to listen to task completion events. */ - private GridLocalEventListener evtLsnr; - - /** Weight of this node. */ - private int nodeWeight = DFLT_NODE_WEIGHT; - - /** Task topologies. First pair value indicates whether or not jobs have been mapped. */ - private ConcurrentMap<IgniteUuid, IgniteBiTuple<Boolean, WeightedTopology>> taskTops = - new ConcurrentHashMap8<>(); - - /** - * Sets a flag to indicate whether node weights should be checked when - * doing random load balancing. Default value is {@code false} which - * means that node weights are disregarded for load balancing logic. - * - * @param isUseWeights If {@code true} then random load is distributed according - * to node weights. - */ - @IgniteSpiConfiguration(optional = true) - public void setUseWeights(boolean isUseWeights) { - this.isUseWeights = isUseWeights; - } - - /** {@inheritDoc} */ - @Override public boolean isUseWeights() { - return isUseWeights; - } - - /** - * Sets weight of this node. Nodes with more processing capacity - * should be assigned proportionally larger weight. Default value - * is {@link #DFLT_NODE_WEIGHT} and is equal for all nodes. - * - * @param nodeWeight Weight of this node. - */ - @IgniteSpiConfiguration(optional = true) - public void setNodeWeight(int nodeWeight) { - this.nodeWeight = nodeWeight; - } - - /** {@inheritDoc} */ - @Override public int getNodeWeight() { - return nodeWeight; - } - - /** {@inheritDoc} */ - @Override public Map<String, Object> getNodeAttributes() throws IgniteSpiException { - return F.<String, Object>asMap(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME), nodeWeight); - } - - /** {@inheritDoc} */ - @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException { - startStopwatch(); - - assertParameter(nodeWeight > 0, "nodeWeight > 0"); - - if (log.isDebugEnabled()) { - log.debug(configInfo("isUseWeights", isUseWeights)); - log.debug(configInfo("nodeWeight", nodeWeight)); - } - - registerMBean(gridName, this, GridWeightedRandomLoadBalancingSpiMBean.class); - - // Ack ok start. - if (log.isDebugEnabled()) - log.debug(startInfo()); - } - - /** {@inheritDoc} */ - @Override public void spiStop() throws IgniteSpiException { - unregisterMBean(); - - // Ack ok stop. - if (log.isDebugEnabled()) - log.debug(stopInfo()); - } - - /** {@inheritDoc} */ - @Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException { - getSpiContext().addLocalEventListener(evtLsnr = new GridLocalEventListener() { - @Override public void onEvent(IgniteEvent evt) { - assert evt instanceof IgniteTaskEvent || evt instanceof IgniteJobEvent; - - if (evt.type() == EVT_TASK_FINISHED || - evt.type() == EVT_TASK_FAILED) { - IgniteUuid sesId = ((IgniteTaskEvent)evt).taskSessionId(); - - taskTops.remove(sesId); - - if (log.isDebugEnabled()) - log.debug("Removed task topology from topology cache for session: " + sesId); - } - // We should keep topology and use cache in GridComputeTask#map() method to - // avoid O(n*n/2) complexity, after that we can drop caches. - // Here we set mapped property and later cache will be ignored - else if (evt.type() == EVT_JOB_MAPPED) { - IgniteUuid sesId = ((IgniteJobEvent)evt).taskSessionId(); - - IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(sesId); - - if (weightedTop != null) - weightedTop.set1(true); - - if (log.isDebugEnabled()) - log.debug("Job has been mapped. Ignore cache for session: " + sesId); - } - } - }, - EVT_TASK_FAILED, - EVT_TASK_FINISHED, - EVT_JOB_MAPPED - ); - } - - /** {@inheritDoc} */ - @Override protected void onContextDestroyed0() { - if (evtLsnr != null) { - IgniteSpiContext ctx = getSpiContext(); - - if (ctx != null) - ctx.removeLocalEventListener(evtLsnr); - } - } - - /** {@inheritDoc} */ - @Override public ClusterNode getBalancedNode(ComputeTaskSession ses, List<ClusterNode> top, ComputeJob job) { - A.notNull(ses, "ses"); - A.notNull(top, "top"); - A.notNull(job, "job"); - - // Optimization for non-weighted randomization. - if (!isUseWeights) - return top.get(RAND.nextInt(top.size())); - - IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(ses.getId()); - - // Create new cached topology if there is no one. Do not - // use cached topology after task has been mapped. - if (weightedTop == null) { - // Called from GridComputeTask#map(). Put new topology and false as not mapped yet. - taskTops.put(ses.getId(), weightedTop = F.t(false, new WeightedTopology(top))); - } - // We have topology - check if task has been mapped. - else if (weightedTop.get1()) { - // Do not use cache after GridComputeTask#map(). - return new WeightedTopology(top).pickWeightedNode(); - } - - return weightedTop.get2().pickWeightedNode(); - } - - /** - * @param node Node to get weight for. - * @return Node weight - */ - private int getWeight(ClusterNode node) { - Integer weight = (Integer)node.attribute(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME)); - - if (weight != null && weight == 0) - throw new IllegalStateException("Node weight cannot be zero: " + node); - - return weight == null ? DFLT_NODE_WEIGHT : weight; - } - - /** - * Holder for weighted topology. - */ - private class WeightedTopology { - /** Total topology weight. */ - private final int totalWeight; - - /** Topology sorted by weight. */ - private final SortedMap<Integer, ClusterNode> circle = new TreeMap<>(); - - /** - * @param top Topology. - */ - WeightedTopology(Collection<ClusterNode> top) { - assert !F.isEmpty(top); - - int totalWeight = 0; - - for (ClusterNode node : top) { - totalWeight += getWeight(node); - - // Complexity of this put is O(logN). - circle.put(totalWeight, node); - } - - this.totalWeight = totalWeight; - } - - /** - * Gets weighted node in random fashion. - * - * @return Weighted node. - */ - ClusterNode pickWeightedNode() { - int weight = RAND.nextInt(totalWeight) + 1; - - SortedMap<Integer, ClusterNode> pick = circle.tailMap(weight); - - assert !pick.isEmpty(); - - return pick.get(pick.firstKey()); - } - } - - /** {@inheritDoc} */ - @Override protected List<String> getConsistentAttributeNames() { - return Collections.singletonList(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME)); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridWeightedRandomLoadBalancingSpi.class, this); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiMBean.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiMBean.java deleted file mode 100644 index 2dfe769..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiMBean.java +++ /dev/null @@ -1,37 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.loadbalancing.weightedrandom; - -import org.apache.ignite.mbean.*; -import org.apache.ignite.spi.*; - -/** - * Management MBean for {@link GridWeightedRandomLoadBalancingSpi} SPI. - */ -@IgniteMBeanDescription("MBean that provides access to weighted random load balancing SPI configuration.") -public interface GridWeightedRandomLoadBalancingSpiMBean extends IgniteSpiManagementMBean { - /** - * Checks whether node weights are considered when doing - * random load balancing. - * - * @return If {@code true} then random load is distributed according - * to node weights. - */ - @IgniteMBeanDescription("Whether node weights are considered when doing random load balancing.") - public boolean isUseWeights(); - - /** - * Gets weight of this node. - * - * @return Weight of this node. - */ - @IgniteMBeanDescription("Weight of this node.") - public int getNodeWeight(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpi.java new file mode 100644 index 0000000..0590d60 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpi.java @@ -0,0 +1,394 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.loadbalancing.weightedrandom; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.events.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.resources.*; +import org.apache.ignite.spi.*; +import org.gridgain.grid.kernal.managers.eventstorage.*; +import org.gridgain.grid.spi.loadbalancing.*; +import org.gridgain.grid.util.typedef.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.jdk8.backport.*; +import org.jetbrains.annotations.*; + +import java.util.*; +import java.util.concurrent.*; + +import static org.apache.ignite.events.IgniteEventType.*; + +/** + * Load balancing SPI that picks a random node for job execution. Note that you can + * optionally assign weights to nodes, so nodes with larger weights will end up getting + * proportionally more jobs routed to them (see {@link #setNodeWeight(int)} + * configuration property). By default all nodes get equal weight defined by + * {@link #DFLT_NODE_WEIGHT} (value is {@code 10}). + * <h1 class="header">Coding Example</h1> + * If you are using {@link org.apache.ignite.compute.ComputeTaskSplitAdapter} then load balancing logic + * is transparent to your code and is handled automatically by the adapter. + * Here is an example of how your task could look: + * <pre name="code" class="java"> + * public class MyFooBarTask extends GridComputeTaskSplitAdapter<Object, Object> { + * @Override + * protected Collection<? extends GridComputeJob> split(int gridSize, Object arg) throws GridException { + * List<MyFooBarJob> jobs = new ArrayList<MyFooBarJob>(gridSize); + * + * for (int i = 0; i < gridSize; i++) { + * jobs.add(new MyFooBarJob(arg)); + * } + * + * // Node assignment via load balancer + * // happens automatically. + * return jobs; + * } + * ... + * } + * </pre> + * If you need more fine-grained control over how some jobs within task get mapped to a node + * and use affinity load balancing for some other jobs within task, then you should use + * {@link org.apache.ignite.compute.ComputeTaskAdapter}. Here is an example of how your task will look. Note that in this + * case we manually inject load balancer and use it to pick the best node. Doing it in + * such way would allow user to map some jobs manually and for others use load balancer. + * <pre name="code" class="java"> + * public class MyFooBarTask extends GridComputeTaskAdapter<String, String> { + * // Inject load balancer. + * @GridLoadBalancerResource + * GridComputeLoadBalancer balancer; + * + * // Map jobs to grid nodes. + * public Map<? extends GridComputeJob, GridNode> map(List<GridNode> subgrid, String arg) throws GridException { + * Map<MyFooBarJob, GridNode> jobs = new HashMap<MyFooBarJob, GridNode>(subgrid.size()); + * + * // In more complex cases, you can actually do + * // more complicated assignments of jobs to nodes. + * for (int i = 0; i < subgrid.size(); i++) { + * // Pick the next best balanced node for the job. + * jobs.put(new MyFooBarJob(arg), balancer.getBalancedNode()) + * } + * + * return jobs; + * } + * + * // Aggregate results into one compound result. + * public String reduce(List<GridComputeJobResult> results) throws GridException { + * // For the purpose of this example we simply + * // concatenate string representation of every + * // job result + * StringBuilder buf = new StringBuilder(); + * + * for (GridComputeJobResult res : results) { + * // Append string representation of result + * // returned by every job. + * buf.append(res.getData().string()); + * } + * + * return buf.string(); + * } + * } + * </pre> + * <p> + * <h1 class="header">Configuration</h1> + * In order to use this load balancer, you should configure your grid instance + * to use {@code GridRandomLoadBalancingSpi} either from Spring XML file or + * directly. The following configuration parameters are supported: + * <h2 class="header">Mandatory</h2> + * This SPI has no mandatory configuration parameters. + * <h2 class="header">Optional</h2> + * The following configuration parameters are optional: + * <ul> + * <li> + * Flag that indicates whether to use weight policy or simple random policy + * (see {@link #setUseWeights(boolean)}) + * </li> + * <li> + * Weight of this node (see {@link #setNodeWeight(int)}). This parameter is ignored + * if {@link #setUseWeights(boolean)} is set to {@code false}. + * </li> + * </ul> + * Below is Java configuration example: + * <pre name="code" class="java"> + * GridWeightedRandomLoadBalancingSpi = new GridWeightedLoadBalancingSpi(); + * + * // Configure SPI to used weighted + * // random load balancing. + * spi.setUseWeights(true); + * + * // Set weight for the local node. + * spi.setWeight( *); + * + * GridConfiguration cfg = new GridConfiguration(); + * + * // Override default load balancing SPI. + * cfg.setLoadBalancingSpi(spi); + * + * // Starts grid. + * G.start(cfg); + * </pre> + * Here is how you can configure {@code GridRandomLoadBalancingSpi} using Spring XML configuration: + * <pre name="code" class="xml"> + * <property name="loadBalancingSpi"> + * <bean class="org.gridgain.grid.spi.loadBalancing.weightedrandom.GridWeightedRandomLoadBalancingSpi"> + * <property name="useWeights" value="true"/> + * <property name="nodeWeight" value="10"/> + * </bean> + * </property> + * </pre> + * <p> + * <img src="http://www.gridgain.com/images/spring-small.png"> + * <br> + * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a> + */ +@IgniteSpiMultipleInstancesSupport(true) +@IgniteSpiConsistencyChecked(optional = true) +public class WeightedRandomLoadBalancingSpi extends IgniteSpiAdapter implements LoadBalancingSpi, + WeightedRandomLoadBalancingSpiMBean { + /** Random number generator. */ + private static final Random RAND = new Random(); + + /** + * Name of node attribute used to indicate load weight of a node + * (value is {@code "gridgain.node.weight.attr.name"}). + * + * @see org.apache.ignite.cluster.ClusterNode#attributes() + */ + public static final String NODE_WEIGHT_ATTR_NAME = "gridgain.node.weight.attr.name"; + + /** Default weight assigned to every node if explicit one is not provided (value is {@code 10}). */ + public static final int DFLT_NODE_WEIGHT = 10; + + /** Grid logger. */ + @IgniteLoggerResource + private IgniteLogger log; + + /** */ + private boolean isUseWeights; + + /** Local event listener to listen to task completion events. */ + private GridLocalEventListener evtLsnr; + + /** Weight of this node. */ + private int nodeWeight = DFLT_NODE_WEIGHT; + + /** Task topologies. First pair value indicates whether or not jobs have been mapped. */ + private ConcurrentMap<IgniteUuid, IgniteBiTuple<Boolean, WeightedTopology>> taskTops = + new ConcurrentHashMap8<>(); + + /** + * Sets a flag to indicate whether node weights should be checked when + * doing random load balancing. Default value is {@code false} which + * means that node weights are disregarded for load balancing logic. + * + * @param isUseWeights If {@code true} then random load is distributed according + * to node weights. + */ + @IgniteSpiConfiguration(optional = true) + public void setUseWeights(boolean isUseWeights) { + this.isUseWeights = isUseWeights; + } + + /** {@inheritDoc} */ + @Override public boolean isUseWeights() { + return isUseWeights; + } + + /** + * Sets weight of this node. Nodes with more processing capacity + * should be assigned proportionally larger weight. Default value + * is {@link #DFLT_NODE_WEIGHT} and is equal for all nodes. + * + * @param nodeWeight Weight of this node. + */ + @IgniteSpiConfiguration(optional = true) + public void setNodeWeight(int nodeWeight) { + this.nodeWeight = nodeWeight; + } + + /** {@inheritDoc} */ + @Override public int getNodeWeight() { + return nodeWeight; + } + + /** {@inheritDoc} */ + @Override public Map<String, Object> getNodeAttributes() throws IgniteSpiException { + return F.<String, Object>asMap(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME), nodeWeight); + } + + /** {@inheritDoc} */ + @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException { + startStopwatch(); + + assertParameter(nodeWeight > 0, "nodeWeight > 0"); + + if (log.isDebugEnabled()) { + log.debug(configInfo("isUseWeights", isUseWeights)); + log.debug(configInfo("nodeWeight", nodeWeight)); + } + + registerMBean(gridName, this, WeightedRandomLoadBalancingSpiMBean.class); + + // Ack ok start. + if (log.isDebugEnabled()) + log.debug(startInfo()); + } + + /** {@inheritDoc} */ + @Override public void spiStop() throws IgniteSpiException { + unregisterMBean(); + + // Ack ok stop. + if (log.isDebugEnabled()) + log.debug(stopInfo()); + } + + /** {@inheritDoc} */ + @Override protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException { + getSpiContext().addLocalEventListener(evtLsnr = new GridLocalEventListener() { + @Override public void onEvent(IgniteEvent evt) { + assert evt instanceof IgniteTaskEvent || evt instanceof IgniteJobEvent; + + if (evt.type() == EVT_TASK_FINISHED || + evt.type() == EVT_TASK_FAILED) { + IgniteUuid sesId = ((IgniteTaskEvent)evt).taskSessionId(); + + taskTops.remove(sesId); + + if (log.isDebugEnabled()) + log.debug("Removed task topology from topology cache for session: " + sesId); + } + // We should keep topology and use cache in GridComputeTask#map() method to + // avoid O(n*n/2) complexity, after that we can drop caches. + // Here we set mapped property and later cache will be ignored + else if (evt.type() == EVT_JOB_MAPPED) { + IgniteUuid sesId = ((IgniteJobEvent)evt).taskSessionId(); + + IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(sesId); + + if (weightedTop != null) + weightedTop.set1(true); + + if (log.isDebugEnabled()) + log.debug("Job has been mapped. Ignore cache for session: " + sesId); + } + } + }, + EVT_TASK_FAILED, + EVT_TASK_FINISHED, + EVT_JOB_MAPPED + ); + } + + /** {@inheritDoc} */ + @Override protected void onContextDestroyed0() { + if (evtLsnr != null) { + IgniteSpiContext ctx = getSpiContext(); + + if (ctx != null) + ctx.removeLocalEventListener(evtLsnr); + } + } + + /** {@inheritDoc} */ + @Override public ClusterNode getBalancedNode(ComputeTaskSession ses, List<ClusterNode> top, ComputeJob job) { + A.notNull(ses, "ses"); + A.notNull(top, "top"); + A.notNull(job, "job"); + + // Optimization for non-weighted randomization. + if (!isUseWeights) + return top.get(RAND.nextInt(top.size())); + + IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(ses.getId()); + + // Create new cached topology if there is no one. Do not + // use cached topology after task has been mapped. + if (weightedTop == null) { + // Called from GridComputeTask#map(). Put new topology and false as not mapped yet. + taskTops.put(ses.getId(), weightedTop = F.t(false, new WeightedTopology(top))); + } + // We have topology - check if task has been mapped. + else if (weightedTop.get1()) { + // Do not use cache after GridComputeTask#map(). + return new WeightedTopology(top).pickWeightedNode(); + } + + return weightedTop.get2().pickWeightedNode(); + } + + /** + * @param node Node to get weight for. + * @return Node weight + */ + private int getWeight(ClusterNode node) { + Integer weight = (Integer)node.attribute(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME)); + + if (weight != null && weight == 0) + throw new IllegalStateException("Node weight cannot be zero: " + node); + + return weight == null ? DFLT_NODE_WEIGHT : weight; + } + + /** + * Holder for weighted topology. + */ + private class WeightedTopology { + /** Total topology weight. */ + private final int totalWeight; + + /** Topology sorted by weight. */ + private final SortedMap<Integer, ClusterNode> circle = new TreeMap<>(); + + /** + * @param top Topology. + */ + WeightedTopology(Collection<ClusterNode> top) { + assert !F.isEmpty(top); + + int totalWeight = 0; + + for (ClusterNode node : top) { + totalWeight += getWeight(node); + + // Complexity of this put is O(logN). + circle.put(totalWeight, node); + } + + this.totalWeight = totalWeight; + } + + /** + * Gets weighted node in random fashion. + * + * @return Weighted node. + */ + ClusterNode pickWeightedNode() { + int weight = RAND.nextInt(totalWeight) + 1; + + SortedMap<Integer, ClusterNode> pick = circle.tailMap(weight); + + assert !pick.isEmpty(); + + return pick.get(pick.firstKey()); + } + } + + /** {@inheritDoc} */ + @Override protected List<String> getConsistentAttributeNames() { + return Collections.singletonList(createSpiAttributeName(NODE_WEIGHT_ATTR_NAME)); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(WeightedRandomLoadBalancingSpi.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpiMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpiMBean.java b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpiMBean.java new file mode 100644 index 0000000..c4daa9e --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/WeightedRandomLoadBalancingSpiMBean.java @@ -0,0 +1,37 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.loadbalancing.weightedrandom; + +import org.apache.ignite.mbean.*; +import org.apache.ignite.spi.*; + +/** + * Management MBean for {@link WeightedRandomLoadBalancingSpi} SPI. + */ +@IgniteMBeanDescription("MBean that provides access to weighted random load balancing SPI configuration.") +public interface WeightedRandomLoadBalancingSpiMBean extends IgniteSpiManagementMBean { + /** + * Checks whether node weights are considered when doing + * random load balancing. + * + * @return If {@code true} then random load is distributed according + * to node weights. + */ + @IgniteMBeanDescription("Whether node weights are considered when doing random load balancing.") + public boolean isUseWeights(); + + /** + * Gets weight of this node. + * + * @return Weight of this node. + */ + @IgniteMBeanDescription("Weight of this node.") + public int getNodeWeight(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/config/io-manager-benchmark.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/io-manager-benchmark.xml b/modules/core/src/test/config/io-manager-benchmark.xml index 67e2b37..01dc6e2 100644 --- a/modules/core/src/test/config/io-manager-benchmark.xml +++ b/modules/core/src/test/config/io-manager-benchmark.xml @@ -50,7 +50,7 @@ <!-- Configure load balancing SPI in the way that do not require extra event subscription. --> <property name="loadBalancingSpi"> - <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinLoadBalancingSpi"> + <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi"> <property name="perTask" value="false"/> </bean> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/config/jobs-load-base.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/jobs-load-base.xml b/modules/core/src/test/config/jobs-load-base.xml index d61356d..97325a2 100644 --- a/modules/core/src/test/config/jobs-load-base.xml +++ b/modules/core/src/test/config/jobs-load-base.xml @@ -97,7 +97,7 @@ </property> <property name="loadBalancingSpi"> - <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinLoadBalancingSpi"> + <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi"> <property name="perTask" value="false"/> </bean> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/config/load/merge-sort-base.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/load/merge-sort-base.xml b/modules/core/src/test/config/load/merge-sort-base.xml index 11a3166..e2293f6 100644 --- a/modules/core/src/test/config/load/merge-sort-base.xml +++ b/modules/core/src/test/config/load/merge-sort-base.xml @@ -128,7 +128,7 @@ </property> <property name="loadBalancingSpi"> - <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinLoadBalancingSpi"> + <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi"> <property name="perTask" value="false"/> </bean> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/config/spring-cache-put-remove-load.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/spring-cache-put-remove-load.xml b/modules/core/src/test/config/spring-cache-put-remove-load.xml index 103f519..052da54 100644 --- a/modules/core/src/test/config/spring-cache-put-remove-load.xml +++ b/modules/core/src/test/config/spring-cache-put-remove-load.xml @@ -42,7 +42,7 @@ </property> <property name="loadBalancingSpi"> - <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinLoadBalancingSpi"> + <bean class="org.gridgain.grid.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi"> <property name="perTask" value="false"/> </bean> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/kernal/GridMultipleSpisSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridMultipleSpisSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridMultipleSpisSelfTest.java index 33b1086..ba5e3b0 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridMultipleSpisSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/GridMultipleSpisSelfTest.java @@ -153,7 +153,7 @@ public class GridMultipleSpisSelfTest extends GridCommonAbstractTest { } /** */ - private class GridTestLoadBalancingSpi extends GridRoundRobinLoadBalancingSpi { + private class GridTestLoadBalancingSpi extends RoundRobinLoadBalancingSpi { /** */ private String expName; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/kernal/managers/GridManagerStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/managers/GridManagerStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/managers/GridManagerStopSelfTest.java index 1776054..d682e4e 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/managers/GridManagerStopSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/managers/GridManagerStopSelfTest.java @@ -187,7 +187,7 @@ public class GridManagerStopSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testStopLoadBalancingManager() throws Exception { - GridRoundRobinLoadBalancingSpi spi = new GridRoundRobinLoadBalancingSpi(); + RoundRobinLoadBalancingSpi spi = new RoundRobinLoadBalancingSpi(); injectLogger(spi); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java index 210c4df..8e080e8 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java @@ -14,13 +14,13 @@ import org.gridgain.testframework.junits.spi.*; /** * */ -@GridSpiTest(spi = GridAdaptiveLoadBalancingSpi.class, group = "LoadBalancing SPI") +@GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "LoadBalancing SPI") public class GridAdaptiveLoadBalancingSpiConfigSelfTest - extends GridSpiAbstractConfigTest<GridAdaptiveLoadBalancingSpi> { + extends GridSpiAbstractConfigTest<AdaptiveLoadBalancingSpi> { /** * @throws Exception If failed. */ public void testNegativeConfig() throws Exception { - checkNegativeSpiProperty(new GridAdaptiveLoadBalancingSpi(), "loadProbe", null); + checkNegativeSpiProperty(new AdaptiveLoadBalancingSpi(), "loadProbe", null); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java index fb9d3ff..33e1a18 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java @@ -19,8 +19,8 @@ import java.util.*; /** * Tests adaptive load balancing SPI. */ -@GridSpiTest(spi = GridAdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") -public class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest extends GridSpiAbstractTest<GridAdaptiveLoadBalancingSpi> { +@GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") +public class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest extends GridSpiAbstractTest<AdaptiveLoadBalancingSpi> { /** */ private static final int RMT_NODE_CNT = 10; @@ -43,8 +43,8 @@ public class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest extends GridSpiAbs * @return {@code True} if node weights should be considered. */ @GridSpiTestConfig - public GridAdaptiveLoadProbe getLoadProbe() { - return new GridAdaptiveLoadProbe() { + public AdaptiveLoadProbe getLoadProbe() { + return new AdaptiveLoadProbe() { @Override public double getLoad(ClusterNode node, int jobsSentSinceLastUpdate) { boolean isFirstTime = node.attribute("used") == null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java index b3e7ded..8a3a2c5 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java @@ -21,8 +21,8 @@ import java.util.*; /** * Tests adaptive load balancing SPI. */ -@GridSpiTest(spi = GridAdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") -public class GridAdaptiveLoadBalancingSpiSelfTest extends GridSpiAbstractTest<GridAdaptiveLoadBalancingSpi> { +@GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") +public class GridAdaptiveLoadBalancingSpiSelfTest extends GridSpiAbstractTest<AdaptiveLoadBalancingSpi> { /** {@inheritDoc} */ @Override protected GridSpiTestContext initSpiContext() throws Exception { GridSpiTestContext ctx = super.initSpiContext(); @@ -36,8 +36,8 @@ public class GridAdaptiveLoadBalancingSpiSelfTest extends GridSpiAbstractTest<Gr * @return {@code True} if node weights should be considered. */ @GridSpiTestConfig - public GridAdaptiveLoadProbe getLoadProbe() { - return new GridAdaptiveLoadProbe() { + public AdaptiveLoadProbe getLoadProbe() { + return new AdaptiveLoadProbe() { @Override public double getLoad(ClusterNode node, int jobsSentSinceLastUpdate) { boolean isFirstTime = node.attribute("used") == null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java index 5ffa8f8..19876e7 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java @@ -16,8 +16,8 @@ import org.gridgain.testframework.junits.spi.*; * Adaptive load balancing SPI start-stop test. */ @SuppressWarnings({"JUnitTestCaseWithNoTests"}) -@GridSpiTest(spi = GridAdaptiveLoadBalancingSpi.class, group = "LoadBalancing SPI") +@GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "LoadBalancing SPI") public class GridAdaptiveLoadBalancingSpiStartStopSelfTest extends - GridSpiStartStopAbstractTest<GridAdaptiveLoadBalancingSpi> { + GridSpiStartStopAbstractTest<AdaptiveLoadBalancingSpi> { // No configs. } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java index 908dff3..ff420e7 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.*; /** * Multithreaded tests for global load balancer. */ -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest - extends GridSpiAbstractTest<GridRoundRobinLoadBalancingSpi> { + extends GridSpiAbstractTest<RoundRobinLoadBalancingSpi> { /** Thread count. */ public static final int THREAD_CNT = 8; @@ -60,7 +60,7 @@ public class GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest * @throws Exception If failed. */ public void testMultipleTaskSessionsMultithreaded() throws Exception { - final GridRoundRobinLoadBalancingSpi spi = getSpi(); + final RoundRobinLoadBalancingSpi spi = getSpi(); final List<ClusterNode> allNodes = (List<ClusterNode>)getSpiContext().nodes(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java index 12f1174..ab992cf 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java @@ -18,9 +18,9 @@ import java.util.*; /** * Tests Round Robin load balancing for single node. */ -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI", triggerDiscovery = true) +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI", triggerDiscovery = true) public class GridRoundRobinLoadBalancingSpiLocalNodeSelfTest extends - GridSpiAbstractTest<GridRoundRobinLoadBalancingSpi> { + GridSpiAbstractTest<RoundRobinLoadBalancingSpi> { /** * @throws Exception If failed. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java index 4651db0..0ab487f 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java @@ -24,11 +24,11 @@ import static org.apache.ignite.events.IgniteEventType.*; /** * Tests round robin load balancing SPI. */ -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest - extends GridSpiAbstractTest<GridRoundRobinLoadBalancingSpi> { + extends GridSpiAbstractTest<RoundRobinLoadBalancingSpi> { /** {@inheritDoc} */ - @Override protected void spiConfigure(GridRoundRobinLoadBalancingSpi spi) throws Exception { + @Override protected void spiConfigure(RoundRobinLoadBalancingSpi spi) throws Exception { super.spiConfigure(spi); spi.setPerTask(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java index 5e887b0..2d11283 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java @@ -25,9 +25,9 @@ import static org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinTestU /** * Tests round robin load balancing. */ -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest - extends GridSpiAbstractTest<GridRoundRobinLoadBalancingSpi> { + extends GridSpiAbstractTest<RoundRobinLoadBalancingSpi> { /** * @return Per-task configuration parameter. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java index aefb445..bc8baf8 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java @@ -13,11 +13,11 @@ import org.gridgain.grid.spi.*; import org.gridgain.testframework.junits.spi.*; /** - * Tests correct start of {@link GridRoundRobinLoadBalancingSpi}. + * Tests correct start of {@link RoundRobinLoadBalancingSpi}. */ @SuppressWarnings({"JUnitTestCaseWithNoTests"}) -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "LoadBalancing SPI") +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "LoadBalancing SPI") public class GridRoundRobinLoadBalancingSpiStartStopSelfTest - extends GridSpiStartStopAbstractTest<GridRoundRobinLoadBalancingSpi> { + extends GridSpiStartStopAbstractTest<RoundRobinLoadBalancingSpi> { // No configs. } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java index 589e1e6..54d9d49 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java @@ -23,9 +23,9 @@ import static org.gridgain.grid.spi.loadbalancing.roundrobin.GridRoundRobinTestU /** * Tests round robin load balancing with topology changes. */ -@GridSpiTest(spi = GridRoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest - extends GridSpiAbstractTest<GridRoundRobinLoadBalancingSpi> { + extends GridSpiAbstractTest<RoundRobinLoadBalancingSpi> { /** * @return Per-task configuration parameter. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinTestUtils.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinTestUtils.java index c9ce5ab..71b7744 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinTestUtils.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/roundrobin/GridRoundRobinTestUtils.java @@ -30,7 +30,7 @@ class GridRoundRobinTestUtils { * @param ses Task session. * @throws GridException If balancer failed. */ - static void checkCyclicBalancing(GridRoundRobinLoadBalancingSpi spi, List<ClusterNode> allNodes, + static void checkCyclicBalancing(RoundRobinLoadBalancingSpi spi, List<ClusterNode> allNodes, List<UUID> orderedNodes, ComputeTaskSession ses) throws GridException { ClusterNode firstNode = spi.getBalancedNode(ses, allNodes, new GridTestJob()); @@ -58,7 +58,7 @@ class GridRoundRobinTestUtils { * @param ses2 Second task session. * @throws GridException If balancer failed. */ - static void checkCyclicBalancing(GridRoundRobinLoadBalancingSpi spi, List<ClusterNode> allNodes, + static void checkCyclicBalancing(RoundRobinLoadBalancingSpi spi, List<ClusterNode> allNodes, List<UUID> orderedNodes, ComputeTaskSession ses1, ComputeTaskSession ses2) throws GridException { ClusterNode firstNode = spi.getBalancedNode(ses1, allNodes, new GridTestJob()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java index a291f3f..40e24f3 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java @@ -14,13 +14,13 @@ import org.gridgain.testframework.junits.spi.*; /** * */ -@GridSpiTest(spi = GridWeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridWeightedRandomLoadBalancingSpiConfigSelfTest extends - GridSpiAbstractConfigTest<GridWeightedRandomLoadBalancingSpi> { + GridSpiAbstractConfigTest<WeightedRandomLoadBalancingSpi> { /** * @throws Exception If failed. */ public void testNegativeConfig() throws Exception { - checkNegativeSpiProperty(new GridWeightedRandomLoadBalancingSpi(), "nodeWeight", 0); + checkNegativeSpiProperty(new WeightedRandomLoadBalancingSpi(), "nodeWeight", 0); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java index 771ceaf..efc21ed 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java @@ -18,9 +18,9 @@ import java.util.*; /** * Weighted random load balancing SPI. */ -@GridSpiTest(spi = GridWeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridWeightedRandomLoadBalancingSpiSelfTest extends - GridSpiAbstractTest<GridWeightedRandomLoadBalancingSpi> { + GridSpiAbstractTest<WeightedRandomLoadBalancingSpi> { /** * @throws Exception If failed. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java index daee18e..4c9b352 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java @@ -16,8 +16,8 @@ import org.gridgain.testframework.junits.spi.*; * Wighted random load balancing SPI start-stop test. */ @SuppressWarnings({"JUnitTestCaseWithNoTests"}) -@GridSpiTest(spi = GridWeightedRandomLoadBalancingSpi.class, group = "LoadBalancing SPI") +@GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "LoadBalancing SPI") public class GridWeightedRandomLoadBalancingSpiStartStopSelfTest extends - GridSpiStartStopAbstractTest<GridWeightedRandomLoadBalancingSpi> { + GridSpiStartStopAbstractTest<WeightedRandomLoadBalancingSpi> { // No configs. } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a62862fe/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java index effca68..289be66 100644 --- a/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java @@ -17,14 +17,14 @@ import org.gridgain.testframework.*; import org.gridgain.testframework.junits.spi.*; import java.util.*; -import static org.gridgain.grid.spi.loadbalancing.weightedrandom.GridWeightedRandomLoadBalancingSpi.*; +import static org.gridgain.grid.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi.*; /** - * {@link GridWeightedRandomLoadBalancingSpi} self test. + * {@link WeightedRandomLoadBalancingSpi} self test. */ -@GridSpiTest(spi = GridWeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") public class GridWeightedRandomLoadBalancingSpiWeightedSelfTest - extends GridSpiAbstractTest<GridWeightedRandomLoadBalancingSpi> { + extends GridSpiAbstractTest<WeightedRandomLoadBalancingSpi> { /** * @return {@code True} if node weights should be considered. */