public abstract class GridSpiAdapter extends Object implements GridSpi, GridSpiManagementMBean
| Modifier | Constructor and Description |
|---|---|
protected |
GridSpiAdapter()
Creates new adapter and initializes it from the current (this) class.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertParameter(boolean cond,
String condDesc)
Throws exception with uniform error message if given parameter's assertion condition
is
false. |
protected void |
checkConfigurationConsistency0(GridSpiContext spiCtx,
GridNode node,
boolean starting)
Method which is called in the end of checkConfigurationConsistency() method.
|
protected String |
configInfo(String name,
Object val)
Gets uniformed string for configuration parameter.
|
protected String |
createSpiAttributeName(String attrName)
Creates new name for the given attribute.
|
protected List<String> |
getConsistentAttributeNames()
Returns back a list of attributes that should be consistent
for this SPI.
|
String |
getGridGainHome()
Gets Gridgain installation home folder (i.e.
|
UUID |
getLocalNodeId()
Gets ID of the local node.
|
String |
getName()
Gets SPI name.
|
Map<String,Object> |
getNodeAttributes()
This method is called before SPI starts (before method
GridSpi.spiStart(String)
is called). |
protected GridSpiContext |
getSpiContext()
Gets SPI context.
|
long |
getStartTimestamp()
Get start timestamp of this SPI.
|
String |
getStartTimestampFormatted()
Gets string presentation of the start timestamp.
|
long |
getUpTime()
Gets up-time of this SPI in ms.
|
String |
getUpTimeFormatted()
Gets string presentation of up-time for this SPI.
|
Collection<Object> |
injectables()
This method returns SPI internal instances that need to be injected as well.
|
void |
onContextDestroyed()
Callback invoked prior to stopping grid before SPI context is destroyed.
|
protected void |
onContextDestroyed0()
Method to be called in the beginning of onContextDestroyed() method.
|
void |
onContextInitialized(GridSpiContext spiCtx)
Callback invoked when SPI context is initialized.
|
protected void |
onContextInitialized0(GridSpiContext spiCtx)
Method to be called in the end of onContextInitialized method.
|
protected <T extends GridSpiManagementMBean> |
registerMBean(String gridName,
T impl,
Class<T> mbeanItf)
Registers SPI MBean.
|
void |
setName(String name)
Sets SPI name.
|
protected String |
startInfo()
Gets uniformly formatted message for SPI start.
|
protected void |
startStopwatch()
Starts startup stopwatch.
|
protected String |
stopInfo()
Gets uniformly format message for SPI stop.
|
protected void |
unregisterMBean()
Unregisters MBean.
|
protected GridSpiAdapter()
Class.getSimpleName()).protected void startStopwatch()
public final String getStartTimestampFormatted()
getStartTimestampFormatted in interface GridSpiManagementMBeanpublic final String getUpTimeFormatted()
getUpTimeFormatted in interface GridSpiManagementMBeanpublic final long getStartTimestamp()
getStartTimestamp in interface GridSpiManagementMBeanpublic final long getUpTime()
getUpTime in interface GridSpiManagementMBeanpublic UUID getLocalNodeId()
getLocalNodeId in interface GridSpiManagementMBeanpublic final String getGridGainHome()
getGridGainHome in interface GridSpiManagementMBeanpublic String getName()
getName in interface GridSpigetName in interface GridSpiManagementMBean@GridSpiConfiguration(optional=true) public void setName(String name)
name - SPI name.public final void onContextInitialized(GridSpiContext spiCtx) throws GridSpiException
This method is invoked after GridSpi.spiStart(String) method is
completed, so SPI should be fully functional at this point. Use this
method for post-start initialization, such as subscribing a discovery
listener, sending a message to remote node, etc...
onContextInitialized in interface GridSpispiCtx - Spi context.GridSpiException - If context initialization failed (grid will be stopped).protected void onContextInitialized0(GridSpiContext spiCtx) throws GridSpiException
spiCtx - SPI context.GridSpiException - In case of errors.public final void onContextDestroyed()
If GridSpiAdapter is used for SPI implementation, then it will
replace actual context with dummy no-op context which is usually good-enough
since grid is about to shut down.
onContextDestroyed in interface GridSpiprotected void onContextDestroyed0()
public Collection<Object> injectables()
protected GridSpiContext getSpiContext()
public Map<String,Object> getNodeAttributes() throws GridSpiException
GridSpi.spiStart(String)
is called). It allows SPI implementation to add attributes to a local
node. Kernal collects these attributes from all SPI implementations
loaded up and then passes it to discovery SPI so that they can be
exchanged with other nodes.getNodeAttributes in interface GridSpiGridSpiException - Throws in case of any error.protected final void assertParameter(boolean cond,
String condDesc)
throws GridSpiException
false.cond - Assertion condition to check.condDesc - Description of failed condition. Note that this description should include
JavaBean name of the property (not a variable name) as well condition in
Java syntax like, for example:
...
assertParameter(dirPath != null, "dirPath != null");
...
Note that in case when variable name is the same as JavaBean property you
can just copy Java condition expression into description as a string.GridSpiException - Thrown if given condition is falseprotected final String startInfo()
protected final String stopInfo()
protected final String configInfo(String name, Object val)
name - Parameter name.val - Parameter value.protected final <T extends GridSpiManagementMBean> void registerMBean(String gridName, T impl, Class<T> mbeanItf) throws GridSpiException
T - Type of the MBeangridName - Grid name. If null, then name will be empty.impl - MBean implementation.mbeanItf - MBean interface (if null, then standard JMX
naming conventions are used.GridSpiException - If registration failed.protected final void unregisterMBean()
throws GridSpiException
GridSpiException - If bean could not be unregistered.protected void checkConfigurationConsistency0(GridSpiContext spiCtx, GridNode node, boolean starting) throws GridSpiException
spiCtx - SPI context.node - Remote node.starting - If this node is starting or not.GridSpiException - in case of errors.protected List<String> getConsistentAttributeNames()
Copyright © 2014. All rights reserved.