Package org.apache.ignite.spi
Class IgniteSpiAdapter
- java.lang.Object
- 
- org.apache.ignite.spi.IgniteSpiAdapter
 
- 
- All Implemented Interfaces:
- IgniteSpi
 - Direct Known Subclasses:
- AdaptiveLoadBalancingSpi,- AlwaysFailoverSpi,- CacheCheckpointSpi,- FifoQueueCollisionSpi,- IsolatedDiscoverySpi,- JdbcCheckpointSpi,- JmxMetricExporterSpi,- JobStealingCollisionSpi,- JobStealingFailoverSpi,- KeystoreEncryptionSpi,- LocalDeploymentSpi,- MemoryEventStorageSpi,- NeverFailoverSpi,- NoopCheckpointSpi,- NoopCollisionSpi,- NoopEncryptionSpi,- NoopEventStorageSpi,- NoopIndexingSpi,- NoopMetricExporterSpi,- NoopTracingSpi,- OpenCensusTracingSpi,- PriorityQueueCollisionSpi,- org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter,- RoundRobinLoadBalancingSpi,- SharedFsCheckpointSpi,- org.apache.ignite.spi.communication.tcp.internal.TcpCommunicationConfigInitializer,- TcpDiscoverySpi,- UriDeploymentSpi,- WeightedRandomLoadBalancingSpi,- ZookeeperDiscoverySpi
 
 public abstract class IgniteSpiAdapter extends Object implements IgniteSpi This class provides convenient adapter for SPI implementations.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IgniteigniteIgnite instance.protected StringigniteInstanceNameIgnite instance name.protected IgniteLoggerlog
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedIgniteSpiAdapter()Creates new adapter and initializes it from the current (this) class.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTimeoutObject(IgniteSpiTimeoutObject obj)protected voidassertParameter(boolean cond, String condDesc)Throws exception with uniform error message if given parameter's assertion condition isfalse.protected voidcheckConfigurationConsistency0(IgniteSpiContext spiCtx, ClusterNode node, boolean starting)Method which is called in the end of checkConfigurationConsistency() method.longclientFailureDetectionTimeout()Returns client failure detection timeout set to use for network related operations.protected StringconfigInfo(String name, Object val)Gets uniformed string for configuration parameter.protected StringcreateSpiAttributeName(String attrName)Creates new name for the given attribute.longfailureDetectionTimeout()Returns failure detection timeout set to use for network related operations.booleanfailureDetectionTimeoutEnabled()Checks whether failure detection timeout is enabled for thisIgniteSpi.voidfailureDetectionTimeoutEnabled(boolean enabled)Enables or disables failure detection timeout.protected List<String>getConsistentAttributeNames()Returns back a list of attributes that should be consistent for this SPI.org.apache.ignite.internal.util.IgniteExceptionRegistrygetExceptionRegistry()Gets Exception registry.protected ClusterNodegetLocalNode()StringgetName()Gets SPI name.Map<String,Object>getNodeAttributes()This method is called before SPI starts (before methodIgniteSpi.spiStart(String)is called).IgniteSpiContextgetSpiContext()Gets SPI context.Igniteignite()Gets ignite instance.protected voidinitFailureDetectionTimeout()Initiates and checks failure detection timeout value.Collection<Object>injectables()This method returns SPI internal instances that need to be injected as well.protected voidinjectResources(Ignite ignite)Inject ignite instance.protected booleanisNodeStopping()voidonBeforeStart()This method is called by built-in managers implementation to avoid repeating SPI start attempts.voidonClientDisconnected(IgniteFuture<?> reconnectFut)Client node disconnected callback.voidonClientReconnected(boolean clusterRestarted)Client node reconnected callback.voidonContextDestroyed()Callback invoked prior to stopping grid before SPI context is destroyed.protected voidonContextDestroyed0()Method to be called in the beginning of onContextDestroyed() method.voidonContextInitialized(IgniteSpiContext spiCtx)Callback invoked when SPI context is initialized.protected voidonContextInitialized0(IgniteSpiContext spiCtx)Method to be called in the end of onContextInitialized method.protected <T extends IgniteSpiManagementMBean>
 voidregisterMBean(String igniteInstanceName, T impl, Class<T> mbeanItf)Registers SPI MBean.protected voidremoveTimeoutObject(IgniteSpiTimeoutObject obj)IgniteSpiAdaptersetName(String name)Sets SPI name.booleanstarted()Checks ifonBeforeStart()has been called on this SPI instance.protected StringstartInfo()Gets uniformly formatted message for SPI start.protected voidstartStopwatch()Starts startup stopwatch.protected StringstopInfo()Gets uniformly format message for SPI stop.protected voidunregisterMBean()Unregisters MBean.
 
