changes.
| | * [#Package] |
| | * [#Built-in Implementations] |
| | * [#Description] |
| | ** [#Peer Class Loading] |
| | * [#Configuration] |
| | ** [#Default Implementation] |
| | |
| | {javadocnote} |
| | |
| | h2. Package |
| | {image:spi_deployment.png} *org.gridgain.grid.spi.deployment* {javadoc:spi/deployment/package-summary.html} |
| | |
| | h2. Built-in Implementations |
| | Gridgain comes with two deployment SPI's supported out of the box |
| | {children:excerpt=true} |
| | |
| | h2. Description |
| | Grid deployment SPI is in charge of deploying/undeploying tasks from different sources. |
| | |
| | Grid task can be deployed directly by calling {{GridDeploymentSpi.deployTask(GridDeploymentTask)}} {javadoc:spi/deployment/GridDeploymentSpi.html#deployTask(org.gridgain.grid.spi.deployment.GridDeploymentTask)} method or by SPI itself, for example by asynchronously scanning some folder for new tasks. Another way is a task auto-deployment when task class is picked up from the local class path by task name. Note that directly deployed tasks has a priority over auto-deployed. |
| | Whenever task is locally deployed through public API via {{Grid.deployTask(Class<? extends GridTask<?>>)}} {javadoc:Grid.html#deployTask(java.lang.Class)} or {{Grid.deployTask(Class<? extends GridTask<?>>, ClassLoader)}} {javadoc:Grid.html#deployTask(java.lang.Class, java.lang,ClassLoader)} methods, the system will call {{GridDeploymentSpi.deployTask(GridDeploymentTask)}} {javadoc:spi/deployment/GridDeploymentSpi.html#deployTask(org.gridgain.grid.spi.deployment.GridDeploymentTask)} method on the Deployment SPI automatically. If peer-class-loading is enabled ({{GridConfiguration.isPeerClassLoadingEnabled()}} {javadoc:GridConfiguration.html#isPeerClassLoadingEnabled()}), this task will be automatically deployed on other nodes. |
| | |
| | When method {{GridDeploymentSpi.findTask(String)}} {javadoc:spi/deployment/GridDeploymentSpi.html#findTask(java.lang.String)} is called by the system, SPI must return a locally deployed task class. Every time a task gets redeployed or released via {{GridDeploymentSpi.undeployTask(String)}} {javadoc:spi/deployment/GridDeploymentSpi.html#undeployTask(java.lang.String)} method, callback {{GridDeploymentListener.onTaskReleased(GridDeploymentTask)}} {javadoc:spi/deployment/GridDeploymentListener.html#onTaskReleased(org.gridgain.grid.spi.deployment.GridDeploymentTask)} must be called by SPI. |
| | |
| | h3. Peer Class Loading |
| |  | If peer class loading is enabled (which is default behavior, see {{GridConfiguration.isPeerClassLoadingEnabled()}} {javadoc:GridConfiguration.html#isPeerClassLoadingEnabled()}) in [Configuring GridGain], then it is enough to deploy a task only on one grid node. Once a task starts executing on the grid, all other nodes will automatically load all task classes from the node that initiated the execution. Hot redeployment is also supported with peer class loading. Every time a task gets redeployed on a node, all other nodes will detect it and will redeploy this task as well. |
| | | If peer class loading is enabled (which is default behavior, see {{GridConfiguration.isPeerClassLoadingEnabled()}} {javadoc:GridConfiguration.html#isPeerClassLoadingEnabled()}) in [Grid Configuration], then it is enough to deploy a task only on one grid node. Once a task starts executing on the grid, all other nodes will automatically load all task classes from the node that initiated the execution. Hot redeployment is also supported with peer class loading. Every time a task gets redeployed on a node, all other nodes will detect it and will redeploy this task as well. |
| | {info:title=Local vs. Peer Deployment} |
| | Note that peer class loading comes into effect only if a task was not locally deployed, otherwise, preference will always be given to a locally deployed task or task class from the local class path. |
| | {info} |
| | |
| | h2. Configuration |
 | | {{GridDeploymentSpi}} is provided in [Configuring GridGain] passed into {{GridFactory}} {javadoc:GridFactory.html} at startup. You can configure a different collision SPI implementation as follows |
| | | {{GridDeploymentSpi}} is provided in [Grid Configuration] passed into {{GridFactory}} {javadoc:GridFactory.html} at startup. You can configure a different collision SPI implementation as follows |
| | |
| | {code} |
| | GridConfigurationAdapter cfg = new GridConfigurationAdapter(); |
| | |
| | GridUriDeploymentSpi deploySpi = new GridUriDeploymentSpi(); |
| | |
| | // Configure your own deployment folder for URI deployment. |
| | deploySpi.setUriList(Collections.singletonList("file:///my/deployment/folder"); |
| | |
| | cfg.setDeploymentSpi(deploySpi); |
| | |
| | GridFactory.start(cfg); |
| | {code} |
| | |
| | Note that {{GridConfiguration}} {javadoc:GridConfiguration.html} interface is just a bean and can also be configured using spring XML configuration. |
| | |
| | {spring} |
| | h3. Default Implementation |
| | [GridLocalDeploymentSpi] is used by default, if no deployment SPI was explicitely provided in grid configuration. |
| | |
| | !http://www.gridgain.com/javadoc/org/gridgain/grid/spi/deployment/GridDeploymentSpiW0H0.gif!!http://www.gridgain.com/javadoc/org/gridgain/grid/spi/deployment/GridDeploymentSpiW1H0.gif! |