Class IgnitionEx
- java.lang.Object
-
- org.apache.ignite.internal.IgnitionEx
-
public class IgnitionEx extends Object
This class is part of an internal API and can be modified at any time without backward compatibility. This class defines a factory for the main Ignite API. It controls Grid life cycle and allows listening for grid events.Grid Loaders
Although user can apply grid factory directly to start and stop grid, grid is often started and stopped by grid loaders. Grid loaders can be found inorg.apache.ignite.startuppackage, for example:CommandLineStartupServletStartup
Examples
Usestart()method to start grid with default configuration. You can also useIgniteConfigurationto override some default configuration. Below is an example on how to start grid with URI deployment.GridConfiguration cfg = new GridConfiguration();
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddListener(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 DependencyResolverdependencyResolver()Custom dependency resolver.static voiddependencyResolver(DependencyResolver rslvr)Sets custom dependency resolver which provides overridden dependenciesstatic T2<Ignite,Boolean>getOrStart(IgniteConfiguration cfg)Gets or starts new grid instance if it hasn't been started yet.static Ignitegrid()Gets an instance of default no-name grid.static Ignitegrid(@Nullable String name)Gets an named grid instance.static Ignitegrid(UUID locNodeId)Gets a grid instance for given local node ID.static IgniteKernalgridx(@Nullable String name)Gets grid instance without waiting its initialization.static IgniteKernalgridxx(UUID locNodeId)Gets grid instance without waiting its initialization and not throwing any exception.static booleanhasKernalStarted(String name)static voidinitializeDefaultMBeanServer(IgniteConfiguration myCfg)Initialize default mbean server.static booleanisClientMode()Gets client mode flag.static voidkill(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> TloadSpringBean(InputStream springXmlStream, String beanName)Loads spring bean by name.static <T> TloadSpringBean(String springXmlPath, String beanName)Loads spring bean by name.static <T> TloadSpringBean(URL springXmlUrl, String beanName)Loads spring bean by name.static IgniteKernallocalIgnite()Gets a name of the grid from thread local config, which is owner of current thread.static booleanremoveListener(IgnitionListener lsnr)Removes lsnr added byaddListener(IgnitionListener)method.static voidrestart(boolean cancel)Restarts all started grids.static voidsetClientMode(boolean clientMode)Sets client mode flag.static Ignitestart()Starts grid with default configuration.static Ignitestart(@Nullable String springCfgPath)Starts all grids specified within given Spring XML configuration file.static Ignitestart(@Nullable String springCfgPath, @Nullable String igniteInstanceName)Starts all grids specified within given Spring XML configuration file.static Ignitestart(@Nullable GridSpringResourceContext springCtx)Starts grid with default configuration.static Ignitestart(InputStream springCfgStream)Starts all grids specified within given Spring XML configuration input stream.static Ignitestart(InputStream springCfgStream, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr)Starts all grids specified within given Spring XML configuration input stream.static Ignitestart(String springCfgPath, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr)Starts all grids specified within given Spring XML configuration file.static Ignitestart(URL springCfgUrl)Starts all grids specified within given Spring XML configuration file URL.static Ignitestart(URL springCfgUrl, @Nullable ClassLoader ldr)Starts all grids specified within given Spring XML configuration file URL.static Ignitestart(URL springCfgUrl, @Nullable String igniteInstanceName, @Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr)Starts all grids specified within given Spring XML configuration file URL.static Ignitestart(IgniteConfiguration cfg)Starts grid with given configuration.static Ignitestart(IgniteConfiguration cfg, boolean failIfStarted)Starts a grid with given configuration.static Ignitestart(IgniteConfiguration cfg, @Nullable GridSpringResourceContext springCtx)Starts grid with given configuration.static T2<Ignite,Boolean>start(IgniteConfiguration cfg, @Nullable GridSpringResourceContext springCtx, boolean failIfStarted)Starts grid with given configuration.static IgniteStatestate()Gets state of grid default grid.static IgniteStatestate(@Nullable String name)Gets states of named Ignite instance.static booleanstop(boolean cancel, @Nullable ShutdownPolicy shutdown)Stops default grid.static booleanstop(@Nullable String name, boolean cancel, boolean stopNotStarted, long timeoutMs)Deprecated.Behavior of the method is the almost same asstop(boolean, ShutdownPolicy).static booleanstop(@Nullable String name, boolean cancel, @Nullable ShutdownPolicy shutdown, boolean stopNotStarted)Stops named Ignite instance.static voidstopAll(boolean cancel, @Nullable ShutdownPolicy shutdown)Stops all started grids.
-
-
-
Field Detail
-
DFLT_CFG
public static final String DFLT_CFG
Default configuration path relative to Ignite home.- See Also:
- Constant Field Values
-
-
Method Detail
-
setClientMode
public static void setClientMode(boolean clientMode)
Sets client mode flag.- Parameters:
clientMode- Client mode flag.
-
isClientMode
public static boolean isClientMode()
Gets client mode flag.- Returns:
- Client mode flag.
-
state
public static IgniteState state()
Gets state of grid default grid.- Returns:
- Default grid state.
-
state
public static IgniteState state(@Nullable @Nullable String name)
Gets states of named Ignite instance. If name isnull, then state of default no-name Ignite instance is returned.- Parameters:
name- Ignite instance name. If name isnull, then state of default no-name Ignite instance is returned.- Returns:
- Grid state.
-
stop
public static boolean stop(boolean cancel, @Nullable @Nullable ShutdownPolicy shutdown)Stops default grid. This method is identical toG.stop(null, cancel)apply. Note that method does not wait for all tasks to be completed.- Parameters:
cancel- Iftruethen all jobs currently executing on default grid will be cancelled by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from executionshutdown- If this parameter is set explicitly this policy will use for stopping node. If this parameter isnullcommon cluster policy will be use.- Returns:
trueif default grid instance was indeed stopped,falseotherwise (if it was not started).
-
stop
public static boolean stop(@Nullable @Nullable String name, boolean cancel, @Nullable @Nullable ShutdownPolicy shutdown, boolean stopNotStarted)Stops named Ignite instance. Ifcancelflag is set totruethen all jobs currently executing on local node will be interrupted. If Ignite instance name isnull, then default no-name Ignite instance will be stopped. If wait parameter is set totruethen Ignite instance will wait for all tasks to be finished.- Parameters:
name- Ignite instance name. Ifnull, then default no-name Ignite instance will be stopped.cancel- Iftruethen all jobs currently will be cancelled by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from execution. Iffalse, 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.shutdown- If this parameter is set explicitly this policy will use for stopping node. If this parameter isnullcommon cluster policy will be use.stopNotStarted- Iftrueand node start did not finish then interrupts starting thread.- Returns:
trueif named Ignite instance was indeed found and stopped,falseotherwise (the instance with givennamewas not found).
-
stop
@Deprecated public static boolean stop(@Nullable @Nullable String name, boolean cancel, boolean stopNotStarted, long timeoutMs)
Deprecated.Behavior of the method is the almost same asstop(boolean, ShutdownPolicy). If node stopping process will not be finished withintimeoutMswhole JVM will be killed.- Parameters:
timeoutMs- Timeout to wait graceful stopping.
-
stopAll
public static void stopAll(boolean cancel, @Nullable @Nullable ShutdownPolicy shutdown)Stops all started grids. Ifcancelflag is set totruethen all jobs currently executing on local node will be interrupted. If wait parameter is set totruethen 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.
- Parameters:
cancel- Iftruethen all jobs currently executing on all grids will be cancelled by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from executionshutdown- If this parameter is set explicitly this policy will use for stopping node. If this parameter isnullcommon cluster policy will be use.
-
restart
public static void restart(boolean cancel)
Restarts all started grids. Ifcancelflag is set totruethen all jobs currently executing on the local node will be interrupted. Ifwaitparameter is set totruethen 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.
- Parameters:
cancel- Iftruethen all jobs currently executing on all grids will be cancelled by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from execution.- See Also:
Ignition.RESTART_EXIT_CODE
-
kill
public static void kill(boolean cancel)
Stops all started grids. Ifcancelflag is set totruethen all jobs currently executing on the local node will be interrupted. Ifwaitparameter is set totruethen 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.- Parameters:
cancel- Iftruethen all jobs currently executing on all grids will be cancelled by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from execution.- See Also:
Ignition.KILL_EXIT_CODE
-
start
public static Ignite start() throws IgniteCheckedException
Starts grid with default configuration. By default this method will use grid configuration defined inIGNITE_HOME/config/default-config.xmlconfiguration file. If such file is not found, then all system defaults will be used.- Returns:
- Started grid.
- Throws:
IgniteCheckedException- If default grid could not be started. This exception will be thrown also if default grid has already been started.
-
start
public static Ignite start(@Nullable @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException
Starts grid with default configuration. By default this method will use grid configuration defined inIGNITE_HOME/config/default-config.xmlconfiguration file. If such file is not found, then all system defaults will be used.- Parameters:
springCtx- Optional Spring application context, possiblynull. 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@SpringApplicationContextResourceannotation.- Returns:
- Started grid.
- Throws:
IgniteCheckedException- If default grid could not be started. This exception will be thrown also if default grid has already been started.
-
start
public static Ignite start(IgniteConfiguration cfg) throws IgniteCheckedException
Starts grid with given configuration. Note that this method is no-op if grid with the name provided in given configuration is already started.- Parameters:
cfg- Grid configuration. This cannot benull.- Returns:
- Started grid.
- Throws:
IgniteCheckedException- If grid could not be started. This exception will be thrown also if named grid has already been started.
-
start
public static Ignite start(IgniteConfiguration cfg, boolean failIfStarted) throws IgniteCheckedException
Starts a grid with given configuration. If the grid is already started and failIfStarted set to TRUE an exception will be thrown.- Parameters:
cfg- Grid configuration. This cannot benull.failIfStarted- When flag istrueand grid with specified name has been already started the exception is thrown. Otherwise the existing instance of the grid is returned.- Returns:
- Started grid or existing grid.
- Throws:
IgniteCheckedException- If grid could not be started. This exception will be thrown also if named grid has already been started.
-
getOrStart
public static T2<Ignite,Boolean> getOrStart(IgniteConfiguration cfg) throws IgniteException
Gets or starts new grid instance if it hasn't been started yet.- Parameters:
cfg- Grid configuration. This cannot benull.- Returns:
- Tuple with: grid instance and flag to indicate the instance is started by this call.
So, when the new ignite instance is started the flag is
true. If an existing instance is returned the flag isfalse. - Throws:
IgniteException- If grid could not be started.
-
start
public static Ignite start(IgniteConfiguration cfg, @Nullable @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException
Starts grid with given configuration. Note that this method will throw and exception if grid with the name provided in given configuration is already started.- Parameters:
cfg- Grid configuration. This cannot benull.springCtx- Optional Spring application context, possiblynull. 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@SpringApplicationContextResourceannotation.- Returns:
- Started grid.
- Throws:
IgniteCheckedException- If grid could not be started. This exception will be thrown also if named grid has already been started.
-
start
public static T2<Ignite,Boolean> start(IgniteConfiguration cfg, @Nullable @Nullable GridSpringResourceContext springCtx, boolean failIfStarted) throws IgniteCheckedException
Starts grid with given configuration. If the grid is already started and failIfStarted set to TRUE an exception will be thrown.- Parameters:
cfg- Grid configuration. This cannot benull.springCtx- Optional Spring application context, possiblynull. 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@SpringApplicationContextResourceannotation.failIfStarted- Throw or not an exception if grid is already started.- Returns:
- Tuple with: grid instance and flag to indicate the instance is started by this call.
So, when the new ignite instance is started the flag is
true. If an existing instance is returned the flag isfalse. - Throws:
IgniteCheckedException- If grid could not be started. This exception will be thrown also if named grid has already been started.
-
start
public static Ignite start(@Nullable @Nullable String springCfgPath) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgPath- Spring XML configuration file path or URL.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(@Nullable @Nullable String springCfgPath, @Nullable @Nullable String igniteInstanceName) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgPath- Spring XML configuration file path or URL.igniteInstanceName- Ignite instance name that will override default.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
loadConfigurations
public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(URL springCfgUrl) throws IgniteCheckedException
Loads all grid configurations specified within given Spring XML configuration file.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.
- Parameters:
springCfgUrl- Spring XML configuration file path or URL. This cannot benull.- Returns:
- Tuple containing all loaded configurations and Spring context used to load them.
- Throws:
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.
-
loadConfigurations
public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(InputStream springCfgStream) throws IgniteCheckedException
Loads all grid configurations specified within given input stream.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.
- Parameters:
springCfgStream- Input stream contained Spring XML configuration. This cannot benull.- Returns:
- Tuple containing all loaded configurations and Spring context used to load them.
- Throws:
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.
-
loadConfigurations
public static IgniteBiTuple<Collection<IgniteConfiguration>,? extends GridSpringResourceContext> loadConfigurations(String springCfgPath) throws IgniteCheckedException
Loads all grid configurations specified within given Spring XML configuration file.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.
- Parameters:
springCfgPath- Spring XML configuration file path. This cannot benull.- Returns:
- Tuple containing all loaded configurations and Spring context used to load them.
- Throws:
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.
-
loadConfiguration
public static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> loadConfiguration(URL springCfgUrl) throws IgniteCheckedException
Loads first found grid configuration specified within given Spring XML configuration file.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.
- Parameters:
springCfgUrl- Spring XML configuration file path or URL. This cannot benull.- Returns:
- First found configuration and Spring context used to load it.
- Throws:
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.
-
loadConfiguration
public static IgniteBiTuple<IgniteConfiguration,GridSpringResourceContext> loadConfiguration(String springCfgPath) throws IgniteCheckedException
Loads first found grid configuration specified within given Spring XML configuration file.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.
- Parameters:
springCfgPath- Spring XML configuration file path. This cannot benull.- Returns:
- First found configuration and Spring context used to load it.
- Throws:
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.
-
start
public static Ignite start(String springCfgPath, @Nullable @Nullable String igniteInstanceName, @Nullable @Nullable GridSpringResourceContext springCtx, @Nullable @Nullable ClassLoader ldr) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgPath- Spring XML configuration file path or URL. This cannot benull.igniteInstanceName- Ignite instance name that will override default.springCtx- Optional Spring application context, possiblynull.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@SpringApplicationContextResourceannotation.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(URL springCfgUrl) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file URL. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgUrl- Spring XML configuration file URL. This cannot benull.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(URL springCfgUrl, @Nullable @Nullable ClassLoader ldr) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file URL. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgUrl- Spring XML configuration file URL. This cannot benull.ldr- Optional class loader that will be used by default.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(URL springCfgUrl, @Nullable @Nullable String igniteInstanceName, @Nullable @Nullable GridSpringResourceContext springCtx, @Nullable @Nullable ClassLoader ldr) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration file URL. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgUrl- Spring XML configuration file URL. This cannot benull.igniteInstanceName- Ignite instance name that will override default.springCtx- Optional Spring application context, possiblynull.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@SpringApplicationContextResourceannotation.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(InputStream springCfgStream) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration input stream. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgStream- Input stream containing Spring XML configuration. This cannot benull.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
start
public static Ignite start(InputStream springCfgStream, @Nullable @Nullable String igniteInstanceName, @Nullable @Nullable GridSpringResourceContext springCtx, @Nullable @Nullable ClassLoader ldr) throws IgniteCheckedException
Starts all grids specified within given Spring XML configuration input stream. If grid with given name is already started, then exception is thrown. In this case all instances that may have been started so far will be stopped too.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.
- Parameters:
springCfgStream- Input stream containing Spring XML configuration. This cannot benull.igniteInstanceName- Ignite instance name that will override default.springCtx- Optional Spring application context, possiblynull.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@SpringApplicationContextResourceannotation.- Returns:
- Started grid. If Spring configuration contains multiple grid instances, then the 1st found instance is returned.
- Throws:
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.
-
loadSpringBean
public static <T> T loadSpringBean(String springXmlPath, String beanName) throws IgniteCheckedException
Loads spring bean by name.- Parameters:
springXmlPath- Spring XML file path.beanName- Bean name.- Returns:
- Bean instance.
- Throws:
IgniteCheckedException- In case of error.
-
loadSpringBean
public static <T> T loadSpringBean(URL springXmlUrl, String beanName) throws IgniteCheckedException
Loads spring bean by name.- Parameters:
springXmlUrl- Spring XML file URL.beanName- Bean name.- Returns:
- Bean instance.
- Throws:
IgniteCheckedException- In case of error.
-
loadSpringBean
public static <T> T loadSpringBean(InputStream springXmlStream, String beanName) throws IgniteCheckedException
Loads spring bean by name.- Parameters:
springXmlStream- Input stream containing Spring XML configuration.beanName- Bean name.- Returns:
- Bean instance.
- Throws:
IgniteCheckedException- In case of error.
-
grid
public static Ignite grid() throws IgniteIllegalStateException
Gets an instance of default no-name grid. Note that caller of this method should not assume that it will return the same instance every time.- Returns:
- An instance of default no-name grid. This method never returns
null. - Throws:
IgniteIllegalStateException- Thrown if default grid was not properly initialized or grid instance was stopped or was not started.
-
allGrids
public static List<Ignite> allGrids()
Gets a list of all grids started so far.- Returns:
- List of all grids started so far.
-
allGridsx
public static List<Ignite> allGridsx()
Gets a list of all grids started so far.- Returns:
- List of all grids started so far.
-
grid
public static Ignite grid(UUID locNodeId) throws IgniteIllegalStateException
Gets a grid instance for given local node ID. Note that grid instance and local node have one-to-one relationship where node has ID and instance has name of the grid to which both grid instance and its node belong. Note also that caller of this method should not assume that it will return the same instance every time.- Parameters:
locNodeId- ID of local node the requested grid instance is managing.- Returns:
- An instance of named grid. This method never returns
null. - Throws:
IgniteIllegalStateException- Thrown if grid was not properly initialized or grid instance was stopped or was not started.
-
gridxx
public static IgniteKernal gridxx(UUID locNodeId)
Gets grid instance without waiting its initialization and not throwing any exception.- Parameters:
locNodeId- ID of local node the requested grid instance is managing.- Returns:
- Grid instance or
null.
-
grid
public static Ignite grid(@Nullable @Nullable String name) throws IgniteIllegalStateException
Gets an named grid instance. If grid name isnullor 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.
- Parameters:
name- Grid name to which requested grid instance belongs to. Ifnull, then grid instance belonging to a default no-name grid will be returned.- Returns:
- An instance of named grid. This method never returns
null. - Throws:
IgniteIllegalStateException- Thrown if default grid was not properly initialized or grid instance was stopped or was not started.
-
localIgnite
public static IgniteKernal localIgnite() throws IllegalArgumentException
Gets a name of the grid from thread local config, which is owner of current thread.- Returns:
- Grid instance related to current thread
- Throws:
IllegalArgumentException- Thrown to indicate, that current thread is not anIgniteThread.
-
gridx
public static IgniteKernal gridx(@Nullable @Nullable String name)
Gets grid instance without waiting its initialization.- Parameters:
name- Grid name.- Returns:
- Grid instance.
-
addListener
public static void addListener(IgnitionListener lsnr)
Adds a lsnr for grid life cycle events.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.
- Parameters:
lsnr- Listener for grid life cycle events. If this listener was already added this method is no-op.
-
removeListener
public static boolean removeListener(IgnitionListener lsnr)
Removes lsnr added byaddListener(IgnitionListener)method.- Parameters:
lsnr- Listener to remove.- Returns:
trueif lsnr was added before,falseotherwise.
-
dependencyResolver
public static void dependencyResolver(DependencyResolver rslvr)
Sets custom dependency resolver which provides overridden dependencies- Parameters:
rslvr- Dependency resolver.
-
dependencyResolver
public static DependencyResolver dependencyResolver()
Custom dependency resolver.- Returns:
- Returns
nullif resolver wasn't added.
-
hasKernalStarted
public static boolean hasKernalStarted(String name)
- Parameters:
name- Grid name (possiblynullfor default grid).- Returns:
- true when all managers, processors, and plugins have started and ignite kernal start method has fully completed.
-
initializeDefaultMBeanServer
public static void initializeDefaultMBeanServer(IgniteConfiguration myCfg)
Initialize default mbean server.
-
-