Resize Images with Grid-Enabled ExecutorService Example.
This example demonstrates how GridGain ExecutorService may be used to convert images.
This example scales and converts images on the grid using JDK encoders.
Every submitted command GridExecutorImageScaleCommand will be transfered to any remote node for execution and will return result (converted image data). Make sure that Grid property peerClassLoadingEnabled initialized as true because command will load resources for processing from classpath via P2P class loader.
Executor service executes its own GridTask ![]()
![]()
![]()
GridExecutorImageScaleCommand loads image from classpath with P2P class loader from origin node and returns result encapsulated in GridExecutorImage object. By default all converted images will be saved on nodes (involved in processing) in folder on local hard drive defined by "java.io.tmpdir" system property.
You can find this example at ${GRIDGAIN_HOME}/examples/java folder in package org.gridgain.examples.executor. Source code is fully Javadoc-ed and you can find the examples' Javadoc at ${GRIDGAIN_HOME}/examples/javadoc folder.
Package:
org.gridgain.examples.executor
| Class | Description |
|---|---|
| GridExecutorExample.java | This is main class in this example. It basically starts grid locally (local node) and executes Callable commands to scale images. |
| GridExecutorImageScaleCommand.java | This class represents all the logic necessary to scale selected image. |
| GridExecutorImage.java | It is a simple convenience bean with encapsulated image data. |
Running Grid Node
This example may be used with one or more remote nodes. Note that you don't need another machine for it - you can start remote node on the same machine you are running example on.
To start a remote node open the terminal window on Linux/Mac OS X or Command Prompt on Windows, change directory to ${GRIDGAIN_HOME}/bin and run the gridgain.{sh|bat} script. It takes 2-3 seconds for grid node to start and if everything worked fine you should see starting log ending with successful start acknowledgment.