- 
- 
- 
Field Detail- 
log@LoggerResource protected IgniteLogger log 
 - 
igniteprotected Ignite ignite Ignite instance.
 - 
igniteInstanceNameprotected String igniteInstanceName Ignite instance name.
 
- 
 - 
Constructor Detail- 
IgniteSpiAdapterprotected IgniteSpiAdapter() Creates new adapter and initializes it from the current (this) class. SPI name will be initialized to the simple name of the class (seeClass.getSimpleName()).
 
- 
 - 
Method Detail- 
startStopwatchprotected void startStopwatch() Starts startup stopwatch.
 - 
onBeforeStartpublic final void onBeforeStart() This method is called by built-in managers implementation to avoid repeating SPI start attempts.
 - 
startedpublic final boolean started() Checks ifonBeforeStart()has been called on this SPI instance.- Returns:
- Trueif- onBeforeStart()has already been called.
 
 - 
getLocalNodeprotected ClusterNode getLocalNode() - Returns:
- Local node.
 
 - 
getNamepublic String getName() Gets SPI name.
 - 
ignitepublic Ignite ignite() Gets ignite instance.- Returns:
- Ignite instance.
 
 - 
setName@IgniteSpiConfiguration(optional=true) public IgniteSpiAdapter setName(String name) Sets SPI name.- Parameters:
- name- SPI name.
- Returns:
- thisfor chaining.
 
 - 
onContextInitializedpublic final void onContextInitialized(IgniteSpiContext spiCtx) throws IgniteSpiException Callback invoked when SPI context is initialized. SPI implementation may store SPI context for future access.This method is invoked after IgniteSpi.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...- Specified by:
- onContextInitializedin interface- IgniteSpi
- Parameters:
- spiCtx- Spi context.
- Throws:
- IgniteSpiException- If context initialization failed (grid will be stopped).
 
 - 
onContextInitialized0protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException Method to be called in the end of onContextInitialized method.- Parameters:
- spiCtx- SPI context.
- Throws:
- IgniteSpiException- In case of errors.
 
 - 
onContextDestroyedpublic final void onContextDestroyed() Callback invoked prior to stopping grid before SPI context is destroyed. Once this method is complete, grid will begin shutdown sequence. Use this callback for de-initialization logic that may involve SPI context. Note that invoking SPI context after this callback is complete is considered illegal and may produce unknown results.If IgniteSpiAdapteris 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.- Specified by:
- onContextDestroyedin interface- IgniteSpi
 
 - 
onClientDisconnectedpublic void onClientDisconnected(IgniteFuture<?> reconnectFut) Client node disconnected callback.- Specified by:
- onClientDisconnectedin interface- IgniteSpi
- Parameters:
- reconnectFut- Future that will be completed when client reconnected.
 
 - 
onClientReconnectedpublic void onClientReconnected(boolean clusterRestarted) Client node reconnected callback.- Specified by:
- onClientReconnectedin interface- IgniteSpi
- Parameters:
- clusterRestarted-- Trueif all cluster nodes restarted while client was disconnected.
 
 - 
injectResources@IgniteInstanceResource protected void injectResources(Ignite ignite) Inject ignite instance.- Parameters:
- ignite- Ignite instance.
 
 - 
onContextDestroyed0protected void onContextDestroyed0() Method to be called in the beginning of onContextDestroyed() method.
 - 
injectablespublic Collection<Object> injectables() This method returns SPI internal instances that need to be injected as well. Usually these will be instances provided to SPI externally by user, e.g. during SPI configuration.- Returns:
- Internal SPI objects that also need to be injected.
 
 - 
getSpiContextpublic IgniteSpiContext getSpiContext() Gets SPI context.- Returns:
- SPI context.
 
 - 
getExceptionRegistrypublic org.apache.ignite.internal.util.IgniteExceptionRegistry getExceptionRegistry() Gets Exception registry.- Returns:
- Exception registry.
 
 - 
