http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java index 489e8ac,0000000..437c478 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java @@@ -1,484 -1,0 +1,484 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite; + + +import org.apache.ignite.internal.jdbc.*; + +import java.sql.*; +import java.util.*; +import java.util.logging.*; + +/** + * JDBC driver implementation for In-Memory Data Grid. + * <p> - * Driver allows to get distributed data from GridGain cache using standard ++ * Driver allows to get distributed data from Ignite cache using standard + * SQL queries and standard JDBC API. It will automatically get only fields that + * you actually need from objects stored in cache. + * <h1 class="header">Limitations</h1> - * Data in GridGain cache is usually distributed across several nodes, ++ * Data in Ignite cache is usually distributed across several nodes, + * so some queries may not work as expected since the query will be sent to each + * individual node and results will then be collected and returned as JDBC result set. + * Keep in mind following limitations (not applied if data is queried from one node only, + * or data is fully co-located or fully replicated on multiple nodes): + * <ul> + * <li> + * {@code Group by} and {@code sort by} statements are applied separately + * on each node, so result set will likely be incorrectly grouped or sorted + * after results from multiple remote nodes are grouped together. + * </li> + * <li> + * Aggregation functions like {@code sum}, {@code max}, {@code avg}, etc. + * are also applied on each node. Therefore you will get several results + * containing aggregated values, one for each node. + * </li> + * <li> + * Joins will work correctly only if joined objects are stored in + * collocated mode. Refer to + * {@link org.apache.ignite.cache.affinity.CacheAffinityKey} + * javadoc for more details. + * </li> + * <li> + * Note that if you are connected to local or replicated cache, all data will + * be queried only on one node, not depending on what caches participate in + * the query (some data from partitioned cache can be lost). And visa versa, + * if you are connected to partitioned cache, data from replicated caches + * will be duplicated. + * </li> + * </ul> + * <h1 class="header">SQL Notice</h1> + * Driver allows to query data from several caches. Cache that driver is connected to is + * treated as default schema in this case. Other caches can be referenced by their names. + * <p> + * Note that cache name is case sensitive and you have to always specify it in quotes. + * <h1 class="header">Dependencies</h1> - * JDBC driver is located in main GridGain JAR and depends on all libraries located in ++ * JDBC driver is located in main Ignite JAR and depends on all libraries located in + * {@code IGNITE_HOME/libs} folder. So if you are using JDBC driver in any external tool, - * you have to add main GridGain JAR will all dependencies to its classpath. ++ * you have to add main Ignite JAR will all dependencies to its classpath. + * <h1 class="header">Configuration</h1> - * Internally JDBC driver <b>is based on GridGain Java client</b>. Therefore, all client ++ * Internally JDBC driver <b>is based on Ignite Java client</b>. Therefore, all client + * configuration properties can be applied to JDBC connection. + * <p> + * JDBC connection URL has the following pattern: - * {@code jdbc:gridgain://<hostname>:<port>/<cache_name>?nodeId=<UUID>}<br> ++ * {@code jdbc:ignite://<hostname>:<port>/<cache_name>?nodeId=<UUID>}<br> + * Note the following: + * <ul> + * <li>Hostname is required.</li> - * <li>If port is not defined, {@code 11211} is used (default for GridGain client).</li> ++ * <li>If port is not defined, {@code 11211} is used (default for Ignite client).</li> + * <li>Leave {@code <cache_name>} empty if you are connecting to default cache.</li> + * <li> + * Provide {@code nodeId} parameter if you want to specify node where to execute + * your queries. Note that local and replicated caches will be queried locally on + * this node while partitioned cache is queried distributively. If node ID is not + * provided, random node is used. If node with provided ID doesn't exist, + * exception is thrown. + * </li> + * </ul> + * Other properties can be defined in {@link Properties} object passed to + * {@link DriverManager#getConnection(String, Properties)} method: + * <table class="doctable"> + * <tr> + * <th>Name</th> + * <th>Description</th> + * <th>Default</th> + * <th>Optional</th> + * </tr> + * <tr> + * <td><b>gg.client.protocol</b></td> + * <td>Communication protocol ({@code TCP} or {@code HTTP}).</td> + * <td>{@code TCP}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.connectTimeout</b></td> + * <td>Socket connection timeout.</td> + * <td>{@code 0} (infinite timeout)</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.tcp.noDelay</b></td> + * <td>Flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections.</td> + * <td>{@code true}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.enabled</b></td> + * <td>Flag indicating that {@code SSL} is needed for connection.</td> + * <td>{@code false}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.protocol</b></td> + * <td>SSL protocol ({@code SSL} or {@code TLS}).</td> + * <td>{@code TLS}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.key.algorithm</b></td> + * <td>Key manager algorithm.</td> + * <td>{@code SunX509}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.keystore.location</b></td> - * <td>Key store to be used by client to connect with GridGain topology.</td> ++ * <td>Key store to be used by client to connect with Ignite topology.</td> + * <td> </td> + * <td>No (if {@code SSL} is enabled)</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.keystore.password</b></td> + * <td>Key store password.</td> + * <td> </td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.keystore.type</b></td> + * <td>Key store type.</td> + * <td>{@code jks}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.truststore.location</b></td> - * <td>Trust store to be used by client to connect with GridGain topology.</td> ++ * <td>Trust store to be used by client to connect with Ignite topology.</td> + * <td> </td> + * <td>No (if {@code SSL} is enabled)</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.truststore.password</b></td> + * <td>Trust store password.</td> + * <td> </td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.ssl.truststore.type</b></td> + * <td>Trust store type.</td> + * <td>{@code jks}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.credentials</b></td> + * <td>Client credentials used in authentication process.</td> + * <td> </td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.cache.top</b></td> + * <td> + * Flag indicating that topology is cached internally. Cache will be refreshed in + * the background with interval defined by {@code gg.client.topology.refresh} + * property (see below). + * </td> + * <td>{@code false}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.topology.refresh</b></td> + * <td>Topology cache refresh frequency (ms).</td> + * <td>{@code 2000}</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td><b>gg.client.idleTimeout</b></td> + * <td>Maximum amount of time that connection can be idle before it is closed (ms).</td> + * <td>{@code 30000}</td> + * <td>Yes</td> + * </tr> + * </table> + * <h1 class="header">Example</h1> + * <pre name="code" class="java"> + * // Register JDBC driver. - * Class.forName("org.gridgain.jdbc.IgniteJdbcDriver"); ++ * Class.forName("org.apache.ignite.jdbc.IgniteJdbcDriver"); + * + * // Open JDBC connection. - * Connection conn = DriverManager.getConnection("jdbc:gridgain://localhost/cache"); ++ * Connection conn = DriverManager.getConnection("jdbc:ignite://localhost/cache"); + * + * // Query persons' names + * ResultSet rs = conn.createStatement().executeQuery("select name from Person"); + * + * while (rs.next()) { + * String name = rs.getString(1); + * + * ... + * } + * + * // Query persons with specific age + * PreparedStatement stmt = conn.prepareStatement("select name, age from Person where age = ?"); + * + * stmt.setInt(1, 30); + * + * ResultSet rs = stmt.executeQuery(); + * + * while (rs.next()) { + * String name = rs.getString("name"); + * int age = rs.getInt("age"); + * + * ... + * } + * </pre> + */ +@SuppressWarnings("JavadocReference") +public class IgniteJdbcDriver implements Driver { + /** Prefix for property names. */ + private static final String PROP_PREFIX = "gg.jdbc."; + + /** Hostname property name. */ + public static final String PROP_HOST = PROP_PREFIX + "host"; + + /** Port number property name. */ + public static final String PROP_PORT = PROP_PREFIX + "port"; + + /** Cache name property name. */ + public static final String PROP_CACHE = PROP_PREFIX + "cache"; + + /** Node ID URL parameter name. */ + public static final String PARAM_NODE_ID = "nodeId"; + + /** Node ID property name. */ + public static final String PROP_NODE_ID = PROP_PREFIX + PARAM_NODE_ID; + + /** URL prefix. */ - public static final String URL_PREFIX = "jdbc:gridgain://"; ++ public static final String URL_PREFIX = "jdbc:ignite://"; + + /** Default port. */ + public static final int DFLT_PORT = 11211; + + /** Major version. */ + private static final int MAJOR_VER = 1; + + /** Minor version. */ + private static final int MINOR_VER = 0; + + /** + * Register driver. + */ + static { + try { + DriverManager.registerDriver(new IgniteJdbcDriver()); + } + catch (SQLException e) { - throw new RuntimeException("Failed to register GridGain JDBC driver.", e); ++ throw new RuntimeException("Failed to register Ignite JDBC driver.", e); + } + } + + /** {@inheritDoc} */ + @Override public Connection connect(String url, Properties props) throws SQLException { + if (!parseUrl(url, props)) + throw new SQLException("URL is invalid: " + url); + + return new JdbcConnection(url, props); + } + + /** {@inheritDoc} */ + @Override public boolean acceptsURL(String url) throws SQLException { + return url.startsWith(URL_PREFIX); + } + + /** {@inheritDoc} */ + @Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { + if (!parseUrl(url, info)) + throw new SQLException("URL is invalid: " + url); + + DriverPropertyInfo[] props = new DriverPropertyInfo[20]; + + props[0] = new PropertyInfo("Hostname", info.getProperty(PROP_HOST), true); + props[1] = new PropertyInfo("Port number", info.getProperty(PROP_PORT), ""); + props[2] = new PropertyInfo("Cache name", info.getProperty(PROP_CACHE), ""); + props[3] = new PropertyInfo("Node ID", info.getProperty(PROP_NODE_ID, "")); + props[4] = new PropertyInfo("gg.client.protocol", info.getProperty("gg.client.protocol", "TCP"), + "Communication protocol (TCP or HTTP)."); + props[5] = new PropertyInfo("gg.client.connectTimeout", info.getProperty("gg.client.connectTimeout", "0"), + "Socket connection timeout."); + props[6] = new PropertyInfo("gg.client.tcp.noDelay", info.getProperty("gg.client.tcp.noDelay", "true"), + "Flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections."); + props[7] = new PropertyInfo("gg.client.ssl.enabled", info.getProperty("gg.client.ssl.enabled", "false"), + "Flag indicating that SSL is needed for connection."); + props[8] = new PropertyInfo("gg.client.ssl.protocol", info.getProperty("gg.client.ssl.protocol", "TLS"), + "SSL protocol."); + props[9] = new PropertyInfo("gg.client.ssl.key.algorithm", info.getProperty("gg.client.ssl.key.algorithm", + "SunX509"), "Key manager algorithm."); + props[10] = new PropertyInfo("gg.client.ssl.keystore.location", + info.getProperty("gg.client.ssl.keystore.location", ""), - "Key store to be used by client to connect with GridGain topology."); ++ "Key store to be used by client to connect with Ignite topology."); + props[11] = new PropertyInfo("gg.client.ssl.keystore.password", + info.getProperty("gg.client.ssl.keystore.password", ""), "Key store password."); + props[12] = new PropertyInfo("gg.client.ssl.keystore.type", info.getProperty("gg.client.ssl.keystore.type", + "jks"), "Key store type."); + props[13] = new PropertyInfo("gg.client.ssl.truststore.location", + info.getProperty("gg.client.ssl.truststore.location", ""), - "Trust store to be used by client to connect with GridGain topology."); ++ "Trust store to be used by client to connect with Ignite topology."); + props[14] = new PropertyInfo("gg.client.ssl.keystore.password", + info.getProperty("gg.client.ssl.truststore.password", ""), "Trust store password."); + props[15] = new PropertyInfo("gg.client.ssl.truststore.type", info.getProperty("gg.client.ssl.truststore.type", + "jks"), "Trust store type."); + props[16] = new PropertyInfo("gg.client.credentials", info.getProperty("gg.client.credentials", ""), + "Client credentials used in authentication process."); + props[17] = new PropertyInfo("gg.client.cache.top", info.getProperty("gg.client.cache.top", "false"), + "Flag indicating that topology is cached internally. Cache will be refreshed in the background with " + + "interval defined by topologyRefreshFrequency property (see below)."); + props[18] = new PropertyInfo("gg.client.topology.refresh", info.getProperty("gg.client.topology.refresh", + "2000"), "Topology cache refresh frequency (ms)."); + props[19] = new PropertyInfo("gg.client.idleTimeout", info.getProperty("gg.client.idleTimeout", "30000"), + "Maximum amount of time that connection can be idle before it is closed (ms)."); + + return props; + } + + /** {@inheritDoc} */ + @Override public int getMajorVersion() { + return MAJOR_VER; + } + + /** {@inheritDoc} */ + @Override public int getMinorVersion() { + return MINOR_VER; + } + + /** {@inheritDoc} */ + @Override public boolean jdbcCompliant() { + return false; + } + + /** {@inheritDoc} */ + @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new SQLFeatureNotSupportedException("java.util.logging is not used."); + } + + /** + * Validates and parses connection URL. + * + * @param props Properties. + * @param url URL. + * @return Whether URL is valid. + */ + private boolean parseUrl(String url, Properties props) { + if (url == null || !url.startsWith(URL_PREFIX) || url.length() == URL_PREFIX.length()) + return false; + + url = url.substring(URL_PREFIX.length()); + + String[] parts = url.split("\\?"); + + if (parts.length > 2) + return false; + + if (parts.length == 2) + if (!parseUrlParameters(parts[1], props)) + return false; + + parts = parts[0].split("/"); + + assert parts.length > 0; + + if (parts.length > 2) + return false; + + if (parts.length == 2 && !parts[1].isEmpty()) + props.setProperty(PROP_CACHE, parts[1]); + + url = parts[0]; + + parts = url.split(":"); + + assert parts.length > 0; + + if (parts.length > 2) + return false; + + props.setProperty(PROP_HOST, parts[0]); + + try { + props.setProperty(PROP_PORT, String.valueOf(parts.length == 2 ? Integer.valueOf(parts[1]) : DFLT_PORT)); + } + catch (NumberFormatException ignored) { + return false; + } + + return true; + } + + /** + * Validates and parses URL parameters. + * + * @param urlParams URL parameters string. + * @param props Properties. + * @return Whether URL parameters string is valid. + */ + private boolean parseUrlParameters(String urlParams, Properties props) { + String[] params = urlParams.split("&"); + + for (String param : params) { + String[] pair = param.split("="); + + if (pair.length != 2 || pair[0].isEmpty() || pair[1].isEmpty()) + return false; + + props.setProperty(PROP_PREFIX + pair[0], pair[1]); + } + + return true; + } + + /** + * Extension of {@link DriverPropertyInfo} that adds + * convenient constructors. + */ + private static class PropertyInfo extends DriverPropertyInfo { + /** + * @param name Name. + * @param val Value. + */ + private PropertyInfo(String name, String val) { + super(name, val); + } + + /** + * @param name Name. + * @param val Value. + * @param desc Description. + */ + private PropertyInfo(String name, String val, String desc) { + super(name, val); + + description = desc; + } + + /** + * @param name Name. + * @param val Value. + * @param required Required flag. + */ + private PropertyInfo(String name, String val, boolean required) { + super(name, val); + + this.required = required; + } + + /** + * @param name Name. + * @param val Value. + * @param desc Description. + * @param required Required flag. + */ + private PropertyInfo(String name, String val, String desc, boolean required) { + super(name, val); + + description = desc; + this.required = required; + } + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/IgniteLogger.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/IgniteLogger.java index 0212212,7b0e4ba..b5a3a10 --- a/modules/core/src/main/java/org/apache/ignite/IgniteLogger.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteLogger.java @@@ -51,12 -51,12 +51,12 @@@ import org.jetbrains.annotations.* * </property> * ... * </pre> - * It's recommended to use GridGain's logger injection instead of using/instantiating + * It's recommended to use Ignite's logger injection instead of using/instantiating - * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource} annotation about logger + * logger in your task/job code. See {@link org.apache.ignite.resources.LoggerResource} annotation about logger * injection. * <h1 class="header">Quiet Mode</h1> - * By default GridGain 3.0 and later starts in "quiet" mode suppressing {@code INFO} and {@code DEBUG} - * log output. If system property {@code IGNITE_QUIET} is set to {@code false} than GridGain + * By default Ignite 3.0 and later starts in "quiet" mode suppressing {@code INFO} and {@code DEBUG} + * log output. If system property {@code IGNITE_QUIET} is set to {@code false} than Ignition * will operate in normal un-suppressed logging mode. Note that all output in "quiet" mode is * done through standard output (STDOUT). * <p> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/IgniteServices.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/IgniteServices.java index e67f655,0000000..02f9639 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteServices.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteServices.java @@@ -1,361 -1,0 +1,361 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.services.*; +import org.apache.ignite.resources.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Defines functionality necessary to deploy distributed services on the grid. Instance of + * {@code GridServices} is obtained from grid projection as follows: + * <pre name="code" class="java"> - * GridServices svcs = GridGain.grid().services(); ++ * GridServices svcs = Ignition.ignite().services(); + * </pre> + * With distributed services you can do the following: + * <ul> + * <li>Automatically deploy any number of service instances on the grid.</li> + * <li> + * Automatically deploy singletons, including <b>cluster-singleton</b>, + * <b>node-singleton</b>, or <b>key-affinity-singleton</b>. + * </li> + * <li>Automatically deploy services on node start-up by specifying them in grid configuration.</li> + * <li>Undeploy any of the deployed services.</li> + * <li>Get information about service deployment topology within the grid.</li> + * </ul> + * <h1 class="header">Deployment From Configuration</h1> + * In addition to deploying managed services by calling any of the provided {@code deploy(...)} methods, + * you can also automatically deploy services on startup by specifying them in {@link IgniteConfiguration} + * like so: + * <pre name="code" class="java"> + * GridConfiguration gridCfg = new GridConfiguration(); + * + * GridServiceConfiguration svcCfg1 = new GridServiceConfiguration(); + * + * // Cluster-wide singleton configuration. + * svcCfg1.setName("myClusterSingletonService"); + * svcCfg1.setMaxPerNodeCount(1); + * svcCfg1.setTotalCount(1); + * svcCfg1.setService(new MyClusterSingletonService()); + * + * GridServiceConfiguration svcCfg2 = new GridServiceConfiguration(); + * + * // Per-node singleton configuration. + * svcCfg2.setName("myNodeSingletonService"); + * svcCfg2.setMaxPerNodeCount(1); + * svcCfg2.setService(new MyNodeSingletonService()); + * + * gridCfg.setServiceConfiguration(svcCfg1, svcCfg2); + * ... - * GridGain.start(gridCfg); ++ * Ignition.start(gridCfg); + * </pre> + * <h1 class="header">Load Balancing</h1> - * In all cases, other than singleton service deployment, GridGain will automatically make sure that ++ * In all cases, other than singleton service deployment, Ignite will automatically make sure that + * an about equal number of services are deployed on each node within the grid. Whenever cluster topology - * changes, GridGain will re-evaluate service deployments and may re-deploy an already deployed service ++ * changes, Ignite will re-evaluate service deployments and may re-deploy an already deployed service + * on another node for better load balancing. + * <h1 class="header">Fault Tolerance</h1> - * GridGain guarantees that services are deployed according to specified configuration regardless ++ * Ignite guarantees that services are deployed according to specified configuration regardless + * of any topology changes, including node crashes. + * <h1 class="header">Resource Injection</h1> + * All distributed services can be injected with + * ignite resources. Both, field and method based injections are supported. The following ignite + * resources can be injected: + * <ul> + * <li>{@link IgniteInstanceResource}</li> + * <li>{@link org.apache.ignite.resources.LoggerResource}</li> + * <li>{@link org.apache.ignite.resources.SpringApplicationContextResource}</li> + * <li>{@link org.apache.ignite.resources.SpringResource}</li> + * </ul> + * Refer to corresponding resource documentation for more information. + * <h1 class="header">Service Example</h1> + * Here is an example of how an distributed service may be implemented and deployed: + * <pre name="code" class="java"> + * // Simple service implementation. + * public class MyGridService implements GridService { + * ... + * // Example of ignite resource injection. All resources are optional. + * // You should inject resources only as needed. + * @IgniteInstanceResource + * private Grid grid; + * ... + * @Override public void cancel(GridServiceContext ctx) { + * // No-op. + * } + * + * @Override public void execute(GridServiceContext ctx) { + * // Loop until service is cancelled. + * while (!ctx.isCancelled()) { + * // Do something. + * ... + * } + * } + * } + * ... + * GridServices svcs = grid.services(); + * + * GridFuture<?> fut = svcs.deployClusterSingleton("mySingleton", new MyGridService()); + * + * // Wait for deployment to complete. + * fut.get(); + * </pre> + */ +public interface IgniteServices extends IgniteAsyncSupport { + /** + * Gets grid projection to which this {@code GridServices} instance belongs. + * + * @return Grid projection to which this {@code GridServices} instance belongs. + */ + public ClusterGroup clusterGroup(); + + /** - * Deploys a cluster-wide singleton service. GridGain will guarantee that there is always ++ * Deploys a cluster-wide singleton service. Ignite will guarantee that there is always + * one instance of the service in the cluster. In case if grid node on which the service - * was deployed crashes or stops, GridGain will automatically redeploy it on another node. ++ * was deployed crashes or stops, Ignite will automatically redeploy it on another node. + * However, if the node on which the service is deployed remains in topology, then the + * service will always be deployed on that node only, regardless of topology changes. + * <p> + * Note that in case of topology changes, due to network delays, there may be a temporary situation + * when a singleton service instance will be active on more than one node (e.g. crash detection delay). + * <p> + * This method is analogous to calling + * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 1, 1)} method. + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @param name Service name. + * @param svc Service instance. + * @throws IgniteException If failed to deploy service. + */ + @IgniteAsyncSupported + public void deployClusterSingleton(String name, Service svc) throws IgniteException; + + /** - * Deploys a per-node singleton service. GridGain will guarantee that there is always ++ * Deploys a per-node singleton service. Ignite will guarantee that there is always + * one instance of the service running on each node. Whenever new nodes are started - * within this grid projection, GridGain will automatically deploy one instance of ++ * within this grid projection, Ignite will automatically deploy one instance of + * the service on every new node. + * <p> + * This method is analogous to calling + * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 0, 1)} method. + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @param name Service name. + * @param svc Service instance. + * @throws IgniteException If failed to deploy service. + */ + @IgniteAsyncSupported + public void deployNodeSingleton(String name, Service svc) throws IgniteException; + + /** + * Deploys one instance of this service on the primary node for a given affinity key. - * Whenever topology changes and primary node assignment changes, GridGain will always ++ * Whenever topology changes and primary node assignment changes, Ignite will always + * make sure that the service is undeployed on the previous primary node and deployed + * on the new primary node. + * <p> + * Note that in case of topology changes, due to network delays, there may be a temporary situation + * when a service instance will be active on more than one node (e.g. crash detection delay). + * <p> + * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)} method + * as follows: + * <pre name="code" class="java"> + * GridServiceConfiguration cfg = new GridServiceConfiguration(); + * + * cfg.setName(name); + * cfg.setService(svc); + * cfg.setCacheName(cacheName); + * cfg.setAffinityKey(affKey); + * cfg.setTotalCount(1); + * cfg.setMaxPerNodeCount(1); + * + * grid.services().deploy(cfg); + * </pre> + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @param name Service name. + * @param svc Service instance. + * @param cacheName Name of the cache on which affinity for key should be calculated, {@code null} for + * default cache. + * @param affKey Affinity cache key. + * @throws IgniteException If failed to deploy service. + */ + @IgniteAsyncSupported + public void deployKeyAffinitySingleton(String name, + Service svc, + @Nullable String cacheName, + Object affKey) + throws IgniteException; + + /** - * Deploys multiple instances of the service on the grid. GridGain will deploy a ++ * Deploys multiple instances of the service on the grid. Ignite will deploy a + * maximum amount of services equal to {@code 'totalCnt'} parameter making sure that + * there are no more than {@code 'maxPerNodeCnt'} service instances running - * on each node. Whenever topology changes, GridGain will automatically rebalance ++ * on each node. Whenever topology changes, Ignite will automatically rebalance + * the deployed services within cluster to make sure that each node will end up with + * about equal number of deployed instances whenever possible. + * <p> + * Note that at least one of {@code 'totalCnt'} or {@code 'maxPerNodeCnt'} parameters must have + * value greater than {@code 0}. + * <p> + * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)} method + * as follows: + * <pre name="code" class="java"> + * GridServiceConfiguration cfg = new GridServiceConfiguration(); + * + * cfg.setName(name); + * cfg.setService(svc); + * cfg.setTotalCount(totalCnt); + * cfg.setMaxPerNodeCount(maxPerNodeCnt); + * + * grid.services().deploy(cfg); + * </pre> + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @param name Service name. + * @param svc Service instance. + * @param totalCnt Maximum number of deployed services in the grid, {@code 0} for unlimited. + * @param maxPerNodeCnt Maximum number of deployed services on each node, {@code 0} for unlimited. + * @throws IgniteException If failed to deploy service. + */ + @IgniteAsyncSupported + public void deployMultiple(String name, + Service svc, + int totalCnt, + int maxPerNodeCnt) + throws IgniteException; + + /** + * Deploys multiple instances of the service on the grid according to provided - * configuration. GridGain will deploy a maximum amount of services equal to ++ * configuration. Ignite will deploy a maximum amount of services equal to + * {@link org.apache.ignite.services.ServiceConfiguration#getTotalCount() cfg.getTotalCount()} parameter + * making sure that there are no more than {@link org.apache.ignite.services.ServiceConfiguration#getMaxPerNodeCount() cfg.getMaxPerNodeCount()} + * service instances running on each node. Whenever topology changes, GridGain will automatically rebalance + * the deployed services within cluster to make sure that each node will end up with + * about equal number of deployed instances whenever possible. + * <p> - * If {@link org.apache.ignite.services.ServiceConfiguration#getAffinityKey() cfg.getAffinityKey()} is not {@code null}, then GridGain ++ * If {@link org.apache.ignite.services.ServiceConfiguration#getAffinityKey() cfg.getAffinityKey()} is not {@code null}, then Ignite + * will deploy the service on the primary node for given affinity key. The affinity will be calculated + * on the cache with {@link org.apache.ignite.services.ServiceConfiguration#getCacheName() cfg.getCacheName()} name. + * <p> + * If {@link org.apache.ignite.services.ServiceConfiguration#getNodeFilter() cfg.getNodeFilter()} is not {@code null}, then - * GridGain will deploy service on all grid nodes for which the provided filter evaluates to {@code true}. ++ * Ignite will deploy service on all grid nodes for which the provided filter evaluates to {@code true}. + * The node filter will be checked in addition to the underlying grid projection filter, or the + * whole grid, if the underlying grid projection includes all grid nodes. + * <p> + * Note that at least one of {@code 'totalCnt'} or {@code 'maxPerNodeCnt'} parameters must have + * value greater than {@code 0}. + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * <p> + * Here is an example of creating service deployment configuration: + * <pre name="code" class="java"> + * GridServiceConfiguration cfg = new GridServiceConfiguration(); + * + * cfg.setName(name); + * cfg.setService(svc); + * cfg.setTotalCount(0); // Unlimited. + * cfg.setMaxPerNodeCount(2); // Deploy 2 instances of service on each node. + * + * grid.services().deploy(cfg); + * </pre> + * + * @param cfg Service configuration. + * @throws IgniteException If failed to deploy service. + */ + @IgniteAsyncSupported + public void deploy(ServiceConfiguration cfg) throws IgniteException; + + /** + * Cancels service deployment. If a service with specified name was deployed on the grid, + * then {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)} method will be called on it. + * <p> - * Note that GridGain cannot guarantee that the service exits from {@link org.apache.ignite.services.Service#execute(org.apache.ignite.services.ServiceContext)} ++ * Note that Ignite cannot guarantee that the service exits from {@link org.apache.ignite.services.Service#execute(org.apache.ignite.services.ServiceContext)} + * method whenever {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)} is called. It is up to the user to + * make sure that the service code properly reacts to cancellations. + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @param name Name of service to cancel. + * @throws IgniteException If failed to cancel service. + */ + @IgniteAsyncSupported + public void cancel(String name) throws IgniteException; + + /** + * Cancels all deployed services. + * <p> + * Note that depending on user logic, it may still take extra time for a service to + * finish execution, even after it was cancelled. + * <p> + * Supports asynchronous execution (see {@link IgniteAsyncSupport}). + * + * @throws IgniteException If failed to cancel services. + */ + @IgniteAsyncSupported + public void cancelAll() throws IgniteException; + + /** + * Gets metadata about all deployed services. + * + * @return Metadata about all deployed services. + */ + public Collection<ServiceDescriptor> serviceDescriptors(); + + /** + * Gets deployed service with specified name. + * + * @param name Service name. + * @param <T> Service type + * @return Deployed service with specified name. + */ + public <T> T service(String name); + + /** + * Gets all deployed services with specified name. + * + * @param name Service name. + * @param <T> Service type. + * @return all deployed services with specified name. + */ + public <T> Collection<T> services(String name); + + /** + * Gets a remote handle on the service. If service is available locally, + * then local instance is returned, otherwise, a remote proxy is dynamically + * created and provided for the specified service. + * + * @param name Service name. + * @param svcItf Interface for the service. - * @param sticky Whether or not GridGain should always contact the same remote ++ * @param sticky Whether or not Ignite should always contact the same remote + * service or try to load-balance between services. + * @return Either proxy over remote service or local service if it is deployed locally. + * @throws IgniteException If failed to create service proxy. + */ + public <T> T serviceProxy(String name, Class<? super T> svcItf, boolean sticky) throws IgniteException; + + /** {@inheritDoc} */ + @Override public IgniteServices withAsync(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/IgniteState.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/Ignition.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/CacheRendezvousAffinityFunction.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/eviction/ignitefs/package.html ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/cache/eviction/ignitefs/package.html index 7505d73,0000000..41c295f mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/ignitefs/package.html +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/ignitefs/package.html @@@ -1,23 -1,0 +1,24 @@@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. - --> ++--> ++ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> +<!-- Package description. --> +Contains GGFS LRU eviction policy implementations. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java index ed5a66e,47d330c..628a5f1 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java @@@ -51,9 -51,9 +51,9 @@@ import org.jetbrains.annotations.* * <h2 class="header">Custom functions in SQL queries.</h2> * It is possible to write custom Java methods and call then form SQL queries. These methods must be public static * and annotated with {@link CacheQuerySqlFunction}. Classes containing these methods must be registered in - * {@link org.apache.ignite.configuration.IgniteQueryConfiguration#setIndexCustomFunctionClasses(Class[])}. + * {@link org.apache.ignite.configuration.QueryConfiguration#setIndexCustomFunctionClasses(Class[])}. * <h1 class="header">Full Text Queries</h1> - * GridGain supports full text queries based on Apache Lucene engine. This queries are created by + * Ignite supports full text queries based on Apache Lucene engine. This queries are created by * {@link CacheQueries#createFullTextQuery(Class, String)} method. Note that all fields that * are expected to show up in text query results must be annotated with {@link CacheQueryTextField} * annotation. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java index e865b63,504abf4..367773f --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java @@@ -84,8 -85,8 +84,8 @@@ import static javax.cache.Cache.* * ... * } * </pre> - * This behavior can be overridden by setting {@link CacheConfiguration#setKeepPortableInStore(boolean)} + * This behavior can be overridden by setting {@link org.apache.ignite.configuration.CacheConfiguration#setKeepPortableInStore(boolean)} - * flag value to {@code false}. In this case, GridGain will deserialize keys and values stored in portable + * flag value to {@code false}. In this case, Ignite will deserialize keys and values stored in portable * format before they are passed to cache store, so that you can use the following cache store signature instead: * <pre name="code" class="java"> * public class ObjectsCacheStore implements GridCacheStore<Integer, Person> { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/compute/ComputeJob.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java index a8cb10a,a948edf..8d390fa --- a/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java +++ b/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContext.java @@@ -50,11 -50,11 +50,11 @@@ import java.util.concurrent.* * ability to check context attributes from within grid task implementation for every job * returned from remote nodes. * <p> - * Job context can be injected into {@link ComputeJob} via {@link org.apache.ignite.resources.IgniteJobContextResource} - * annotation. Refer to the {@link org.apache.ignite.resources.IgniteJobContextResource} + * Job context can be injected into {@link ComputeJob} via {@link org.apache.ignite.resources.JobContextResource} + * annotation. Refer to the {@link org.apache.ignite.resources.JobContextResource} * documentation for coding examples on how to inject job context. * <p> - * Attribute names that start with {@code "gridgain:"} are reserved for internal system use. + * Attribute names that start with {@code "apache.ignite:"} are reserved for internal system use. */ public interface ComputeJobContext extends ComputeJobContinuation { /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobContinuationAdapter.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/compute/ComputeTask.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskSession.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/configuration/AddressResolver.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/configuration/AddressResolver.java index 7a3d27a,0000000..7170dac mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/AddressResolver.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/AddressResolver.java @@@ -1,43 -1,0 +1,43 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.configuration; + +import org.apache.ignite.*; + +import java.net.*; +import java.util.*; + +/** + * Provides resolution between external and internal addresses. In some cases + * network routers are configured to perform address mapping between external + * and internal networks and the same mapping must be available to SPIs - * in GridGain that perform communication over IP protocols. ++ * in Ignite that perform communication over IP protocols. + */ +public interface AddressResolver { + /** + * Maps internal address to a collection of external addresses. + * + * @param addr Internal (local) address. + * @return Collection of addresses that this local address is "known" outside. + * Note that if there are more than one external network the local address + * can be mapped differently to each and therefore may need to return + * multiple external addresses. + * @throws IgniteCheckedException Thrown if any exception occurs. + */ + public Collection<InetSocketAddress> getExternalAddresses(InetSocketAddress addr) throws IgniteCheckedException; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/configuration/DeploymentMode.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/configuration/DeploymentMode.java index cef3947,0000000..9d49a2e mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/DeploymentMode.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/DeploymentMode.java @@@ -1,181 -1,0 +1,181 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.configuration; + +import org.jetbrains.annotations.*; + +/** + * Grid deployment mode. Deployment mode is specified at grid startup via + * {@link org.apache.ignite.configuration.IgniteConfiguration#getDeploymentMode()} configuration property + * (it can also be specified in Spring XML configuration file). The main + * difference between all deployment modes is how classes are loaded on remote nodes via peer-class-loading mechanism. + * <p> + * The following deployment modes are supported: + * <ul> + * <li>{@link #PRIVATE}</li> + * <li>{@link #ISOLATED}</li> + * <li>{@link #SHARED}</li> + * <li>{@link #CONTINUOUS}</li> + * </ul> + * <h1 class="header">User Version</h1> + * User version comes into play whenever you would like to redeploy tasks deployed - * in {@link #SHARED} or {@link #CONTINUOUS} modes. By default, GridGain will ++ * in {@link #SHARED} or {@link #CONTINUOUS} modes. By default, Ignite will + * automatically detect if class-loader changed or a node is restarted. However, + * if you would like to change and redeploy code on a subset of nodes, or in + * case of {@link #CONTINUOUS} mode to kill the ever living deployment, you should + * change the user version. + * <p> - * User version is specified in {@code META-INF/gridgain.xml} file as follows: ++ * User version is specified in {@code META-INF/ignite.xml} file as follows: + * <pre name="code" class="xml"> + * <!-- User version. --> + * <bean id="userVersion" class="java.lang.String"> + * <constructor-arg value="0"/> + * </bean> + * </pre> - * By default, all gridgain startup scripts ({@code gridgain.sh} or {@code gridgain.bat}) ++ * By default, all ignite startup scripts ({@code ignite.sh} or {@code ignite.bat}) + * pick up user version from {@code IGNITE_HOME/config/userversion} folder. Usually, it + * is just enough to update user version under that folder, however, in case of {@code GAR} - * or {@code JAR} deployment, you should remember to provide {@code META-INF/gridgain.xml} ++ * or {@code JAR} deployment, you should remember to provide {@code META-INF/ignite.xml} + * file with desired user version in it. + * <p> + * <h1 class="header">Always-Local Development</h1> - * GridGain deployment (regardless of mode) allows you to develop everything as you would ++ * Ignite deployment (regardless of mode) allows you to develop everything as you would + * locally. You never need to specifically write any kind of code for remote nodes. For + * example, if you need to use a distributed cache from your {@link org.apache.ignite.compute.ComputeJob}, then you can + * the following: + * <ol> + * <li> - * Simply startup stand-alone GridGain nodes by executing ++ * Simply startup stand-alone Ignite nodes by executing + * {@code IGNITE_HOME/ignite.{sh|bat}} scripts. + * </li> + * <li> + * Now, all jobs executing locally or remotely can have a single instance of cache + * on every node, and all jobs can access instances stored by any other job without + * any need for explicit deployment. + * </li> + * </ol> + */ +public enum DeploymentMode { + /** + * In this mode deployed classes do not share resources. Basically, resources are created + * once per deployed task class and then get reused for all executions. + * <p> + * Note that classes deployed within the same class loader on master + * node, will still share the same class loader remotely on worker nodes. + * However, tasks deployed from different master nodes will not + * share the same class loader on worker nodes, which is useful in + * development when different developers can be working on different + * versions of the same classes. + * <p> + * Also note that resources are associated with task deployment, + * not task execution. If the same deployed task gets executed multiple + * times, then it will keep reusing the same user resources + * every time. + */ + PRIVATE, + + /** + * Unlike {@link #PRIVATE} mode, where different deployed tasks will + * never use the same instance of resources, in {@code ISOLATED} + * mode, tasks or classes deployed within the same class loader + * will share the same instances of resources. + * This means that if multiple tasks classes are loaded by the same + * class loader on master node, then they will share instances + * of resources on worker nodes. In other words, user resources + * get initialized once per class loader and then get reused for all + * consecutive executions. + * <p> + * Note that classes deployed within the same class loader on master + * node, will still share the same class loader remotely on worker nodes. + * However, tasks deployed from different master nodes will not + * share the same class loader on worker nodes, which is especially + * useful when different developers can be working on different versions + * of the same classes. + */ + ISOLATED, + + /** + * Same as {@link #ISOLATED}, but now tasks from + * different master nodes with the same user version and same + * class loader will share the same class loader on remote + * nodes. Classes will be undeployed whenever all master + * nodes leave grid or user version changes. + * <p> + * The advantage of this approach is that it allows tasks coming from + * different master nodes share the same instances of resources on worker nodes. This allows for all + * tasks executing on remote nodes to reuse, for example, the same instances of + * connection pools or caches. When using this mode, you can - * startup multiple stand-alone GridGain worker nodes, define resources ++ * startup multiple stand-alone Ignite worker nodes, define resources + * on master nodes and have them initialize once on worker nodes regardless + * of which master node they came from. + * <p> + * This method is specifically useful in production as, in comparison + * to {@link #ISOLATED} deployment mode, which has a scope of single + * class loader on a single master node, this mode broadens the + * deployment scope to all master nodes. + * <p> + * Note that classes deployed in this mode will be undeployed if + * all master nodes left grid or if user version changed. User version can - * be specified in {@code META-INF/gridgain.xml} file as a Spring bean ++ * be specified in {@code META-INF/ignite.xml} file as a Spring bean + * property with name {@code userVersion}. This file has to be in the class + * path of the class used for task execution. + * <p> + * {@code SHARED} deployment mode is default mode used by the grid. + */ + SHARED, + + /** + * Same as {@link #SHARED} deployment mode, but resources will not be undeployed even after all master + * nodes left grid. Tasks from different master nodes with the same user + * version and same class loader will share the same class loader on remote + * worker nodes. Classes will be undeployed whenever user version changes. + * <p> + * The advantage of this approach is that it allows tasks coming from + * different master nodes share the same instances of resources on worker nodes. This allows for all + * tasks executing on remote nodes to reuse, for example, the same instances of + * connection pools or caches. When using this mode, you can - * startup multiple stand-alone GridGain worker nodes, define resources ++ * startup multiple stand-alone Ignite worker nodes, define resources + * on master nodes and have them initialize once on worker nodes regardless + * of which master node they came from. + * <p> + * This method is specifically useful in production as, in comparison + * to {@link #ISOLATED} deployment mode, which has a scope of single + * class loader on a single master node, <tt>CONTINUOUS</tt> mode broadens + * the deployment scope to all master nodes. + * <p> + * Note that classes deployed in <tt>CONTINUOUS</tt> mode will be undeployed + * only if user version changes. User version can be specified in - * {@code META-INF/gridgain.xml} file as a Spring bean property with name ++ * {@code META-INF/ignite.xml} file as a Spring bean property with name + * {@code userVersion}. This file has to be in the class + * path of the class used for task execution. + */ + CONTINUOUS; + + /** Enum values. */ + private static final DeploymentMode[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value. + */ + @Nullable public static DeploymentMode fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java ----------------------------------------------------------------------