| // Licensed to the Apache Software Foundation (ASF) under one or more |
| // contributor license agreements. See the NOTICE file distributed with |
| // this work for additional information regarding copyright ownership. |
| // The ASF licenses this file to You under the Apache License, Version 2.0 |
| // (the "License"); you may not use this file except in compliance with |
| // the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| = Job Scheduling |
| |
| :javaFile: {javaCodeDir}/JobScheduling.java |
| |
| When jobs arrive at the destination node, they are submitted to a thread pool and scheduled for execution in random order. |
| However, you can change job ordering by configuring `CollisionSpi`. |
| The `CollisionSpi` interface provides a way to control how jobs are scheduled for processing on each node. |
| |
| Ignite provides several implementations of the `CollisionSpi` interface: |
| |
| - `FifoQueueCollisionSpi` — simple FIFO ordering in multiple threads. This implementation is used by default; |
| - `PriorityQueueCollisionSpi` — priority ordering; |
| - `JobStealingFailoverSpi` — use this implementation to enable link:distributed-computing/load-balancing#job-stealing[job stealing]. |
| |
| To enable a specific collision spi, change the `IgniteConfiguration.collisionSpi` property. |
| |
| == FIFO Ordering |
| |
| `FifoQueueCollisionSpi` provides FIFO ordering of jobs as they arrive. The jobs are executed in multiple threads. The number of threads is controlled by the `parallelJobsNumber` parameter. The default value equals 2 times the number of processor cores. |
| |
| [tabs] |
| -- |
| tab:XML[] |
| [source,xml] |
| ---- |
| include::code-snippets/xml/job-scheduling-fifo.xml[tags=ignite-config;!discovery, indent=0] |
| ---- |
| tab:Java[] |
| [source,java] |
| ---- |
| include::{javaFile}[tag=fifo,indent=0] |
| ---- |
| tab:C#/.NET[unsupported] |
| -- |
| |
| |
| == Priority Ordering |
| |
| Use `PriorityQueueCollisionSpi` to assign priorities to individual jobs, so that jobs with higher priority are executed ahead of lower priority jobs. You can also specify the number of threads to process jobs. |
| |
| [tabs] |
| -- |
| tab:XML[] |
| [source,xml] |
| ---- |
| include::code-snippets/xml/job-scheduling-priority.xml[tags=ignite-config;!discovery, indent=0] |
| ---- |
| tab:Java[] |
| [source,java] |
| ---- |
| include::{javaFile}[tag=priority,indent=0] |
| ---- |
| tab:C#/.NET[unsupported] |
| tab:C++[unsupported] |
| -- |
| |
| Task priorities are set in the link:distributed-computing/map-reduce#distributed-task-session[task session] via the `grid.task.priority` attribute. If no priority is assigned to a task, then the default priority of 0 is used. |
| |
| |
| [source, java] |
| ---- |
| include::{javaFile}[tag=task-priority,indent=0] |
| ---- |
| |