getNodeAttributespublic Map<String,Object> getNodeAttributes() throws IgniteSpiException This method is called before SPI starts (before methodIgniteSpi.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.- Specified by:
- getNodeAttributesin interface- IgniteSpi
- Returns:
- Map of local node attributes this SPI wants to add.
- Throws:
- IgniteSpiException- Throws in case of any error.
 
 - 
assertParameterprotected final void assertParameter(boolean cond, String condDesc) throws IgniteSpiExceptionThrows exception with uniform error message if given parameter's assertion condition isfalse.- Parameters:
- 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.
- Throws:
- IgniteSpiException- Thrown if given condition is- false
 
 - 
startInfoprotected final String startInfo() Gets uniformly formatted message for SPI start.- Returns:
- Uniformly formatted message for SPI start.
 
 - 
stopInfoprotected final String stopInfo() Gets uniformly format message for SPI stop.- Returns:
- Uniformly format message for SPI stop.
 
 - 
configInfoprotected final String configInfo(String name, Object val) Gets uniformed string for configuration parameter.- Parameters:
- name- Parameter name.
- val- Parameter value.
- Returns:
- Uniformed string for configuration parameter.
 
 - 
registerMBeanprotected final <T extends IgniteSpiManagementMBean> void registerMBean(String igniteInstanceName, T impl, Class<T> mbeanItf) throws IgniteSpiException Registers SPI MBean. Note that SPI can only register one MBean.- Type Parameters:
- T- Type of the MBean
- Parameters:
- igniteInstanceName- Ignite instance name. If null, then name will be empty.
- impl- MBean implementation.
- mbeanItf- MBean interface (if- null, then standard JMX naming conventions are used.
- Throws:
- IgniteSpiException- If registration failed.
 
 - 
unregisterMBeanprotected final void unregisterMBean() throws IgniteSpiExceptionUnregisters MBean.- Throws:
- IgniteSpiException- If bean could not be unregistered.
 
 - 
isNodeStoppingprotected final boolean isNodeStopping() - Returns:
- Trueif node is stopping.
 
 - 
checkConfigurationConsistency0protected void checkConfigurationConsistency0(IgniteSpiContext spiCtx, ClusterNode node, boolean starting) throws IgniteSpiException Method which is called in the end of checkConfigurationConsistency() method. May be overriden in SPIs.- Parameters:
- spiCtx- SPI context.
- node- Remote node.
- starting- If this node is starting or not.
- Throws:
- IgniteSpiException- in case of errors.
 
 - 
getConsistentAttributeNamesprotected List<String> getConsistentAttributeNames() Returns back a list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.- Returns:
- List or attribute names.
 
 - 
createSpiAttributeNameprotected String createSpiAttributeName(String attrName) Creates new name for the given attribute. Name contains SPI name prefix.- Parameters:
- attrName- SPI attribute name.
- Returns:
- New name with SPI name prefix.
 
 - 
addTimeoutObjectprotected void addTimeoutObject(IgniteSpiTimeoutObject obj) - Parameters:
- obj- Timeout object.
- See Also:
- IgniteSpiContext.addTimeoutObject(IgniteSpiTimeoutObject)
 
 - 
removeTimeoutObjectprotected void removeTimeoutObject(IgniteSpiTimeoutObject obj) - Parameters:
- obj- Timeout object.
- See Also:
- IgniteSpiContext.removeTimeoutObject(IgniteSpiTimeoutObject)
 
 - 
initFailureDetectionTimeoutprotected void initFailureDetectionTimeout() Initiates and checks failure detection timeout value.
 - 
failureDetectionTimeoutEnabledpublic void failureDetectionTimeoutEnabled(boolean enabled) Enables or disables failure detection timeout.- Parameters:
- enabled-- trueif enable,- falseotherwise.
 
 - 
failureDetectionTimeoutEnabledpublic boolean failureDetectionTimeoutEnabled() Checks whether failure detection timeout is enabled for thisIgniteSpi.- Returns:
- trueif enabled,- falseotherwise.
 
 - 
clientFailureDetectionTimeoutpublic long clientFailureDetectionTimeout() Returns client failure detection timeout set to use for network related operations.- Returns:
- client failure detection timeout in milliseconds or 0if the timeout is disabled.
 
 - 
failureDetectionTimeoutpublic long failureDetectionTimeout() Returns failure detection timeout set to use for network related operations.- Returns:
- failure detection timeout in milliseconds or 0if the timeout is disabled.
 
 
- 
 
-