You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/19 16:02:38 UTC
[1/4] incubator-ignite git commit: # ignite-reflectionFactory: copu
JavaDoc
Repository: incubator-ignite
Updated Branches:
refs/heads/IgniteReflectionFactory-doc [created] 8e0ce491d
# ignite-reflectionFactory: copu JavaDoc
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/11e4489f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/11e4489f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/11e4489f
Branch: refs/heads/IgniteReflectionFactory-doc
Commit: 11e4489f2d3eed840e489fdbab64adf5d22f9011
Parents: 188cd82
Author: ashutak <as...@gridgain.com>
Authored: Fri Jun 19 13:07:52 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jun 19 13:07:52 2015 +0300
----------------------------------------------------------------------
.../configuration/IgniteReflectionFactory.java | 112 +++++++++++++++++++
1 file changed, 112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11e4489f/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
index 3222938..8d645ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
@@ -18,6 +18,12 @@
package org.apache.ignite.configuration;
import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import javax.cache.*;
import javax.cache.configuration.*;
@@ -28,6 +34,112 @@ import java.util.*;
/**
* Convenience class for reflection-based object creation.
*/
+/**
+ * Discovery SPI implementation that uses TCP/IP for node discovery.
+ * <p>
+ * Nodes are organized in ring. So almost all network exchange (except few cases) is
+ * done across it.
+ * <p>
+ * If node is configured as client node (see {@link IgniteConfiguration#clientMode})
+ * TcpDiscoverySpi starts in client mode as well. In this case node does not take its place in the ring,
+ * but it connects to random node in the ring (IP taken from IP finder configured) and
+ * use it as a router for discovery traffic.
+ * Therefore slow client node or its shutdown will not affect whole cluster. If TcpDiscoverySpi
+ * needs to be started in server mode regardless of {@link IgniteConfiguration#clientMode},
+ * {@link #forceSrvMode} should be set to true.
+ * <p>
+ * At startup SPI tries to send messages to random IP taken from
+ * {@link TcpDiscoveryIpFinder} about self start (stops when send succeeds)
+ * and then this info goes to coordinator. When coordinator processes join request
+ * and issues node added messages and all other nodes then receive info about new node.
+ * <h1 class="header">Failure Detection</h1>
+ * Configuration defaults (see Configuration section below for details)
+ * are chosen to make possible for discovery SPI work reliably on
+ * most of hardware and virtual deployments, but this has made failure detection time worse.
+ * <p>
+ * For stable low-latency networks the following more aggressive settings are recommended
+ * (which allows failure detection time ~200ms):
+ * <ul>
+ * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)}) - 100ms</li>
+ * <li>Socket timeout (see {@link #setSocketTimeout(long)}) - 200ms</li>
+ * <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)}) - 50ms</li>
+ * </ul>
+ * <h1 class="header">Configuration</h1>
+ * <h2 class="header">Mandatory</h2>
+ * There are no mandatory configuration parameters.
+ * <h2 class="header">Optional</h2>
+ * The following configuration parameters are optional:
+ * <ul>
+ * <li>IP finder to share info about nodes IP addresses
+ * (see {@link #setIpFinder(TcpDiscoveryIpFinder)}).
+ * See the following IP finder implementations for details on configuration:
+ * <ul>
+ * <li>{@link TcpDiscoverySharedFsIpFinder}</li>
+ * <li>{@ignitelink org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder}</li>
+ * <li>{@link TcpDiscoveryJdbcIpFinder}</li>
+ * <li>{@link TcpDiscoveryVmIpFinder}</li>
+ * <li>{@link TcpDiscoveryMulticastIpFinder} - default</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * <ul>
+ * </li>
+ * <li>Local address (see {@link #setLocalAddress(String)})</li>
+ * <li>Local port to bind to (see {@link #setLocalPort(int)})</li>
+ * <li>Local port range to try binding to if previous ports are in use
+ * (see {@link #setLocalPortRange(int)})</li>
+ * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)})</li>
+ * <li>Max missed heartbeats (see {@link #setMaxMissedHeartbeats(int)})</li>
+ * <li>Number of times node tries to (re)establish connection to another node
+ * (see {@link #setReconnectCount(int)})</li>
+ * <li>Network timeout (see {@link #setNetworkTimeout(long)})</li>
+ * <li>Socket timeout (see {@link #setSocketTimeout(long)})</li>
+ * <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)})</li>
+ * <li>Maximum message acknowledgement timeout (see {@link #setMaxAckTimeout(long)})</li>
+ * <li>Join timeout (see {@link #setJoinTimeout(long)})</li>
+ * <li>Thread priority for threads started by SPI (see {@link #setThreadPriority(int)})</li>
+ * <li>IP finder clean frequency (see {@link #setIpFinderCleanFrequency(long)})</li>
+ * <li>Statistics print frequency (see {@link #setStatisticsPrintFrequency(long)}</li>
+ * <li>Force server mode (see {@link #setForceServerMode(boolean)}</li>
+ * </ul>
+ * <h2 class="header">Java Example</h2>
+ * <pre name="code" class="java">
+ * TcpDiscoverySpi spi = new TcpDiscoverySpi();
+ *
+ * TcpDiscoveryVmIpFinder finder =
+ * new GridTcpDiscoveryVmIpFinder();
+ *
+ * spi.setIpFinder(finder);
+ *
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * // Override default discovery SPI.
+ * cfg.setDiscoverySpi(spi);
+ *
+ * // Start grid.
+ * Ignition.start(cfg);
+ * </pre>
+ * <h2 class="header">Spring Example</h2>
+ * TcpDiscoverySpi can be configured from Spring XML configuration file:
+ * <pre name="code" class="xml">
+ * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
+ * ...
+ * <property name="discoverySpi">
+ * <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ * <property name="ipFinder">
+ * <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder" />
+ * </property>
+ * </bean>
+ * </property>
+ * ...
+ * </bean>
+ * </pre>
+ * <p>
+ * <img src="http://ignite.incubator.apache.org/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ * @see DiscoverySpi
+ */
public class IgniteReflectionFactory<T> implements Factory<T> {
/** */
private static final long serialVersionUID = 0L;
[4/4] incubator-ignite git commit: # ignite-reflectionFactory: head
Posted by sb...@apache.org.
# ignite-reflectionFactory: head
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8e0ce491
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8e0ce491
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8e0ce491
Branch: refs/heads/IgniteReflectionFactory-doc
Commit: 8e0ce491d39c2238001943c0bff0fc94b10b5683
Parents: 2e472ee
Author: ashutak <as...@gridgain.com>
Authored: Fri Jun 19 17:02:41 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jun 19 17:02:41 2015 +0300
----------------------------------------------------------------------
.../configuration/IgniteReflectionFactory.java | 51 +++-----------------
1 file changed, 8 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e0ce491/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
index 3c17a32..2c106d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
@@ -18,12 +18,6 @@
package org.apache.ignite.configuration;
import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.spi.discovery.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import javax.cache.*;
import javax.cache.configuration.*;
@@ -32,43 +26,14 @@ import java.lang.reflect.*;
import java.util.*;
/**
- * Convenience class for reflection-based object creation.
- */
-/**
- * Discovery SPI implementation that uses TCP/IP for node discovery.
- * <p>
- * Nodes are organized in ring. So almost all network exchange (except few cases) is
- * done across it.
- * <p>
- * If node is configured as client node (see {@link IgniteConfiguration#clientMode})
- * TcpDiscoverySpi starts in client mode as well. In this case node does not take its place in the ring,
- * but it connects to random node in the ring (IP taken from IP finder configured) and
- * use it as a router for discovery traffic.
- * Therefore slow client node or its shutdown will not affect whole cluster. If TcpDiscoverySpi
- * needs to be started in server mode regardless of {@link IgniteConfiguration#clientMode},
- * {@link #forceSrvMode} should be set to true.
- * <p>
- * At startup SPI tries to send messages to random IP taken from
- * {@link TcpDiscoveryIpFinder} about self start (stops when send succeeds)
- * and then this info goes to coordinator. When coordinator processes join request
- * and issues node added messages and all other nodes then receive info about new node.
- * <h1 class="header">Failure Detection</h1>
- * Configuration defaults (see Configuration section below for details)
- * are chosen to make possible for discovery SPI work reliably on
- * most of hardware and virtual deployments, but this has made failure detection time worse.
- * <p>
- * For stable low-latency networks the following more aggressive settings are recommended
- * (which allows failure detection time ~200ms):
- * <ul>
- * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)}) - 100ms</li>
- * <li>Socket timeout (see {@link #setSocketTimeout(long)}) - 200ms</li>
- * <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)}) - 50ms</li>
- *
- *
- *
- *
- * * * * * *
- * </ul>
+ * Factory implementation that use reflection to creat instance of given class.
+ * <p/>
+ * There are 2 modes of factory: singleton and non-sigletton.
+ * <p/>
+ * Class that should be created by {@link IgniteReflectionFactory} (component class) have to be
+ * public java POJO with public setters for field
+ * for which property injection will be used (see {@link #setProperties(Map)}).
+ * <p/>
* <h1 class="header">Configuration</h1>
* <h2 class="header">Mandatory</h2>
* The following configuration parameters are mandatory:
[3/4] incubator-ignite git commit: # ignite-reflectionFactory: spring
cfg
Posted by sb...@apache.org.
# ignite-reflectionFactory: spring cfg
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2e472eeb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2e472eeb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2e472eeb
Branch: refs/heads/IgniteReflectionFactory-doc
Commit: 2e472eeb280d59d9a140873c0dd2d990c83adc06
Parents: e89ab78
Author: ashutak <as...@gridgain.com>
Authored: Fri Jun 19 16:52:17 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jun 19 16:52:17 2015 +0300
----------------------------------------------------------------------
.../configuration/IgniteReflectionFactory.java | 25 +++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2e472eeb/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
index a6d4c40..3c17a32 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
@@ -102,17 +102,24 @@ import java.util.*;
* <h2 class="header">Spring Example</h2>
* TcpDiscoverySpi can be configured from Spring XML configuration file:
* <pre name="code" class="xml">
- * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
- * ...
- * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteCacheConfiguration">
- * <property name="discoverySpi">
- * <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- * <property name="ipFinder">
- * <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder" />
+ * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ * ...
+ * <property name="cacheConfiguration">
+ * <list>
+ * <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ * ...
+ * <property name="cacheStoreSessionListenerFactories">
+ * <list>
+ * <bean class="org.apache.ignite.configuration.IgniteReflectionFactory">
+ * <property name="componentClass" value="custom.project.MyCacheStoreSessionListener"/>
+ * </bean>
+ * </list>
* </property>
+ * ...
* </bean>
- * </property>
- * ...
+ * </list>
+ * </property>
+ * ...
* </bean>
* </pre>
* <p>
[2/4] incubator-ignite git commit: # ignite-reflectionFactory: config
params and java-example
Posted by sb...@apache.org.
# ignite-reflectionFactory: config params and java-example
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e89ab786
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e89ab786
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e89ab786
Branch: refs/heads/IgniteReflectionFactory-doc
Commit: e89ab78693cd44f5d893593a13f62e034359e4a7
Parents: 11e4489
Author: ashutak <as...@gridgain.com>
Authored: Fri Jun 19 16:20:10 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jun 19 16:20:10 2015 +0300
----------------------------------------------------------------------
.../configuration/IgniteReflectionFactory.java | 77 ++++++++------------
1 file changed, 32 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e89ab786/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
index 8d645ac..a6d4c40 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteReflectionFactory.java
@@ -63,58 +63,38 @@ import java.util.*;
* <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)}) - 100ms</li>
* <li>Socket timeout (see {@link #setSocketTimeout(long)}) - 200ms</li>
* <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)}) - 50ms</li>
+ *
+ *
+ *
+ *
+ * * * * * *
* </ul>
* <h1 class="header">Configuration</h1>
* <h2 class="header">Mandatory</h2>
- * There are no mandatory configuration parameters.
- * <h2 class="header">Optional</h2>
- * The following configuration parameters are optional:
- * <ul>
- * <li>IP finder to share info about nodes IP addresses
- * (see {@link #setIpFinder(TcpDiscoveryIpFinder)}).
- * See the following IP finder implementations for details on configuration:
+ * The following configuration parameters are mandatory:
* <ul>
- * <li>{@link TcpDiscoverySharedFsIpFinder}</li>
- * <li>{@ignitelink org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder}</li>
- * <li>{@link TcpDiscoveryJdbcIpFinder}</li>
- * <li>{@link TcpDiscoveryVmIpFinder}</li>
- * <li>{@link TcpDiscoveryMulticastIpFinder} - default</li>
- * </ul>
- * </li>
+ * <li>Component class - class to be created (see {@link #setComponentClass(Class)}.
+ * It have to be public java POJO class with default constructor
+ * and public setters to be used by properties injection (see {@link #setProperties(Map)})</li>
* </ul>
+ * <h2 class="header">Optional</h2>
+ * The following configuration parameters are optional:
* <ul>
* </li>
- * <li>Local address (see {@link #setLocalAddress(String)})</li>
- * <li>Local port to bind to (see {@link #setLocalPort(int)})</li>
- * <li>Local port range to try binding to if previous ports are in use
- * (see {@link #setLocalPortRange(int)})</li>
- * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)})</li>
- * <li>Max missed heartbeats (see {@link #setMaxMissedHeartbeats(int)})</li>
- * <li>Number of times node tries to (re)establish connection to another node
- * (see {@link #setReconnectCount(int)})</li>
- * <li>Network timeout (see {@link #setNetworkTimeout(long)})</li>
- * <li>Socket timeout (see {@link #setSocketTimeout(long)})</li>
- * <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)})</li>
- * <li>Maximum message acknowledgement timeout (see {@link #setMaxAckTimeout(long)})</li>
- * <li>Join timeout (see {@link #setJoinTimeout(long)})</li>
- * <li>Thread priority for threads started by SPI (see {@link #setThreadPriority(int)})</li>
- * <li>IP finder clean frequency (see {@link #setIpFinderCleanFrequency(long)})</li>
- * <li>Statistics print frequency (see {@link #setStatisticsPrintFrequency(long)}</li>
- * <li>Force server mode (see {@link #setForceServerMode(boolean)}</li>
+ * <li>Singleton mode (see {@link #setSingleton(boolean)})</li>
+ * <li>Properties map (see {@link #setProperties(Map)}</li>
+ * <li>With method (see {@link #setWithMethod(Object, String, Serializable)}</li>
* </ul>
* <h2 class="header">Java Example</h2>
* <pre name="code" class="java">
- * TcpDiscoverySpi spi = new TcpDiscoverySpi();
- *
- * TcpDiscoveryVmIpFinder finder =
- * new GridTcpDiscoveryVmIpFinder();
- *
- * spi.setIpFinder(finder);
+ * Factory<CacheStoreSessionListener> factory =
+ * new IgniteReflectionFactory<CacheStoreSessionListener>(MyCacheStoreSessionListener.class);
*
- * IgniteConfiguration cfg = new IgniteConfiguration();
+ * CacheConfiguration cc = new CacheConfiguration()
+ * .setCacheStoreSessionListenerFactories(factory);
*
- * // Override default discovery SPI.
- * cfg.setDiscoverySpi(spi);
+ * IgniteConfiguration cfg = new IgniteConfiguration()
+ * .setCacheConfiguration(cc);
*
* // Start grid.
* Ignition.start(cfg);
@@ -124,6 +104,7 @@ import java.util.*;
* <pre name="code" class="xml">
* <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
* ...
+ * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteCacheConfiguration">
* <property name="discoverySpi">
* <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
* <property name="ipFinder">
@@ -138,26 +119,26 @@ import java.util.*;
* <img src="http://ignite.incubator.apache.org/images/spring-small.png">
* <br>
* For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- * @see DiscoverySpi
+ * @see Factory
*/
public class IgniteReflectionFactory<T> implements Factory<T> {
/** */
private static final long serialVersionUID = 0L;
- /** */
+ /** Singletom mode */
private volatile boolean singleton;
- /** */
+ /** Component class */
private volatile Class<? extends T> cls;
- /** */
+ /** Properties */
private volatile Map<String, Serializable> props;
/** */
private transient T instance;
/**
- *
+ * Default constructor.
*/
public IgniteReflectionFactory() {
// No-op.
@@ -210,6 +191,9 @@ public class IgniteReflectionFactory<T> implements Factory<T> {
}
/**
+ * Gets a map of properties. Map contains entries of component class field name
+ * to value of the filed which will be used as initial value.
+ *
* @return Properties.
*/
public Map<String, Serializable> getProperties() {
@@ -217,6 +201,9 @@ public class IgniteReflectionFactory<T> implements Factory<T> {
}
/**
+ * Sets a map of properties. Map contains entries of component class field name
+ * to a value of the filed which will be used as initial value.
+ *
* @param props Properties.
*/
public void setProperties(Map<String, Serializable> props) {