public class IgnitionEx extends Object
org.apache.ignite.startup
package, for example:
CommandLineStartup
ServletStartup
start()
method to start grid with default configuration. You can also use
IgniteConfiguration
to override some default configuration. Below is an
example on how to start grid with URI deployment.
GridConfiguration cfg = new GridConfiguration();
Modifier and Type | Field and Description |
---|---|
static String |
DFLT_CFG
Default configuration path relative to Ignite home.
|
Modifier and Type | Method and Description |
---|---|
static void |
addListener(IgnitionListener lsnr)
Adds a lsnr for grid life cycle events.
|
static List<Ignite> |
allGrids()
Gets a list of all grids started so far.
|
static List<Ignite> |
allGridsx()
Gets a list of all grids started so far.
|
static T2<Ignite,Boolean> |
getOrStart(IgniteConfiguration cfg)
Gets or starts new grid instance if it hasn't been started yet.
|
static Ignite |
grid()
Gets an instance of default no-name grid.
|
static Ignite |
grid(String name)
Gets an named grid instance.
|
static Ignite |
grid(UUID locNodeId)
Gets a grid instance for given local node ID.
|
static IgniteKernal |
gridx(String name)
Gets grid instance without waiting its initialization.
|
static IgniteKernal |
gridxx(UUID locNodeId)
Gets grid instance without waiting its initialization and not throwing any exception.
|
static boolean |
isClientMode()
Gets client mode flag.
|
static boolean |
isDaemon()
Gets daemon flag.
|
static void |
kill(boolean cancel)
Stops all started grids.
|
static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> |
loadConfiguration(String springCfgPath)
Loads first found grid configuration specified within given Spring XML configuration file.
|
static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> |
loadConfiguration(URL springCfgUrl)
Loads first found grid configuration specified within given Spring XML configuration file.
|
static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> |
loadConfigurations(InputStream springCfgStream)
Loads all grid configurations specified within given input stream.
|
static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> |
loadConfigurations(String springCfgPath)
Loads all grid configurations specified within given Spring XML configuration file.
|
static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> |
loadConfigurations(URL springCfgUrl)
Loads all grid configurations specified within given Spring XML configuration file.
|
static <T> T |
loadSpringBean(InputStream springXmlStream,
String beanName)
Loads spring bean by name.
|
static <T> T |
loadSpringBean(String springXmlPath,
String beanName)
Loads spring bean by name.
|
static <T> T |
loadSpringBean(URL springXmlUrl,
String beanName)
Loads spring bean by name.
|
static IgniteKernal |
localIgnite()
Gets a name of the grid from thread local config, which is owner of current thread.
|
static boolean |
removeListener(IgnitionListener lsnr)
Removes lsnr added by
addListener(IgnitionListener) method. |
static void |
restart(boolean cancel)
Restarts all started grids.
|
static void |
setClientMode(boolean clientMode)
Sets client mode flag.
|
static void |
setDaemon(boolean daemon)
Sets daemon flag.
|
static Ignite |
start()
Starts grid with default configuration.
|
static Ignite |
start(GridSpringResourceContext springCtx)
Starts grid with default configuration.
|
static Ignite |
start(IgniteConfiguration cfg)
Starts grid with given configuration.
|
static Ignite |
start(IgniteConfiguration cfg,
boolean failIfStarted)
Starts a grid with given configuration.
|
static Ignite |
start(IgniteConfiguration cfg,
GridSpringResourceContext springCtx)
Starts grid with given configuration.
|
static T2<Ignite,Boolean> |
start(IgniteConfiguration cfg,
GridSpringResourceContext springCtx,
boolean failIfStarted)
Starts grid with given configuration.
|
static Ignite |
start(InputStream springCfgStream)
Starts all grids specified within given Spring XML configuration input stream.
|
static Ignite |
start(InputStream springCfgStream,
String igniteInstanceName,
GridSpringResourceContext springCtx,
ClassLoader ldr)
Starts all grids specified within given Spring XML configuration input stream.
|
static Ignite |
start(String springCfgPath)
Starts all grids specified within given Spring XML configuration file.
|
static Ignite |
start(String springCfgPath,
String igniteInstanceName)
Starts all grids specified within given Spring XML configuration file.
|
static Ignite |
start(String springCfgPath,
String igniteInstanceName,
GridSpringResourceContext springCtx,
ClassLoader ldr)
Starts all grids specified within given Spring XML configuration file.
|
static Ignite |
start(URL springCfgUrl)
Starts all grids specified within given Spring XML configuration file URL.
|
static Ignite |
start(URL springCfgUrl,
ClassLoader ldr)
Starts all grids specified within given Spring XML configuration file URL.
|
static Ignite |
start(URL springCfgUrl,
String igniteInstanceName,
GridSpringResourceContext springCtx,
ClassLoader ldr)
Starts all grids specified within given Spring XML configuration file URL.
|
static IgniteState |
state()
Gets state of grid default grid.
|
static IgniteState |
state(String name)
Gets states of named Ignite instance.
|
static boolean |
stop(boolean cancel)
Stops default grid.
|
static boolean |
stop(String name,
boolean cancel,
boolean stopNotStarted)
Stops named Ignite instance.
|
static void |
stopAll(boolean cancel)
Stops all started grids.
|
public static final String DFLT_CFG
public static void setDaemon(boolean daemon)
If daemon flag is set then all grid instances created by the factory will be
daemon, i.e. the local node for these instances will be a daemon node. Note that
if daemon flag is set - it will override the same settings in IgniteConfiguration.isDaemon()
.
Note that you can set on and off daemon flag at will.
daemon
- Daemon flag to set.public static boolean isDaemon()
If daemon flag it set then all grid instances created by the factory will be
daemon, i.e. the local node for these instances will be a daemon node. Note that
if daemon flag is set - it will override the same settings in IgniteConfiguration.isDaemon()
.
Note that you can set on and off daemon flag at will.
public static void setClientMode(boolean clientMode)
clientMode
- Client mode flag.public static boolean isClientMode()
public static IgniteState state()
public static IgniteState state(@Nullable String name)
null
, then state of
default no-name Ignite instance is returned.name
- Ignite instance name. If name is null
, then state of
default no-name Ignite instance is returned.public static boolean stop(boolean cancel)
G.stop(null, cancel)
apply.
Note that method does not wait for all tasks to be completed.cancel
- If true
then all jobs currently executing on
default grid will be cancelled by calling ComputeJob.cancel()
method. Note that just like with Thread.interrupt()
, it is
up to the actual job to exit from executiontrue
if default grid instance was indeed stopped,
false
otherwise (if it was not started).public static boolean stop(@Nullable String name, boolean cancel, boolean stopNotStarted)
cancel
flag is set to true
then
all jobs currently executing on local node will be interrupted. If
Ignite instance name is null
, then default no-name Ignite instance will be stopped.
If wait parameter is set to true
then Ignite instance will wait for all
tasks to be finished.name
- Ignite instance name. If null
, then default no-name
Ignite instance will be stopped.cancel
- If true
then all jobs currently will be cancelled
by calling ComputeJob.cancel()
method. Note that just like with
Thread.interrupt()
, it is up to the actual job to exit from
execution. If false
, then jobs currently running will not be
canceled. In either case, grid node will wait for completion of all
jobs running on it before stopping.stopNotStarted
- If true
and node start did not finish then interrupts starting thread.true
if named Ignite instance was indeed found and stopped,
false
otherwise (the instance with given name
was
not found).public static void stopAll(boolean cancel)
cancel
flag is set to true
then
all jobs currently executing on local node will be interrupted.
If wait parameter is set to true
then grid will wait for all
tasks to be finished.
Note: it is usually safer and more appropriate to stop grid instances individually instead of blanket operation. In most cases, the party that started the grid instance should be responsible for stopping it.
cancel
- If true
then all jobs currently executing on
all grids will be cancelled by calling ComputeJob.cancel()
method. Note that just like with Thread.interrupt()
, it is
up to the actual job to exit from executionpublic static void restart(boolean cancel)
cancel
flag is set to true
then
all jobs currently executing on the local node will be interrupted.
If wait
parameter is set to true
then grid will wait for all
tasks to be finished.
Note: it is usually safer and more appropriate to stop grid instances individually instead of blanket operation. In most cases, the party that started the grid instance should be responsible for stopping it.
Note also that restarting functionality only works with the tools that specifically support Ignite's protocol for restarting. Currently only standard ignite.{sh|bat} scripts support restarting of JVM Ignite's process.
cancel
- If true
then all jobs currently executing on
all grids will be cancelled by calling ComputeJob.cancel()
method. Note that just like with Thread.interrupt()
, it is
up to the actual job to exit from execution.Ignition.RESTART_EXIT_CODE
public static void kill(boolean cancel)
cancel
flag is set to true
then
all jobs currently executing on the local node will be interrupted.
If wait
parameter is set to true
then grid will wait for all
tasks to be finished.
Note: it is usually safer and more appropriate to stop grid instances individually instead of blanket operation. In most cases, the party that started the grid instance should be responsible for stopping it.
Note that upon completion of this method, the JVM with forcefully exist with
exit code Ignition.KILL_EXIT_CODE
.
cancel
- If true
then all jobs currently executing on
all grids will be cancelled by calling ComputeJob.cancel()
method. Note that just like with Thread.interrupt()
, it is
up to the actual job to exit from execution.Ignition.KILL_EXIT_CODE
public static Ignite start() throws IgniteCheckedException
IGNITE_HOME/config/default-config.xml
configuration file. If such file is not found, then all system defaults will be used.IgniteCheckedException
- If default grid could not be started. This exception will be thrown
also if default grid has already been started.public static Ignite start(@Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException
IGNITE_HOME/config/default-config.xml
configuration file. If such file is not found, then all system defaults will be used.springCtx
- Optional Spring application context, possibly null
.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.IgniteCheckedException
- If default grid could not be started. This exception will be thrown
also if default grid has already been started.public static Ignite start(IgniteConfiguration cfg) throws IgniteCheckedException
cfg
- Grid configuration. This cannot be null
.IgniteCheckedException
- If grid could not be started. This exception will be thrown
also if named grid has already been started.public static Ignite start(IgniteConfiguration cfg, boolean failIfStarted) throws IgniteCheckedException
cfg
- Grid configuration. This cannot be null
.
failIfStarted Throw or not an exception if grid is already started.failIfStarted
- When flag is true
and grid with specified name has been already started
the exception is thrown. Otherwise the existing instance of the grid is returned.IgniteCheckedException
- If grid could not be started. This exception will be thrown
also if named grid has already been started.public static T2<Ignite,Boolean> getOrStart(IgniteConfiguration cfg) throws IgniteException
cfg
- Grid configuration. This cannot be null
.true
. If an existing instance is returned
the flag is false
.IgniteException
- If grid could not be started.public static Ignite start(IgniteConfiguration cfg, @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException
cfg
- Grid configuration. This cannot be null
.springCtx
- Optional Spring application context, possibly null
.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.IgniteCheckedException
- If grid could not be started. This exception will be thrown
also if named grid has already been started.public static T2<Ignite,Boolean> start(IgniteConfiguration cfg, @Nullable GridSpringResourceContext springCtx, boolean failIfStarted) throws IgniteCheckedException
cfg
- Grid configuration. This cannot be null
.springCtx
- Optional Spring application context, possibly null
.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.failIfStarted
- Throw or not an exception if grid is already started.true
. If an existing instance is returned
the flag is false
.IgniteCheckedException
- If grid could not be started. This exception will be thrown
also if named grid has already been started.public static Ignite start(@Nullable String springCfgPath) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgPath
- Spring XML configuration file path or URL.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(@Nullable String springCfgPath, @Nullable String igniteInstanceName) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgPath
- Spring XML configuration file path or URL.igniteInstanceName
- Ignite instance name that will override default.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(URL springCfgUrl) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgUrl
- Spring XML configuration file path or URL. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(InputStream springCfgStream) throws IgniteCheckedException
Usually Spring XML input stream will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration input stream by type, so the name of the Grid configuration bean is ignored.
springCfgStream
- Input stream contained Spring XML configuration. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(String springCfgPath) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgPath
- Spring XML configuration file path. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> loadConfiguration(URL springCfgUrl) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgUrl
- Spring XML configuration file path or URL. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> loadConfiguration(String springCfgPath) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgPath
- Spring XML configuration file path. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(String springCfgPath, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgPath
- Spring XML configuration file path or URL. This cannot be null
.igniteInstanceName
- Ignite instance name that will override default.springCtx
- Optional Spring application context, possibly null
.ldr
- Optional class loader that will be used by default.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(URL springCfgUrl) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgUrl
- Spring XML configuration file URL. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(URL springCfgUrl, @Nullable ClassLoader ldr) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgUrl
- Spring XML configuration file URL. This cannot be null
.ldr
- Optional class loader that will be used by default.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(URL springCfgUrl, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr) throws IgniteCheckedException
Usually Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
springCfgUrl
- Spring XML configuration file URL. This cannot be null
.igniteInstanceName
- Ignite instance name that will override default.springCtx
- Optional Spring application context, possibly null
.ldr
- Optional class loader that will be used by default.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(InputStream springCfgStream) throws IgniteCheckedException
Usually Spring XML configuration input stream will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration input stream by type, so the name of the Grid configuration bean is ignored.
springCfgStream
- Input stream containing Spring XML configuration. This cannot be null
.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static Ignite start(InputStream springCfgStream, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr) throws IgniteCheckedException
Usually Spring XML configuration input stream will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration input stream by type, so the name of the Grid configuration bean is ignored.
springCfgStream
- Input stream containing Spring XML configuration. This cannot be null
.igniteInstanceName
- Ignite instance name that will override default.springCtx
- Optional Spring application context, possibly null
.ldr
- Optional class loader that will be used by default.
Spring bean definitions for bean injection are taken from this context.
If provided, this context can be injected into grid tasks and grid jobs using
@SpringApplicationContextResource
annotation.IgniteCheckedException
- If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.public static <T> T loadSpringBean(String springXmlPath, String beanName) throws IgniteCheckedException
springXmlPath
- Spring XML file path.beanName
- Bean name.IgniteCheckedException
- In case of error.public static <T> T loadSpringBean(URL springXmlUrl, String beanName) throws IgniteCheckedException
springXmlUrl
- Spring XML file URL.beanName
- Bean name.IgniteCheckedException
- In case of error.public static <T> T loadSpringBean(InputStream springXmlStream, String beanName) throws IgniteCheckedException
springXmlStream
- Input stream containing Spring XML configuration.beanName
- Bean name.IgniteCheckedException
- In case of error.public static Ignite grid() throws IgniteIllegalStateException
This method is identical to G.grid(null)
apply.
null
.IgniteIllegalStateException
- Thrown if default grid was not properly
initialized or grid instance was stopped or was not started.public static List<Ignite> allGrids()
public static List<Ignite> allGridsx()
public static Ignite grid(UUID locNodeId) throws IgniteIllegalStateException
locNodeId
- ID of local node the requested grid instance is managing.null
.IgniteIllegalStateException
- Thrown if grid was not properly
initialized or grid instance was stopped or was not started.public static IgniteKernal gridxx(UUID locNodeId)
locNodeId
- ID of local node the requested grid instance is managing.null
.public static Ignite grid(@Nullable String name) throws IgniteIllegalStateException
null
or empty string,
then default no-name grid will be returned. Note that caller of this method
should not assume that it will return the same instance every time.
Note that Java VM can run multiple grid instances and every grid instance (and its node) can belong to a different grid. Grid name defines what grid a particular grid instance (and correspondingly its node) belongs to.
name
- Grid name to which requested grid instance belongs to. If null
,
then grid instance belonging to a default no-name grid will be returned.null
.IgniteIllegalStateException
- Thrown if default grid was not properly
initialized or grid instance was stopped or was not started.public static IgniteKernal localIgnite() throws IllegalArgumentException
IllegalArgumentException
- Thrown to indicate, that current thread is not an IgniteThread
.public static IgniteKernal gridx(@Nullable String name)
name
- Grid name.public static void addListener(IgnitionListener lsnr)
Note that unlike other listeners in Ignite this listener will be notified from the same thread that triggers the state change. Because of that it is the responsibility of the user to make sure that listener logic is light-weight and properly handles (catches) any runtime exceptions, if any are expected.
lsnr
- Listener for grid life cycle events. If this listener was already added
this method is no-op.public static boolean removeListener(IgnitionListener lsnr)
addListener(IgnitionListener)
method.lsnr
- Listener to remove.true
if lsnr was added before, false
otherwise.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017