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 2017/09/18 08:43:01 UTC
[01/26] ignite git commit: ignite-6289 Remove "allOrNone" flag from
IgniteServices#deployAll method
Repository: ignite
Updated Branches:
refs/heads/ignite-6149 7815a977e -> 62dbb11d5
ignite-6289 Remove "allOrNone" flag from IgniteServices#deployAll method
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91cf66e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91cf66e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91cf66e7
Branch: refs/heads/ignite-6149
Commit: 91cf66e7083e4e73b2bcd08e81fdb29cf06ddc59
Parents: 50c7002
Author: Denis Mekhanikov <dm...@gmail.com>
Authored: Fri Sep 15 11:19:18 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 15 11:19:18 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteServices.java | 44 +++---
.../ignite/internal/IgniteServicesImpl.java | 13 +-
.../GridServiceDeploymentCompoundFuture.java | 129 ++---------------
.../service/GridServiceProcessor.java | 64 +++------
.../service/PreparedConfigurations.java | 8 +-
...ServiceDeploymentCompoundFutureSelfTest.java | 121 +---------------
...GridServiceProcessorBatchDeploySelfTest.java | 137 +++++--------------
7 files changed, 95 insertions(+), 421 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteServices.java b/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
index e161b11..2222db0 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
@@ -435,46 +435,40 @@ public interface IgniteServices extends IgniteAsyncSupport {
/**
* Deploys multiple services described by provided configurations. Depending on specified parameters, multiple
- * instances of the same service may be deployed (see {@link ServiceConfiguration}).
- * 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.
+ * instances of the same service may be deployed (see {@link ServiceConfiguration}). 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.
*
- * If deployment fails, then {@link ServiceDeploymentException} containing a list of failed services will be
- * thrown. It is guaranteed that all services that were provided to this method and are not present in the list of
- * failed services are successfully deployed by the moment of the exception being thrown.
+ * If deployment of some of the provided services fails, then {@link ServiceDeploymentException} containing a list
+ * of failed services will be thrown. It is guaranteed that all services that were provided to this method and are
+ * not present in the list of failed services are successfully deployed by the moment of the exception being thrown.
+ * Note that if exception is thrown, then partial deployment may have occurred.
*
* @param cfgs {@link Collection} of service configurations to be deployed.
- * @param allOrNone Specifies behavior in case when errors during deployment occur. If {@code true}, then two
- * outcomes are possible: either all services will be deployed, or none of them. If {@code false}, then partial
- * deployments are permitted.
* @throws ServiceDeploymentException If failed to deploy services.
* @see IgniteServices#deploy(ServiceConfiguration)
- * @see IgniteServices#deployAllAsync(Collection, boolean)
+ * @see IgniteServices#deployAllAsync(Collection)
*/
- public void deployAll(Collection<ServiceConfiguration> cfgs, boolean allOrNone) throws ServiceDeploymentException;
+ public void deployAll(Collection<ServiceConfiguration> cfgs) throws ServiceDeploymentException;
/**
* Asynchronously deploys multiple services described by provided configurations. Depending on specified parameters,
- * multiple instances of the same service may be deployed (see {@link ServiceConfiguration}).
- * 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.
+ * multiple instances of the same service may be deployed (see {@link ServiceConfiguration}). 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.
*
- * If deployment fails, then {@link ServiceDeploymentException} containing a list of failed services will be
- * thrown from {@link IgniteFuture#get get()} method of the returned future. It is guaranteed that all services,
- * that were provided to this method and are not present in the list of failed services, are successfully deployed
- * by the moment of the exception being thrown.
+ * If deployment of some of the provided services fails, then {@link ServiceDeploymentException} containing a list
+ * of failed services will be thrown from {@link IgniteFuture#get get()} method of the returned future. It is
+ * guaranteed that all services, that were provided to this method and are not present in the list of failed
+ * services, are successfully deployed by the moment of the exception being thrown. Note that if exception is
+ * thrown, then partial deployment may have occurred.
*
* @param cfgs {@link Collection} of service configurations to be deployed.
- * @param allOrNone Specifies behavior in case when errors during deployment occur. If {@code true}, then two
- * outcomes are possible: either all services will be deployed, or none of them. If {@code false}, then partial
- * deployments are permitted.
* @return a Future representing pending completion of the operation.
* @see IgniteServices#deploy(ServiceConfiguration)
- * @see IgniteServices#deployAll(Collection,boolean)
+ * @see IgniteServices#deployAll(Collection)
*/
- public IgniteFuture<Void> deployAllAsync(Collection<ServiceConfiguration> cfgs, boolean allOrNone);
+ public IgniteFuture<Void> deployAllAsync(Collection<ServiceConfiguration> cfgs);
/**
* Cancels service deployment. If a service with specified name was deployed on the grid,
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
index ad455d8..00d6078 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
@@ -218,24 +218,24 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
@Override public void deploy(ServiceConfiguration cfg) {
A.notNull(cfg, "cfg");
- deployAll(Collections.singleton(cfg), false);
+ deployAll(Collections.singleton(cfg));
}
/** {@inheritDoc} */
@Override public IgniteFuture<Void> deployAsync(ServiceConfiguration cfg) {
A.notNull(cfg, "cfg");
- return deployAllAsync(Collections.singleton(cfg), false);
+ return deployAllAsync(Collections.singleton(cfg));
}
/** {@inheritDoc} */
- @Override public void deployAll(Collection<ServiceConfiguration> cfgs, boolean allOrNone) {
+ @Override public void deployAll(Collection<ServiceConfiguration> cfgs) {
A.notNull(cfgs, "cfgs");
guard();
try {
- saveOrGet(ctx.service().deployAll(cfgs, allOrNone));
+ saveOrGet(ctx.service().deployAll(cfgs));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -246,14 +246,13 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
- @Override public IgniteFuture<Void> deployAllAsync(Collection<ServiceConfiguration> cfgs,
- boolean allOrNone) {
+ @Override public IgniteFuture<Void> deployAllAsync(Collection<ServiceConfiguration> cfgs) {
A.notNull(cfgs, "cfgs");
guard();
try {
- return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployAll(cfgs, allOrNone));
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployAll(cfgs));
}
finally {
unguard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFuture.java
index bbf0370..45ccc24 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFuture.java
@@ -20,140 +20,51 @@ package org.apache.ignite.internal.processors.service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.services.ServiceConfiguration;
import org.apache.ignite.services.ServiceDeploymentException;
import org.jetbrains.annotations.Nullable;
/**
- * Service deployment compound future, {@code allOrNone} parameter specifies failing policy.
- * <p>
- * If {@code allOrNone} parameter is set to {@code false}, then this future waits for completion of all child futures.
- * If any exceptions are thrown during deployment, then {@link IgniteCheckedException} with {@link
- * ServiceDeploymentException} as a cause will be thrown from {@link IgniteInternalFuture#get get()} method after all
- * futures complete or fail. Inner exception will contain configurations of failed services.
+ * Service deployment compound future. If any exceptions are thrown during deployment, then {@link
+ * IgniteCheckedException} with {@link ServiceDeploymentException} as a cause will be thrown from {@link
+ * IgniteInternalFuture#get get()} method after all futures complete or fail. Inner exception will contain
+ * configurations of failed services.
*/
public class GridServiceDeploymentCompoundFuture extends GridCompoundFuture<Object, Object> {
- /** */
- private final boolean allOrNone;
-
- /** Kernal context. */
- private final GridKernalContext ctx;
-
- /** Logger. */
- private final IgniteLogger log;
-
/** Names of services written to cache during current deployment. */
private Collection<String> svcsToRollback;
/** */
private volatile ServiceDeploymentException err;
- /**
- * @param allOrNone Failing policy.
- * @param ctx Kernal context.
- */
- GridServiceDeploymentCompoundFuture(boolean allOrNone, GridKernalContext ctx) {
- this.allOrNone = allOrNone;
- this.ctx = ctx;
- this.log = ctx.log(getClass());
- }
-
/** {@inheritDoc} */
@Override protected boolean processFailure(Throwable err, IgniteInternalFuture<Object> fut) {
assert fut instanceof GridServiceDeploymentFuture : fut;
GridServiceDeploymentFuture depFut = (GridServiceDeploymentFuture)fut;
- if (allOrNone) {
- if (initialized()) {
- onDone(new IgniteCheckedException(
- new ServiceDeploymentException("Failed to deploy provided services.", err, getConfigurations())));
- }
- else {
- synchronized (this) {
- if (this.err == null) {
- this.err = new ServiceDeploymentException("Failed to deploy provided services.", err,
- new ArrayList<ServiceConfiguration>());
- }
- else
- this.err.addSuppressed(err);
- }
+ synchronized (this) {
+ if (this.err == null) {
+ this.err = new ServiceDeploymentException("Failed to deploy some services.",
+ new ArrayList<ServiceConfiguration>());
}
- }
- else {
- synchronized (this) {
- if (this.err == null)
- this.err = new ServiceDeploymentException("Failed to deploy some services.",
- new ArrayList<ServiceConfiguration>());
- this.err.getFailedConfigurations().add(depFut.configuration());
- this.err.addSuppressed(err);
- }
+ this.err.getFailedConfigurations().add(depFut.configuration());
+ this.err.addSuppressed(err);
}
return true;
}
- /**
- * Marks this future as initialized. Will complete with error if failures before initialization occurred and
- * all-or-none policy is followed.
- */
- public void serviceDeploymentMarkInitialized() {
- if (allOrNone && this.err != null) {
- this.err.getFailedConfigurations().addAll(getConfigurations());
-
- onDone(new IgniteCheckedException(this.err));
- }
- else
- super.markInitialized();
- }
-
/** {@inheritDoc} */
- @Override protected boolean onDone(@Nullable final Object res, @Nullable Throwable err, final boolean cancel) {
- final Throwable resErr;
-
+ @Override protected boolean onDone(@Nullable Object res, @Nullable Throwable err, boolean cancel) {
if (err == null && this.err != null)
- resErr = new IgniteCheckedException(this.err);
- else
- resErr = err;
-
- if (allOrNone && this.err != null && svcsToRollback != null) {
- U.warn(log, "Failed to deploy provided services. The following services will be cancelled:" + svcsToRollback);
-
- IgniteInternalFuture<?> fut = ctx.service().cancelAll(svcsToRollback);
-
- /*
- Can not call fut.get() since it is possible we are in system pool now and
- fut also should be completed from system pool.
- */
- fut.listen(new IgniteInClosure<IgniteInternalFuture>() {
- @Override public void apply(IgniteInternalFuture fut) {
- try {
- fut.get();
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to cancel deployed services.", e);
- }
- finally {
- svcsToRollback = null;
- }
-
- GridServiceDeploymentCompoundFuture.super.onDone(res, resErr, cancel);
- }
- });
-
- return false;
- }
+ err = new IgniteCheckedException(this.err);
- return super.onDone(res, resErr, cancel);
+ return super.onDone(res, err, cancel);
}
/**
@@ -180,18 +91,4 @@ public class GridServiceDeploymentCompoundFuture extends GridCompoundFuture<Obje
else
return Collections.emptyList();
}
-
- /**
- * @return Collection of configurations, stored in child futures.
- */
- private Collection<ServiceConfiguration> getConfigurations() {
- Collection<IgniteInternalFuture<Object>> futs = futures();
-
- List<ServiceConfiguration> cfgs = new ArrayList<>(futs.size());
-
- for (IgniteInternalFuture<Object> fut : futs)
- cfgs.add(((GridServiceDeploymentFuture)fut).configuration());
-
- return cfgs;
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index f750053..9272760 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -270,7 +270,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
c.setNodeFilter(ctx.cluster().get().forServers().predicate());
}
- deployAll(Arrays.asList(cfgs), true).get();
+ deployAll(Arrays.asList(cfgs)).get();
}
if (log.isDebugEnabled())
@@ -495,10 +495,9 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
/**
* @param cfgs Service configurations.
- * @param allOrNone Failure processing policy.
* @return Configurations to deploy.
*/
- private PreparedConfigurations prepareServiceConfigurations(Collection<ServiceConfiguration> cfgs, boolean allOrNone) {
+ private PreparedConfigurations prepareServiceConfigurations(Collection<ServiceConfiguration> cfgs) {
List<ServiceConfiguration> cfgsCp = new ArrayList<>(cfgs.size());
Marshaller marsh = ctx.config().getMarshaller();
@@ -545,40 +544,28 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
}
if (err != null) {
- if (allOrNone) {
- return new PreparedConfigurations(null,
- null,
- new IgniteCheckedException(
- new ServiceDeploymentException("None of the provided services were deplyed.", err, cfgs)));
- }
- else {
- if (failedFuts == null)
- failedFuts = new ArrayList<>();
+ if (failedFuts == null)
+ failedFuts = new ArrayList<>();
- GridServiceDeploymentFuture fut = new GridServiceDeploymentFuture(cfg);
+ GridServiceDeploymentFuture fut = new GridServiceDeploymentFuture(cfg);
- fut.onDone(err);
+ fut.onDone(err);
- failedFuts.add(fut);
- }
+ failedFuts.add(fut);
}
}
- return new PreparedConfigurations(cfgsCp, failedFuts, null);
+ return new PreparedConfigurations(cfgsCp, failedFuts);
}
/**
* @param cfgs Service configurations.
- * @param allOrNone Failure processing policy.
* @return Future for deployment.
*/
- public IgniteInternalFuture<?> deployAll(Collection<ServiceConfiguration> cfgs, boolean allOrNone) {
+ public IgniteInternalFuture<?> deployAll(Collection<ServiceConfiguration> cfgs) {
assert cfgs != null;
- PreparedConfigurations srvCfg = prepareServiceConfigurations(cfgs, allOrNone);
-
- if (srvCfg.err != null)
- return new GridFinishedFuture<>(srvCfg.err);
+ PreparedConfigurations srvCfg = prepareServiceConfigurations(cfgs);
List<ServiceConfiguration> cfgsCp = srvCfg.cfgs;
@@ -593,7 +580,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
GridServiceDeploymentCompoundFuture res;
while (true) {
- res = new GridServiceDeploymentCompoundFuture(allOrNone, ctx);
+ res = new GridServiceDeploymentCompoundFuture();
if (ctx.deploy().enabled())
ctx.cache().context().deploy().ignoreOwnership(true);
@@ -610,16 +597,8 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
catch (IgniteCheckedException e) {
if (X.hasCause(e, ClusterTopologyCheckedException.class))
throw e; // Retry.
-
- if (allOrNone) {
- for (String name : res.servicesToRollback())
- depFuts.remove(name).onDone(e);
-
- res.onDone(new IgniteCheckedException(new ServiceDeploymentException(
- "Failed to deploy provided services.", e, cfgs)));
-
- return res;
- }
+ else
+ U.error(log, e.getMessage());
}
}
@@ -653,7 +632,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
if (ctx.clientDisconnected()) {
IgniteClientDisconnectedCheckedException err =
new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(),
- "Failed to deploy services, client node disconnected: " + cfgs);
+ "Failed to deploy services, client node disconnected: " + cfgs);
for (String name : res.servicesToRollback()) {
GridServiceDeploymentFuture fut = depFuts.remove(name);
@@ -670,7 +649,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
res.add(fut, false);
}
- res.serviceDeploymentMarkInitialized();
+ res.markInitialized();
return res;
}
@@ -707,12 +686,8 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
if (dep != null) {
if (!dep.configuration().equalsIgnoreNodeFilter(cfg)) {
- String err = "Failed to deploy service (service already exists with different " +
- "configuration) [deployed=" + dep.configuration() + ", new=" + cfg + ']';
-
- U.error(log, err);
-
- throw new IgniteCheckedException(err);
+ throw new IgniteCheckedException("Failed to deploy service (service already exists with " +
+ "different configuration) [deployed=" + dep.configuration() + ", new=" + cfg + ']');
}
else {
res.add(fut, false);
@@ -755,7 +730,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
public IgniteInternalFuture<?> deploy(ServiceConfiguration cfg) {
A.notNull(cfg, "cfg");
- return deployAll(Collections.singleton(cfg), false);
+ return deployAll(Collections.singleton(cfg));
}
/**
@@ -771,7 +746,8 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
if (X.hasCause(e, ClusterTopologyCheckedException.class)) {
if (log.isDebugEnabled())
log.debug("Topology changed while cancelling service (will retry): " + e.getMessage());
- } else {
+ }
+ else {
U.error(log, "Failed to undeploy service: " + name, e);
return new GridFinishedFuture<>(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/main/java/org/apache/ignite/internal/processors/service/PreparedConfigurations.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/PreparedConfigurations.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/PreparedConfigurations.java
index a581e15..dc41c22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/PreparedConfigurations.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/PreparedConfigurations.java
@@ -31,19 +31,13 @@ class PreparedConfigurations {
/** */
final List<GridServiceDeploymentFuture> failedFuts;
- /** */
- final Exception err;
-
/**
* @param cfgs Configurations to deploy.
* @param failedFuts Finished futures for failed configurations.
- * @param err Error if need to stop deploy.
*/
- PreparedConfigurations(List<ServiceConfiguration> cfgs, List<GridServiceDeploymentFuture> failedFuts,
- Exception err) {
+ PreparedConfigurations(List<ServiceConfiguration> cfgs, List<GridServiceDeploymentFuture> failedFuts) {
this.cfgs = cfgs;
this.failedFuts = failedFuts;
- this.err = err;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java
index ca95198..bcc0504 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java
@@ -22,9 +22,7 @@ import java.util.Collection;
import java.util.List;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
-import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.services.ServiceConfiguration;
@@ -33,16 +31,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
/** */
public class GridServiceDeploymentCompoundFutureSelfTest extends GridCommonAbstractTest {
- /** */
- private static GridKernalContext ctx;
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- IgniteKernal kernal = (IgniteKernal)startGrid(0);
-
- ctx = kernal.context();
- }
-
/** {@inheritDoc} */
@Override protected void afterTestsStopped() throws Exception {
stopAllGrids();
@@ -51,8 +39,8 @@ public class GridServiceDeploymentCompoundFutureSelfTest extends GridCommonAbstr
/**
* @throws Exception If failed.
*/
- public void testWaitForCompletionOnFailingFuturePartial() throws Exception {
- GridServiceDeploymentCompoundFuture compFut = new GridServiceDeploymentCompoundFuture(false, ctx);
+ public void testWaitForCompletionOnFailingFuture() throws Exception {
+ GridServiceDeploymentCompoundFuture compFut = new GridServiceDeploymentCompoundFuture();
int failingFutsNum = 2;
@@ -80,7 +68,7 @@ public class GridServiceDeploymentCompoundFutureSelfTest extends GridCommonAbstr
compFut.add(fut);
}
- compFut.serviceDeploymentMarkInitialized();
+ compFut.markInitialized();
List<Exception> causes = new ArrayList<>();
@@ -126,109 +114,6 @@ public class GridServiceDeploymentCompoundFutureSelfTest extends GridCommonAbstr
}
/**
- * @throws Exception if failed.
- */
- public void testFailAllAfterInitialized() throws Exception {
- GridServiceDeploymentCompoundFuture compFut = new GridServiceDeploymentCompoundFuture(true, ctx);
-
- ServiceConfiguration failingCfg = config("Failed");
-
- GridServiceDeploymentFuture failingFut = new GridServiceDeploymentFuture(failingCfg);
-
- compFut.add(failingFut);
-
- int futsNum = 5;
-
- List<ServiceConfiguration> cfgs = new ArrayList<>(futsNum + 1);
-
- cfgs.add(failingCfg);
-
- for (int i = 0; i < futsNum; i++) {
- ServiceConfiguration cfg = config(String.valueOf(i));
-
- cfgs.add(cfg);
-
- compFut.add(new GridServiceDeploymentFuture(cfg));
- }
-
- compFut.serviceDeploymentMarkInitialized();
-
- Exception expCause = new Exception("Test error");
-
- failingFut.onDone(expCause);
-
- assertFailAll(compFut, cfgs, expCause);
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testFailAllBeforeInitialized() throws Exception {
- GridServiceDeploymentCompoundFuture compFut = new GridServiceDeploymentCompoundFuture(true, ctx);
-
- ServiceConfiguration failingCfg = config("Failed");
-
- GridServiceDeploymentFuture failingFut = new GridServiceDeploymentFuture(failingCfg);
-
- Exception expCause = new Exception("Test error");
-
- failingFut.onDone(expCause);
-
- compFut.add(failingFut);
-
- assertFalse(compFut.isDone());
-
- int futsNum = 5;
-
- List<ServiceConfiguration> cfgs = new ArrayList<>(futsNum + 1);
-
- cfgs.add(failingCfg);
-
- for (int i = 0; i < futsNum; i++) {
- ServiceConfiguration cfg = config(String.valueOf(i));
-
- cfgs.add(cfg);
-
- compFut.add(new GridServiceDeploymentFuture(cfg));
- }
-
- compFut.serviceDeploymentMarkInitialized();
-
- assertFailAll(compFut, cfgs, expCause);
- }
-
- /**
- * Try waiting for the future completion and check that a proper exception is thrown.
- *
- * @param fut Future.
- * @param expCfgs Expected cfgs.
- * @param expCause Expected cause.
- */
- private void assertFailAll(GridServiceDeploymentCompoundFuture fut, Collection<ServiceConfiguration> expCfgs,
- Exception expCause) {
- try {
- fut.get();
-
- fail("Should never reach here.");
- }
- catch (IgniteCheckedException ce) {
- log.info("Expected exception: " + ce.getMessage());
-
- IgniteException e = U.convertException(ce);
-
- assertTrue(e instanceof ServiceDeploymentException);
-
- assertEqualsCollections(expCfgs, ((ServiceDeploymentException)e).getFailedConfigurations());
-
- Throwable actCause = e.getCause();
-
- assertTrue(actCause instanceof IgniteCheckedException);
-
- assertEquals(expCause, actCause.getCause());
- }
- }
-
- /**
* @param name Name.
* @return Dummy configuration with a specified name.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/91cf66e7/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java
index dc19f33..f0e2e71 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java
@@ -100,7 +100,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(cfgs, false);
+ client.services().deployAll(cfgs);
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
@@ -119,7 +119,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- IgniteFuture<Void> fut = client.services().deployAllAsync(cfgs, false);
+ IgniteFuture<Void> fut = client.services().deployAllAsync(cfgs);
fut.get();
@@ -129,7 +129,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
}
/**
- * TODO: enable when IGNITE-6259 is fixed
+ * TODO: enable when IGNITE-6259 is fixed.
*
* @throws Exception If failed.
*/
@@ -166,7 +166,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
while (from < numServices) {
int to = Math.min(numServices, from + batchSize);
- client.services().deployAllAsync(cfgs.subList(from, to), false).get(5000);
+ client.services().deployAllAsync(cfgs.subList(from, to)).get(5000);
from = to;
}
@@ -183,7 +183,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
}
/**
- * TODO: enable when IGNITE-6259 is fixed
+ * TODO: enable when IGNITE-6259 is fixed.
*
* @throws Exception If failed.
*/
@@ -231,7 +231,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
failingCfgs.add(failingCfg);
try {
- client.services().deployAllAsync(cfgsBatch, false).get(5000);
+ client.services().deployAllAsync(cfgsBatch).get(5000);
fail("Should never reach here.");
}
@@ -264,37 +264,22 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
/**
* @throws Exception If failed.
*/
- public void testDeployAllFailAll() throws Exception {
- deployAllFail(false, true);
+ public void testDeployAllFail() throws Exception {
+ deployAllFail(false);
}
/**
* @throws Exception If failed.
*/
- public void testDeployAllPartial() throws Exception {
- deployAllFail(false, false);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDeployAllAsyncFailAll() throws Exception {
- deployAllFail(true, true);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDeployAllAsyncFailPartial() throws Exception {
- deployAllFail(true, false);
+ public void testDeployAllAsyncFail() throws Exception {
+ deployAllFail(true);
}
/**
* @param async If {@code true}, then asynchronous method of deployment will be performed.
- * @param allOrNone Failing strategy.
* @throws Exception If failed.
*/
- private void deployAllFail(boolean async, boolean allOrNone) throws Exception {
+ private void deployAllFail(boolean async) throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
CountDownLatch latch = new CountDownLatch(NUM_SERVICES - 1);
@@ -307,20 +292,11 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
failingCfg.setName(null);
- assertFailingDeploy(client, async, allOrNone, cfgs, failingCfg);
+ assertFailingDeploy(client, async, cfgs, failingCfg);
- if (allOrNone) {
- assertFalse("Some of the services were deployed.", latch.await(2, TimeUnit.SECONDS));
-
- assertEquals(NUM_SERVICES - 1, latch.getCount());
-
- assertTrue(client.services().serviceDescriptors().isEmpty());
- }
- else {
- assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
+ assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
- assertDeployedServices(client, cfgs.subList(0, cfgs.size() - 1));
- }
+ assertDeployedServices(client, cfgs.subList(0, cfgs.size() - 1));
}
/**
@@ -338,8 +314,8 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES);
- IgniteFuture<Void> fstFut = client.services().deployAllAsync(fstBatch, false);
- IgniteFuture<Void> sndFut = client.services().deployAllAsync(sndBatch, false);
+ IgniteFuture<Void> fstFut = client.services().deployAllAsync(fstBatch);
+ IgniteFuture<Void> sndFut = client.services().deployAllAsync(sndBatch);
fstFut.get();
sndFut.get();
@@ -352,32 +328,12 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
/**
* @throws Exception If failed.
*/
- public void testClashingNamesFailAll() throws Exception {
- clashingNamesFail(true);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClashingNamesPartial() throws Exception {
- clashingNamesFail(false);
- }
-
- /**
- * @param allOrNone Failing strategy.
- * @throws Exception If failed.
- */
- private void clashingNamesFail(boolean allOrNone) throws Exception {
+ public void testClashingNamesFail() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
- int numDepSvcs;
-
- if (allOrNone)
- numDepSvcs = NUM_SERVICES / 2;
- else
- numDepSvcs = NUM_SERVICES - 1;
+ int numDepSvcs = NUM_SERVICES - 1;
CountDownLatch latch = new CountDownLatch(numDepSvcs);
@@ -386,13 +342,13 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- IgniteFuture<Void> fut = client.services().deployAllAsync(fstBatch, false);
+ IgniteFuture<Void> fut = client.services().deployAllAsync(fstBatch);
ServiceConfiguration failingCfg = cfgs.get(NUM_SERVICES - 1);
failingCfg.setName(null);
- assertFailingDeploy(client, false, allOrNone, sndBatch, failingCfg);
+ assertFailingDeploy(client, false, sndBatch, failingCfg);
fut.get();
@@ -404,33 +360,12 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
/**
* @throws Exception If failed.
*/
- public void testClashingNameDifferentConfigFailAll() throws Exception {
- testClashingNameDifferentConfig(true);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClashingNameDifferentConfigPartial() throws Exception {
- testClashingNameDifferentConfig(false);
- }
-
- /**
- * @param allOrNone Failing strategy.
- * @throws Exception If failed.
- */
- private void testClashingNameDifferentConfig(boolean allOrNone) throws Exception {
+ public void testClashingNameDifferentConfig() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
- int numDepSvcs;
-
- if (allOrNone)
- numDepSvcs = NUM_SERVICES / 2;
- else
- numDepSvcs = NUM_SERVICES - 1;
-
+ int numDepSvcs = NUM_SERVICES - 1;
CountDownLatch latch = new CountDownLatch(numDepSvcs);
@@ -439,7 +374,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(fstBatch, false);
+ client.services().deployAll(fstBatch);
ServiceConfiguration failingCfg = copyService(cfgs.get(NUM_SERVICES - 1));
@@ -449,7 +384,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
sndBatch.add(failingCfg);
- assertFailingDeploy(client, false, allOrNone, sndBatch, failingCfg);
+ assertFailingDeploy(client, false, sndBatch, failingCfg);
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
@@ -468,7 +403,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(cfgs, true);
+ client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
@@ -489,7 +424,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(cfgs, true);
+ client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
@@ -501,7 +436,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
}
/**
- * TODO: enable when IGNITE-6259 is fixed
+ * TODO: enable when IGNITE-6259 is fixed.
*
* @throws Exception If failed.
*/
@@ -516,7 +451,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(cfgs, true);
+ client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
@@ -564,7 +499,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
subscribeExeLatch(cfgs, latch);
- client.services().deployAll(cfgs, true);
+ client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
@@ -595,35 +530,29 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT
* @param client Client.
* @param async If {@code true}, then async version of deploy method will be used.
* @param cfgs Service configurations.
- * @param allOrNone Failing policy.
* @param failingCfg Configuration of the failing service.
* @throws Exception If failed.
*/
- private void assertFailingDeploy(Ignite client, boolean async, boolean allOrNone, List<ServiceConfiguration> cfgs,
+ private void assertFailingDeploy(Ignite client, boolean async, List<ServiceConfiguration> cfgs,
ServiceConfiguration failingCfg) throws Exception {
IgniteFuture<Void> fut = null;
if (async)
- fut = client.services().deployAllAsync(cfgs, allOrNone);
+ fut = client.services().deployAllAsync(cfgs);
try {
if (async)
fut.get();
else
- client.services().deployAll(cfgs, allOrNone);
+ client.services().deployAll(cfgs);
fail("Should never reach here.");
}
catch (ServiceDeploymentException e) {
info("Expected exception: " + e.getMessage());
- Collection<ServiceConfiguration> expFails;
-
- if (allOrNone)
- expFails = cfgs;
- else
- expFails = Collections.singleton(failingCfg);
+ Collection<ServiceConfiguration> expFails = Collections.singleton(failingCfg);
Collection<ServiceConfiguration> actFails = e.getFailedConfigurations();
[18/26] ignite git commit: Updated Ignite description
Posted by sb...@apache.org.
Updated Ignite description
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b8615320
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b8615320
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b8615320
Branch: refs/heads/ignite-6149
Commit: b86153208f28cfd76c9d21b6170d228e23deaead
Parents: 2da8861
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 15 13:31:19 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 15 13:31:19 2017 -0700
----------------------------------------------------------------------
README.md | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b8615320/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index b6b5987..59baf90 100644
--- a/README.md
+++ b/README.md
@@ -19,33 +19,47 @@ with powerful <b>SQL</b>, <b>key-value</b> and <b>processing</b> APIs.
## Durable Memory
Ignite's durable memory component treats RAM not just as a caching layer but as a complete fully functional storage layer. This means that users can turn the persistence on and off as needed. If the persistence is off, then Ignite can act as a distributed **in-memory database** or **in-memory data grid**, depending on whether you prefer to use SQL or key-value APIs. If the persistence is turned on, then Ignite becomes a distributed, **horizontally scalable database** that guarantees full data consistency and is resilient to full cluster failures.
+[Read More](https://apacheignite.readme.io/docs/durable-memory)
+
## Ignite Persistence
-Ignite Native Persistence is a distributed ACID and SQL-compliant disk store that transparently integrates with Ignite's Durable Memory as an optional disk layer storing data and indexes on SSD, Flash, 3D XPoint, and other types of non-volatile storages.
+Ignite Native Persistence is a distributed, ACID, and SQL-compliant **disk store** that transparently integrates with Ignite's Durable Memory as an optional disk layer storing data and indexes on SSD, Flash, 3D XPoint, and other types of non-volatile storages.
With the Ignite Persistence enabled, you no longer need to keep all the data and indexes in memory or warm it up after a node or cluster restart because the Durable Memory is tightly coupled with persistence and treats it as a secondary memory tier. This implies that if a subset of data or an index is missing in RAM, the Durable Memory will take it from the disk.
<p align="center">
<a href="https://apacheignite.readme.io/docs/distributed-persistent-store">
- <img src="https://ignite.apache.org/images/check_pointing-2.png" width="400px"/>
+ <img src="https://ignite.apache.org/images/native_persistence.png" width="400px"/>
</a>
</p>
+[Read More](https://apacheignite.readme.io/docs/distributed-persistent-store)
+
## ACID Compliance
Data stored in Ignite is ACID-compliant both in memory and on disk, making Ignite a **strongly consistent** system. Ignite transactions work across the network and can span multiple servers.
+[Read More](https://apacheignite.readme.io/docs/transactions)
+
## Complete SQL Support
Ignite provides full support for SQL, DDL and DML, allowing users to interact with Ignite using pure SQL without writing any code. This means that users can create tables and indexes as well as insert, update, and query data using only SQL. Having such complete SQL support makes Ignite a one-of-a-kind **distributed SQL database**.
+[Read More](https://apacheignite.readme.io/docs/distributed-sql)
+
## Key-Value
The in-memory data grid component in Ignite is a fully transactional **distributed key-value store** that can scale horizontally across 100s of servers in the cluster. When persistence is enabled, Ignite can also store more data than fits in memory and survive full cluster restarts.
+[Read More](https://apacheignite.readme.io/docs/data-grid)
+
## Collocated Processing
Most traditional databases work in a client-server fashion, meaning that data must be brought to the client side for processing. This approach requires lots of data movement from servers to clients and generally does not scale. Ignite, on the other hand, allows for sending light-weight computations to the data, i.e. **collocating** computations with data. As a result, Ignite scales better and minimizes data movement.
+[Read More](https://apacheignite.readme.io/docs/collocate-compute-and-data)
+
## Scalability and Durability
Ignite is an elastic, horizontally scalable distributed system that supports adding and removing cluster nodes on demand. Ignite also allows for storing multiple copies of the data, making it resilient to partial cluster failures. If the persistence is enabled, then data stored in Ignite will also survive full cluster failures. Cluster restarts in Ignite can be very fast, as the data becomes operational instantaneously directly from disk. As a result, the data does not need to be preloaded in-memory to begin processing, and Ignite caches will lazily warm up resuming the in memory performance.
+[Read More](https://apacheignite.readme.io/docs/clustering)
+
## Ignite Facts
<b>Is Ignite a persistent or pure in-memory storage?</b><br/>
[06/26] ignite git commit: IGNITE-6251 Clear selection from removed
rows.
Posted by sb...@apache.org.
IGNITE-6251 Clear selection from removed rows.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8741acce
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8741acce
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8741acce
Branch: refs/heads/ignite-6149
Commit: 8741acce15f50f978257da193cce2a5e2c5bd816
Parents: 1fcc96d
Author: vsisko <vs...@gridgain.com>
Authored: Fri Sep 15 18:02:59 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Sep 15 18:02:59 2017 +0700
----------------------------------------------------------------------
.../list-of-registered-users.controller.js | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8741acce/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
index 58e93b4..2e36c5c 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
@@ -71,10 +71,15 @@ export default class IgniteListOfRegisteredUsersCtrl {
.then(() => {
const i = _.findIndex($ctrl.gridOptions.data, (u) => u._id === user._id);
- if (i >= 0)
+ if (i >= 0) {
$ctrl.gridOptions.data.splice(i, 1);
- })
- .then(() => $ctrl.adjustHeight($ctrl.gridOptions.data.length));
+ $ctrl.gridApi.selection.clearSelectedRows();
+ }
+
+ $ctrl.adjustHeight($ctrl.gridOptions.data.length);
+
+ return $ctrl._refreshRows();
+ });
};
const toggleAdmin = () => {
@@ -165,6 +170,8 @@ export default class IgniteListOfRegisteredUsersCtrl {
fastWatch: true,
exporterSuppressColumns: ['actions'],
exporterCsvColumnSeparator: ';',
+ rowIdentity: (row) => row._id,
+ getRowIdentity: (row) => row._id,
onRegisterApi: (api) => {
$ctrl.gridApi = api;
@@ -193,6 +200,8 @@ export default class IgniteListOfRegisteredUsersCtrl {
$ctrl.countries = _.values(_.groupBy(data, 'countryCode'));
$ctrl.adjustHeight(data.length);
+
+ $ctrl._refreshRows();
});
};
@@ -246,6 +255,13 @@ export default class IgniteListOfRegisteredUsersCtrl {
this.selected = ids;
}
+ _refreshRows() {
+ if (this.gridApi) {
+ this.gridApi.grid.refreshRows()
+ .then(() => this.selected.length && this._updateSelected());
+ }
+ }
+
exportCsv() {
this.gridApi.exporter.csvExport('visible', 'visible');
}
[23/26] ignite git commit: IGNITE-5620: Implemented SQLSTATE error
code for server-side logic and JDBC thin client. This closes #2541.
Posted by sb...@apache.org.
IGNITE-5620: Implemented SQLSTATE error code for server-side logic and JDBC thin client. This closes #2541.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c4d0bc2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c4d0bc2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c4d0bc2
Branch: refs/heads/ignite-6149
Commit: 7c4d0bc2a84cfcc9c240f41c48aa129b5f60eca0
Parents: 9fd8221
Author: Alexander Paschenko <al...@gmail.com>
Authored: Sat Sep 16 17:41:34 2017 +0300
Committer: devozerov <pp...@gmail.com>
Committed: Sat Sep 16 17:41:34 2017 +0300
----------------------------------------------------------------------
.../jdbc2/JdbcDynamicIndexAbstractSelfTest.java | 39 +-
.../jdbc2/JdbcInsertStatementSelfTest.java | 9 +-
.../ignite/jdbc/JdbcErrorsAbstractSelfTest.java | 158 +++++++
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 2 +
.../jdbc/thin/JdbcThinConnectionSelfTest.java | 2 +-
.../JdbcThinDynamicIndexAbstractSelfTest.java | 4 +-
.../jdbc/thin/JdbcThinErrorsSelfTest.java | 467 +++++++++++++++++++
.../thin/JdbcThinInsertStatementSelfTest.java | 2 +-
.../jdbc/thin/JdbcThinNoDefaultSchemaTest.java | 2 +-
.../jdbc/thin/JdbcThinResultSetSelfTest.java | 2 +-
.../internal/jdbc/thin/JdbcThinConnection.java | 67 ++-
.../jdbc/thin/JdbcThinDatabaseMetadata.java | 142 ++----
.../jdbc/thin/JdbcThinPreparedStatement.java | 54 +--
.../internal/jdbc/thin/JdbcThinResultSet.java | 111 ++---
.../internal/jdbc/thin/JdbcThinStatement.java | 39 +-
.../internal/jdbc/thin/JdbcThinTcpIo.java | 234 +++-------
.../cache/query/IgniteQueryErrorCode.java | 48 +-
.../internal/processors/odbc/SqlStateCode.java | 69 +++
.../odbc/jdbc/JdbcRequestHandler.java | 74 ++-
.../processors/query/IgniteSQLException.java | 84 +++-
.../query/h2/DmlStatementsProcessor.java | 79 ++--
.../query/h2/sql/GridSqlQueryParser.java | 35 +-
.../query/h2/sql/GridQueryParsingTest.java | 2 +-
23 files changed, 1178 insertions(+), 547 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java
index 7bbda6f..9485d0d 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java
@@ -23,7 +23,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collections;
import java.util.List;
-import javax.cache.CacheException;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
@@ -31,8 +30,6 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
-import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.util.typedef.F;
/**
@@ -176,7 +173,7 @@ public abstract class JdbcDynamicIndexAbstractSelfTest extends JdbcAbstractDmlSt
@Override public void run() throws Exception {
jdbcRun(CREATE_INDEX);
}
- }, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
+ });
}
/**
@@ -227,7 +224,7 @@ public abstract class JdbcDynamicIndexAbstractSelfTest extends JdbcAbstractDmlSt
@Override public void run() throws Exception {
jdbcRun(DROP_INDEX);
}
- }, IgniteQueryErrorCode.INDEX_NOT_FOUND);
+ });
}
/**
@@ -312,45 +309,21 @@ public abstract class JdbcDynamicIndexAbstractSelfTest extends JdbcAbstractDmlSt
* Ensure that SQL exception is thrown.
*
* @param r Runnable.
- * @param expCode Error code.
*/
- private static void assertSqlException(RunnableX r, int expCode) {
+ private static void assertSqlException(RunnableX r) {
// We expect IgniteSQLException with given code inside CacheException inside JDBC SQLException.
try {
r.run();
}
- catch (SQLException ex) {
- if (ex.getCause() != null) {
- try {
- throw ex.getCause();
- }
- catch (CacheException ex1) {
- if (ex1.getCause() != null) {
- try {
- throw ex1.getCause();
- }
- catch (IgniteSQLException e) {
- assertEquals("Unexpected error code [expected=" + expCode + ", actual=" + e.statusCode() + ']',
- expCode, e.statusCode());
-
- return;
- }
- catch (Throwable t) {
- fail("Unexpected exception: " + t);
- }
- }
- }
- catch (Throwable t) {
- fail("Unexpected exception: " + t);
- }
- }
+ catch (SQLException e) {
+ return;
}
catch (Exception e) {
fail("Unexpected exception: " + e);
}
- fail(IgniteSQLException.class.getSimpleName() + " is not thrown.");
+ fail(SQLException.class.getSimpleName() + " is not thrown.");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java
index 407d6e2..44a45b7 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java
@@ -164,15 +164,12 @@ public class JdbcInsertStatementSelfTest extends JdbcAbstractDmlStatementSelfTes
}
}, SQLException.class, null);
- assertNotNull(reason.getCause());
-
- reason = reason.getCause().getCause();
+ reason = reason.getCause();
assertNotNull(reason);
- assertEquals(IgniteSQLException.class, reason.getClass());
-
- assertEquals("Failed to INSERT some keys because they are already in cache [keys=[p2]]", reason.getMessage());
+ assertTrue(reason.getMessage().contains(
+ "Failed to INSERT some keys because they are already in cache [keys=[p2]]"));
assertEquals(3, jcache(0).withKeepBinary().getAll(new HashSet<>(Arrays.asList("p1", "p2", "p3"))).size());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java
new file mode 100644
index 0000000..f600e73
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Collections;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test SQLSTATE codes propagation with (any) Ignite JDBC driver.
+ */
+public abstract class JdbcErrorsAbstractSelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(getConfiguration(getTestIgniteInstanceName(0))
+ .setCacheConfiguration(new CacheConfiguration("test")
+ .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class)))));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * Test that H2 specific error codes get propagated to Ignite SQL exceptions.
+ * @throws SQLException if failed.
+ */
+ public void testParsingErrors() throws SQLException {
+ checkErrorState("gibberish", "42000");
+ }
+
+ /**
+ * Test that error codes from tables related DDL operations get propagated to Ignite SQL exceptions.
+ * @throws SQLException if failed.
+ */
+ public void testTableErrors() throws SQLException {
+ checkErrorState("DROP TABLE \"PUBLIC\".missing", "42000");
+ }
+
+ /**
+ * Test that error codes from indexes related DDL operations get propagated to Ignite SQL exceptions.
+ * @throws SQLException if failed.
+ */
+ public void testIndexErrors() throws SQLException {
+ checkErrorState("DROP INDEX \"PUBLIC\".missing", "42000");
+ }
+
+ /**
+ * Test that error codes from DML operations get propagated to Ignite SQL exceptions.
+ * @throws SQLException if failed.
+ */
+ public void testDmlErrors() throws SQLException {
+ checkErrorState("INSERT INTO \"test\".INTEGER(_key, _val) values(1, null)", "22004");
+
+ checkErrorState("INSERT INTO \"test\".INTEGER(_key, _val) values(1, 'zzz')", "50000");
+ }
+
+ /**
+ * Test error code for the case when user attempts to refer a future currently unsupported.
+ * @throws SQLException if failed.
+ */
+ public void testUnsupportedSql() throws SQLException {
+ checkErrorState("ALTER TABLE \"test\".Integer DROP COLUMN _key", "0A000");
+ }
+
+ /**
+ * @return Connection to execute statements on.
+ * @throws SQLException if failed.
+ */
+ protected abstract Connection getConnection() throws SQLException;
+
+ /**
+ * Test that running given SQL statement yields expected SQLSTATE code.
+ * @param sql statement.
+ * @param expState expected SQLSTATE code.
+ * @throws SQLException if failed.
+ */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ private void checkErrorState(final String sql, String expState) throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (final PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.execute();
+ }
+ }
+ }, expState);
+ }
+
+ /**
+ * Test that running given closure yields expected SQLSTATE code.
+ * @param clo closure.
+ * @param expState expected SQLSTATE code.
+ * @throws SQLException if failed.
+ */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ protected void checkErrorState(final ConnClosure clo, String expState) throws SQLException {
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ try (final Connection conn = getConnection()) {
+ clo.run(conn);
+
+ fail();
+
+ return null;
+ }
+ }
+ }, expState);
+ }
+
+ /**
+ * Test that running given closure yields expected SQLSTATE code.
+ * @param clo closure.
+ * @param expState expected SQLSTATE code.
+ * @throws SQLException if failed.
+ */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ protected void checkErrorState(final IgniteCallable<Void> clo, String expState) throws SQLException {
+ SQLException ex = (SQLException)GridTestUtils.assertThrows(null, clo, SQLException.class, null);
+
+ assertEquals(expState, ex.getSQLState());
+ }
+
+ /**
+ * Runnable that accepts a {@link Connection} and can throw an exception.
+ */
+ protected interface ConnClosure {
+ /**
+ * @throws Exception On error.
+ */
+ void run(Connection conn) throws Exception;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
index c2ac6cb..424ec21 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
@@ -46,6 +46,7 @@ import org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexTransactionalPartitionedN
import org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexTransactionalPartitionedSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexTransactionalReplicatedSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinEmptyCacheSelfTest;
+import org.apache.ignite.jdbc.thin.JdbcThinErrorsSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinInsertStatementSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinMergeStatementSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinMetadataSelfTest;
@@ -124,6 +125,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
suite.addTest(new TestSuite(JdbcThinNoDefaultSchemaTest.class));
suite.addTest(new TestSuite(JdbcThinEmptyCacheSelfTest.class));
suite.addTest(new TestSuite(JdbcThinMetadataSelfTest.class));
+ suite.addTest(new TestSuite(JdbcThinErrorsSelfTest.class));
suite.addTest(new TestSuite(JdbcThinInsertStatementSelfTest.class));
suite.addTest(new TestSuite(JdbcThinUpdateStatementSelfTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
index 9bf6282..95068c5 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
@@ -346,7 +346,7 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest {
private static JdbcThinTcpIo io(Connection conn) throws Exception {
JdbcThinConnection conn0 = conn.unwrap(JdbcThinConnection.class);
- return conn0.io();
+ return GridTestUtils.getFieldValue(conn0, JdbcThinConnection.class, "cliIo");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java
index 3f762fc..5089894 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java
@@ -183,7 +183,7 @@ public abstract class JdbcThinDynamicIndexAbstractSelfTest extends JdbcThinAbstr
return null;
}
- }, IgniteCheckedException.class, "Index already exists: IDX");
+ }, SQLException.class, "Index already exists: IDX");
}
/**
@@ -237,7 +237,7 @@ public abstract class JdbcThinDynamicIndexAbstractSelfTest extends JdbcThinAbstr
return null;
}
- }, IgniteCheckedException.class, "Index doesn't exist: IDX");
+ }, SQLException.class, "Index doesn't exist: IDX");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java
new file mode 100644
index 0000000..706be27
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java
@@ -0,0 +1,467 @@
+/*
+ * 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.jdbc.thin;
+
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.List;
+import org.apache.ignite.jdbc.JdbcErrorsAbstractSelfTest;
+import org.apache.ignite.lang.IgniteCallable;
+
+/**
+ * Test SQLSTATE codes propagation with thin client driver.
+ */
+public class JdbcThinErrorsSelfTest extends JdbcErrorsAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected Connection getConnection() throws SQLException {
+ return DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1");
+ }
+
+ /**
+ * Test error code for the case when connection string is fine but client can't reach server
+ * due to <b>communication problems</b> (not due to clear misconfiguration).
+ * @throws SQLException if failed.
+ */
+ public void testConnectionError() throws SQLException {
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ DriverManager.getConnection("jdbc:ignite:thin://unknown.host");
+
+ return null;
+ }
+ }, "08001");
+ }
+
+ /**
+ * Test error code for the case when connection string is a mess.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidConnectionStringFormat() throws SQLException {
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ // Invalid port number yields an error.
+ DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:1000000");
+
+ return null;
+ }
+ }, "08001");
+ }
+
+ /* ALL TESTS PAST THIS POINT MUST BE MOVED TO PARENT CLASS JdbcErrorsAbstractSelfTest
+ * ONCE ERROR CODES RELATED WORK ON JDBC2 DRIVER IS FINISHED */
+
+ /**
+ * Test error code for the case when user attempts to use a closed connection.
+ * @throws SQLException if failed.
+ */
+ public void testConnectionClosed() throws SQLException {
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ conn.close();
+
+ conn.prepareStatement("SELECT 1");
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ conn.close();
+
+ conn.createStatement();
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ conn.close();
+
+ conn.getMetaData();
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ DatabaseMetaData meta = conn.getMetaData();
+
+ conn.close();
+
+ meta.getIndexInfo(null, null, null, false, false);
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ DatabaseMetaData meta = conn.getMetaData();
+
+ conn.close();
+
+ meta.getColumns(null, null, null, null);
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ DatabaseMetaData meta = conn.getMetaData();
+
+ conn.close();
+
+ meta.getPrimaryKeys(null, null, null);
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ DatabaseMetaData meta = conn.getMetaData();
+
+ conn.close();
+
+ meta.getSchemas(null, null);
+
+ return null;
+ }
+ }, "08003");
+
+ checkErrorState(new IgniteCallable<Void>() {
+ @Override public Void call() throws Exception {
+ Connection conn = getConnection();
+
+ DatabaseMetaData meta = conn.getMetaData();
+
+ conn.close();
+
+ meta.getTables(null, null, null, null);
+
+ return null;
+ }
+ }, "08003");
+ }
+
+ /**
+ * Test error code for the case when user attempts to use a closed result set.
+ * @throws SQLException if failed.
+ */
+ public void testResultSetClosed() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 1")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.close();
+
+ rs.getInt(1);
+ }
+ }
+ }, "24000");
+ }
+
+ /**
+ * Test error code for the case when user attempts to set an invalid isolation level to a connection.
+ * @throws SQLException if failed.
+ */
+ @SuppressWarnings("MagicConstant")
+ public void testInvalidIsolationLevel() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ conn.setTransactionIsolation(1000);
+ }
+ }, "0700E");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code int} value
+ * from column whose value can't be converted to an {@code int}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidIntFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getLong(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code long} value
+ * from column whose value can't be converted to an {@code long}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidLongFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getLong(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code float} value
+ * from column whose value can't be converted to an {@code float}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidFloatFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getFloat(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code double} value
+ * from column whose value can't be converted to an {@code double}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidDoubleFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getDouble(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code byte} value
+ * from column whose value can't be converted to an {@code byte}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidByteFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getByte(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code short} value
+ * from column whose value can't be converted to an {@code short}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidShortFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getShort(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code BigDecimal} value
+ * from column whose value can't be converted to an {@code BigDecimal}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidBigDecimalFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getBigDecimal(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code boolean} value
+ * from column whose value can't be converted to an {@code boolean}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidBooleanFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getBoolean(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@code boolean} value
+ * from column whose value can't be converted to an {@code boolean}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidObjectFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getObject(1, List.class);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@link Date} value
+ * from column whose value can't be converted to a {@link Date}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidDateFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getDate(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@link Time} value
+ * from column whose value can't be converted to a {@link Time}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidTimeFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getTime(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@link Timestamp} value
+ * from column whose value can't be converted to a {@link Timestamp}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidTimestampFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getTimestamp(1);
+ }
+ }
+ }, "0700B");
+ }
+
+ /**
+ * Test error code for the case when user attempts to get {@link URL} value
+ * from column whose value can't be converted to a {@link URL}.
+ * @throws SQLException if failed.
+ */
+ public void testInvalidUrlFormat() throws SQLException {
+ checkErrorState(new ConnClosure() {
+ @Override public void run(Connection conn) throws Exception {
+ try (PreparedStatement stmt = conn.prepareStatement("SELECT 'zzz'")) {
+ ResultSet rs = stmt.executeQuery();
+
+ rs.next();
+
+ rs.getURL(1);
+ }
+ }
+ }, "0700B");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java
index 3b86757..8ab5760 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java
@@ -177,7 +177,7 @@ public class JdbcThinInsertStatementSelfTest extends JdbcThinAbstractDmlStatemen
@Override public Object call() throws Exception {
return stmt.execute(SQL);
}
- }, IgniteCheckedException.class,
+ }, SQLException.class,
"Failed to INSERT some keys because they are already in cache [keys=[p2]]");
assertEquals(3, jcache(0).withKeepBinary().getAll(new HashSet<>(Arrays.asList("p1", "p2", "p3"))).size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java
index 7b226e5..65ebf9a 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java
@@ -217,7 +217,7 @@ public class JdbcThinNoDefaultSchemaTest extends JdbcThinAbstractSelfTest {
return null;
}
- }, SQLException.class, "Failed to query Ignite");
+ }, SQLException.class, "Failed to parse query");
conn.setSchema("cache1");
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java
index 76eb5bc..5a3c5df 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java
@@ -695,7 +695,7 @@ public class JdbcThinResultSetSelfTest extends JdbcThinAbstractSelfTest {
return null;
}
- }, IgniteCheckedException.class, "Custom objects are not supported");
+ }, SQLException.class, "Custom objects are not supported");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
index 23235dc..511eba0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
@@ -37,7 +37,14 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
+import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResponse;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResult;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteProductVersion;
import static java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT;
import static java.sql.ResultSet.CONCUR_READ_ONLY;
@@ -138,7 +145,8 @@ public class JdbcThinConnection implements Connection {
catch (Exception e) {
cliIo.close();
- throw new SQLException("Failed to connect to Ignite node [host=" + host + ", port=" + port + ']', e);
+ throw new SQLException("Failed to connect to Ignite cluster [host=" + host + ", port=" + port + ']',
+ SqlStateCode.CLIENT_CONNECTION_FAILED, e);
}
}
@@ -347,7 +355,7 @@ public class JdbcThinConnection implements Connection {
break;
default:
- throw new SQLException("Invalid transaction isolation level.");
+ throw new SQLException("Invalid transaction isolation level.", SqlStateCode.INVALID_TRANSACTION_LEVEL);
}
txIsolation = level;
@@ -626,16 +634,49 @@ public class JdbcThinConnection implements Connection {
*
* @throws SQLException If connection is closed.
*/
- private void ensureNotClosed() throws SQLException {
+ public void ensureNotClosed() throws SQLException {
if (closed)
- throw new SQLException("Connection is closed.");
+ throw new SQLException("Connection is closed.", SqlStateCode.CONNECTION_CLOSED);
}
/**
- * @return Ignite endpoint and I/O protocol.
+ * @return Ignite server version.
*/
- public JdbcThinTcpIo io() {
- return cliIo;
+ IgniteProductVersion igniteVersion() {
+ return cliIo.igniteVersion();
+ }
+
+ /**
+ * @return Auto close server cursors flag.
+ */
+ boolean autoCloseServerCursor() {
+ return cliIo.autoCloseServerCursor();
+ }
+
+ /**
+ * Send request for execution via {@link #cliIo}.
+ * @param req Request.
+ * @return Server response.
+ * @throws SQLException On any error.
+ */
+ @SuppressWarnings("unchecked")
+ <R extends JdbcResult> R sendRequest(JdbcRequest req) throws SQLException {
+ try {
+ JdbcResponse res = cliIo.sendRequest(req);
+
+ if (res.status() != ClientListenerResponse.STATUS_SUCCESS)
+ throw new SQLException(res.error(), IgniteQueryErrorCode.codeToSqlState(res.status()));
+
+ return (R)res.response();
+ }
+ catch (SQLException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ close();
+
+ throw new SQLException("Failed to communicate with Ignite cluster.", SqlStateCode.CONNECTION_FAILURE, e);
+ }
}
/**
@@ -652,7 +693,7 @@ public class JdbcThinConnection implements Connection {
host = host.trim();
if (F.isEmpty(host))
- throw new SQLException("Host name is empty.");
+ throw new SQLException("Host name is empty.", SqlStateCode.CLIENT_CONNECTION_FAILED);
return host;
}
@@ -676,10 +717,10 @@ public class JdbcThinConnection implements Connection {
port = Integer.parseInt(portStr);
if (port <= 0 || port > 0xFFFF)
- throw new SQLException("Invalid port: " + portStr);
+ throw new SQLException("Invalid port: " + portStr, SqlStateCode.CLIENT_CONNECTION_FAILED);
}
catch (NumberFormatException e) {
- throw new SQLException("Invalid port: " + portStr, e);
+ throw new SQLException("Invalid port: " + portStr, SqlStateCode.CLIENT_CONNECTION_FAILED);
}
return port;
@@ -706,7 +747,7 @@ public class JdbcThinConnection implements Connection {
return false;
else
throw new SQLException("Failed to parse boolean property [name=" + JdbcThinUtils.trimPrefix(propName) +
- ", value=" + strVal + ']');
+ ", value=" + strVal + ']', SqlStateCode.CLIENT_CONNECTION_FAILED);
}
/**
@@ -723,7 +764,7 @@ public class JdbcThinConnection implements Connection {
if (res < 0)
throw new SQLException("Property cannot be negative [name=" + JdbcThinUtils.trimPrefix(propName) +
- ", value=" + res + ']');
+ ", value=" + res + ']', SqlStateCode.CLIENT_CONNECTION_FAILED);
return res;
}
@@ -748,7 +789,7 @@ public class JdbcThinConnection implements Connection {
}
catch (NumberFormatException e) {
throw new SQLException("Failed to parse int property [name=" + JdbcThinUtils.trimPrefix(propName) +
- ", value=" + strVal + ']');
+ ", value=" + strVal + ']', SqlStateCode.CLIENT_CONNECTION_FAILED);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinDatabaseMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinDatabaseMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinDatabaseMetadata.java
index 1f20bb2..d13ef68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinDatabaseMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinDatabaseMetadata.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.jdbc.thin;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
@@ -29,15 +28,19 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteVersionUtils;
import org.apache.ignite.internal.jdbc2.JdbcUtils;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcColumnMeta;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcIndexMeta;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaColumnsRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaColumnsResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaIndexesRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaIndexesResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaPrimaryKeysRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaPrimaryKeysResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaSchemasRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaSchemasResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaTablesRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaTablesResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcPrimaryKeyMeta;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcTableMeta;
@@ -119,7 +122,7 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
/** {@inheritDoc} */
@Override public String getDatabaseProductVersion() throws SQLException {
- return conn.io().igniteVersion().toString();
+ return conn.igniteVersion().toString();
}
/** {@inheritDoc} */
@@ -702,10 +705,9 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
}
/** {@inheritDoc} */
- @Override public ResultSet getTables(String catalog, String schemaPtrn, String tblNamePtrn,
- String[] tblTypes) throws SQLException {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
+ @Override public ResultSet getTables(String catalog, String schemaPtrn, String tblNamePtrn, String[] tblTypes)
+ throws SQLException {
+ conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = Arrays.asList(
new JdbcColumnMeta(null, null, "TABLE_CAT", String.class),
@@ -736,24 +738,14 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
if (!validCatalogPattern(catalog) || !tblTypeMatch)
return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), meta);
- try {
- JdbcMetaTablesResult res = conn.io().tablesMeta(schemaPtrn, tblNamePtrn);
+ JdbcMetaTablesResult res = conn.sendRequest(new JdbcMetaTablesRequest(schemaPtrn, tblNamePtrn));
- List<List<Object>> rows = new LinkedList<>();
+ List<List<Object>> rows = new LinkedList<>();
- for (JdbcTableMeta tblMeta : res.meta())
- rows.add(tableRow(tblMeta));
+ for (JdbcTableMeta tblMeta : res.meta())
+ rows.add(tableRow(tblMeta));
- return new JdbcThinResultSet(rows, meta);
- }
- catch (IOException e) {
- conn.close();
-
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return new JdbcThinResultSet(rows, meta);
}
/**
@@ -797,10 +789,9 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
}
/** {@inheritDoc} */
- @Override public ResultSet getColumns(String catalog, String schemaPtrn, String tblNamePtrn,
- String colNamePtrn) throws SQLException {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
+ @Override public ResultSet getColumns(String catalog, String schemaPtrn, String tblNamePtrn, String colNamePtrn)
+ throws SQLException {
+ conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = Arrays.asList(
new JdbcColumnMeta(null, null, "TABLE_CAT", String.class),
@@ -827,24 +818,14 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
if (!validCatalogPattern(catalog))
return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), meta);
- try {
- JdbcMetaColumnsResult res = conn.io().columnsMeta(schemaPtrn, tblNamePtrn, colNamePtrn);
+ JdbcMetaColumnsResult res = conn.sendRequest(new JdbcMetaColumnsRequest(schemaPtrn, tblNamePtrn, colNamePtrn));
- List<List<Object>> rows = new LinkedList<>();
+ List<List<Object>> rows = new LinkedList<>();
- for (int i = 0; i < res.meta().size(); ++i)
- rows.add(columnRow(res.meta().get(i), i + 1));
+ for (int i = 0; i < res.meta().size(); ++i)
+ rows.add(columnRow(res.meta().get(i), i + 1));
- return new JdbcThinResultSet(rows, meta);
- }
- catch (IOException e) {
- conn.close();
-
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return new JdbcThinResultSet(rows, meta);
}
/**
@@ -939,8 +920,7 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
/** {@inheritDoc} */
@Override public ResultSet getPrimaryKeys(String catalog, String schema, String tbl) throws SQLException {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
+ conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = Arrays.asList(
new JdbcColumnMeta(null, null, "TABLE_CAT", String.class),
@@ -953,24 +933,14 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
if (!validCatalogPattern(catalog))
return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), meta);
- try {
- JdbcMetaPrimaryKeysResult res = conn.io().primaryKeysMeta(schema, tbl);
+ JdbcMetaPrimaryKeysResult res = conn.sendRequest(new JdbcMetaPrimaryKeysRequest(schema, tbl));
- List<List<Object>> rows = new LinkedList<>();
+ List<List<Object>> rows = new LinkedList<>();
- for (JdbcPrimaryKeyMeta pkMeta : res.meta())
- rows.addAll(primaryKeyRows(pkMeta));
-
- return new JdbcThinResultSet(rows, meta);
- }
- catch (IOException e) {
- conn.close();
+ for (JdbcPrimaryKeyMeta pkMeta : res.meta())
+ rows.addAll(primaryKeyRows(pkMeta));
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return new JdbcThinResultSet(rows, meta);
}
/**
@@ -1170,8 +1140,7 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
/** {@inheritDoc} */
@Override public ResultSet getIndexInfo(String catalog, String schema, String tbl, boolean unique,
boolean approximate) throws SQLException {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
+ conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = Arrays.asList(
new JdbcColumnMeta(null, null, "TABLE_CAT", String.class),
@@ -1191,24 +1160,14 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
if (!validCatalogPattern(catalog))
return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), meta);
- try {
- JdbcMetaIndexesResult res = conn.io().indexMeta(schema, tbl);
-
- List<List<Object>> rows = new LinkedList<>();
+ JdbcMetaIndexesResult res = conn.sendRequest(new JdbcMetaIndexesRequest(schema, tbl));
- for (JdbcIndexMeta idxMeta : res.meta())
- rows.addAll(indexRows(idxMeta));
+ List<List<Object>> rows = new LinkedList<>();
- return new JdbcThinResultSet(rows, meta);
- }
- catch (IOException e) {
- conn.close();
+ for (JdbcIndexMeta idxMeta : res.meta())
+ rows.addAll(indexRows(idxMeta));
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return new JdbcThinResultSet(rows, meta);
}
/**
@@ -1404,12 +1363,12 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
/** {@inheritDoc} */
@Override public int getDatabaseMajorVersion() throws SQLException {
- return conn.io().igniteVersion().major();
+ return conn.igniteVersion().major();
}
/** {@inheritDoc} */
@Override public int getDatabaseMinorVersion() throws SQLException {
- return conn.io().igniteVersion().minor();
+ return conn.igniteVersion().minor();
}
/** {@inheritDoc} */
@@ -1444,8 +1403,7 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
/** {@inheritDoc} */
@Override public ResultSet getSchemas(String catalog, String schemaPtrn) throws SQLException {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
+ conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = Arrays.asList(
new JdbcColumnMeta(null, null, "TABLE_SCHEM", String.class),
@@ -1455,30 +1413,20 @@ public class JdbcThinDatabaseMetadata implements DatabaseMetaData {
if (!validCatalogPattern(catalog))
return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), meta);
- try {
- JdbcMetaSchemasResult res = conn.io().schemasMeta(schemaPtrn);
+ JdbcMetaSchemasResult res = conn.sendRequest(new JdbcMetaSchemasRequest(schemaPtrn));
- List<List<Object>> rows = new LinkedList<>();
+ List<List<Object>> rows = new LinkedList<>();
- for (String schema : res.schemas()) {
- List<Object> row = new ArrayList<>(2);
+ for (String schema : res.schemas()) {
+ List<Object> row = new ArrayList<>(2);
- row.add(schema);
- row.add(null);
+ row.add(schema);
+ row.add(null);
- rows.add(row);
- }
-
- return new JdbcThinResultSet(rows, meta);
+ rows.add(row);
}
- catch (IOException e) {
- conn.close();
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return new JdbcThinResultSet(rows, meta);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
index 5aa503c..ce1b65c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.jdbc.thin;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -40,8 +39,9 @@ import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.odbc.SqlListenerUtils;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaParamsRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaParamsResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcStatementType;
@@ -79,14 +79,15 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
ResultSet rs = getResultSet();
if (rs == null)
- throw new SQLException("The query isn't SELECT query: " + sql);
+ throw new SQLException("The query isn't SELECT query: " + sql, SqlStateCode.PARSING_EXCEPTION);
return rs;
}
/** {@inheritDoc} */
@Override public ResultSet executeQuery(String sql) throws SQLException {
- throw new SQLException("The method 'executeQuery(String)' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'executeQuery(String)' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@@ -96,29 +97,33 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
int res = getUpdateCount();
if (res == -1)
- throw new SQLException("The query is not DML statement: " + sql);
+ throw new SQLException("The query is not DML statement: " + sql, SqlStateCode.PARSING_EXCEPTION);
return res;
}
/** {@inheritDoc} */
@Override public int executeUpdate(String sql) throws SQLException {
- throw new SQLException("The method 'executeUpdate(String)' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'executeUpdate(String)' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
- throw new SQLException("The method 'executeUpdate(String, int)' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'executeUpdate(String, int)' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@Override public int executeUpdate(String sql, int columnIndexes[]) throws SQLException {
- throw new SQLException("The method 'executeUpdate(String, int[])' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'executeUpdate(String, int[])' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@Override public int executeUpdate(String sql, String columnNames[]) throws SQLException {
- throw new SQLException("The method 'executeUpdate(String, String[])' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'executeUpdate(String, String[])' is called on PreparedStatement " +
+ "instance.", SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@@ -248,7 +253,8 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
/** {@inheritDoc} */
@Override public boolean execute(String sql) throws SQLException {
- throw new SQLException("The method 'execute(String)' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'execute(String)' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@@ -268,7 +274,8 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
/** {@inheritDoc} */
@Override public void addBatch(String sql) throws SQLException {
- throw new SQLException("The method 'addBatch(String)' is called on PreparedStatement instance.");
+ throw new SQLException("The method 'addBatch(String)' is called on PreparedStatement instance.",
+ SqlStateCode.UNSUPPORTED_OPERATION);
}
/** {@inheritDoc} */
@@ -346,27 +353,15 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
/** {@inheritDoc} */
@Override public ParameterMetaData getParameterMetaData() throws SQLException {
ensureNotClosed();
- try {
- if (conn.isClosed())
- throw new SQLException("Connection is closed.");
- if (metaData != null)
- return metaData;
-
- JdbcMetaParamsResult res = conn.io().parametersMeta(conn.getSchema(), sql);
+ if (metaData != null)
+ return metaData;
- metaData = new JdbcThinParameterMetadata(res.meta());
+ JdbcMetaParamsResult res = conn.sendRequest(new JdbcMetaParamsRequest(conn.getSchema(), sql));
- return metaData;
- }
- catch (IOException e) {
- conn.close();
+ metaData = new JdbcThinParameterMetadata(res.meta());
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ return metaData;
}
/** {@inheritDoc} */
@@ -525,7 +520,8 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
ensureNotClosed();
if (val != null && !SqlListenerUtils.isPlainType(val.getClass()))
- throw new SQLException("Parameter type is unsupported. [cls=" + val.getClass() + ']');
+ throw new SQLException("Parameter type is unsupported. [cls=" + val.getClass() + ']',
+ SqlStateCode.INVALID_PARAMETER_VALUE);
if (paramIdx < 1)
throw new SQLException("Parameter index is invalid: " + paramIdx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinResultSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinResultSet.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinResultSet.java
index 0a0c978..189175b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinResultSet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinResultSet.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.jdbc.thin;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -47,9 +46,12 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcColumnMeta;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCloseRequest;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchResult;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataResult;
/**
@@ -197,22 +199,12 @@ public class JdbcThinResultSet implements ResultSet {
ensureNotClosed();
if ((rowsIter == null || !rowsIter.hasNext()) && !finished) {
- try {
- JdbcQueryFetchResult res = stmt.connection().io().queryFetch(qryId, fetchSize);
-
- rows = res.items();
- finished = res.last();
+ JdbcQueryFetchResult res = stmt.conn.sendRequest(new JdbcQueryFetchRequest(qryId, fetchSize));
- rowsIter = rows.iterator();
- }
- catch (IOException e) {
- stmt.connection().close();
+ rows = res.items();
+ finished = res.last();
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
+ rowsIter = rows.iterator();
}
if (rowsIter != null) {
@@ -249,20 +241,10 @@ public class JdbcThinResultSet implements ResultSet {
if (isClosed())
return;
- try {
- if (!finished || (isQuery && !autoClose))
- stmt.connection().io().queryClose(qryId);
-
- closed = true;
- }
- catch (IOException e) {
- stmt.connection().close();
+ if (!finished || (isQuery && !autoClose))
+ stmt.conn.sendRequest(new JdbcQueryCloseRequest(qryId));
- throw new SQLException("Failed to close Ignite query.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to close Ignite query.", e);
- }
+ closed = true;
}
/** {@inheritDoc} */
@@ -298,11 +280,11 @@ public class JdbcThinResultSet implements ResultSet {
return Integer.parseInt(val.toString()) != 0;
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to boolean: " + val, e);
+ throw new SQLException("Cannot convert to boolean: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to boolean: " + val);
+ throw new SQLException("Cannot convert to boolean: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -323,11 +305,11 @@ public class JdbcThinResultSet implements ResultSet {
return Byte.parseByte(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to byte: " + val, e);
+ throw new SQLException("Cannot convert to byte: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to byte: " + val);
+ throw new SQLException("Cannot convert to byte: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -348,11 +330,11 @@ public class JdbcThinResultSet implements ResultSet {
return Short.parseShort(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to short: " + val, e);
+ throw new SQLException("Cannot convert to short: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to short: " + val);
+ throw new SQLException("Cannot convert to short: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -373,11 +355,11 @@ public class JdbcThinResultSet implements ResultSet {
return Integer.parseInt(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to int: " + val, e);
+ throw new SQLException("Cannot convert to int: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to int: " + val);
+ throw new SQLException("Cannot convert to int: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -398,11 +380,11 @@ public class JdbcThinResultSet implements ResultSet {
return Long.parseLong(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to long: " + val, e);
+ throw new SQLException("Cannot convert to long: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to long: " + val);
+ throw new SQLException("Cannot convert to long: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -423,11 +405,11 @@ public class JdbcThinResultSet implements ResultSet {
return Float.parseFloat(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to float: " + val, e);
+ throw new SQLException("Cannot convert to float: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to float: " + val);
+ throw new SQLException("Cannot convert to float: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -448,11 +430,11 @@ public class JdbcThinResultSet implements ResultSet {
return Double.parseDouble(val.toString());
}
catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to double: " + val, e);
+ throw new SQLException("Cannot convert to double: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to double: " + val);
+ throw new SQLException("Cannot convert to double: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -494,7 +476,7 @@ public class JdbcThinResultSet implements ResultSet {
else if (cls == String.class)
return ((String)val).getBytes();
else
- throw new SQLException("Cannot convert to byte[]: " + val);
+ throw new SQLException("Cannot convert to byte[]: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -511,7 +493,7 @@ public class JdbcThinResultSet implements ResultSet {
else if (cls == java.util.Date.class || cls == Time.class || cls == Timestamp.class)
return new Date(((java.util.Date)val).getTime());
else
- throw new SQLException("Cannot convert to date: " + val);
+ throw new SQLException("Cannot convert to date: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -528,7 +510,7 @@ public class JdbcThinResultSet implements ResultSet {
else if (cls == java.util.Date.class || cls == Date.class || cls == Timestamp.class)
return new Time(((java.util.Date)val).getTime());
else
- throw new SQLException("Cannot convert to time: " + val);
+ throw new SQLException("Cannot convert to time: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -545,7 +527,7 @@ public class JdbcThinResultSet implements ResultSet {
else if (cls == java.util.Date.class || cls == Date.class || cls == Time.class)
return new Timestamp(((java.util.Date)val).getTime());
else
- throw new SQLException("Cannot convert to timestamp: " + val);
+ throw new SQLException("Cannot convert to timestamp: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -564,11 +546,11 @@ public class JdbcThinResultSet implements ResultSet {
return new URL(val.toString());
}
catch (MalformedURLException e) {
- throw new SQLException("Cannot convert to URL: " + val, e);
+ throw new SQLException("Cannot convert to URL: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to URL: " + val);
+ throw new SQLException("Cannot convert to URL: " + val, SqlStateCode.CONVERSION_FAILED);
}
@@ -753,7 +735,7 @@ public class JdbcThinResultSet implements ResultSet {
Integer order = columnOrder().get(colLb.toUpperCase());
if (order == null)
- throw new SQLException("Column not found: " + colLb);
+ throw new SQLException("Column not found: " + colLb, SqlStateCode.PARSING_EXCEPTION);
assert order >= 0;
@@ -794,11 +776,11 @@ public class JdbcThinResultSet implements ResultSet {
return (BigDecimal)decimalFormat.get().parse(val.toString());
}
catch (ParseException e) {
- throw new SQLException("Cannot convert to BigDecimal: " + val, e);
+ throw new SQLException("Cannot convert to BigDecimal: " + val, SqlStateCode.CONVERSION_FAILED, e);
}
}
else
- throw new SQLException("Cannot convert to BigDecimal: " + val);
+ throw new SQLException("Cannot convert to BigDecimal: " + val, SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@@ -1834,7 +1816,8 @@ public class JdbcThinResultSet implements ResultSet {
if (targetCls == cls)
return val;
else
- throw new SQLException("Cannot convert to " + targetCls.getName() + ": " + val);
+ throw new SQLException("Cannot convert to " + targetCls.getName() + ": " + val,
+ SqlStateCode.CONVERSION_FAILED);
}
}
@@ -1858,7 +1841,7 @@ public class JdbcThinResultSet implements ResultSet {
return val;
}
catch (IndexOutOfBoundsException e) {
- throw new SQLException("Invalid column index: " + colIdx, e);
+ throw new SQLException("Invalid column index: " + colIdx, SqlStateCode.PARSING_EXCEPTION, e);
}
}
@@ -1869,7 +1852,7 @@ public class JdbcThinResultSet implements ResultSet {
*/
private void ensureNotClosed() throws SQLException {
if (closed)
- throw new SQLException("Result set is closed.");
+ throw new SQLException("Result set is closed.", SqlStateCode.INVALID_CURSOR_STATE);
}
/**
@@ -1888,24 +1871,14 @@ public class JdbcThinResultSet implements ResultSet {
*/
private List<JdbcColumnMeta> meta() throws SQLException {
if (finished && (!isQuery || autoClose))
- throw new SQLException("Server cursor is already closed.");
+ throw new SQLException("Server cursor is already closed.", SqlStateCode.INVALID_CURSOR_STATE);
if (!metaInit) {
- try {
- JdbcQueryMetadataResult res = stmt.connection().io().queryMeta(qryId);
+ JdbcQueryMetadataResult res = stmt.conn.sendRequest(new JdbcQueryMetadataRequest(qryId));
- meta = res.meta();
+ meta = res.meta();
- metaInit = true;
- }
- catch (IOException e) {
- stmt.connection().close();
-
- throw new SQLException("Failed to get query metadata.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to get query metadata.", e);
- }
+ metaInit = true;
}
return meta;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
index d9bef54..6ab50de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.jdbc.thin;
-import java.io.IOException;
import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -27,11 +26,13 @@ import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcStatementType;
@@ -96,7 +97,7 @@ public class JdbcThinStatement implements Statement {
ResultSet rs = getResultSet();
if (rs == null)
- throw new SQLException("The query isn't SELECT query: " + sql);
+ throw new SQLException("The query isn't SELECT query: " + sql, SqlStateCode.PARSING_EXCEPTION);
return rs;
}
@@ -122,23 +123,13 @@ public class JdbcThinStatement implements Statement {
if (sql == null || sql.isEmpty())
throw new SQLException("SQL query is empty.");
- try {
- JdbcQueryExecuteResult res = conn.io().queryExecute(stmtType, conn.getSchema(), pageSize, maxRows,
- sql, args);
-
- assert res != null;
+ JdbcQueryExecuteResult res = conn.sendRequest(new JdbcQueryExecuteRequest(stmtType, conn.getSchema(), pageSize,
+ maxRows, sql, args == null ? null : args.toArray(new Object[args.size()])));
- rs = new JdbcThinResultSet(this, res.getQueryId(), pageSize, res.last(), res.items(),
- res.isQuery(), conn.io().autoCloseServerCursor(), res.updateCount(), closeOnCompletion);
- }
- catch (IOException e) {
- conn.close();
+ assert res != null;
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite [err=\"" + e.getMessage() + "\"]", e);
- }
+ rs = new JdbcThinResultSet(this, res.getQueryId(), pageSize, res.last(), res.items(),
+ res.isQuery(), conn.autoCloseServerCursor(), res.updateCount(), closeOnCompletion);
}
/** {@inheritDoc} */
@@ -148,7 +139,7 @@ public class JdbcThinStatement implements Statement {
int res = getUpdateCount();
if (res == -1)
- throw new SQLException("The query is not DML statememt: " + sql);
+ throw new SQLException("The query is not DML statement: " + sql, SqlStateCode.PARSING_EXCEPTION);
return res;
}
@@ -378,21 +369,13 @@ public class JdbcThinStatement implements Statement {
throw new SQLException("Batch is empty.");
try {
- JdbcBatchExecuteResult res = conn.io().batchExecute(conn.getSchema(), batch);
+ JdbcBatchExecuteResult res = conn.sendRequest(new JdbcBatchExecuteRequest(conn.getSchema(), batch));
if (res.errorCode() != ClientListenerResponse.STATUS_SUCCESS)
throw new BatchUpdateException(res.errorMessage(), null, res.errorCode(), res.updateCounts());
return res.updateCounts();
}
- catch (IOException e) {
- conn.close();
-
- throw new SQLException("Failed to query Ignite.", e);
- }
- catch (IgniteCheckedException e) {
- throw new SQLException("Failed to query Ignite.", e);
- }
finally {
batch = null;
}
[15/26] ignite git commit: Updated Ignite description
Posted by sb...@apache.org.
Updated Ignite description
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1b5ca444
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1b5ca444
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1b5ca444
Branch: refs/heads/ignite-6149
Commit: 1b5ca4446f7961e6c1b3f9c6bab0d8dc540b932f
Parents: 8bcd69d
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 15 09:54:44 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 15 09:54:44 2017 -0700
----------------------------------------------------------------------
README.md | 194 +++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 140 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1b5ca444/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index b9833ef..d018878 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,50 @@
-# Apache Ignite In-Memory Data Fabric
+# Apache Ignite In-Memory Computing Platform
-<img src="https://ignite.apache.org/images/logo3.png" hspace="20" />
+<a href="https://ignite.apache.org/"><img src="https://ignite.apache.org/images/logo3.png" hspace="20"/></a>
[](https://gitter.im/apacheignite/ignite?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<a href="http://ci.ignite.apache.org/viewType.html?buildTypeId=IgniteTests_IgniteBasic&branch_IgniteTests=%3Cdefault%3E"><img src="http://ci.ignite.apache.org/app/rest/builds/buildType:(id:IgniteTests_IgniteBasic)/statusIcon" /></a>
-The [Apache Ignite][apache-homepage] In-Memory Data Fabric is a high-performance, integrated and distributed in-memory platform for computing and transacting on large-scale data sets in real-time, orders of magnitude faster than possible with traditional disk-based or flash technologies.
+[Apache Ignite][apache-homepage] is the <b>in-memory</b> computing platform
+that is <b>durable</b>, <b>strongly consistent</b>, and <b>highly available</b>
+with powerful <b>SQL</b>, <b>key-value</b> and <b>processing</b> APIs.
<p align="center">
<a href="https://apacheignite.readme.io/docs">
- <img src="https://ignite.apache.org/images/apache-ignite.png" />
+ <img src="https://ignite.apache.org/images/durable-memory.png" width="900px"/>
</a>
</p>
-Apache Ignite In-Memory Data Fabric is designed to deliver uncompromised performance for a wide set of in-memory computing use cases from [high performance computing](https://ignite.apache.org/features.html), to the industry most advanced [data grid](https://ignite.apache.org/features.html), highly available [service grid](https://ignite.apache.org/features.html), and [streaming](https://ignite.apache.org/features.html).
+## Durable Memory
+Ignite's durable memory component treats RAM not just as a caching layer but as a complete fully functional storage layer. This means that users can turn the persistence on and off as needed. If the persistence is off, then Ignite can act as a distributed **in-memory database** or **in-memory data grid**, depending on whether you prefer to use SQL or key-value APIs. If the persistence is turned on, then Ignite becomes a distributed, **horizontally scalable database** that guarantees full data consistency and is resilient to full cluster failures.
+
+## ACID Compliance
+Data stored in Ignite is ACID-compliant both in memory and on disk, making Ignite a **strongly consistent** system. Ignite transactions work across the network and can span multiple servers.
+
+## Complete SQL Support
+Ignite provides full support for SQL, DDL and DML, allowing users to interact with Ignite using pure SQL without writing any code. This means that users can create tables and indexes as well as insert, update, and query data using only SQL. Having such complete SQL support makes Ignite a one-of-a-kind **distributed SQL database**.
+
+## Key-Value
+The in-memory data grid component in Ignite is a fully transactional **distributed key-value store** that can scale horizontally across 100s of servers in the cluster. When persistence is enabled, Ignite can also store more data than fits in memory and survive full cluster restarts.
+
+## Collocated Processing
+Most traditional databases work in a client-server fashion, meaning that data must be brought to the client side for processing. This approach requires lots of data movement from servers to clients and generally does not scale. Ignite, on the other hand, allows for sending light-weight computations to the data, i.e. **collocating** computations with data. As a result, Ignite scales better and minimizes data movement.
+
+## Scalability and Durability
+Ignite is an elastic, horizontally scalable distributed system that supports adding and removing cluster nodes on demand. Ignite also allows for storing multiple copies of the data, making it resilient to partial cluster failures. If the persistence is enabled, then data stored in Ignite will also survive full cluster failures. Cluster restarts in Ignite can be very fast, as the data becomes operational instantaneously directly from disk. As a result, the data does not need to be preloaded in-memory to begin processing, and Ignite caches will lazily warm up resuming the in memory performance.
+
+## Ignite Persistence
+
+Ignite Native Persistence is a distributed ACID and SQL-compliant disk store that transparently integrates with Ignite's Durable Memory as an optional disk layer storing data and indexes on SSD, Flash, 3D XPoint, and other types of non-volatile storages.
+
+With the Ignite Persistence enabled, you no longer need to keep all the data and indexes in memory or warm it up after a node or cluster restart because the Durable Memory is tightly coupled with persistence and treats it as a secondary memory tier. This implies that if a subset of data or an index is missing in RAM, the Durable Memory will take it from the disk.
+
+<p align="center">
+ <a href="https://apacheignite.readme.io/docs/distributed-persistent-store">
+ <img src="https://ignite.apache.org/images/check_pointing-2.png" width="400px"/>
+ </a>
+</p>
## Advanced Clustering
@@ -26,6 +56,14 @@ Ignite nodes can automatically discover each other. This helps to scale the clus
</a>
</p>
+Apache Ignite can be deployed on:
+* AWS
+* Docker
+* Google Cloud
+* Kubernetes
+* Mesos
+* YARN
+
## Data Grid (JCache)
Ignite data grid is an in-memory distributed key-value store which can be viewed as a distributed partitioned hash map, with every cluster node owning a portion of the overall data. This way the more cluster nodes we add, the more data we can cache.
@@ -42,64 +80,61 @@ Ignite data grid supports local, replicated, and partitioned data sets and allow
Our data grid offers many features, some of which are:
-* Primary & Backup Copies.
-* Near Caches.
-* Cache queries and SQL queries.
-* Continuous Queries.
-* Transactions.
-* Off-Heap Memory.
-* Affinity Collocation.
-* Persistent Store.
-* Automatic Persistence.
-* Data Loading.
-* Eviction and Expiry Policies.
+* Primary & Backup Copies
+* Near Caches
+* Cache queries and SQL queries
+* Continuous Queries
+* Transactions
+* Off-Heap Memory
+* Affinity Collocation
+* Persistent Store
+* Automatic Persistence
+* Data Loading
+* Eviction and Expiry Policies
* Data Rebalancing
-* Web Session Clustering.
-* Hibernate L2 Cache.
-* JDBC Driver.
-* Spring Caching.
-* Topology Validation.
+* Web Session Clustering
+* Hibernate L2 Cache
+* JDBC Driver
+* Spring Caching
+* Topology Validation
-## Streaming & CEP
+## SQL Grid
+Apache Ignite incorporates distributed SQL database capabilities as a part of its platform. The database is horizontally scalable, fault tolerant and SQL ANSI-99 compliant. It supports all SQL, DDL, and DML commands including SELECT, UPDATE, INSERT, MERGE, and DELETE queries. It also provides support for a subset of DDL commands relevant for distributed databases.
-Ignite streaming allows to process continuous never-ending streams of data in scalable and fault-tolerant fashion. The rates at which data can be injected into Ignite can be very high and easily exceed millions of events per second on a moderately sized cluster.
+With Ignite Durable Memory architecture, data as well as indexes can be stored both in memory and, optionally, on disk. This allows executing distributed SQL operations across different memory layers achieving in-memory performance with the durability of disk.
-Real-time data is ingested via data streamers. We offer streamers for JMS 1.1, Apache Kafka, MQTT, Twitter, Apache Flume and Apache Camel already, and we keep adding new ones every release.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/streaming--cep">
- <img src="https://ignite.apache.org/images/data-streamers.png" />
- </a>
-</p>
+You can interact with Apache Ignite using the SQL language via natively developed APIs for Java, .NET and C++, or via the Ignite JDBC or ODBC drivers. This provides a true cross-platform connectivity from languages such as PHP, Ruby and more.
-The data can then be queried within sliding windows, if needed:
<p align="center">
- <a href="https://apacheignite.readme.io/docs/streaming--cep">
- <img src="https://ignite.apache.org/images/sliding-event-window.png" />
+ <a href="https://apacheignite.readme.io/docs/distributed-sql">
+ <img src="https://ignite.apache.org/images/ignite-distributed-database.png" vspace="15" width="400px"/>
</a>
</p>
+
## Compute Grid
Distributed computations are performed in parallel fashion to gain high performance, low latency, and linear scalability. Ignite compute grid provides a set of simple APIs that allow users distribute computations and data processing across multiple computers in the cluster. Distributed parallel processing is based on the ability to take any computation and execute it on any set of cluster nodes and return the results back.
<p align="center">
<a href="https://apacheignite.readme.io/docs/compute-grid">
- <img src="https://ignite.apache.org/images/in_memory_compute.png" />
+ <img src="https://ignite.apache.org/images/in_memory_compute.png" vspace="15"/>
</a>
</p>
We support these features, amongst others:
-* Distributed Closure Execution.
-* MapReduce & ForkJoin Processing.
-* Clustered Executor Service.
-* Collocation of Compute and Data.
-* Load Balancing.
-* Fault Tolerance.
-* Job State Checkpointing.
-* Job Scheduling.
+* Distributed Closure Execution
+* MapReduce & ForkJoin Processing
+* Continuous Mapping
+* Clustered Executor Service
+* Per-Node Shared State
+* Collocation of Compute and Data
+* Load Balancing
+* Fault Tolerance
+* Job State Checkpointing
+* Job Scheduling
## Service Grid
@@ -121,12 +156,12 @@ In addition, IGFS provides API to execute map-reduce tasks over file system data
## Distributed Data Structures
-Ignite supports complex data structures in a distributed fashion:
+Ignite supports complex data structures in a distributed fashion:
-* Queues and sets: ordinary, bounded, collocated, non-collocated.
-* Atomic types: `AtomicLong` and `AtomicReference`.
-* `CountDownLatch`.
-* ID Generators.
+* Queues and sets: ordinary, bounded, collocated, non-collocated
+* Atomic types: `AtomicLong` and `AtomicReference`
+* `CountDownLatch`
+* ID Generators
## Distributed Messaging
@@ -147,7 +182,7 @@ Our Hadoop Accelerator provides a set of components allowing for in-memory Hadoo
An alternate high-performant implementation of job tracker which replaces standard Hadoop MapReduce. Use it to boost your Hadoop MapReduce job execution performance.
<p align="center">
- <a href="https://apacheignite.readme.io/docs/map-reduce">
+ <a href="https://apacheignite-fs.readme.io/docs/map-reduce">
<img src="https://ignite.apache.org/images/hadoop-mapreduce.png" vspace="15" height="400"/>
</a>
</p>
@@ -157,7 +192,7 @@ An alternate high-performant implementation of job tracker which replaces standa
A Hadoop-compliant IGFS File System implementation over which Hadoop can run over in plug-n-play fashion and significantly reduce I/O and improve both, latency and throughput.
<p align="center">
- <a href="https://apacheignite.readme.io/docs/file-system">
+ <a href="https://apacheignite-fs.readme.io/docs/in-memory-file-system">
<img src="https://ignite.apache.org/images/ignite_filesystem.png" height="300" vspace="15"/>
</a>
</p>
@@ -168,21 +203,72 @@ An implementation of `SecondaryFileSystem`. This implementation can be injected
### Supported Hadoop distributions
-* Apache Hadoop.
-* Cloudera CDH.
-* Hortonworks HDP.
-* Apache BigTop.
+* Apache Hadoop
+* Cloudera CDH
+* Hortonworks HDP
+* Apache BigTop
## Spark Shared RDDs
Apache Ignite provides an implementation of Spark RDD abstraction which allows to easily share state in memory across Spark jobs. The main difference between native Spark `RDD` and `IgniteRDD` is that Ignite RDD provides a shared in-memory view on data across different Spark jobs, workers, or applications, while native Spark RDD cannot be seen by other Spark jobs or applications.
<p align="center">
- <a href="https://apacheignite.readme.io/docs/shared-rdd">
+ <a href="https://apacheignite-fs.readme.io/docs/ignite-for-spark">
<img src="https://ignite.apache.org/images/spark-ignite-rdd.png" height="400" vspace="15" />
</a>
</p>
+## Ignite Facts
+
+<b>Is Ignite a persistent or pure in-memory storage?</b><br/>
+**Both**. Native persistence in Ignite can be turned on and off. This allows Ignite to store data sets bigger than can fit in the available memory. Essentially, the smaller operational data sets can be stored in-memory only, and larger data sets that do not fit in memory can be stored on disk, using memory as a caching layer for better performance.
+
+[Read More](https://apacheignite.readme.io/docs/distributed-persistent-store)
+
+<b>Is Ignite a distributed database?</b><br/>
+**Yes**. Data in Ignite is either *partitioned* or *replicated* across a cluster of multiple nodes. This provides scalability and adds resilience to the system. Ignite automatically controls how data is partitioned, however, users can plug in their own distribution (affinity) functions and collocate various pieces of data together for efficiency.
+
+[Read More](https://apacheignite.readme.io/docs/distributed-sql)
+
+<b>Is Ignite a relational SQL database?</b><br/>
+**Not fully**. Although Ignite aims to behave like any other relational SQL database, there are differences in how Ignite handles constraints and indexes. Ignite supports *primary* and *secondary* indexes, however, the *uniqueness* can only be enforced for the *primary* indexes. Ignite also does not support *foreign key* constraints.
+
+Essentially, Ignite purposely does not support any constraints that would entail a cluster broadcast message for each update and significantly hurt performance and scalability of the system.
+
+[Read More](https://apacheignite.readme.io/docs/indexes)
+
+<b>Is Ignite an in-memory database?</b><br/>
+**Yes**. Even though Ignite *durable memory* works well in-memory and on-disk, the disk persistence can be disabled and Ignite can act as a pure *in-memory database*.
+
+[Read More](https://apacheignite.readme.io/docs/distributed-sql)
+
+<b>Is Ignite a transactional database?</b><br/>
+**Not fully**. ACID Transactions are supported, but only at *key-value* API level. Ignite also supports *cross-partition* transactions, which means that transactions can span keys residing in different partitions on different servers.
+
+At *SQL* level Ignite supports *atomic*, but not yet *transactional* consistency. Ignite community plans to implement SQL transactions in version 2.2.
+
+[Read More](https://apacheignite.readme.io/docs/sql-queries#known-limitations)
+
+<b>Is Ignite a key-value store?</b><br/>
+**Yes**. Ignite provides a feature rich key-value API, that is JCache (JSR-107) compliant and supports Java, C++, and .NET.
+
+[Read More](https://apacheignite.readme.io/docs/data-grid)
+
+<b>Is Ignite an in-memory data grid?</b><br/>
+**Yes**. Ignite is a full-featured data grid, which can be used either in pure in-memory mode or with Ignite native persistence. It can also integrate with any 3rd party database, including any RDBMS or NoSQL store.
+
+[Read More](https://apacheignite.readme.io/docs/data-grid)
+
+<b>What is durable memory?</b><br/>
+Ignite *durable memory* architecture allows Ignite to extend in-memory computing to disk. It is based on a paged-based off-heap memory allocator which becomes durable by persisting to the *write-ahead-log (WAL)* and, then, to main Ignite persistent storage. When persistence is disabled, durable memory acts like a pure in-memory storage.
+
+[Read More](https://apacheignite.readme.io/docs/durable-memory)
+
+<b>What is collocated processing?</b><br/>
+Ignite is a distributed system and, therefore, it is important to be able to collocate data with data and compute with data to avoid distributed data noise. Data collocation becomes especially important when performing distributed SQL joins. Ignite also supports sending user logic (functions, lambdas, etc.) directly to the nodes where the data resides and computing on the data locally.
+
+[Read More](https://apacheignite.readme.io/docs/collocate-compute-and-data)
+
## Ignite On Other Platforms
<a href="modules/platforms/dotnet">Ignite.NET</a>
[05/26] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1fcc96d6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1fcc96d6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1fcc96d6
Branch: refs/heads/ignite-6149
Commit: 1fcc96d624356b04de78f79b831d9e0049b8928b
Parents: 8610471 319aa84
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 15 13:50:14 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 15 13:50:14 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/pagemem/PageIdUtils.java | 13 +++
.../pagemem/wal/record/CheckpointRecord.java | 6 ++
.../internal/pagemem/wal/record/DataEntry.java | 1 +
.../internal/pagemem/wal/record/DataRecord.java | 2 +-
.../wal/record/MemoryRecoveryRecord.java | 7 ++
.../pagemem/wal/record/PageSnapshot.java | 23 +++++-
.../internal/pagemem/wal/record/TxRecord.java | 6 ++
.../delta/DataPageInsertFragmentRecord.java | 13 ++-
.../wal/record/delta/DataPageInsertRecord.java | 6 ++
.../wal/record/delta/DataPageRemoveRecord.java | 2 +-
.../delta/DataPageSetFreeListPageRecord.java | 6 ++
.../wal/record/delta/DataPageUpdateRecord.java | 6 ++
.../wal/record/delta/FixCountRecord.java | 9 +++
.../record/delta/FixLeftmostChildRecord.java | 9 +++
.../pagemem/wal/record/delta/FixRemoveId.java | 6 ++
.../wal/record/delta/InitNewPageRecord.java | 2 -
.../wal/record/delta/InnerReplaceRecord.java | 6 ++
.../pagemem/wal/record/delta/InsertRecord.java | 2 +-
.../pagemem/wal/record/delta/MergeRecord.java | 2 +-
.../wal/record/delta/MetaPageAddRootRecord.java | 9 +++
.../wal/record/delta/MetaPageCutRootRecord.java | 6 ++
.../wal/record/delta/MetaPageInitRecord.java | 6 ++
.../delta/MetaPageInitRootInlineRecord.java | 7 +-
.../record/delta/MetaPageInitRootRecord.java | 6 ++
.../delta/MetaPageUpdateLastAllocatedIndex.java | 6 ++
...aPageUpdateLastSuccessfulFullSnapshotId.java | 6 ++
.../MetaPageUpdateLastSuccessfulSnapshotId.java | 6 ++
.../delta/MetaPageUpdateNextSnapshotId.java | 6 ++
.../MetaPageUpdatePartitionDataRecord.java | 2 +-
.../wal/record/delta/NewRootInitRecord.java | 6 ++
.../delta/PageListMetaResetCountRecord.java | 6 ++
.../delta/PagesListInitNewPageRecord.java | 4 +-
.../record/delta/PagesListRemovePageRecord.java | 3 +-
.../record/delta/PagesListSetNextRecord.java | 6 ++
.../delta/PagesListSetPreviousRecord.java | 6 ++
.../record/delta/PartitionDestroyRecord.java | 6 ++
.../record/delta/PartitionMetaStateRecord.java | 6 ++
.../pagemem/wal/record/delta/RecycleRecord.java | 15 ++++
.../pagemem/wal/record/delta/RemoveRecord.java | 2 +-
.../pagemem/wal/record/delta/ReplaceRecord.java | 6 ++
.../record/delta/SplitExistingPageRecord.java | 2 +-
.../record/delta/SplitForwardPageRecord.java | 24 ++++++
.../record/delta/TrackingPageDeltaRecord.java | 14 +++-
.../distributed/dht/GridDhtTxPrepareFuture.java | 3 +-
.../cache/persistence/file/FileIODecorator.java | 1 -
.../freelist/io/PagesListMetaIO.java | 21 +++++
.../freelist/io/PagesListNodeIO.java | 16 ++++
.../cache/persistence/tree/io/BPlusIO.java | 12 +++
.../cache/persistence/tree/io/BPlusMetaIO.java | 12 +++
.../cache/persistence/tree/io/DataPageIO.java | 25 +++++-
.../cache/persistence/tree/io/PageIO.java | 27 +++++++
.../cache/persistence/tree/io/PageMetaIO.java | 14 ++++
.../tree/io/PagePartitionCountersIO.java | 27 +++++++
.../tree/io/PagePartitionMetaIO.java | 19 +++++
.../persistence/tree/io/TrackingPageIO.java | 31 ++++++++
.../wal/FileWriteAheadLogManager.java | 6 ++
.../reader/StandaloneWalRecordsIterator.java | 2 +-
.../persistence/wal/record/HeaderRecord.java | 6 ++
.../wal/serializer/RecordV1Serializer.java | 21 ++++-
.../database/IgniteDbAbstractTest.java | 6 --
modules/dev-utils/pom.xml | 50 ++++++++++++
.../development/utils/IgniteWalConverter.java | 83 ++++++++++++++++++++
pom.xml | 1 +
63 files changed, 643 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
[22/26] ignite git commit: IGNITE-5620: Implemented SQLSTATE error
code for server-side logic and JDBC thin client. This closes #2541.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
index 27b9407..70cf00e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -22,7 +22,7 @@ import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
-import java.util.List;
+import java.sql.SQLException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
@@ -31,33 +31,13 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.processors.odbc.ClientListenerNioListener;
import org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion;
import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
-import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaColumnsRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaColumnsResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaIndexesRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaIndexesResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaParamsRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaParamsResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaPrimaryKeysRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaPrimaryKeysResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaSchemasRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaSchemasResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaTablesRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaTablesResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCloseRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryFetchResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryMetadataResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResponse;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcStatementType;
import org.apache.ignite.internal.util.ipc.loopback.IpcClientTcpEndpoint;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteProductVersion;
@@ -173,10 +153,10 @@ public class JdbcThinTcpIo {
}
/**
- * @throws IgniteCheckedException On error.
+ * @throws SQLException On connection error or reject.
* @throws IOException On IO error in handshake.
*/
- public void start() throws IgniteCheckedException, IOException {
+ public void start() throws SQLException, IOException {
Socket sock = new Socket();
if (sockSndBuf != 0)
@@ -189,24 +169,25 @@ public class JdbcThinTcpIo {
try {
sock.connect(new InetSocketAddress(host, port));
- }
- catch (IOException e) {
- throw new IgniteCheckedException("Failed to connect to server [host=" + host + ", port=" + port + ']', e);
- }
- endpoint = new IpcClientTcpEndpoint(sock);
+ endpoint = new IpcClientTcpEndpoint(sock);
- out = new BufferedOutputStream(endpoint.outputStream());
- in = new BufferedInputStream(endpoint.inputStream());
+ out = new BufferedOutputStream(endpoint.outputStream());
+ in = new BufferedInputStream(endpoint.inputStream());
+ }
+ catch (IOException | IgniteCheckedException e) {
+ throw new SQLException("Failed to connect to server [host=" + host + ", port=" + port + ']',
+ SqlStateCode.CLIENT_CONNECTION_FAILED, e);
+ }
handshake();
}
/**
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
+ * @throws IOException On IO error.
+ * @throws SQLException On connection reject.
*/
- public void handshake() throws IOException, IgniteCheckedException {
+ public void handshake() throws IOException, SQLException {
BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
null, null);
@@ -262,8 +243,9 @@ public class JdbcThinTcpIo {
if (VER_2_1_0.equals(srvProtocolVer))
handshake_2_1_0();
else {
- throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
- ", remoteNodeProtocolVer=" + srvProtocolVer + ", err=" + err + ']');
+ throw new SQLException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
+ ", remoteNodeProtocolVer=" + srvProtocolVer + ", err=" + err + ']',
+ SqlStateCode.CONNECTION_REJECTED);
}
}
}
@@ -271,10 +253,10 @@ public class JdbcThinTcpIo {
/**
* Compatibility handshake for server version 2.1.0
*
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
+ * @throws IOException On IO error.
+ * @throws SQLException On connection reject.
*/
- public void handshake_2_1_0() throws IOException, IgniteCheckedException {
+ private void handshake_2_1_0() throws IOException, SQLException {
BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
null, null);
@@ -310,38 +292,20 @@ public class JdbcThinTcpIo {
ClientListenerProtocolVersion ver = ClientListenerProtocolVersion.create(maj, min, maintenance);
- throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
- ", remoteNodeProtocolVer=" + ver + ", err=" + err + ']');
+ throw new SQLException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
+ ", remoteNodeProtocolVer=" + ver + ", err=" + err + ']', SqlStateCode.CONNECTION_REJECTED);
}
}
/**
- * @param stmtType Expected statement type.
- * @param cache Cache name.
- * @param fetchSize Fetch size.
- * @param maxRows Max rows.
- * @param sql SQL statement.
- * @param args Query parameters.
- * @return Execute query results.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcQueryExecuteResult queryExecute(JdbcStatementType stmtType, String cache, int fetchSize, int maxRows,
- String sql, List<Object> args)
- throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcQueryExecuteRequest(stmtType, cache, fetchSize, maxRows, sql,
- args == null ? null : args.toArray(new Object[args.size()])), DYNAMIC_SIZE_MSG_CAP);
- }
-
- /**
* @param req Request.
- * @param cap Initial ouput stream capacity.
* @return Server response.
- * @throws IOException On IO error.
- * @throws IgniteCheckedException On error.
+ * @throws IOException In case of IO error.
*/
@SuppressWarnings("unchecked")
- public <R extends JdbcResult> R sendRequest(JdbcRequest req, int cap) throws IOException, IgniteCheckedException {
+ JdbcResponse sendRequest(JdbcRequest req) throws IOException {
+ int cap = guessCapacity(req);
+
BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(cap), null, null);
req.writeBinary(writer);
@@ -354,125 +318,33 @@ public class JdbcThinTcpIo {
res.readBinary(reader);
- if (res.status() != ClientListenerResponse.STATUS_SUCCESS)
- throw new IgniteCheckedException("Error server response: [req=" + req + ", resp=" + res + ']');
-
- return (R)res.response();
+ return res;
}
/**
- * @param qryId Query ID.
- * @param pageSize pageSize.
- * @return Fetch results.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcQueryFetchResult queryFetch(Long qryId, int pageSize)
- throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcQueryFetchRequest(qryId, pageSize), QUERY_FETCH_MSG_SIZE);
- }
-
-
- /**
- * @param qryId Query ID.
- * @return Fetch results.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcQueryMetadataResult queryMeta(Long qryId)
- throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcQueryMetadataRequest(qryId), QUERY_META_MSG_SIZE);
- }
-
- /**
- * @param qryId Query ID.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public void queryClose(long qryId) throws IOException, IgniteCheckedException {
- sendRequest(new JdbcQueryCloseRequest(qryId), QUERY_CLOSE_MSG_SIZE);
- }
-
- /**
- * @param schemaName Schema.
- * @param batch Batch queries.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcBatchExecuteResult batchExecute(String schemaName, List<JdbcQuery> batch)
- throws IOException, IgniteCheckedException {
- int cnt = Math.min(MAX_BATCH_QRY_CNT, batch.size());
-
- return sendRequest(new JdbcBatchExecuteRequest(schemaName, batch), DYNAMIC_SIZE_MSG_CAP * cnt);
- }
-
- /**
- * @param schemaPtrn Schema name pattern.
- * @param tablePtrn Table name pattern.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcMetaTablesResult tablesMeta(String schemaPtrn, String tablePtrn)
- throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaTablesRequest(schemaPtrn, tablePtrn), DYNAMIC_SIZE_MSG_CAP);
- }
-
- /**
- * @param schemaPtrn Schema name pattern.
- * @param tablePtrn Table name pattern.
- * @param columnPtrn Column name pattern.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcMetaColumnsResult columnsMeta(String schemaPtrn, String tablePtrn, String columnPtrn)
- throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaColumnsRequest(schemaPtrn, tablePtrn, columnPtrn), DYNAMIC_SIZE_MSG_CAP);
- }
-
- /**
- * @param schemaPtrn Schema name pattern.
- * @param tablePtrn Table name pattern.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcMetaIndexesResult indexMeta(String schemaPtrn, String tablePtrn) throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaIndexesRequest(schemaPtrn, tablePtrn), DYNAMIC_SIZE_MSG_CAP);
- }
-
- /**
- * @param schemaPtrn Schema name pattern.
- * @param sql SQL query.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
+ * Try to guess request capacity.
+ *
+ * @param req Request.
+ * @return Expected capacity.
*/
- public JdbcMetaParamsResult parametersMeta(String schemaPtrn, String sql) throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaParamsRequest(schemaPtrn, sql), DYNAMIC_SIZE_MSG_CAP);
- }
+ private static int guessCapacity(JdbcRequest req) {
+ int cap;
- /**
- * @param schemaPtrn Schema name pattern.
- * @param tablePtrn Table name pattern.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcMetaPrimaryKeysResult primaryKeysMeta(String schemaPtrn, String tablePtrn) throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaPrimaryKeysRequest(schemaPtrn, tablePtrn), DYNAMIC_SIZE_MSG_CAP);
- }
+ if (req instanceof JdbcBatchExecuteRequest) {
+ int cnt = Math.min(MAX_BATCH_QRY_CNT, ((JdbcBatchExecuteRequest)req).queries().size());
- /**
- * @param schemaPtrn Schema name pattern.
- * @return Result.
- * @throws IOException On error.
- * @throws IgniteCheckedException On error.
- */
- public JdbcMetaSchemasResult schemasMeta(String schemaPtrn) throws IOException, IgniteCheckedException {
- return sendRequest(new JdbcMetaSchemasRequest(schemaPtrn), DYNAMIC_SIZE_MSG_CAP);
+ cap = cnt * DYNAMIC_SIZE_MSG_CAP;
+ }
+ else if (req instanceof JdbcQueryCloseRequest)
+ cap = QUERY_CLOSE_MSG_SIZE;
+ else if (req instanceof JdbcQueryMetadataRequest)
+ cap = QUERY_META_MSG_SIZE;
+ else if (req instanceof JdbcQueryFetchRequest)
+ cap = QUERY_FETCH_MSG_SIZE;
+ else
+ cap = DYNAMIC_SIZE_MSG_CAP;
+
+ return cap;
}
/**
@@ -495,9 +367,8 @@ public class JdbcThinTcpIo {
/**
* @return Bytes of a response from server.
* @throws IOException On error.
- * @throws IgniteCheckedException On error.
*/
- private byte[] read() throws IOException, IgniteCheckedException {
+ private byte[] read() throws IOException {
byte[] sizeBytes = read(4);
int msgSize = (((0xFF & sizeBytes[3]) << 24) | ((0xFF & sizeBytes[2]) << 16)
@@ -510,9 +381,8 @@ public class JdbcThinTcpIo {
* @param size Count of bytes to read from stream.
* @return Read bytes.
* @throws IOException On error.
- * @throws IgniteCheckedException On error.
*/
- private byte [] read(int size) throws IOException, IgniteCheckedException {
+ private byte [] read(int size) throws IOException {
int off = 0;
byte[] data = new byte[size];
@@ -521,7 +391,7 @@ public class JdbcThinTcpIo {
int res = in.read(data, off, size - off);
if (res == -1)
- throw new IgniteCheckedException("Failed to read incoming message (not enough data).");
+ throw new IOException("Failed to read incoming message (not enough data).");
off += res;
}
@@ -603,7 +473,7 @@ public class JdbcThinTcpIo {
}
/**
- * @return Ignnite server version.
+ * @return Ignite server version.
*/
IgniteProductVersion igniteVersion() {
return igniteVer;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
index d05c9fd..8e5af31 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.query;
import java.sql.SQLException;
import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
/**
* Error codes for query operations.
@@ -76,6 +77,9 @@ public final class IgniteQueryErrorCode {
/** Required column already exists. */
public final static int COLUMN_ALREADY_EXISTS = 3009;
+ /** Conversion failure. */
+ public final static int CONVERSION_FAILED = 3013;
+
/* 4xxx - cache related runtime errors */
/** Attempt to INSERT a key that is already in cache. */
@@ -102,13 +106,53 @@ public final class IgniteQueryErrorCode {
}
/**
- * Create a {@link SQLException} for given code and message with null state.
+ * Create a {@link SQLException} for given code and message with detected state.
*
* @param msg Message.
* @param code Ignite status code.
* @return {@link SQLException} with given details.
*/
public static SQLException createJdbcSqlException(String msg, int code) {
- return new SQLException(msg, null, code);
+ return new SQLException(msg, codeToSqlState(code));
+ }
+
+ /**
+ * Map Ignite specific error code to standard SQL state.
+ * @param statusCode Ignite specific error code.
+ * @return SQL state string.
+ * @see <a href="http://en.wikibooks.org/wiki/Structured_Query_Language/SQLSTATE">Wikipedia: SQLSTATE spec.</a>
+ * @see IgniteQueryErrorCode
+ */
+ public static String codeToSqlState(int statusCode) {
+ switch (statusCode) {
+ case DUPLICATE_KEY:
+ return SqlStateCode.CONSTRAINT_VIOLATION;
+
+ case NULL_KEY:
+ case NULL_VALUE:
+ return SqlStateCode.NULL_VALUE;
+
+ case UNSUPPORTED_OPERATION:
+ return SqlStateCode.UNSUPPORTED_OPERATION;
+
+ case CONVERSION_FAILED:
+ return SqlStateCode.CONVERSION_FAILED;
+
+ case PARSING:
+ case TABLE_NOT_FOUND:
+ case TABLE_ALREADY_EXISTS:
+ case INDEX_ALREADY_EXISTS:
+ case INDEX_NOT_FOUND:
+ case COLUMN_NOT_FOUND:
+ case COLUMN_ALREADY_EXISTS:
+ case STMT_TYPE_MISMATCH:
+ case UNEXPECTED_OPERATION:
+ case UNEXPECTED_ELEMENT_TYPE:
+ case KEY_UPDATE:
+ return SqlStateCode.PARSING_EXCEPTION;
+
+ default:
+ return SqlStateCode.INTERNAL_ERROR;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlStateCode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlStateCode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlStateCode.java
new file mode 100644
index 0000000..eff680f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlStateCode.java
@@ -0,0 +1,69 @@
+/*
+ * 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.internal.processors.odbc;
+
+/**
+ * SQL state codes.
+ */
+public final class SqlStateCode {
+ /**
+ * No-op constructor to prevent instantiation.
+ */
+ private SqlStateCode() {
+ // No-op.
+ }
+
+ /** Client has failed to open connection with specified server. */
+ public final static String CLIENT_CONNECTION_FAILED = "08001";
+
+ /** Connection unexpectedly turned out to be in closed state. */
+ public final static String CONNECTION_CLOSED = "08003";
+
+ /** Connection was rejected by server. */
+ public final static String CONNECTION_REJECTED = "08004";
+
+ /** IO error during communication. */
+ public final static String CONNECTION_FAILURE = "08006";
+
+ /** Null value occurred where it wasn't expected to. */
+ public final static String NULL_VALUE = "22004";
+
+ /** Parameter type is not supported. */
+ public final static String INVALID_PARAMETER_VALUE = "22023";
+
+ /** Data integrity constraint violation. */
+ public final static String CONSTRAINT_VIOLATION = "23000";
+
+ /** Invalid result set state. */
+ public final static String INVALID_CURSOR_STATE = "24000";
+
+ /** Conversion failure. */
+ public final static String CONVERSION_FAILED = "0700B";
+
+ /** Invalid transaction level. */
+ public final static String INVALID_TRANSACTION_LEVEL = "0700E";
+
+ /** Requested operation is not supported. */
+ public final static String UNSUPPORTED_OPERATION = "0A000";
+
+ /** Parsing exception. */
+ public final static String PARSING_EXCEPTION = "42000";
+
+ /** Internal error. */
+ public final static String INTERNAL_ERROR = "50000"; // Generic value for custom "50" class.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
index 4250ba5..fe50bb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
@@ -36,12 +36,14 @@ import org.apache.ignite.internal.IgniteVersionUtils;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.jdbc2.JdbcSqlFieldsQuery;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
+import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.odbc.OdbcQueryGetColumnsMetaRequest;
import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.typedef.F;
@@ -138,7 +140,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
JdbcRequest req = (JdbcRequest)req0;
if (!busyLock.enterBusy())
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN,
"Failed to handle JDBC request because node is stopping.");
try {
@@ -177,7 +179,8 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
return getSchemas((JdbcMetaSchemasRequest)req);
}
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, "Unsupported JDBC request [req=" + req + ']');
+ return new JdbcResponse(IgniteQueryErrorCode.UNSUPPORTED_OPERATION,
+ "Unsupported JDBC request [req=" + req + ']');
}
finally {
busyLock.leaveBusy();
@@ -186,7 +189,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
/** {@inheritDoc} */
@Override public ClientListenerResponse handleException(Exception e) {
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
/** {@inheritDoc} */
@@ -232,7 +235,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
int cursorCnt = qryCursors.size();
if (maxCursors > 0 && cursorCnt >= maxCursors)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, "Too many opened cursors (either close other " +
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, "Too many opened cursors (either close other " +
"opened cursors or increase the limit through OdbcConfiguration.setMaxOpenCursors()) " +
"[maximum=" + maxCursors + ", current=" + cursorCnt + ']');
@@ -269,8 +272,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
qry.setLazy(lazy);
if (req.pageSize() <= 0)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
- "Invalid fetch size : [fetchSize=" + req.pageSize() + ']');
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, "Invalid fetch size: " + req.pageSize());
qry.setPageSize(req.pageSize());
@@ -312,7 +314,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
U.error(log, "Failed to execute SQL query [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -327,7 +329,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.remove(req.queryId());
if (cur == null)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN,
"Failed to find query cursor with ID: " + req.queryId());
cur.close();
@@ -339,7 +341,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
U.error(log, "Failed to close SQL query [reqId=" + req.requestId() + ", req=" + req.queryId() + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -354,11 +356,11 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.get(req.queryId());
if (cur == null)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN,
"Failed to find query cursor with ID: " + req.queryId());
if (req.pageSize() <= 0)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN,
"Invalid fetch size : [fetchSize=" + req.pageSize() + ']');
cur.pageSize(req.pageSize());
@@ -376,7 +378,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to fetch SQL query result [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -389,7 +391,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.get(req.queryId());
if (cur == null)
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN,
"Failed to find query with ID: " + req.queryId());
JdbcQueryMetadataResult res = new JdbcQueryMetadataResult(req.queryId(),
@@ -400,7 +402,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to fetch SQL query result [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -451,8 +453,22 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to execute batch query [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(new JdbcBatchExecuteResult(Arrays.copyOf(updCnts, successQueries),
- ClientListenerResponse.STATUS_FAILED, e.toString()));
+ int code;
+
+ String msg;
+
+ if (e instanceof IgniteSQLException) {
+ code = ((IgniteSQLException) e).statusCode();
+
+ msg = e.getMessage();
+ }
+ else {
+ code = IgniteQueryErrorCode.UNKNOWN;
+
+ msg = e.getMessage();
+ }
+
+ return new JdbcResponse(new JdbcBatchExecuteResult(Arrays.copyOf(updCnts, successQueries), code, msg));
}
}
@@ -486,7 +502,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get tables metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -528,7 +544,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get columns metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -558,7 +574,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -585,7 +601,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -631,7 +647,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -657,7 +673,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get schemas metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
+ return exceptionToResult(e);
}
}
@@ -672,4 +688,18 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
return str != null && (F.isEmpty(ptrn) ||
str.matches(ptrn.replace("%", ".*").replace("_", ".")));
}
+
+ /**
+ * Create {@link JdbcResponse} bearing appropriate Ignite specific result code if possible
+ * from given {@link Exception}.
+ *
+ * @param e Exception to convert.
+ * @return resulting {@link JdbcResponse}.
+ */
+ private JdbcResponse exceptionToResult(Exception e) {
+ if (e instanceof IgniteSQLException)
+ return new JdbcResponse(((IgniteSQLException) e).statusCode(), e.getMessage());
+ else
+ return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, e.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/core/src/main/java/org/apache/ignite/internal/processors/query/IgniteSQLException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/IgniteSQLException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/IgniteSQLException.java
index 0666493..2bacc23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/IgniteSQLException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/IgniteSQLException.java
@@ -22,6 +22,9 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.UNKNOWN;
+import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.codeToSqlState;
+
/**
* Specific exception bearing information about query processing errors for more detailed
* errors in JDBC driver.
@@ -38,45 +41,82 @@ public class IgniteSQLException extends IgniteException {
/** Code to return as {@link SQLException#vendorCode} */
private final int statusCode;
- /** */
+ /**
+ * Constructor.
+ *
+ * @param msg Exception message.
+ */
public IgniteSQLException(String msg) {
- this(msg, null, 0);
+ this(msg, UNKNOWN, (String)null);
}
/**
- * Minimalistic ctor accepting only {@link SQLException} as the cause.
+ * Constructor.
+ *
+ * @param cause Cause to throw this exception.
*/
public IgniteSQLException(SQLException cause) {
super(cause);
- this.sqlState = null;
- this.statusCode = 0;
+
+ this.sqlState = cause.getSQLState();
+ this.statusCode = UNKNOWN;
}
- /** */
+ /**
+ * Constructor.
+ *
+ * @param msg Exception message.
+ * @param cause Cause to throw this exception.
+ */
public IgniteSQLException(String msg, @Nullable Throwable cause) {
- super(msg, cause);
- this.sqlState = null;
- this.statusCode = 0;
+ this(msg, UNKNOWN, cause);
}
- /** */
+ /**
+ * Constructor.
+ *
+ * @param msg Exception message.
+ * @param statusCode Ignite specific error code.
+ * @param cause Cause to throw this exception.
+ * @see IgniteQueryErrorCode
+ */
public IgniteSQLException(String msg, int statusCode, @Nullable Throwable cause) {
- super(msg, cause);
- this.sqlState = null;
- this.statusCode = statusCode;
+ this(msg, statusCode, codeToSqlState(statusCode), cause);
}
- /** */
- public IgniteSQLException(String msg, String sqlState, int statusCode) {
- super(msg);
- this.sqlState = sqlState;
- this.statusCode = statusCode;
+ /**
+ * Constructor.
+ * @param msg Exception message.
+ * @param statusCode Ignite specific error code.
+ * @see IgniteQueryErrorCode
+ */
+ public IgniteSQLException(String msg, int statusCode) {
+ this(msg, statusCode, codeToSqlState(statusCode));
}
- /** */
- public IgniteSQLException(String msg, int statusCode) {
- super(msg);
- this.sqlState = null;
+ /**
+ * Constructor.
+ * @param msg Exception message.
+ * @param statusCode Ignite specific error code.
+ * @param sqlState SQLSTATE standard code.
+ * @see IgniteQueryErrorCode
+ */
+ public IgniteSQLException(String msg, int statusCode, String sqlState) {
+ this(msg, statusCode, sqlState, null);
+ }
+
+ /**
+ * Constructor.
+ * @param msg Exception message.
+ * @param statusCode Ignite specific error code.
+ * @param sqlState SQLSTATE standard code.
+ * @param cause Cause to throw this exception.
+ * @see IgniteQueryErrorCode
+ */
+ private IgniteSQLException(String msg, int statusCode, String sqlState, @Nullable Throwable cause) {
+ super(msg, cause);
+
+ this.sqlState = sqlState;
this.statusCode = statusCode;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 0634a52..cbaa478 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -49,6 +49,7 @@ import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -663,48 +664,56 @@ public class DmlStatementsProcessor {
Class<?> currCls = val.getClass();
- if (val instanceof Date && currCls != Date.class && expCls == Date.class) {
- // H2 thinks that java.util.Date is always a Timestamp, while binary marshaller expects
- // precise Date instance. Let's satisfy it.
- return new Date(((Date) val).getTime());
- }
+ try {
+ if (val instanceof Date && currCls != Date.class && expCls == Date.class) {
+ // H2 thinks that java.util.Date is always a Timestamp, while binary marshaller expects
+ // precise Date instance. Let's satisfy it.
+ return new Date(((Date) val).getTime());
+ }
- // User-given UUID is always serialized by H2 to byte array, so we have to deserialize manually
- if (type == Value.UUID && currCls == byte[].class)
- return U.unmarshal(desc.context().marshaller(), (byte[]) val,
- U.resolveClassLoader(desc.context().gridConfig()));
+ // User-given UUID is always serialized by H2 to byte array, so we have to deserialize manually
+ if (type == Value.UUID && currCls == byte[].class)
+ return U.unmarshal(desc.context().marshaller(), (byte[]) val,
+ U.resolveClassLoader(desc.context().gridConfig()));
- if (LocalDateTimeUtils.isJava8DateApiPresent()) {
- if (val instanceof Timestamp && LocalDateTimeUtils.isLocalDateTime(expCls))
- return LocalDateTimeUtils.valueToLocalDateTime(ValueTimestamp.get((Timestamp)val));
+ if (LocalDateTimeUtils.isJava8DateApiPresent()) {
+ if (val instanceof Timestamp && LocalDateTimeUtils.isLocalDateTime(expCls))
+ return LocalDateTimeUtils.valueToLocalDateTime(ValueTimestamp.get((Timestamp) val));
- if (val instanceof Date && LocalDateTimeUtils.isLocalDate(expCls))
- return LocalDateTimeUtils.valueToLocalDate(ValueDate.fromDateValue(
- DateTimeUtils.dateValueFromDate(((Date)val).getTime())));
+ if (val instanceof Date && LocalDateTimeUtils.isLocalDate(expCls))
+ return LocalDateTimeUtils.valueToLocalDate(ValueDate.fromDateValue(
+ DateTimeUtils.dateValueFromDate(((Date) val).getTime())));
- if (val instanceof Time && LocalDateTimeUtils.isLocalTime(expCls))
- return LocalDateTimeUtils.valueToLocalTime(ValueTime.get((Time)val));
- }
+ if (val instanceof Time && LocalDateTimeUtils.isLocalTime(expCls))
+ return LocalDateTimeUtils.valueToLocalTime(ValueTime.get((Time) val));
+ }
- // We have to convert arrays of reference types manually - see https://issues.apache.org/jira/browse/IGNITE-4327
- // Still, we only can convert from Object[] to something more precise.
- if (type == Value.ARRAY && currCls != expCls) {
- if (currCls != Object[].class)
- throw new IgniteCheckedException("Unexpected array type - only conversion from Object[] is assumed");
+ // We have to convert arrays of reference types manually -
+ // see https://issues.apache.org/jira/browse/IGNITE-4327
+ // Still, we only can convert from Object[] to something more precise.
+ if (type == Value.ARRAY && currCls != expCls) {
+ if (currCls != Object[].class)
+ throw new IgniteCheckedException("Unexpected array type - only conversion from Object[] " +
+ "is assumed");
- // Why would otherwise type be Value.ARRAY?
- assert expCls.isArray();
+ // Why would otherwise type be Value.ARRAY?
+ assert expCls.isArray();
- Object[] curr = (Object[]) val;
+ Object[] curr = (Object[]) val;
- Object newArr = Array.newInstance(expCls.getComponentType(), curr.length);
+ Object newArr = Array.newInstance(expCls.getComponentType(), curr.length);
- System.arraycopy(curr, 0, newArr, 0, curr.length);
+ System.arraycopy(curr, 0, newArr, 0, curr.length);
- return newArr;
- }
+ return newArr;
+ }
- return H2Utils.convert(val, desc, type);
+ return H2Utils.convert(val, desc, type);
+ }
+ catch (Exception e) {
+ throw new IgniteSQLException("Value conversion failed [from=" + currCls.getName() + ", to=" +
+ expCls.getName() +']', IgniteQueryErrorCode.CONVERSION_FAILED, e);
+ }
}
/**
@@ -839,7 +848,7 @@ public class DmlStatementsProcessor {
String msg = "Failed to INSERT some keys because they are already in cache " +
"[keys=" + sender.failedKeys() + ']';
- SQLException dupEx = new SQLException(msg, null, IgniteQueryErrorCode.DUPLICATE_KEY);
+ SQLException dupEx = new SQLException(msg, SqlStateCode.CONSTRAINT_VIOLATION);
if (resEx == null)
resEx = dupEx;
@@ -972,7 +981,8 @@ public class DmlStatementsProcessor {
}
/** {@inheritDoc} */
- @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
+ @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments)
+ throws EntryProcessorException {
if (entry.exists())
return false;
@@ -1000,7 +1010,8 @@ public class DmlStatementsProcessor {
}
/** {@inheritDoc} */
- @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
+ @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments)
+ throws EntryProcessorException {
if (!entry.exists())
return null; // Someone got ahead of us and removed this entry, let's skip it.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index a2de62b..3046c20 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -941,7 +941,8 @@ public class GridSqlQueryParser {
int valColsNum = cols.size() - pkCols.size();
if (valColsNum == 0)
- throw new IgniteSQLException("No cache value related columns found");
+ throw new IgniteSQLException("Table must have at least one non PRIMARY KEY column.",
+ IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
res.columns(cols);
res.primaryKeyColumns(pkCols);
@@ -1014,8 +1015,36 @@ public class GridSqlQueryParser {
case CommandInterface.ALTER_TABLE_ADD_COLUMN:
return parseAddColumn(stmt);
- default:
- throw new IgniteSQLException("Unsupported operation code: " + stmt.getType());
+ default: {
+ String stmtName = null;
+
+ switch (stmt.getType()) {
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_CHANGE_TYPE:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_DEFAULT:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_NOT_NULL:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_RENAME:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_NULL:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_SELECTIVITY:
+ case CommandInterface.ALTER_TABLE_ALTER_COLUMN_VISIBILITY:
+ stmtName = "ALTER COLUMN";
+
+ break;
+
+ case CommandInterface.ALTER_TABLE_DROP_COLUMN:
+ stmtName = "DROP COLUMN";
+
+ break;
+ }
+
+ if (stmtName == null) {
+ throw new IgniteSQLException("Unsupported operation: " + stmt.getSQL(),
+ IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+ }
+ else {
+ throw new IgniteSQLException(stmtName + " is not supported",
+ IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c4d0bc2/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index 6a78df3..61694dd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -596,7 +596,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
IgniteSQLException.class, "CREATE TABLE ... AS ... syntax is not supported");
assertParseThrows("create table Person (id int primary key)",
- IgniteSQLException.class, "No cache value related columns found");
+ IgniteSQLException.class, "Table must have at least one non PRIMARY KEY column.");
assertParseThrows("create table Person (id int primary key, age int unique) WITH \"template=cache\"",
IgniteSQLException.class, "Too many constraints - only PRIMARY KEY is supported for CREATE TABLE");
[14/26] ignite git commit: IGNITE-6395: Remove old test. This closes
#2673.
Posted by sb...@apache.org.
IGNITE-6395: Remove old test. This closes #2673.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8bcd69dd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8bcd69dd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8bcd69dd
Branch: refs/heads/ignite-6149
Commit: 8bcd69dd4ef14f747b7d7c582b89b14fda961348
Parents: 4a88ec3
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Sep 15 17:25:26 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Sep 15 17:25:26 2017 +0300
----------------------------------------------------------------------
.../jdbc/thin/JdbcThinStatementSelfTest.java | 26 ++++----------------
1 file changed, 5 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bcd69dd/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
index 234a319..16f118c 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
@@ -44,7 +44,7 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
/**
* Statement test.
*/
-@SuppressWarnings("ThrowableNotThrown")
+@SuppressWarnings({"ThrowableNotThrown", "ThrowableResultOfMethodCallIgnored"})
public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest {
/** IP finder. */
private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
@@ -951,25 +951,6 @@ public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest {
/**
* @throws Exception If failed.
*/
- public void testCloseOnCompletion() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-5344");
-
- assert !stmt.isCloseOnCompletion() : "Default value of CloseOnCompletion is invalid";
-
- stmt.execute("select 1");
-
- stmt.closeOnCompletion();
-
- assert stmt.isCloseOnCompletion();
-
- stmt.getResultSet().close();
-
- assert stmt.isClosed() : "Must be closed on complete";
- }
-
- /**
- * @throws Exception If failed.
- */
public void testCancel() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-5439");
@@ -1048,7 +1029,10 @@ public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest {
ResultSet rs = stmt.executeQuery("select val from test where _key=1");
- assert rs.next();
+ boolean next = rs.next();
+
+ assert next;
+
assert rs.getInt(1) == 1 : "The data must not be updated. " +
"Because update statement is executed via 'executeQuery' method." +
" Data [val=" + rs.getInt(1) + ']';
[26/26] ignite git commit: ignite-6149
Posted by sb...@apache.org.
ignite-6149
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/62dbb11d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/62dbb11d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/62dbb11d
Branch: refs/heads/ignite-6149
Commit: 62dbb11d5d4f9cb2b23f6311f0dd124a5ade00e9
Parents: 9e21683
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 18 11:32:11 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 18 11:32:11 2017 +0300
----------------------------------------------------------------------
.../cache/mvcc/CacheCoordinatorsSharedManager.java | 17 +++++++++++++----
.../cache/mvcc/MvccCoordinatorVersionResponse.java | 14 +++++++-------
2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/62dbb11d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsSharedManager.java
index 0d3029a..b3cf54e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsSharedManager.java
@@ -462,7 +462,7 @@ public class CacheCoordinatorsSharedManager<K, V> extends GridCacheSharedManager
* @param txId Transaction ID.
* @return Counter.
*/
- private MvccCoordinatorVersionResponse assignTxCounter(GridCacheVersion txId, long futId) {
+ private synchronized MvccCoordinatorVersionResponse assignTxCounter(GridCacheVersion txId, long futId) {
assert crdVer != 0;
long nextCtr = mvccCntr.incrementAndGet();
@@ -493,11 +493,20 @@ public class CacheCoordinatorsSharedManager<K, V> extends GridCacheSharedManager
* @param txId Transaction ID.
*/
private void onTxDone(GridCacheVersion txId) {
- Long cntr = activeTxs.remove(txId);
+ GridFutureAdapter fut; // TODO IGNITE-3478.
- assert cntr != null;
+ synchronized (this) {
+ Long cntr = activeTxs.remove(txId);
+
+ assert cntr != null;
+
+ committedCntr.setIfGreater(cntr);
- committedCntr.setIfGreater(cntr);
+ fut = waitTxFuts.remove(cntr);
+ }
+
+ if (fut != null)
+ fut.onDone();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/62dbb11d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
index 3ec6c90..9d61a6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
@@ -26,7 +26,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
/**
- *
+ * TODO IGNITE-3478: make sure writeTo/readFrom for txs is optimal.
*/
public class MvccCoordinatorVersionResponse implements MvccCoordinatorMessage, MvccCoordinatorVersion, MvccLongList {
/** */
@@ -78,18 +78,18 @@ public class MvccCoordinatorVersionResponse implements MvccCoordinatorMessage, M
txs[txsCnt++] = txId;
}
- @Override
- public int size() {
+ /** {@inheritDoc} */
+ @Override public int size() {
return txsCnt;
}
- @Override
- public long get(int i) {
+ /** {@inheritDoc} */
+ @Override public long get(int i) {
return txs[i];
}
- @Override
- public boolean contains(long val) {
+ /** {@inheritDoc} */
+ @Override public boolean contains(long val) {
for (int i = 0; i < txsCnt; i++) {
if (txs[i] == val)
return true;
[08/26] ignite git commit: IGNITE-6368: Initial .NET part of thin
client. This closes #2670.
Posted by sb...@apache.org.
IGNITE-6368: Initial .NET part of thin client. This closes #2670.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a00052e9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a00052e9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a00052e9
Branch: refs/heads/ignite-6149
Commit: a00052e94531528c5df0dc4485d8882514b40af4
Parents: 8741acc
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Sep 15 14:05:53 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Sep 15 14:05:53 2017 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 6 +
.../Binary/BinaryFooterTest.cs | 2 +-
.../Client/CacheTest.cs | 201 ++++++++++++++
.../Client/CacheTestNoMeta.cs | 159 +++++++++++
.../Client/ClientConnectionTest.cs | 146 ++++++++++
.../Client/IgniteClientConfigurationTest.cs | 42 +++
.../Apache.Ignite.Core.Tests/Client/Person.cs | 48 ++++
.../Client/RawSocketTest.cs | 164 ++++++++++++
.../IgniteConfigurationTest.cs | 2 +
.../Apache.Ignite.Core.csproj | 9 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 9 +-
.../Client/Cache/ICacheClient.cs | 59 +++++
.../Apache.Ignite.Core/Client/IIgniteClient.cs | 44 ++++
.../Client/IgniteClientConfiguration.cs | 104 ++++++++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 4 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 17 ++
.../Impl/Binary/BinaryProcessorClient.cs | 113 ++++++++
.../Impl/Binary/BinaryUtils.cs | 16 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 4 +-
.../Impl/Client/Cache/CacheClient.cs | 160 +++++++++++
.../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 32 +++
.../Impl/Client/ClientProtocolVersion.cs | 119 +++++++++
.../Impl/Client/ClientSocket.cs | 263 +++++++++++++++++++
.../Impl/Client/IgniteClient.cs | 152 +++++++++++
.../Impl/Cluster/ClusterGroupImpl.cs | 2 +-
.../Impl/Compute/ComputeJobHolder.cs | 2 +-
.../Impl/Deployment/PeerAssemblyResolver.cs | 4 +-
.../Impl/Deployment/PeerLoadingObjectHolder.cs | 2 +-
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 7 +-
.../Apache.Ignite.Core/Impl/IIgniteInternal.cs | 13 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 10 +-
31 files changed, 1891 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 3f5f9b3..31e95fb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -92,6 +92,12 @@
<Compile Include="Cache\Query\Linq\CacheLinqTest.Contains.cs" />
<Compile Include="Cache\Store\CacheStoreSessionTestCodeConfig.cs" />
<Compile Include="Cache\Store\CacheStoreSessionTestSharedFactory.cs" />
+ <Compile Include="Client\CacheTestNoMeta.cs" />
+ <Compile Include="Client\Person.cs" />
+ <Compile Include="Client\RawSocketTest.cs" />
+ <Compile Include="Client\CacheTest.cs" />
+ <Compile Include="Client\ClientConnectionTest.cs" />
+ <Compile Include="Client\IgniteClientConfigurationTest.cs" />
<Compile Include="Deployment\CacheGetFunc.cs" />
<Compile Include="Deployment\GetAddressFunc.cs" />
<Compile Include="Deployment\PeerAssemblyLoadingAllApisTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs
index 5088e5a..9fa4538 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryFooterTest.cs
@@ -137,7 +137,7 @@ namespace Apache.Ignite.Core.Tests.Binary
return;
}
- var cache = ignite.GetOrCreateCache<int, OffsetTest>(
+ var cache = ignite.GetIgnite().GetOrCreateCache<int, OffsetTest>(
new CacheConfiguration("offs", new QueryEntity(typeof(int), typeof(OffsetTest))));
// Cache operation.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
new file mode 100644
index 0000000..2831e57
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Threading;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Client;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Thin client cache test.
+ /// </summary>
+ public sealed class CacheTest
+ {
+ /** Cache name. */
+ private const string CacheName = "cache";
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Ignition.Start(TestUtils.GetTestConfiguration());
+ }
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the cache put / get with primitive data types.
+ /// </summary>
+ [Test]
+ public void TestPutGetPrimitives()
+ {
+ using (var client = GetClient())
+ {
+ GetCache<string>().Put(1, "foo");
+
+ var clientCache = client.GetCache<int?, string>(CacheName);
+
+ clientCache.Put(2, "bar");
+ clientCache[3] = "baz";
+
+ // Existing key.
+ Assert.AreEqual("foo", clientCache.Get(1));
+ Assert.AreEqual("foo", clientCache[1]);
+ Assert.AreEqual("bar", clientCache[2]);
+ Assert.AreEqual("baz", clientCache[3]);
+
+ // Missing key.
+ Assert.Throws<KeyNotFoundException>(() => clientCache.Get(-1));
+
+ // Null key.
+ Assert.Throws<ArgumentNullException>(() => clientCache.Get(null));
+ }
+ }
+
+ /// <summary>
+ /// Tests the cache put / get with user data types.
+ /// </summary>
+ [Test]
+ public void TestPutGetUserObjects([Values(true, false)] bool compactFooter)
+ {
+ var cfg = GetClientConfiguration();
+
+ cfg.BinaryConfiguration = new BinaryConfiguration
+ {
+ CompactFooter = compactFooter
+ };
+
+ using (var client = Ignition.StartClient(cfg))
+ {
+ var person = new Person {Id = 100, Name = "foo"};
+ var person2 = new Person2 {Id = 200, Name = "bar"};
+
+ var serverCache = GetCache<Person>();
+ var clientCache = client.GetCache<int?, Person>(CacheName);
+
+ Assert.AreEqual(CacheName, clientCache.Name);
+
+ // Put through server cache.
+ serverCache.Put(1, person);
+
+ // Put through client cache.
+ clientCache.Put(2, person2);
+ clientCache[3] = person2;
+
+ // Read from client cache.
+ Assert.AreEqual("foo", clientCache.Get(1).Name);
+ Assert.AreEqual(100, clientCache[1].Id);
+ Assert.AreEqual(200, clientCache[2].Id);
+ Assert.AreEqual(200, clientCache[3].Id);
+
+ // Read from server cache.
+ Assert.AreEqual("foo", serverCache.Get(1).Name);
+ Assert.AreEqual(100, serverCache[1].Id);
+ Assert.AreEqual(200, serverCache[2].Id);
+ Assert.AreEqual(200, serverCache[3].Id);
+
+ // Null key or value.
+ Assert.Throws<ArgumentNullException>(() => clientCache.Put(10, null));
+ Assert.Throws<ArgumentNullException>(() => clientCache.Put(null, person));
+ }
+ }
+
+ /// <summary>
+ /// Tests client get in multiple threads with a single client.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestGetMultithreadedSingleClient()
+ {
+ GetCache<string>().Put(1, "foo");
+
+ using (var client = GetClient())
+ {
+ var clientCache = client.GetCache<int, string>(CacheName);
+
+ TestUtils.RunMultiThreaded(() => Assert.AreEqual("foo", clientCache.Get(1)),
+ Environment.ProcessorCount, 5);
+ }
+ }
+
+ /// <summary>
+ /// Tests client get in multiple threads with multiple clients.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestGetMultithreadedMultiClient()
+ {
+ GetCache<string>().Put(1, "foo");
+
+ // One client per thread.
+ var clients = new ConcurrentDictionary<int, IIgniteClient>();
+
+ TestUtils.RunMultiThreaded(() =>
+ {
+ var client = clients.GetOrAdd(Thread.CurrentThread.ManagedThreadId, _ => GetClient());
+
+ var clientCache = client.GetCache<int, string>(CacheName);
+
+ Assert.AreEqual("foo", clientCache.Get(1));
+ },
+ Environment.ProcessorCount, 5);
+
+ clients.ToList().ForEach(x => x.Value.Dispose());
+ }
+
+ /// <summary>
+ /// Gets the cache.
+ /// </summary>
+ private static ICache<int, T> GetCache<T>()
+ {
+ return Ignition.GetIgnite().GetOrCreateCache<int, T>(CacheName);
+ }
+
+ /// <summary>
+ /// Gets the client.
+ /// </summary>
+ private static IIgniteClient GetClient()
+ {
+ return Ignition.StartClient(GetClientConfiguration());
+ }
+
+ /// <summary>
+ /// Gets the client configuration.
+ /// </summary>
+ private static IgniteClientConfiguration GetClientConfiguration()
+ {
+ return new IgniteClientConfiguration {Host = "127.0.0.1"};
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTestNoMeta.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTestNoMeta.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTestNoMeta.cs
new file mode 100644
index 0000000..a011583
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTestNoMeta.cs
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Client;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.Metadata;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Client cache test without metadata (no-op binary processor).
+ /// </summary>
+ public class CacheTestNoMeta
+ {
+ /** Cache name. */
+ private const string CacheName = "cache";
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Ignition.Start(TestUtils.GetTestConfiguration());
+ }
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the cache put / get with user data types.
+ /// </summary>
+ [Test]
+ public void TestPutGetUserObjects()
+ {
+ var cfg = new IgniteClientConfiguration
+ {
+ BinaryProcessor = new NoopBinaryProcessor(),
+ BinaryConfiguration = new BinaryConfiguration
+ {
+ CompactFooter = false
+ },
+ Host = IPAddress.Loopback.ToString()
+ };
+
+ using (var client = Ignition.StartClient(cfg))
+ {
+ var serverCache = Ignition.GetIgnite().GetOrCreateCache<int?, Person>(
+ new CacheConfiguration(CacheName, new QueryEntity
+ {
+ KeyType = typeof(int),
+ ValueType = typeof(Person),
+ Fields = new[]
+ {
+ new QueryField("id", typeof(int)),
+ new QueryField("name", typeof(string))
+ }
+ }));
+
+ var clientCache = client.GetCache<int?, Person>(CacheName);
+
+ // Put through client cache.
+ clientCache.Put(1, new Person { Id = 100, Name = "foo" });
+ clientCache[2] = new Person { Id = 200, Name = "bar" };
+
+ // Read from client cache.
+ Assert.AreEqual("foo", clientCache.Get(1).Name);
+ Assert.AreEqual(100, clientCache[1].Id);
+ Assert.AreEqual(200, clientCache[2].Id);
+
+ // Read from server cache.
+ Assert.AreEqual("foo", serverCache.Get(1).Name);
+ Assert.AreEqual(100, serverCache[1].Id);
+ Assert.AreEqual(200, serverCache[2].Id);
+
+ // SQL from server cache.
+ var sqlRes = serverCache.Query(new SqlQuery(typeof(Person), "where id = 100")).GetAll().Single();
+ Assert.AreEqual(1, sqlRes.Key);
+ Assert.AreEqual(100, sqlRes.Value.Id);
+ Assert.AreEqual("foo", sqlRes.Value.Name);
+ }
+ }
+
+ /// <summary>
+ /// No-op binary processor (does not send meta to cluster).
+ /// </summary>
+ private class NoopBinaryProcessor : IBinaryProcessor
+ {
+ /** <inheritdoc /> */
+ public BinaryType GetBinaryType(int typeId)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public List<IBinaryType> GetBinaryTypes()
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public int[] GetSchema(int typeId, int schemaId)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public void PutBinaryTypes(ICollection<BinaryType> types)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public bool RegisterType(int id, string typeName)
+ {
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public string GetTypeName(int id)
+ {
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
new file mode 100644
index 0000000..8874bb5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ using System;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Sockets;
+ using Apache.Ignite.Core.Client;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Configuration;
+ using Apache.Ignite.Core.Impl.Client;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests client connection: port ranges, version checks, etc.
+ /// </summary>
+ public class ClientConnectionTest
+ {
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests that missing server yields connection refused error.
+ /// </summary>
+ [Test]
+ public void TestNoServerConnectionRefused()
+ {
+ var ex = Assert.Throws<AggregateException>(() => StartClient());
+ var socketEx = ex.InnerExceptions.OfType<SocketException>().First();
+ Assert.AreEqual(SocketError.ConnectionRefused, socketEx.SocketErrorCode);
+ }
+
+ /// <summary>
+ /// Tests that multiple clients can connect to one server.
+ /// </summary>
+ [Test]
+ public void TestMultipleClients()
+ {
+ using (Ignition.Start(TestUtils.GetTestConfiguration()))
+ {
+ var client1 = StartClient();
+ var client2 = StartClient();
+ var client3 = StartClient();
+
+ client1.Dispose();
+ client2.Dispose();
+ client3.Dispose();
+ }
+ }
+
+ /// <summary>
+ /// Tests custom connector and client configuration.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestCustomConfig()
+ {
+ var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ SqlConnectorConfiguration = new SqlConnectorConfiguration
+ {
+ Host = "localhost",
+ Port = 2000,
+ PortRange = 1
+ }
+ };
+
+ var clientCfg = new IgniteClientConfiguration
+ {
+ Host = "localhost",
+ Port = 2000
+ };
+
+ using (Ignition.Start(servCfg))
+ using (Ignition.StartClient(clientCfg))
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Tests that default configuration throws.
+ /// </summary>
+ [Test]
+ public void TestDefaultConfigThrows()
+ {
+ Assert.Throws<ArgumentNullException>(() => Ignition.StartClient(new IgniteClientConfiguration()));
+ }
+
+ /// <summary>
+ /// Tests the incorrect protocol version error.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)]
+ public void TestIncorrectProtocolVersionError()
+ {
+ using (Ignition.Start(TestUtils.GetTestConfiguration()))
+ {
+ // ReSharper disable once ObjectCreationAsStatement
+ var ex = Assert.Throws<IgniteException>(() => new ClientSocket(GetClientConfiguration(),
+ new ClientProtocolVersion(-1, -1, -1)));
+
+ Assert.AreEqual("Client handhsake failed: 'Unsupported version.'. " +
+ "Client version: -1.-1.-1. Server version: 1.0.0", ex.Message);
+ }
+ }
+
+ /// <summary>
+ /// Starts the client.
+ /// </summary>
+ private static IIgniteClient StartClient()
+ {
+ return Ignition.StartClient(GetClientConfiguration());
+ }
+
+ /// <summary>
+ /// Gets the client configuration.
+ /// </summary>
+ private static IgniteClientConfiguration GetClientConfiguration()
+ {
+ return new IgniteClientConfiguration { Host = IPAddress.Loopback.ToString() };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
new file mode 100644
index 0000000..0734f42
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ using Apache.Ignite.Core.Client;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="IgniteClientConfiguration"/>.
+ /// </summary>
+ public class IgniteClientConfigurationTest
+ {
+ /// <summary>
+ /// Tests the defaults.
+ /// </summary>
+ [Test]
+ public void TestDefaults()
+ {
+ var cfg = new IgniteClientConfiguration();
+
+ Assert.AreEqual(IgniteClientConfiguration.DefaultPort, cfg.Port);
+ Assert.AreEqual(IgniteClientConfiguration.DefaultSocketBufferSize, cfg.SocketReceiveBufferSize);
+ Assert.AreEqual(IgniteClientConfiguration.DefaultSocketBufferSize, cfg.SocketSendBufferSize);
+ Assert.AreEqual(IgniteClientConfiguration.DefaultTcpNoDelay, cfg.TcpNoDelay);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Person.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Person.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Person.cs
new file mode 100644
index 0000000..7f0309f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Person.cs
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ public class Person
+ {
+ /// <summary>
+ /// Gets or sets the identifier.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the parent.
+ /// </summary>
+ public Person Parent { get;set; }
+ }
+
+ /// <summary>
+ /// Test person 2.
+ /// </summary>
+ public class Person2 : Person
+ {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
new file mode 100644
index 0000000..9e2200f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
@@ -0,0 +1,164 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client
+{
+ using System;
+ using System.Net;
+ using System.Net.Sockets;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Configuration;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests the thin client mode with a raw socket.
+ /// </summary>
+ public class RawSocketTest
+ {
+ /// <summary>
+ /// Tests the socket handshake connection.
+ /// </summary>
+ [Test]
+ public void TestCacheGet()
+ {
+ var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ SqlConnectorConfiguration = new SqlConnectorConfiguration()
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var marsh = ((Ignite) ignite).Marshaller;
+
+ // Create cache.
+ var cacheCfg = new CacheConfiguration("foo", new QueryEntity(typeof(int), typeof(string)));
+ var cache = ignite.CreateCache<int, string>(cacheCfg);
+ cache[1] = "bar";
+
+ // Connect socket.
+ var sock = GetSocket(SqlConnectorConfiguration.DefaultPort);
+ Assert.IsTrue(sock.Connected);
+
+ DoHandshake(sock);
+
+ // Cache get.
+ SendRequest(sock, stream =>
+ {
+ stream.WriteShort(1); // OP_GET
+ stream.WriteLong(1); // Request id.
+ var cacheId = BinaryUtils.GetStringHashCode(cache.Name);
+ stream.WriteInt(cacheId);
+ stream.WriteByte(0); // Flags (withSkipStore, etc)
+
+ var writer = marsh.StartMarshal(stream);
+
+ writer.WriteObject(1); // Key
+ });
+
+ var msg = ReceiveMessage(sock);
+
+ using (var stream = new BinaryHeapStream(msg))
+ {
+ var reader = marsh.StartUnmarshal(stream);
+
+ var requestId = reader.ReadLong();
+ Assert.AreEqual(1, requestId);
+
+ var res = reader.ReadObject<string>();
+ Assert.AreEqual(cache[1], res);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Does the handshake.
+ /// </summary>
+ /// <param name="sock">The sock.</param>
+ private static void DoHandshake(Socket sock)
+ {
+ var sentBytes = SendRequest(sock, stream =>
+ {
+ // Handshake.
+ stream.WriteByte(1);
+
+ // Protocol version.
+ stream.WriteShort(1);
+ stream.WriteShort(0);
+ stream.WriteShort(0);
+
+ // Client type: platform.
+ stream.WriteByte(2);
+ });
+
+ Assert.AreEqual(12, sentBytes);
+
+ // ACK.
+ var ack = ReceiveMessage(sock);
+
+ Assert.AreEqual(1, ack.Length);
+ Assert.AreEqual(1, ack[0]);
+ }
+
+ /// <summary>
+ /// Receives the message.
+ /// </summary>
+ private static byte[] ReceiveMessage(Socket sock)
+ {
+ var buf = new byte[4];
+ sock.Receive(buf);
+
+ using (var stream = new BinaryHeapStream(buf))
+ {
+ var size = stream.ReadInt();
+ buf = new byte[size];
+ sock.Receive(buf);
+ return buf;
+ }
+ }
+
+ /// <summary>
+ /// Sends the request.
+ /// </summary>
+ private static int SendRequest(Socket sock, Action<BinaryHeapStream> writeAction)
+ {
+ using (var stream = new BinaryHeapStream(128))
+ {
+ stream.WriteInt(0); // Reserve message size.
+
+ writeAction(stream);
+
+ stream.WriteInt(0, stream.Position - 4); // Write message size.
+
+ return sock.Send(stream.GetArray(), stream.Position, SocketFlags.None);
+ }
+ }
+
+ /// <summary>
+ /// Gets the socket.
+ /// </summary>
+ private static Socket GetSocket(int port)
+ {
+ var endPoint = new IPEndPoint(IPAddress.Loopback, port);
+ var sock = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
+ sock.Connect(endPoint);
+ return sock;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 93d6af3..950f36d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Core.Tests
using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Eviction;
+ using Apache.Ignite.Core.Client;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Communication.Tcp;
using Apache.Ignite.Core.Configuration;
@@ -87,6 +88,7 @@ namespace Apache.Ignite.Core.Tests
CheckDefaultValueAttributes(new MemoryPolicyConfiguration());
CheckDefaultValueAttributes(new SqlConnectorConfiguration());
CheckDefaultValueAttributes(new PersistentStoreConfiguration());
+ CheckDefaultValueAttributes(new IgniteClientConfiguration());
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 65b8372..615ce90 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -97,12 +97,21 @@
<Compile Include="Cache\Configuration\MemoryPolicyConfiguration.cs" />
<Compile Include="Cache\Configuration\PartitionLossPolicy.cs" />
<Compile Include="Cache\IMemoryMetrics.cs" />
+ <Compile Include="Client\Cache\ICacheClient.cs" />
+ <Compile Include="Client\IgniteClientConfiguration.cs" />
+ <Compile Include="Client\IIgniteClient.cs" />
<Compile Include="Common\ExceptionFactory.cs" />
<Compile Include="Configuration\Package-Info.cs" />
<Compile Include="Impl\Binary\BinaryTypeId.cs" />
<Compile Include="Impl\Cache\Query\PlatformQueryQursorBase.cs" />
+ <Compile Include="Impl\Binary\BinaryProcessorClient.cs" />
<Compile Include="Impl\Binary\IBinaryProcessor.cs" />
<Compile Include="Impl\IIgniteInternal.cs" />
+ <Compile Include="Impl\Client\Cache\CacheClient.cs" />
+ <Compile Include="Impl\Client\ClientOp.cs" />
+ <Compile Include="Impl\Client\ClientProtocolVersion.cs" />
+ <Compile Include="Impl\Client\ClientSocket.cs" />
+ <Compile Include="Impl\Client\IgniteClient.cs" />
<Compile Include="Impl\IPlatformTargetInternal.cs" />
<Compile Include="Impl\PersistentStore\PersistentStoreMetrics.cs" />
<Compile Include="Impl\PlatformDisposableTargetAdapter.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 8c7fcf9..f83f279 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -251,32 +251,33 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="key">Key.</param>
/// <returns>Cache value with the specified key.</returns>
+ /// <exception cref="KeyNotFoundException">If the key is not present in the cache.</exception>
TV this[TK key] { get; set; }
/// <summary>
- /// Retrieves value mapped to the specified key from cache. Throws an exception if t
+ /// Retrieves value mapped to the specified key from cache.
///
/// If the value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disable, and if read-through is allowed, value
/// will be loaded from persistent store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
- /// If key is not present in cache, KeyNotFoundException will be thrown.
/// </summary>
/// <param name="key">Key.</param>
/// <returns>Value.</returns>
+ /// <exception cref="KeyNotFoundException">If the key is not present in the cache.</exception>
TV Get(TK key);
/// <summary>
- /// Retrieves value mapped to the specified key from cache. Throws an exception if t
+ /// Retrieves value mapped to the specified key from cache.
///
/// If the value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disable, and if read-through is allowed, value
/// will be loaded from persistent store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
- /// If key is not present in cache, KeyNotFoundException will be thrown.
/// </summary>
/// <param name="key">Key.</param>
/// <returns>Value.</returns>
+ /// <exception cref="KeyNotFoundException">If the key is not present in the cache.</exception>
Task<TV> GetAsync(TK key);
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
new file mode 100644
index 0000000..b4cd3c5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Client.Cache
+{
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Client cache API. See <see cref="IIgniteClient.GetCache{K, V}"/>.
+ /// </summary>
+ public interface ICacheClient<TK, TV>
+ {
+ /// <summary>
+ /// Name of this cache (<c>null</c> for default cache).
+ /// </summary>
+ string Name { get; }
+
+ /// <summary>
+ /// Associates the specified value with the specified key in the cache.
+ /// <para />
+ /// If the cache previously contained a mapping for the key,
+ /// the old value is replaced by the specified value.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is to be associated.</param>
+ /// <param name="val">Value to be associated with the specified key.</param>
+ void Put(TK key, TV val);
+
+ /// <summary>
+ /// Retrieves value mapped to the specified key from cache.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>Value.</returns>
+ /// <exception cref="KeyNotFoundException">If the key is not present in the cache.</exception>
+ TV Get(TK key);
+
+ /// <summary>
+ /// Gets or sets a cache value with the specified key.
+ /// Shortcut to <see cref="Get"/> and <see cref="Put"/>
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>Cache value with the specified key.</returns>
+ /// <exception cref="KeyNotFoundException">If the key is not present in the cache.</exception>
+ TV this[TK key] { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
new file mode 100644
index 0000000..ceb8f26
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Client
+{
+ using System;
+ using Apache.Ignite.Core.Client.Cache;
+
+ /// <summary>
+ /// Main entry point for Ignite Thin Client APIs.
+ /// You can obtain an instance of <see cref="IIgniteClient"/> through <see cref="Ignition.StartClient"/>.
+ /// </summary>
+ public interface IIgniteClient : IDisposable
+ {
+ /// <summary>
+ /// Gets the cache instance for the given name to work with keys and values of specified types.
+ /// <para/>
+ /// You can get instances of <see cref="ICacheClient{TK,TV}"/> of the same name,
+ /// but with different key/value types.
+ /// These will use the same named cache, but only allow working with entries of specified types.
+ /// Attempt to retrieve an entry of incompatible type will result in <see cref="InvalidCastException"/>.
+ /// Use <see cref="GetCache{TK,TV}"/> in order to work with entries of arbitrary types.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <returns>Cache instance for given name.</returns>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ ICacheClient<TK, TV> GetCache<TK, TV>(string name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientConfiguration.cs
new file mode 100644
index 0000000..3339c65
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientConfiguration.cs
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Client
+{
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Ignite thin client configuration.
+ /// <para />
+ /// Ignite thin client connects to a specific Ignite node with a socket and does not start JVM in process.
+ /// This configuration should correspond to <see cref="IgniteConfiguration.SqlConnectorConfiguration"/>
+ /// on a target node.
+ /// </summary>
+ public class IgniteClientConfiguration
+ {
+ /// <summary>
+ /// Default port.
+ /// </summary>
+ public const int DefaultPort = 10800;
+
+ /// <summary>
+ /// Default socket buffer size.
+ /// </summary>
+ public const int DefaultSocketBufferSize = 0;
+
+ /// <summary>
+ /// Default value of <see cref="TcpNoDelay" /> property.
+ /// </summary>
+ public const bool DefaultTcpNoDelay = true;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteClientConfiguration"/> class.
+ /// </summary>
+ public IgniteClientConfiguration()
+ {
+ Port = DefaultPort;
+ SocketSendBufferSize = DefaultSocketBufferSize;
+ SocketReceiveBufferSize = DefaultSocketBufferSize;
+ TcpNoDelay = DefaultTcpNoDelay;
+ }
+
+ /// <summary>
+ /// Gets or sets the host. Should not be null.
+ /// </summary>
+ public string Host { get; set; }
+
+ /// <summary>
+ /// Gets or sets the port.
+ /// </summary>
+ [DefaultValue(DefaultPort)]
+ public int Port { get; set; }
+
+ /// <summary>
+ /// Gets or sets the size of the socket send buffer. When set to 0, operating system default is used.
+ /// </summary>
+ [DefaultValue(DefaultSocketBufferSize)]
+ public int SocketSendBufferSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the size of the socket receive buffer. When set to 0, operating system default is used.
+ /// </summary>
+ [DefaultValue(DefaultSocketBufferSize)]
+ public int SocketReceiveBufferSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the value for <c>TCP_NODELAY</c> socket option. Each
+ /// socket will be opened using provided value.
+ /// <para />
+ /// Setting this option to <c>true</c> disables Nagle's algorithm
+ /// for socket decreasing latency and delivery time for small messages.
+ /// <para />
+ /// For systems that work under heavy network load it is advisable to set this value to <c>false</c>.
+ /// </summary>
+ [DefaultValue(DefaultTcpNoDelay)]
+ public bool TcpNoDelay { get; set; }
+
+ /// <summary>
+ /// Gets or sets the binary configuration.
+ /// </summary>
+ public BinaryConfiguration BinaryConfiguration { get; set; }
+
+ /// <summary>
+ /// Gets or sets custom binary processor. Internal property for tests.
+ /// </summary>
+ internal IBinaryProcessor BinaryProcessor { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index bf061db..9548aca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -39,9 +39,9 @@ namespace Apache.Ignite.Core
/// <summary>
/// Main entry point for all Ignite APIs.
- /// You can obtain an instance of <c>IGrid</c> through <see cref="Ignition.GetIgnite()"/>,
+ /// You can obtain an instance of <see cref="IIgnite"/> through <see cref="Ignition.GetIgnite()"/>,
/// or for named grids you can use <see cref="Ignition.GetIgnite(string)"/>. Note that you
- /// can have multiple instances of <c>IGrid</c> running in the same process by giving
+ /// can have multiple instances of <see cref="IIgnite"/> running in the same process by giving
/// each instance a different name.
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 568eea7..1bb6b3d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -28,11 +28,13 @@ namespace Apache.Ignite.Core
using System.Threading;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Client;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
using Apache.Ignite.Core.Impl.Cache.Affinity;
+ using Apache.Ignite.Core.Impl.Client;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Handle;
using Apache.Ignite.Core.Impl.Log;
@@ -730,6 +732,21 @@ namespace Apache.Ignite.Core
}
/// <summary>
+ /// Connects Ignite lightweight (thin) client to an Ignite node.
+ /// <para />
+ /// Thin client connects to an existing Ignite node with a socket and does not start JVM in process.
+ /// </summary>
+ /// <param name="clientConfiguration">The client configuration.</param>
+ /// <returns>Ignite instance.</returns>
+ public static IIgniteClient StartClient(IgniteClientConfiguration clientConfiguration)
+ {
+ IgniteArgumentCheck.NotNull(clientConfiguration, "clientConfiguration");
+ IgniteArgumentCheck.NotNull(clientConfiguration.Host, "clientConfiguration.Host");
+
+ return new IgniteClient(clientConfiguration);
+ }
+
+ /// <summary>
/// Handles the DomainUnload event of the CurrentDomain control.
/// </summary>
/// <param name="sender">The source of the event.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
new file mode 100644
index 0000000..26a8e9b
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary.Metadata;
+ using Apache.Ignite.Core.Impl.Client;
+
+ /// <summary>
+ /// Thin client binary processor.
+ /// </summary>
+ internal class BinaryProcessorClient : IBinaryProcessor
+ {
+ /** Type registry platform id. See org.apache.ignite.internal.MarshallerPlatformIds in Java. */
+ private const byte DotNetPlatformId = 1;
+
+ /** Socket. */
+ private readonly ClientSocket _socket;
+
+ /** Marshaller. */
+ private readonly Marshaller _marsh = BinaryUtils.Marshaller;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinaryProcessorClient"/> class.
+ /// </summary>
+ /// <param name="socket">The socket.</param>
+ public BinaryProcessorClient(ClientSocket socket)
+ {
+ Debug.Assert(socket != null);
+
+ _socket = socket;
+ }
+
+ /** <inheritdoc /> */
+ public BinaryType GetBinaryType(int typeId)
+ {
+ return _socket.DoOutInOp(ClientOp.BinaryTypeGet, s => s.WriteInt(typeId),
+ s => new BinaryType(_marsh.StartUnmarshal(s), true));
+ }
+
+ /** <inheritdoc /> */
+ public List<IBinaryType> GetBinaryTypes()
+ {
+ throw new NotImplementedException();
+ }
+
+ /** <inheritdoc /> */
+ public int[] GetSchema(int typeId, int schemaId)
+ {
+ return GetBinaryType(typeId).Schema.Get(schemaId);
+ }
+
+ /** <inheritdoc /> */
+ public void PutBinaryTypes(ICollection<BinaryType> types)
+ {
+ Debug.Assert(types != null);
+
+ foreach (var binaryType in types)
+ {
+ var type = binaryType; // Access to modified closure.
+
+ _socket.DoOutInOp<object>(ClientOp.BinaryTypePut,
+ s => BinaryProcessor.WriteBinaryType(_marsh.StartMarshal(s), type), null);
+ }
+ }
+
+ /** <inheritdoc /> */
+ public bool RegisterType(int id, string typeName)
+ {
+ return _socket.DoOutInOp(ClientOp.BinaryTypeNamePut, s =>
+ {
+ s.WriteByte(DotNetPlatformId);
+ s.WriteInt(id);
+ _marsh.StartMarshal(s).WriteString(typeName);
+ }, s => s.ReadBool());
+ }
+
+ /** <inheritdoc /> */
+ public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values)
+ {
+ throw new NotImplementedException();
+ }
+
+ /** <inheritdoc /> */
+ public string GetTypeName(int id)
+ {
+ return _socket.DoOutInOp(ClientOp.BinaryTypeNameGet, s =>
+ {
+ s.WriteByte(DotNetPlatformId);
+ s.WriteInt(id);
+ },
+ s => _marsh.StartUnmarshal(s).ReadString());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 1146f35..46e6752 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -1330,11 +1330,9 @@ namespace Apache.Ignite.Core.Impl.Binary
return res;
}
- /**
- * <summary>Get string hash code.</summary>
- * <param name="val">Value.</param>
- * <returns>Hash code.</returns>
- */
+ /// <summary>
+ /// Gets the string hash code using Java algorithm.
+ /// </summary>
public static int GetStringHashCode(string val)
{
if (val == null)
@@ -1353,6 +1351,14 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
+ /// Gets the cache identifier.
+ /// </summary>
+ public static int GetCacheId(string cacheName)
+ {
+ return string.IsNullOrEmpty(cacheName) ? 1 : GetStringHashCode(cacheName);
+ }
+
+ /// <summary>
/// Cleans the name of the field.
/// </summary>
public static string CleanFieldName(string fieldName)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 921b5e0..9d45f50 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -84,7 +84,7 @@ namespace Apache.Ignite.Core.Impl.Cache
_flagPartitionRecover = flagPartitionRecover;
_txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
- ? new CacheTransactionManager(_ignite.GetTransactions())
+ ? new CacheTransactionManager(_ignite.GetIgnite().GetTransactions())
: null;
_readException = stream => ReadException(Marshaller.StartUnmarshal(stream));
@@ -93,7 +93,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/** <inheritDoc /> */
public IIgnite Ignite
{
- get { return _ignite; }
+ get { return _ignite.GetIgnite(); }
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
new file mode 100644
index 0000000..affa815
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client.Cache
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.IO;
+ using Apache.Ignite.Core.Client;
+ using Apache.Ignite.Core.Client.Cache;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+ using Apache.Ignite.Core.Impl.Client;
+ using Apache.Ignite.Core.Impl.Common;
+ using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
+
+ /// <summary>
+ /// Client cache implementation.
+ /// </summary>
+ internal class CacheClient<TK, TV> : ICacheClient<TK, TV>
+ {
+ /** Cache name. */
+ private readonly string _name;
+
+ /** Cache id. */
+ private readonly int _id;
+
+ /** Ignite. */
+ private readonly IgniteClient _ignite;
+
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheClient{TK, TV}" /> class.
+ /// </summary>
+ /// <param name="ignite">Ignite.</param>
+ /// <param name="name">Cache name.</param>
+ public CacheClient(IgniteClient ignite, string name)
+ {
+ Debug.Assert(ignite != null);
+ Debug.Assert(name != null);
+
+ _name = name;
+ _ignite = ignite;
+ _marsh = _ignite.Marshaller;
+ _id = BinaryUtils.GetCacheId(name);
+ }
+
+ /** <inheritDoc /> */
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ /** <inheritDoc /> */
+ public IIgniteClient Ignite
+ {
+ get { return _ignite; }
+ }
+
+ /** <inheritDoc /> */
+ public TV this[TK key]
+ {
+ get { return Get(key); }
+ set { Put(key, value); }
+ }
+
+ /** <inheritDoc /> */
+ public TV Get(TK key)
+ {
+ IgniteArgumentCheck.NotNull(key, "key");
+
+ return DoOutInOp(ClientOp.CacheGet, w => w.WriteObject(key), UnmarshalNotNull<TV>);
+ }
+
+ /** <inheritDoc /> */
+ public void Put(TK key, TV val)
+ {
+ IgniteArgumentCheck.NotNull(key, "key");
+ IgniteArgumentCheck.NotNull(val, "val");
+
+ DoOutOp(ClientOp.CachePut, w =>
+ {
+ w.WriteObjectDetached(key);
+ w.WriteObjectDetached(val);
+ });
+ }
+
+ /// <summary>
+ /// Does the out in op.
+ /// </summary>
+ private T DoOutInOp<T>(ClientOp opId, Action<BinaryWriter> writeAction,
+ Func<IBinaryStream, T> readFunc)
+ {
+ return _ignite.Socket.DoOutInOp(opId, stream =>
+ {
+ stream.WriteInt(_id);
+ stream.WriteByte(0); // Flags (skipStore, etc).
+
+ if (writeAction != null)
+ {
+ var writer = _marsh.StartMarshal(stream);
+
+ writeAction(writer);
+
+ _marsh.FinishMarshal(writer);
+ }
+ }, readFunc);
+ }
+
+ /// <summary>
+ /// Does the out op.
+ /// </summary>
+ private void DoOutOp(ClientOp opId, Action<BinaryWriter> writeAction)
+ {
+ DoOutInOp<object>(opId, writeAction, null);
+ }
+
+ /// <summary>
+ /// Unmarshals the value, throwing an exception for nulls.
+ /// </summary>
+ private T UnmarshalNotNull<T>(IBinaryStream stream)
+ {
+ var hdr = stream.ReadByte();
+
+ if (hdr == BinaryUtils.HdrNull)
+ {
+ throw GetKeyNotFoundException();
+ }
+
+ stream.Seek(-1, SeekOrigin.Current);
+
+ return _marsh.Unmarshal<T>(stream);
+ }
+
+ /// <summary>
+ /// Gets the key not found exception.
+ /// </summary>
+ private static KeyNotFoundException GetKeyNotFoundException()
+ {
+ return new KeyNotFoundException("The given key was not present in the cache.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
new file mode 100644
index 0000000..79d7c9e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client
+{
+ /// <summary>
+ /// Client op code.
+ /// </summary>
+ internal enum ClientOp : short
+ {
+ CacheGet = 1,
+ BinaryTypeNameGet = 2,
+ BinaryTypeGet = 3,
+ CachePut = 4,
+ BinaryTypeNamePut = 5,
+ BinaryTypePut = 6
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientProtocolVersion.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientProtocolVersion.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientProtocolVersion.cs
new file mode 100644
index 0000000..bfdf5a3
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientProtocolVersion.cs
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client
+{
+ using System;
+
+ /// <summary>
+ /// Client protocol version.
+ /// </summary>
+ internal struct ClientProtocolVersion : IEquatable<ClientProtocolVersion>
+ {
+ /** */
+ private readonly short _major;
+
+ /** */
+ private readonly short _minor;
+
+ /** */
+ private readonly short _maintenance;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ClientProtocolVersion"/> struct.
+ /// </summary>
+ public ClientProtocolVersion(short major, short minor, short maintenance)
+ {
+ _major = major;
+ _minor = minor;
+ _maintenance = maintenance;
+ }
+
+ /// <summary>
+ /// Gets the major part.
+ /// </summary>
+ public short Major
+ {
+ get { return _major; }
+ }
+
+ /// <summary>
+ /// Gets the minor part.
+ /// </summary>
+ public short Minor
+ {
+ get { return _minor; }
+ }
+
+ /// <summary>
+ /// Gets the maintenance part.
+ /// </summary>
+ public short Maintenance
+ {
+ get { return _maintenance; }
+ }
+
+ /// <summary>
+ /// Returns a value indicating whether specified instance equals to current.
+ /// </summary>
+ public bool Equals(ClientProtocolVersion other)
+ {
+ return _major == other._major && _minor == other._minor && _maintenance == other._maintenance;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+
+ return obj is ClientProtocolVersion && Equals((ClientProtocolVersion) obj);
+ }
+
+ /** <inheritdoc /> */
+ public static bool operator ==(ClientProtocolVersion left, ClientProtocolVersion right)
+ {
+ return left.Equals(right);
+ }
+
+ /** <inheritdoc /> */
+ public static bool operator !=(ClientProtocolVersion left, ClientProtocolVersion right)
+ {
+ return !left.Equals(right);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hashCode = _major.GetHashCode();
+ hashCode = (hashCode * 397) ^ _minor.GetHashCode();
+ hashCode = (hashCode * 397) ^ _maintenance.GetHashCode();
+ return hashCode;
+ }
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return string.Format("{0}.{1}.{2}", Major, Minor, Maintenance);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
new file mode 100644
index 0000000..0204ef8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
@@ -0,0 +1,263 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Sockets;
+ using System.Threading;
+ using Apache.Ignite.Core.Client;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+
+ /// <summary>
+ /// Wrapper over framework socket for Ignite thin client operations.
+ /// </summary>
+ internal class ClientSocket : IDisposable
+ {
+ /** Current version. */
+ private static readonly ClientProtocolVersion CurrentProtocolVersion = new ClientProtocolVersion(1, 0, 0);
+
+ /** Handshake opcode. */
+ private const byte OpHandshake = 1;
+
+ /** Client type code. */
+ private const byte ClientType = 2;
+
+ /** Unerlying socket. */
+ private readonly Socket _socket;
+
+ /** */
+ private long _requestId;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ClientSocket" /> class.
+ /// </summary>
+ /// <param name="clientConfiguration">The client configuration.</param>
+ /// <param name="version">Protocol version.</param>
+ public ClientSocket(IgniteClientConfiguration clientConfiguration, ClientProtocolVersion? version = null)
+ {
+ Debug.Assert(clientConfiguration != null);
+
+ _socket = Connect(clientConfiguration);
+
+ Handshake(_socket, version ?? CurrentProtocolVersion);
+ }
+
+ /// <summary>
+ /// Performs a send-receive operation.
+ /// </summary>
+ public T DoOutInOp<T>(ClientOp opId, Action<IBinaryStream> writeAction,
+ Func<IBinaryStream, T> readFunc)
+ {
+ var requestId = Interlocked.Increment(ref _requestId);
+
+ var resBytes = SendReceive(_socket, stream =>
+ {
+ stream.WriteShort((short) opId);
+ stream.WriteLong(requestId);
+
+ if (writeAction != null)
+ {
+ writeAction(stream);
+ }
+ });
+
+ using (var stream = new BinaryHeapStream(resBytes))
+ {
+ var resRequestId = stream.ReadLong();
+ Debug.Assert(requestId == resRequestId);
+
+ if (readFunc != null)
+ {
+ return readFunc(stream);
+ }
+ }
+
+ return default(T);
+ }
+
+ /// <summary>
+ /// Performs client protocol handshake.
+ /// </summary>
+ private static void Handshake(Socket sock, ClientProtocolVersion version)
+ {
+ var res = SendReceive(sock, stream =>
+ {
+ // Handshake.
+ stream.WriteByte(OpHandshake);
+
+ // Protocol version.
+ stream.WriteShort(version.Major);
+ stream.WriteShort(version.Minor);
+ stream.WriteShort(version.Maintenance);
+
+ // Client type: platform.
+ stream.WriteByte(ClientType);
+ }, 20);
+
+ using (var stream = new BinaryHeapStream(res))
+ {
+ var success = stream.ReadBool();
+
+ if (success)
+ {
+ return;
+ }
+
+ var serverVersion =
+ new ClientProtocolVersion(stream.ReadShort(), stream.ReadShort(), stream.ReadShort());
+
+ var errMsg = BinaryUtils.Marshaller.Unmarshal<string>(stream);
+
+ throw new IgniteException(string.Format(
+ "Client handhsake failed: '{0}'. Client version: {1}. Server version: {2}",
+ errMsg, version, serverVersion));
+ }
+ }
+
+ /// <summary>
+ /// Sends the request and receives a response.
+ /// </summary>
+ private static byte[] SendReceive(Socket sock, Action<IBinaryStream> writeAction, int bufSize = 128)
+ {
+ int messageLen;
+ var buf = WriteMessage(writeAction, bufSize, out messageLen);
+
+ lock (sock)
+ {
+ var sent = sock.Send(buf, messageLen, SocketFlags.None);
+ Debug.Assert(sent == messageLen);
+
+ buf = new byte[4];
+ var received = sock.Receive(buf);
+ Debug.Assert(received == buf.Length);
+
+ using (var stream = new BinaryHeapStream(buf))
+ {
+ var size = stream.ReadInt();
+
+ buf = new byte[size];
+ received = sock.Receive(buf);
+ Debug.Assert(received == buf.Length);
+
+ return buf;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Writes the message to a byte array.
+ /// </summary>
+ private static byte[] WriteMessage(Action<IBinaryStream> writeAction, int bufSize, out int messageLen)
+ {
+ using (var stream = new BinaryHeapStream(bufSize))
+ {
+ stream.WriteInt(0); // Reserve message size.
+
+ writeAction(stream);
+
+ stream.WriteInt(0, stream.Position - 4); // Write message size.
+
+ messageLen = stream.Position;
+
+ return stream.GetArray();
+ }
+ }
+
+ /// <summary>
+ /// Connects the socket.
+ /// </summary>
+ private static Socket Connect(IgniteClientConfiguration cfg)
+ {
+ List<Exception> errors = null;
+
+ foreach (var ipEndPoint in GetEndPoints(cfg))
+ {
+ try
+ {
+ var socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
+ {
+ SendBufferSize = cfg.SocketSendBufferSize,
+ ReceiveBufferSize = cfg.SocketReceiveBufferSize,
+ NoDelay = cfg.TcpNoDelay
+ };
+
+ socket.Connect(ipEndPoint);
+
+ return socket;
+ }
+ catch (SocketException e)
+ {
+ if (errors == null)
+ {
+ errors = new List<Exception>();
+ }
+
+ errors.Add(e);
+ }
+ }
+
+ if (errors == null)
+ {
+ throw new IgniteException("Failed to resolve client host: " + cfg.Host);
+ }
+
+ throw new AggregateException("Failed to establish Ignite thin client connection, " +
+ "examine inner exceptions for details.", errors);
+ }
+
+ /// <summary>
+ /// Gets the endpoints: all combinations of IP addresses and ports according to configuration.
+ /// </summary>
+ private static IEnumerable<IPEndPoint> GetEndPoints(IgniteClientConfiguration cfg)
+ {
+ var host = cfg.Host;
+
+ if (host == null)
+ {
+ throw new IgniteException("IgniteClientConfiguration.Host cannot be null.");
+ }
+
+ // GetHostEntry accepts IPs, but TryParse is a more efficient shortcut.
+ IPAddress ip;
+
+ if (IPAddress.TryParse(host, out ip))
+ {
+ return new[] {new IPEndPoint(ip, cfg.Port)};
+ }
+
+ return Dns.GetHostEntry(host).AddressList.Select(x => new IPEndPoint(x, cfg.Port));
+ }
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
+ public void Dispose()
+ {
+ _socket.Dispose();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
new file mode 100644
index 0000000..29b8a2c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Client
+{
+ using System;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Client;
+ using Apache.Ignite.Core.Client.Cache;
+ using Apache.Ignite.Core.Datastream;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Client.Cache;
+ using Apache.Ignite.Core.Impl.Cluster;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Handle;
+ using Apache.Ignite.Core.Impl.Plugin;
+
+ /// <summary>
+ /// Thin client implementation
+ /// </summary>
+ internal class IgniteClient : IIgniteInternal, IIgniteClient
+ {
+ /** Socket. */
+ private readonly ClientSocket _socket;
+
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /** Binary processor. */
+ private readonly IBinaryProcessor _binProc;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteClient"/> class.
+ /// </summary>
+ /// <param name="clientConfiguration">The client configuration.</param>
+ public IgniteClient(IgniteClientConfiguration clientConfiguration)
+ {
+ Debug.Assert(clientConfiguration != null);
+
+ _socket = new ClientSocket(clientConfiguration);
+
+ _marsh = new Marshaller(clientConfiguration.BinaryConfiguration)
+ {
+ Ignite = this
+ };
+
+ _binProc = clientConfiguration.BinaryProcessor ?? new BinaryProcessorClient(_socket);
+ }
+
+ /// <summary>
+ /// Gets the socket.
+ /// </summary>
+ public ClientSocket Socket
+ {
+ get { return _socket; }
+ }
+
+ /** <inheritDoc /> */
+ [SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly",
+ Justification = "There is no finalizer.")]
+ public void Dispose()
+ {
+ _socket.Dispose();
+ }
+
+ /** <inheritDoc /> */
+ public ICacheClient<TK, TV> GetCache<TK, TV>(string name)
+ {
+ IgniteArgumentCheck.NotNull(name, "name");
+
+ return new CacheClient<TK, TV>(this, name);
+ }
+
+ /** <inheritDoc /> */
+ public IIgnite GetIgnite()
+ {
+ throw GetClientNotSupportedException();
+ }
+
+ /** <inheritDoc /> */
+ public IBinary GetBinary()
+ {
+ throw GetClientNotSupportedException();
+ }
+
+ /** <inheritDoc /> */
+ public IBinaryProcessor BinaryProcessor
+ {
+ get { return _binProc; }
+ }
+
+ /** <inheritDoc /> */
+ public IgniteConfiguration Configuration
+ {
+ get { throw GetClientNotSupportedException(); }
+ }
+
+ /** <inheritDoc /> */
+ public HandleRegistry HandleRegistry
+ {
+ get { throw GetClientNotSupportedException(); }
+ }
+
+ /** <inheritDoc /> */
+ public ClusterNodeImpl GetNode(Guid? id)
+ {
+ throw GetClientNotSupportedException();
+ }
+
+ /** <inheritDoc /> */
+ public Marshaller Marshaller
+ {
+ get { return _marsh; }
+ }
+
+ /** <inheritDoc /> */
+ public PluginProcessor PluginProcessor
+ {
+ get { throw GetClientNotSupportedException(); }
+ }
+
+ /** <inheritDoc /> */
+ public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName, bool keepBinary)
+ {
+ throw GetClientNotSupportedException();
+ }
+
+ /// <summary>
+ /// Gets the client not supported exception.
+ /// </summary>
+ private static NotSupportedException GetClientNotSupportedException()
+ {
+ return new NotSupportedException("Operation is not supported in thin client mode.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 6d6756f..b32d331 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -190,7 +190,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
/** <inheritDoc /> */
public IIgnite Ignite
{
- get { return _ignite; }
+ get { return _ignite.GetIgnite(); }
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
index 945f2ab..1489f59 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
@@ -86,7 +86,7 @@ namespace Apache.Ignite.Core.Impl.Compute
success ? null : new IgniteException("Compute job has failed on local node, " +
"examine InnerException for details.", (Exception) res),
_job,
- _ignite.GetCluster().GetLocalNode().Id,
+ _ignite.GetIgnite().GetCluster().GetLocalNode().Id,
cancel
);
}
[09/26] ignite git commit: .NET: Remove unused imports
Posted by sb...@apache.org.
.NET: Remove unused imports
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8936a0db
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8936a0db
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8936a0db
Branch: refs/heads/ignite-6149
Commit: 8936a0db52d1d290a482f9f0044908e3076dc899
Parents: a00052e
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Sep 15 14:17:30 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Sep 15 14:17:30 2017 +0300
----------------------------------------------------------------------
.../platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 1 -
.../platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs | 1 -
.../dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs | 2 --
.../Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs | 1 -
.../Plugin/TestIgnitePluginConfiguration.cs | 1 -
.../Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs | 2 --
.../examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs | 1 -
7 files changed, 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
index 40ae01e..2571c14 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Benchmarks
using System;
using System.Diagnostics;
using System.Text;
- using Apache.Ignite.Benchmarks.Binary;
using Apache.Ignite.Benchmarks.Interop;
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
index 2831e57..3b0daa1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/CacheTest.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Tests.Client
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
- using System.Net;
using System.Threading;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
index e60ad4a..e3f3d61 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -18,10 +18,8 @@
namespace Apache.Ignite.Core.Tests.Compute
{
using System;
- using System.Collections.Generic;
using System.Linq;
using System.Threading;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Tests.Process;
using NUnit.Framework;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
index 3482456..8e7a60f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
using NUnit.Framework;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/TestIgnitePluginConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/TestIgnitePluginConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/TestIgnitePluginConfiguration.cs
index 7eacfff..b2334c7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/TestIgnitePluginConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/TestIgnitePluginConfiguration.cs
@@ -19,7 +19,6 @@
{
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Plugin;
- using Apache.Ignite.Examples.Datagrid;
/// <summary>
/// Plugin configuration.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
index f7caa78..119504b 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
@@ -25,8 +25,6 @@ namespace Apache.Ignite.Examples.Datagrid
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Eviction;
- using Apache.Ignite.Core.Discovery.Tcp;
- using Apache.Ignite.Core.Discovery.Tcp.Static;
/// <summary>
/// This example demonstrates on how to configure a multi-tiered Ignite cache that will store data in different
http://git-wip-us.apache.org/repos/asf/ignite/blob/8936a0db/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
index c30d60a..466f2fe 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -18,7 +18,6 @@
namespace Apache.Ignite.Examples.Misc
{
using System;
- using System.Collections.Generic;
using Apache.Ignite.Core;
using Apache.Ignite.Core.Discovery.Tcp;
using Apache.Ignite.Core.Discovery.Tcp.Static;
[21/26] ignite git commit: IGNITE-6327: Added thin client
configuration. This closes #2672.
Posted by sb...@apache.org.
IGNITE-6327: Added thin client configuration. This closes #2672.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9fd82212
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9fd82212
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9fd82212
Branch: refs/heads/ignite-6149
Commit: 9fd82212e528a6287cf89d279416aefa92c0cad5
Parents: b861532
Author: devozerov <pp...@gmail.com>
Authored: Sat Sep 16 14:57:55 2017 +0300
Committer: devozerov <pp...@gmail.com>
Committed: Sat Sep 16 14:57:55 2017 +0300
----------------------------------------------------------------------
.../ClientConnectorConfiguration.java | 275 +++++++++++++++++
.../configuration/IgniteConfiguration.java | 37 ++-
.../ignite/configuration/OdbcConfiguration.java | 4 +-
.../SqlConnectorConfiguration.java | 7 +-
.../ignite/internal/GridKernalContext.java | 5 +-
.../ignite/internal/GridKernalContextImpl.java | 11 +-
.../apache/ignite/internal/IgniteKernal.java | 4 +-
.../internal/jdbc/thin/JdbcThinStatement.java | 4 +-
.../internal/jdbc/thin/JdbcThinTcpIo.java | 28 +-
.../internal/jdbc/thin/JdbcThinUtils.java | 4 +-
.../wal/reader/StandaloneGridKernalContext.java | 4 +-
.../odbc/ClientListenerBufferedParser.java | 81 +++++
.../odbc/ClientListenerConnectionContext.java | 62 ++++
.../odbc/ClientListenerMessageParser.java | 39 +++
.../odbc/ClientListenerNioListener.java | 245 +++++++++++++++
.../odbc/ClientListenerNioServerBuffer.java | 114 +++++++
.../odbc/ClientListenerProcessor.java | 308 +++++++++++++++++++
.../odbc/ClientListenerProtocolVersion.java | 116 +++++++
.../processors/odbc/ClientListenerRequest.java | 31 ++
.../odbc/ClientListenerRequestHandler.java | 48 +++
.../odbc/ClientListenerRequestNoId.java | 28 ++
.../processors/odbc/ClientListenerResponse.java | 76 +++++
.../odbc/SqlListenerBufferedParser.java | 81 -----
.../odbc/SqlListenerConnectionContext.java | 62 ----
.../odbc/SqlListenerMessageParser.java | 39 ---
.../processors/odbc/SqlListenerNioListener.java | 248 ---------------
.../odbc/SqlListenerNioServerBuffer.java | 114 -------
.../processors/odbc/SqlListenerProcessor.java | 278 -----------------
.../odbc/SqlListenerProtocolVersion.java | 116 -------
.../processors/odbc/SqlListenerRequest.java | 31 --
.../odbc/SqlListenerRequestHandler.java | 48 ---
.../processors/odbc/SqlListenerRequestNoId.java | 28 --
.../processors/odbc/SqlListenerResponse.java | 76 -----
.../odbc/jdbc/JdbcConnectionContext.java | 28 +-
.../processors/odbc/jdbc/JdbcMessageParser.java | 12 +-
.../processors/odbc/jdbc/JdbcRequest.java | 4 +-
.../odbc/jdbc/JdbcRequestHandler.java | 64 ++--
.../processors/odbc/jdbc/JdbcResponse.java | 4 +-
.../odbc/odbc/OdbcConnectionContext.java | 28 +-
.../processors/odbc/odbc/OdbcMessageParser.java | 16 +-
.../processors/odbc/odbc/OdbcRequest.java | 4 +-
.../odbc/odbc/OdbcRequestHandler.java | 46 +--
.../processors/odbc/odbc/OdbcResponse.java | 4 +-
.../client/ClientConnectionContext.java | 22 +-
.../platform/client/ClientMessageParser.java | 12 +-
.../platform/client/ClientRequest.java | 4 +-
.../platform/client/ClientRequestHandler.java | 12 +-
.../platform/client/ClientResponse.java | 4 +-
.../utils/PlatformConfigurationUtils.java | 4 +
.../distributed/IgniteCache150ClientsTest.java | 4 +-
.../OdbcConfigurationValidationSelfTest.java | 1 -
...onnectorConfigurationValidationSelfTest.java | 241 +++++++++++++++
...onnectorConfigurationValidationSelfTest.java | 3 +-
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../odbc-test/config/queries-test-default.xml | 4 +-
.../odbc-test/config/queries-test-noodbc-32.xml | 2 +-
.../odbc-test/config/queries-test-noodbc.xml | 2 +-
57 files changed, 1881 insertions(+), 1298 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
new file mode 100644
index 0000000..1c33a00
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
@@ -0,0 +1,275 @@
+/*
+ * 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.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Client connector configuration.
+ */
+public class ClientConnectorConfiguration {
+ /** Default port. */
+ public static final int DFLT_PORT = 10800;
+
+ /** Default port range. */
+ public static final int DFLT_PORT_RANGE = 100;
+
+ /** Default socket send and receive buffer size. */
+ public static final int DFLT_SOCK_BUF_SIZE = 0;
+
+ /** Default value for {@code TCP_NODELAY} socket option (value is <tt>true</tt>). */
+ public static final boolean DFLT_TCP_NO_DELAY = true;
+
+ /** Default max number of open cursors per connection. */
+ public static final int DFLT_MAX_OPEN_CURSORS_PER_CONN = 128;
+
+ /** Default size of thread pool. */
+ public static final int DFLT_THREAD_POOL_SIZE = IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT;
+
+ /** Host. */
+ private String host;
+
+ /** Port. */
+ private int port = DFLT_PORT;
+
+ /** Port range. */
+ private int portRange = DFLT_PORT_RANGE;
+
+ /** Socket send buffer size. */
+ private int sockSndBufSize = DFLT_SOCK_BUF_SIZE;
+
+ /** Socket receive buffer size. */
+ private int sockRcvBufSize = DFLT_SOCK_BUF_SIZE;
+
+ /** TCP no delay. */
+ private boolean tcpNoDelay = DFLT_TCP_NO_DELAY;
+
+ /** Max number of opened cursors per connection. */
+ private int maxOpenCursorsPerConn = DFLT_MAX_OPEN_CURSORS_PER_CONN;
+
+ /** Thread pool size. */
+ private int threadPoolSize = DFLT_THREAD_POOL_SIZE;
+
+ /**
+ * Creates SQL connector configuration with all default values.
+ */
+ public ClientConnectorConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Creates SQL connector configuration by copying all properties from given configuration.
+ *
+ * @param cfg Configuration to copy.
+ */
+ public ClientConnectorConfiguration(ClientConnectorConfiguration cfg) {
+ assert cfg != null;
+
+ host = cfg.getHost();
+ maxOpenCursorsPerConn = cfg.getMaxOpenCursorsPerConnection();
+ port = cfg.getPort();
+ portRange = cfg.getPortRange();
+ sockRcvBufSize = cfg.getSocketReceiveBufferSize();
+ sockSndBufSize = cfg.getSocketSendBufferSize();
+ tcpNoDelay = cfg.isTcpNoDelay();
+ threadPoolSize = cfg.getThreadPoolSize();
+ }
+
+ /**
+ * Get host.
+ *
+ * @return Host.
+ */
+ @Nullable public String getHost() {
+ return host;
+ }
+
+ /**
+ * Set host.
+ *
+ * @param host Host.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setHost(@Nullable String host) {
+ this.host = host;
+
+ return this;
+ }
+
+ /**
+ * Get port.
+ *
+ * @return Port.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Set port.
+ *
+ * @param port Port.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setPort(int port) {
+ this.port = port;
+
+ return this;
+ }
+
+ /**
+ * Get port range.
+ *
+ * @return Port range.
+ */
+ public int getPortRange() {
+ return portRange;
+ }
+
+ /**
+ * Set port range.
+ *
+ * @param portRange Port range.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setPortRange(int portRange) {
+ this.portRange = portRange;
+
+ return this;
+ }
+
+ /**
+ * Gets socket send buffer size. When set to zero, operation system default will be used.
+ * <p>
+ * Defaults to {@link #DFLT_SOCK_BUF_SIZE}
+ *
+ * @return Socket send buffer size in bytes.
+ */
+ public int getSocketSendBufferSize() {
+ return sockSndBufSize;
+ }
+
+ /**
+ * Sets socket send buffer size. See {@link #getSocketSendBufferSize()} for more information.
+ *
+ * @param sockSndBufSize Socket send buffer size in bytes.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setSocketSendBufferSize(int sockSndBufSize) {
+ this.sockSndBufSize = sockSndBufSize;
+
+ return this;
+ }
+
+ /**
+ * Gets socket receive buffer size. When set to zero, operation system default will be used.
+ * <p>
+ * Defaults to {@link #DFLT_SOCK_BUF_SIZE}.
+ *
+ * @return Socket receive buffer size in bytes.
+ */
+ public int getSocketReceiveBufferSize() {
+ return sockRcvBufSize;
+ }
+
+ /**
+ * Sets socket receive buffer size. See {@link #getSocketReceiveBufferSize()} for more information.
+ *
+ * @param sockRcvBufSize Socket receive buffer size in bytes.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setSocketReceiveBufferSize(int sockRcvBufSize) {
+ this.sockRcvBufSize = sockRcvBufSize;
+
+ return this;
+ }
+
+ /**
+ * Get TCP NO_DELAY flag.
+ *
+ * @return TCP NO_DELAY flag.
+ */
+ public boolean isTcpNoDelay() {
+ return tcpNoDelay;
+ }
+
+ /**
+ * Set TCP NO_DELAY flag.
+ *
+ * @param tcpNoDelay TCP NO_DELAY flag.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setTcpNoDelay(boolean tcpNoDelay) {
+ this.tcpNoDelay = tcpNoDelay;
+
+ return this;
+ }
+
+ /**
+ * Gets maximum number of opened cursors per connection.
+ * <p>
+ * Defaults to {@link #DFLT_MAX_OPEN_CURSORS_PER_CONN}.
+ *
+ * @return Maximum number of opened cursors.
+ */
+ public int getMaxOpenCursorsPerConnection() {
+ return maxOpenCursorsPerConn;
+ }
+
+ /**
+ * Sets maximum number of opened cursors per connection.
+ *
+ * @param maxOpenCursorsPerConn Maximum number of opened cursors.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setMaxOpenCursorsPerConnection(int maxOpenCursorsPerConn) {
+ this.maxOpenCursorsPerConn = maxOpenCursorsPerConn;
+
+ return this;
+ }
+
+ /**
+ * Size of thread pool that is in charge of processing SQL requests.
+ * <p>
+ * Defaults {@link #DFLT_THREAD_POOL_SIZE}.
+ *
+ * @return Thread pool that is in charge of processing SQL requests.
+ */
+ public int getThreadPoolSize() {
+ return threadPoolSize;
+ }
+
+ /**
+ * Sets thread pool that is in charge of processing SQL requests. See {@link #getThreadPoolSize()} for more
+ * information.
+ *
+ * @param threadPoolSize Thread pool that is in charge of processing SQL requests.
+ * @return This instance for chaining.
+ */
+ public ClientConnectorConfiguration setThreadPoolSize(int threadPoolSize) {
+ this.threadPoolSize = threadPoolSize;
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ClientConnectorConfiguration.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 1cc99da..b445205 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -74,6 +74,7 @@ import org.apache.ignite.spi.indexing.IndexingSpi;
import org.apache.ignite.spi.loadbalancing.LoadBalancingSpi;
import org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi;
import org.apache.ignite.ssl.SslContextFactory;
+import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.STOP;
@@ -467,7 +468,11 @@ public class IgniteConfiguration {
private long longQryWarnTimeout = DFLT_LONG_QRY_WARN_TIMEOUT;
/** SQL connector configuration. */
- private SqlConnectorConfiguration sqlConnCfg = new SqlConnectorConfiguration();
+ @Deprecated
+ private SqlConnectorConfiguration sqlConnCfg;
+
+ /** Client connector configuration. */
+ private ClientConnectorConfiguration cliConnCfg;
/**
* Creates valid grid configuration with all default values.
@@ -513,6 +518,7 @@ public class IgniteConfiguration {
classLdr = cfg.getClassLoader();
clientFailureDetectionTimeout = cfg.getClientFailureDetectionTimeout();
clientMode = cfg.isClientMode();
+ cliConnCfg = cfg.getClientConnectorConfiguration();
connectorCfg = cfg.getConnectorConfiguration();
consistentId = cfg.getConsistentId();
daemon = cfg.isDaemon();
@@ -2483,7 +2489,7 @@ public class IgniteConfiguration {
* Gets configuration for ODBC.
*
* @return ODBC configuration.
- * @deprecated Use {@link #getSqlConnectorConfiguration()} instead.
+ * @deprecated Use {@link #getClientConnectorConfiguration()} ()} instead.
*/
@Deprecated
public OdbcConfiguration getOdbcConfiguration() {
@@ -2495,7 +2501,7 @@ public class IgniteConfiguration {
*
* @param odbcCfg ODBC configuration.
* @return {@code this} for chaining.
- * @deprecated Use {@link #setSqlConnectorConfiguration(SqlConnectorConfiguration)} instead.
+ * @deprecated Use {@link #setClientConnectorConfiguration(ClientConnectorConfiguration)} instead.
*/
@Deprecated
public IgniteConfiguration setOdbcConfiguration(OdbcConfiguration odbcCfg) {
@@ -2796,7 +2802,9 @@ public class IgniteConfiguration {
*
* @param sqlConnCfg SQL connector configuration.
* @return {@code this} for chaining.
+ * @deprecated Use {@link #setClientConnectorConfiguration(ClientConnectorConfiguration)} instead.
*/
+ @Deprecated
public IgniteConfiguration setSqlConnectorConfiguration(SqlConnectorConfiguration sqlConnCfg) {
this.sqlConnCfg = sqlConnCfg;
@@ -2807,11 +2815,34 @@ public class IgniteConfiguration {
* Gets SQL connector configuration.
*
* @return SQL connector configuration.
+ * @deprecated Use {@link #getClientConnectorConfiguration()} instead.
*/
+ @Deprecated
public SqlConnectorConfiguration getSqlConnectorConfiguration() {
return sqlConnCfg;
}
+ /**
+ * Sets client connector configuration.
+ *
+ * @param cliConnCfg Client connector configuration.
+ * @return {@code this} for chaining.
+ */
+ public IgniteConfiguration setClientConnectorConfiguration(@Nullable ClientConnectorConfiguration cliConnCfg) {
+ this.cliConnCfg = cliConnCfg;
+
+ return this;
+ }
+
+ /**
+ * Gets client connector configuration.
+ *
+ * @return Client connector configuration.
+ */
+ @Nullable public ClientConnectorConfiguration getClientConnectorConfiguration() {
+ return cliConnCfg;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgniteConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
index 6d7ab38..4bc3a7f 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
@@ -22,8 +22,8 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC configuration.
* <p>
- * Deprecated as of Apache Ignite 2.1. Please use {@link SqlConnectorConfiguration} and
- * {@link IgniteConfiguration#setSqlConnectorConfiguration(SqlConnectorConfiguration)} instead.
+ * Deprecated as of Apache Ignite 2.1. Please use {@link ClientConnectorConfiguration} and
+ * {@link IgniteConfiguration#setClientConnectorConfiguration(ClientConnectorConfiguration)} instead.
*/
@Deprecated
public class OdbcConfiguration {
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
index 9921974..4233d44 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
@@ -21,8 +21,13 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
/**
- * SQL connector configuration.
+ * SQL connection configuration.
+ * <p>
+ * Deprecated as of Apache Ignite 2.3. Please use {@link ClientConnectorConfiguration} and
+ * {@link IgniteConfiguration#setClientConnectorConfiguration(ClientConnectorConfiguration)} instead.
*/
+@SuppressWarnings("deprecation")
+@Deprecated
public class SqlConnectorConfiguration {
/** Default port. */
public static final int DFLT_PORT = 10800;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index 48a1e3e..99c7cce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -33,7 +33,6 @@ import org.apache.ignite.internal.managers.failover.GridFailoverManager;
import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
-import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
@@ -49,7 +48,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.marshaller.GridMarshallerMappingProcessor;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProcessor;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
import org.apache.ignite.internal.processors.pool.PoolProcessor;
@@ -335,7 +334,7 @@ public interface GridKernalContext extends Iterable<GridComponent> {
*
* @return SQL listener processor.
*/
- public SqlListenerProcessor sqlListener();
+ public ClientListenerProcessor sqlListener();
/**
* @return Plugin processor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 89ead1a..07e5970 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -47,7 +47,6 @@ import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
import org.apache.ignite.internal.processors.cache.CacheConflictResolutionManager;
-import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
@@ -65,7 +64,7 @@ import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.marshaller.GridMarshallerMappingProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProcessor;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.platform.plugin.PlatformPluginProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
@@ -161,7 +160,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
/** */
@GridToStringInclude
- private SqlListenerProcessor sqlListenerProc;
+ private ClientListenerProcessor sqlListenerProc;
/** */
@GridToStringInclude
@@ -568,8 +567,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
pluginProc = (IgnitePluginProcessor)comp;
else if (comp instanceof GridQueryProcessor)
qryProc = (GridQueryProcessor)comp;
- else if (comp instanceof SqlListenerProcessor)
- sqlListenerProc = (SqlListenerProcessor)comp;
+ else if (comp instanceof ClientListenerProcessor)
+ sqlListenerProc = (ClientListenerProcessor)comp;
else if (comp instanceof DataStructuresProcessor)
dataStructuresProc = (DataStructuresProcessor)comp;
else if (comp instanceof ClusterProcessor)
@@ -825,7 +824,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
}
/** {@inheritDoc} */
- @Override public SqlListenerProcessor sqlListener() {
+ @Override public ClientListenerProcessor sqlListener() {
return sqlListenerProc;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 3922b39..67f76e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -129,7 +129,7 @@ import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.marshaller.GridMarshallerMappingProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
import org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProcessor;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
import org.apache.ignite.internal.processors.platform.PlatformNoopProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.platform.plugin.PlatformPluginProcessor;
@@ -944,7 +944,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
startProcessor(new GridClusterStateProcessor(ctx));
startProcessor(new GridCacheProcessor(ctx));
startProcessor(new GridQueryProcessor(ctx));
- startProcessor(new SqlListenerProcessor(ctx));
+ startProcessor(new ClientListenerProcessor(ctx));
startProcessor(new GridServiceProcessor(ctx));
startProcessor(new GridTaskSessionProcessor(ctx));
startProcessor(new GridJobProcessor(ctx));
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
index 44477cd..d9bef54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
@@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.query.SqlQuery;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryExecuteResult;
@@ -380,7 +380,7 @@ public class JdbcThinStatement implements Statement {
try {
JdbcBatchExecuteResult res = conn.io().batchExecute(conn.getSchema(), batch);
- if (res.errorCode() != SqlListenerResponse.STATUS_SUCCESS)
+ if (res.errorCode() != ClientListenerResponse.STATUS_SUCCESS)
throw new BatchUpdateException(res.errorMessage(), null, res.errorCode(), res.updateCounts());
return res.updateCounts();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
index 9775254..27b9407 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -28,10 +28,10 @@ import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.processors.odbc.SqlListenerNioListener;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerNioListener;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMetaColumnsRequest;
@@ -67,10 +67,10 @@ import org.apache.ignite.lang.IgniteProductVersion;
*/
public class JdbcThinTcpIo {
/** Current version. */
- private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2, 1, 5);
+ private static final ClientListenerProtocolVersion CURRENT_VER = ClientListenerProtocolVersion.create(2, 1, 5);
/** Version 2.1.0. */
- private static final SqlListenerProtocolVersion VER_2_1_0 = SqlListenerProtocolVersion.create(2, 1, 0);
+ private static final ClientListenerProtocolVersion VER_2_1_0 = ClientListenerProtocolVersion.create(2, 1, 0);
/** Initial output stream capacity for handshake. */
private static final int HANDSHAKE_MSG_SIZE = 13;
@@ -139,7 +139,7 @@ public class JdbcThinTcpIo {
private IgniteProductVersion igniteVer;
/** Ignite server protocol version. */
- private SqlListenerProtocolVersion srvProtocolVer;
+ private ClientListenerProtocolVersion srvProtocolVer;
/**
* Constructor.
@@ -210,13 +210,13 @@ public class JdbcThinTcpIo {
BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
null, null);
- writer.writeByte((byte)SqlListenerRequest.HANDSHAKE);
+ writer.writeByte((byte) ClientListenerRequest.HANDSHAKE);
writer.writeShort(CURRENT_VER.major());
writer.writeShort(CURRENT_VER.minor());
writer.writeShort(CURRENT_VER.maintenance());
- writer.writeByte(SqlListenerNioListener.JDBC_CLIENT);
+ writer.writeByte(ClientListenerNioListener.JDBC_CLIENT);
writer.writeBoolean(distributedJoins);
writer.writeBoolean(enforceJoinOrder);
@@ -257,7 +257,7 @@ public class JdbcThinTcpIo {
String err = reader.readString();
- srvProtocolVer = SqlListenerProtocolVersion.create(maj, min, maintenance);
+ srvProtocolVer = ClientListenerProtocolVersion.create(maj, min, maintenance);
if (VER_2_1_0.equals(srvProtocolVer))
handshake_2_1_0();
@@ -278,13 +278,13 @@ public class JdbcThinTcpIo {
BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
null, null);
- writer.writeByte((byte)SqlListenerRequest.HANDSHAKE);
+ writer.writeByte((byte) ClientListenerRequest.HANDSHAKE);
writer.writeShort(VER_2_1_0.major());
writer.writeShort(VER_2_1_0.minor());
writer.writeShort(VER_2_1_0.maintenance());
- writer.writeByte(SqlListenerNioListener.JDBC_CLIENT);
+ writer.writeByte(ClientListenerNioListener.JDBC_CLIENT);
writer.writeBoolean(distributedJoins);
writer.writeBoolean(enforceJoinOrder);
@@ -308,7 +308,7 @@ public class JdbcThinTcpIo {
String err = reader.readString();
- SqlListenerProtocolVersion ver = SqlListenerProtocolVersion.create(maj, min, maintenance);
+ ClientListenerProtocolVersion ver = ClientListenerProtocolVersion.create(maj, min, maintenance);
throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" + CURRENT_VER +
", remoteNodeProtocolVer=" + ver + ", err=" + err + ']');
@@ -354,7 +354,7 @@ public class JdbcThinTcpIo {
res.readBinary(reader);
- if (res.status() != SqlListenerResponse.STATUS_SUCCESS)
+ if (res.status() != ClientListenerResponse.STATUS_SUCCESS)
throw new IgniteCheckedException("Error server response: [req=" + req + ", resp=" + res + ']');
return (R)res.response();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
index bb6eb14..52b3abc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.jdbc.thin;
-import org.apache.ignite.configuration.SqlConnectorConfiguration;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
import java.sql.Time;
import java.sql.Timestamp;
@@ -109,7 +109,7 @@ public class JdbcThinUtils {
public static final String PROP_AUTO_CLOSE_SERVER_CURSORS = PROP_PREFIX + PARAM_AUTO_CLOSE_SERVER_CURSOR;
/** Default port. */
- public static final int DFLT_PORT = SqlConnectorConfiguration.DFLT_PORT;
+ public static final int DFLT_PORT = ClientConnectorConfiguration.DFLT_PORT;
/**
* Trim prefix from property.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
index c2afdef..07be8b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
@@ -61,7 +61,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.marshaller.GridMarshallerMappingProcessor;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProcessor;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
import org.apache.ignite.internal.processors.pool.PoolProcessor;
@@ -371,7 +371,7 @@ public class StandaloneGridKernalContext implements GridKernalContext {
}
/** {@inheritDoc} */
- @Override public SqlListenerProcessor sqlListener() {
+ @Override public ClientListenerProcessor sqlListener() {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerBufferedParser.java
new file mode 100644
index 0000000..eb7bfe8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerBufferedParser.java
@@ -0,0 +1,81 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.util.nio.GridNioParser;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * This class implements stream parser based on {@link ClientListenerNioServerBuffer}.
+ * <p>
+ * The rule for this parser is that every message sent over the stream is prepended with
+ * 4-byte integer header containing message size. So, the stream structure is as follows:
+ * <pre>
+ * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
+ * | MSG_SIZE | MESSAGE | MSG_SIZE | MESSAGE |
+ * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
+ * </pre>
+ */
+public class ClientListenerBufferedParser implements GridNioParser {
+ /** Buffer metadata key. */
+ private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
+
+ /** {@inheritDoc} */
+ @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
+ ClientListenerNioServerBuffer nioBuf = ses.meta(BUF_META_KEY);
+
+ // Decode for a given session is called per one thread, so there should not be any concurrency issues.
+ // However, we make some additional checks.
+ if (nioBuf == null) {
+ nioBuf = new ClientListenerNioServerBuffer();
+
+ ClientListenerNioServerBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
+
+ assert old == null;
+ }
+
+ return nioBuf.read(buf);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
+ byte[] msg0 = (byte[])msg;
+
+ ByteBuffer res = ByteBuffer.allocate(msg0.length + 4);
+
+ res.order(ByteOrder.LITTLE_ENDIAN);
+
+ res.putInt(msg0.length);
+ res.put(msg0);
+
+ res.flip();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return ClientListenerBufferedParser.class.getSimpleName();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java
new file mode 100644
index 0000000..3605f03
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java
@@ -0,0 +1,62 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
+
+/**
+ * SQL listener connection context.
+ */
+public interface ClientListenerConnectionContext {
+ /**
+ * @param ver Version to check.
+ * @return {@code true} if version is supported.
+ */
+ boolean isVersionSupported(ClientListenerProtocolVersion ver);
+
+ /**
+ * @return Current context version.
+ */
+ ClientListenerProtocolVersion currentVersion();
+
+ /**
+ * Initialize from handshake message.
+ *
+ * @param ver Protocol version.
+ * @param reader Reader set to the configuration part of the handshake message.
+ */
+ void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader);
+
+ /**
+ * Handler getter.
+ * @return Request handler for the connection.
+ */
+ ClientListenerRequestHandler handler();
+
+ /**
+ * Parser getter
+ * @return Message parser for the connection.
+ */
+ ClientListenerMessageParser parser();
+
+ /**
+ * Called whenever client is disconnected due to correct connection close
+ * or due to {@code IOException} during network operations.
+ */
+ void onDisconnected();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerMessageParser.java
new file mode 100644
index 0000000..ab80f47
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerMessageParser.java
@@ -0,0 +1,39 @@
+/*
+ * 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.internal.processors.odbc;
+
+/**
+ * Client listener message parser.
+ */
+public interface ClientListenerMessageParser {
+ /**
+ * Decode request from byte array.
+ *
+ * @param msg Message.
+ * @return Request.
+ */
+ public ClientListenerRequest decode(byte[] msg);
+
+ /**
+ * Encode response to byte array.
+ *
+ * @param resp Response.
+ * @return Message.
+ */
+ public byte[] encode(ClientListenerResponse resp);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
new file mode 100644
index 0000000..e8ba18d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
@@ -0,0 +1,245 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
+import org.apache.ignite.internal.binary.BinaryWriterExImpl;
+import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext;
+import org.apache.ignite.internal.processors.odbc.odbc.OdbcConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.util.GridSpinBusyLock;
+import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Client message listener.
+ */
+public class ClientListenerNioListener extends GridNioServerListenerAdapter<byte[]> {
+ /** ODBC driver handshake code. */
+ public static final byte ODBC_CLIENT = 0;
+
+ /** JDBC driver handshake code. */
+ public static final byte JDBC_CLIENT = 1;
+
+ /** Thin client handshake code. */
+ public static final byte THIN_CLIENT = 2;
+
+ /** Connection-related metadata key. */
+ private static final int CONN_CTX_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
+
+ /** Busy lock. */
+ private final GridSpinBusyLock busyLock;
+
+ /** Kernal context. */
+ private final GridKernalContext ctx;
+
+ /** Maximum allowed cursors. */
+ private final int maxCursors;
+
+ /** Logger. */
+ private final IgniteLogger log;
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Context.
+ * @param busyLock Shutdown busy lock.
+ * @param maxCursors Maximum allowed cursors.
+ */
+ public ClientListenerNioListener(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors) {
+ this.ctx = ctx;
+ this.busyLock = busyLock;
+ this.maxCursors = maxCursors;
+
+ log = ctx.log(getClass());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onConnected(GridNioSession ses) {
+ if (log.isDebugEnabled())
+ log.debug("Client connected: " + ses.remoteAddress());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
+ ClientListenerConnectionContext connCtx = ses.meta(CONN_CTX_META_KEY);
+
+ if (connCtx != null)
+ connCtx.onDisconnected();
+
+ if (log.isDebugEnabled()) {
+ if (e == null)
+ log.debug("Client disconnected: " + ses.remoteAddress());
+ else
+ log.debug("Client disconnected due to an error [addr=" + ses.remoteAddress() + ", err=" + e + ']');
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onMessage(GridNioSession ses, byte[] msg) {
+ assert msg != null;
+
+ ClientListenerConnectionContext connCtx = ses.meta(CONN_CTX_META_KEY);
+
+ if (connCtx == null) {
+ onHandshake(ses, msg);
+
+ return;
+ }
+
+ ClientListenerMessageParser parser = connCtx.parser();
+ ClientListenerRequestHandler handler = connCtx.handler();
+
+ ClientListenerRequest req;
+
+ try {
+ req = parser.decode(msg);
+ }
+ catch (Exception e) {
+ log.error("Failed to parse client request.", e);
+
+ ses.close();
+
+ return;
+ }
+
+ assert req != null;
+
+ try {
+ long startTime = 0;
+
+ if (log.isDebugEnabled()) {
+ startTime = System.nanoTime();
+
+ log.debug("Client request received [reqId=" + req.requestId() + ", addr=" +
+ ses.remoteAddress() + ", req=" + req + ']');
+ }
+
+ ClientListenerResponse resp = handler.handle(req);
+
+ if (log.isDebugEnabled()) {
+ long dur = (System.nanoTime() - startTime) / 1000;
+
+ log.debug("Client request processed [reqId=" + req.requestId() + ", dur(mcs)=" + dur +
+ ", resp=" + resp.status() + ']');
+ }
+
+ byte[] outMsg = parser.encode(resp);
+
+ ses.send(outMsg);
+ }
+ catch (Exception e) {
+ log.error("Failed to process client request [req=" + req + ']', e);
+
+ ses.send(parser.encode(handler.handleException(e)));
+ }
+ }
+
+ /**
+ * Perform handshake.
+ *
+ * @param ses Session.
+ * @param msg Message bytes.
+ */
+ private void onHandshake(GridNioSession ses, byte[] msg) {
+ BinaryInputStream stream = new BinaryHeapInputStream(msg);
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null, true);
+
+ byte cmd = reader.readByte();
+
+ if (cmd != ClientListenerRequest.HANDSHAKE) {
+ log.error("Unexpected client request (will close session): " + ses.remoteAddress());
+
+ ses.close();
+
+ return;
+ }
+
+ short verMajor = reader.readShort();
+ short verMinor = reader.readShort();
+ short verMaintenance = reader.readShort();
+
+ ClientListenerProtocolVersion ver = ClientListenerProtocolVersion.create(verMajor, verMinor, verMaintenance);
+
+ byte clientType = reader.readByte();
+
+ ClientListenerConnectionContext connCtx = prepareContext(clientType);
+
+ String errMsg = null;
+
+ if (connCtx.isVersionSupported(ver)) {
+ connCtx.initializeFromHandshake(ver, reader);
+
+ ses.addMeta(CONN_CTX_META_KEY, connCtx);
+ }
+ else {
+ log.warning("Unsupported version: " + ver.toString());
+
+ errMsg = "Unsupported version.";
+ }
+
+ // Send response.
+ BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(8), null, null);
+
+ if (errMsg == null)
+ connCtx.handler().writeHandshake(writer);
+ else {
+ ClientListenerProtocolVersion currentVer = connCtx.currentVersion();
+
+ // Failed handshake response
+ writer.writeBoolean(false);
+ writer.writeShort(currentVer.major());
+ writer.writeShort(currentVer.minor());
+ writer.writeShort(currentVer.maintenance());
+ writer.doWriteString(errMsg);
+ }
+
+ ses.send(writer.array());
+ }
+
+ /**
+ * Prepare context.
+ *
+ * @param clientType Client type.
+ * @return Context.
+ */
+ private ClientListenerConnectionContext prepareContext(byte clientType) {
+ switch (clientType) {
+ case ODBC_CLIENT:
+ return new OdbcConnectionContext(ctx, busyLock, maxCursors);
+
+ case JDBC_CLIENT:
+ return new JdbcConnectionContext(ctx, busyLock, maxCursors);
+
+ case THIN_CLIENT:
+ return new ClientConnectionContext(ctx);
+
+ default:
+ throw new IgniteException("Unknown client type: " + clientType);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioServerBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioServerBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioServerBuffer.java
new file mode 100644
index 0000000..30ee69f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioServerBuffer.java
@@ -0,0 +1,114 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.jetbrains.annotations.Nullable;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Client NIO server buffer.
+ */
+public class ClientListenerNioServerBuffer {
+ /** Current message data. */
+ private byte[] data;
+
+ /** Count of received bytes of the current message. */
+ private int cnt = -4;
+
+ /** Current message size. */
+ private int msgSize;
+
+ /**
+ * Reset buffer state.
+ */
+ public void reset() {
+ msgSize = 0;
+ cnt = -4;
+ data = null;
+ }
+
+ /**
+ * Checks whether the byte array is filled.
+ *
+ * @return Flag indicating whether byte array is filled or not.
+ */
+ public boolean isFilled() {
+ return cnt > 0 && cnt == msgSize;
+ }
+
+ /**
+ * Get data withing the buffer.
+ *
+ * @return Data.
+ */
+ public byte[] data() {
+ return data;
+ }
+
+ /**
+ * @param buf Buffer.
+ * @return Message bytes or {@code null} if message is not fully read yet.
+ * @throws IgniteCheckedException If failed to parse message.
+ */
+ @Nullable public byte[] read(ByteBuffer buf) throws IgniteCheckedException {
+ if (cnt < 0) {
+ for (; cnt < 0 && buf.hasRemaining(); cnt++)
+ msgSize |= (buf.get() & 0xFF) << (8*(4 + cnt));
+
+ if (cnt < 0)
+ return null;
+
+ // If count is 0 then message size should be inited.
+ if (msgSize <= 0)
+ throw new IgniteCheckedException("Invalid message size: " + msgSize);
+
+ data = new byte[msgSize];
+ }
+
+ assert msgSize > 0;
+ assert cnt >= 0;
+
+ int remaining = buf.remaining();
+
+ // If there are more bytes in buffer.
+ if (remaining > 0) {
+ int missing = msgSize - cnt;
+
+ // Read only up to message size.
+ if (missing > 0) {
+ int len = missing < remaining ? missing : remaining;
+
+ buf.get(data, cnt, len);
+
+ cnt += len;
+ }
+ }
+
+ if (cnt == msgSize) {
+ byte[] data0 = data;
+
+ reset();
+
+ return data0;
+ }
+ else
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java
new file mode 100644
index 0000000..3462da2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java
@@ -0,0 +1,308 @@
+/*
+ * 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.internal.processors.odbc;
+
+import java.net.InetAddress;
+import java.nio.ByteOrder;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.configuration.SqlConnectorConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.GridProcessorAdapter;
+import org.apache.ignite.internal.util.GridSpinBusyLock;
+import org.apache.ignite.internal.util.HostAndPortRange;
+import org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter;
+import org.apache.ignite.internal.util.nio.GridNioCodecFilter;
+import org.apache.ignite.internal.util.nio.GridNioFilter;
+import org.apache.ignite.internal.util.nio.GridNioServer;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.IgnitePortProtocol;
+import org.apache.ignite.thread.IgniteThreadPoolExecutor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Client connector processor.
+ */
+public class ClientListenerProcessor extends GridProcessorAdapter {
+ /** Default number of selectors. */
+ private static final int DFLT_SELECTOR_CNT = Math.min(4, Runtime.getRuntime().availableProcessors());
+
+ /** Default TCP direct buffer flag. */
+ private static final boolean DFLT_TCP_DIRECT_BUF = false;
+
+ /** Busy lock. */
+ private final GridSpinBusyLock busyLock = new GridSpinBusyLock();
+
+ /** TCP Server. */
+ private GridNioServer<byte[]> srv;
+
+ /** Executor service. */
+ private ExecutorService execSvc;
+
+ /**
+ * @param ctx Kernal context.
+ */
+ public ClientListenerProcessor(GridKernalContext ctx) {
+ super(ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteCheckedException {
+ IgniteConfiguration cfg = ctx.config();
+
+ ClientConnectorConfiguration cliConnCfg = prepareConfiguration(cfg);
+
+ if (cliConnCfg != null) {
+ try {
+ validateConfiguration(cliConnCfg);
+
+ // Resolve host.
+ String host = cliConnCfg.getHost();
+
+ if (host == null)
+ host = cfg.getLocalHost();
+
+ InetAddress hostAddr;
+
+ try {
+ hostAddr = U.resolveLocalHost(host);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException("Failed to resolve client connector host: " + host, e);
+ }
+
+ execSvc = new IgniteThreadPoolExecutor(
+ "client-connector",
+ cfg.getIgniteInstanceName(),
+ cliConnCfg.getThreadPoolSize(),
+ cliConnCfg.getThreadPoolSize(),
+ 0,
+ new LinkedBlockingQueue<Runnable>());
+
+ Exception lastErr = null;
+
+ int portTo = cliConnCfg.getPort() + cliConnCfg.getPortRange();
+
+ if (portTo <= 0) // Handle int overflow.
+ portTo = Integer.MAX_VALUE;
+
+ for (int port = cliConnCfg.getPort(); port <= portTo && port <= 65535; port++) {
+ try {
+ GridNioFilter[] filters = new GridNioFilter[] {
+ new GridNioAsyncNotifyFilter(ctx.igniteInstanceName(), execSvc, log) {
+ @Override public void onSessionOpened(GridNioSession ses)
+ throws IgniteCheckedException {
+ proceedSessionOpened(ses);
+ }
+ },
+ new GridNioCodecFilter(new ClientListenerBufferedParser(), log, false)
+ };
+
+ int maxOpenCursors = cliConnCfg.getMaxOpenCursorsPerConnection();
+
+ GridNioServer<byte[]> srv0 = GridNioServer.<byte[]>builder()
+ .address(hostAddr)
+ .port(port)
+ .listener(new ClientListenerNioListener(ctx, busyLock, maxOpenCursors))
+ .logger(log)
+ .selectorCount(DFLT_SELECTOR_CNT)
+ .igniteInstanceName(ctx.igniteInstanceName())
+ .serverName("client-listener")
+ .tcpNoDelay(cliConnCfg.isTcpNoDelay())
+ .directBuffer(DFLT_TCP_DIRECT_BUF)
+ .byteOrder(ByteOrder.nativeOrder())
+ .socketSendBufferSize(cliConnCfg.getSocketSendBufferSize())
+ .socketReceiveBufferSize(cliConnCfg.getSocketReceiveBufferSize())
+ .filters(filters)
+ .directMode(false)
+ .idleTimeout(Long.MAX_VALUE)
+ .build();
+
+ srv0.start();
+
+ srv = srv0;
+
+ ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
+
+ if (log.isInfoEnabled())
+ log.info("Client connector processor has started on TCP port " + port);
+
+ lastErr = null;
+
+ break;
+ }
+ catch (Exception e) {
+ lastErr = e;
+ }
+ }
+
+ assert (srv != null && lastErr == null) || (srv == null && lastErr != null);
+
+ if (lastErr != null)
+ throw new IgniteCheckedException("Failed to bind to any [host:port] from the range [" +
+ "host=" + host + ", portFrom=" + cliConnCfg.getPort() + ", portTo=" + portTo +
+ ", lastErr=" + lastErr + ']');
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException("Failed to start client connector processor.", e);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onKernalStop(boolean cancel) {
+ if (srv != null) {
+ busyLock.block();
+
+ srv.stop();
+
+ ctx.ports().deregisterPorts(getClass());
+
+ if (execSvc != null) {
+ U.shutdownNow(getClass(), execSvc, log);
+
+ execSvc = null;
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Client connector processor stopped.");
+ }
+ }
+
+ /**
+ * Prepare connector configuration.
+ *
+ * @param cfg Ignote configuration.
+ * @return Connector configuration.
+ * @throws IgniteCheckedException If failed.
+ */
+ @SuppressWarnings("deprecation")
+ @Nullable private ClientConnectorConfiguration prepareConfiguration(IgniteConfiguration cfg)
+ throws IgniteCheckedException {
+ OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration();
+ SqlConnectorConfiguration sqlConnCfg = cfg.getSqlConnectorConfiguration();
+ ClientConnectorConfiguration cliConnCfg = cfg.getClientConnectorConfiguration();
+
+ if (cliConnCfg != null) {
+ // User set configuration explicitly. User it, but print a warning about ignored SQL/ODBC configs.
+ if (odbcCfg != null) {
+ U.warn(log, "Deprecated " + OdbcConfiguration.class.getSimpleName() + " will be ignored because " +
+ ClientConnectorConfiguration.class.getSimpleName() + " is set.");
+ }
+
+ if (sqlConnCfg != null) {
+ U.warn(log, "Deprecated " + SqlConnectorConfiguration.class.getSimpleName() + " will be ignored " +
+ "because " + ClientConnectorConfiguration.class.getSimpleName() + " is set.");
+ }
+ }
+ else {
+ cliConnCfg = new ClientConnectorConfiguration();
+
+ if (sqlConnCfg != null) {
+ // Migrate from SQL configuration.
+ cliConnCfg = new ClientConnectorConfiguration();
+
+ cliConnCfg.setHost(sqlConnCfg.getHost());
+ cliConnCfg.setMaxOpenCursorsPerConnection(sqlConnCfg.getMaxOpenCursorsPerConnection());
+ cliConnCfg.setPort(sqlConnCfg.getPort());
+ cliConnCfg.setPortRange(sqlConnCfg.getPortRange());
+ cliConnCfg.setSocketSendBufferSize(sqlConnCfg.getSocketSendBufferSize());
+ cliConnCfg.setSocketReceiveBufferSize(sqlConnCfg.getSocketReceiveBufferSize());
+ cliConnCfg.setTcpNoDelay(sqlConnCfg.isTcpNoDelay());
+ cliConnCfg.setThreadPoolSize(sqlConnCfg.getThreadPoolSize());
+
+ U.warn(log, "Automatically converted deprecated " + SqlConnectorConfiguration.class.getSimpleName() +
+ " to " + ClientConnectorConfiguration.class.getSimpleName() + ".");
+
+ if (odbcCfg != null) {
+ U.warn(log, "Deprecated " + OdbcConfiguration.class.getSimpleName() + " will be ignored because " +
+ SqlConnectorConfiguration.class.getSimpleName() + " is set.");
+ }
+ }
+ else if (odbcCfg != null) {
+ // Migrate from ODBC configuration.
+ HostAndPortRange hostAndPort = parseOdbcEndpoint(odbcCfg);
+
+ cliConnCfg = new ClientConnectorConfiguration();
+
+ cliConnCfg.setHost(hostAndPort.host());
+ cliConnCfg.setPort(hostAndPort.portFrom());
+ cliConnCfg.setPortRange(hostAndPort.portTo() - hostAndPort.portFrom());
+ cliConnCfg.setThreadPoolSize(odbcCfg.getThreadPoolSize());
+ cliConnCfg.setSocketSendBufferSize(odbcCfg.getSocketSendBufferSize());
+ cliConnCfg.setSocketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize());
+ cliConnCfg.setMaxOpenCursorsPerConnection(odbcCfg.getMaxOpenCursors());
+
+ U.warn(log, "Automatically converted deprecated " + OdbcConfiguration.class.getSimpleName() +
+ " to " + ClientConnectorConfiguration.class.getSimpleName() + ".");
+ }
+ }
+
+ return cliConnCfg;
+ }
+
+ /**
+ * Validate client connector configuration.
+ *
+ * @param cfg Configuration.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void validateConfiguration(ClientConnectorConfiguration cfg) throws IgniteCheckedException {
+ assertParameter(cfg.getPort() > 1024, "port > 1024");
+ assertParameter(cfg.getPort() <= 65535, "port <= 65535");
+ assertParameter(cfg.getPortRange() >= 0, "portRange > 0");
+ assertParameter(cfg.getSocketSendBufferSize() >= 0, "socketSendBufferSize > 0");
+ assertParameter(cfg.getSocketReceiveBufferSize() >= 0, "socketReceiveBufferSize > 0");
+ assertParameter(cfg.getMaxOpenCursorsPerConnection() >= 0, "maxOpenCursorsPerConnection() >= 0");
+ assertParameter(cfg.getThreadPoolSize() > 0, "threadPoolSize > 0");
+ }
+
+ /**
+ * Parse ODBC endpoint.
+ *
+ * @param odbcCfg ODBC configuration.
+ * @return ODBC host and port range.
+ * @throws IgniteCheckedException If failed.
+ */
+ @SuppressWarnings("deprecation")
+ private HostAndPortRange parseOdbcEndpoint(OdbcConfiguration odbcCfg) throws IgniteCheckedException {
+ HostAndPortRange res;
+
+ if (F.isEmpty(odbcCfg.getEndpointAddress())) {
+ res = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST,
+ OdbcConfiguration.DFLT_TCP_PORT_FROM,
+ OdbcConfiguration.DFLT_TCP_PORT_TO
+ );
+ }
+ else {
+ res = HostAndPortRange.parse(odbcCfg.getEndpointAddress(),
+ OdbcConfiguration.DFLT_TCP_PORT_FROM,
+ OdbcConfiguration.DFLT_TCP_PORT_TO,
+ "Failed to parse ODBC endpoint address"
+ );
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProtocolVersion.java
new file mode 100644
index 0000000..72936db
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProtocolVersion.java
@@ -0,0 +1,116 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Client listener protocol version.
+ */
+public class ClientListenerProtocolVersion implements Comparable<ClientListenerProtocolVersion> {
+ /** Major part. */
+ private final short major;
+
+ /** Minor part. */
+ private final short minor;
+
+ /** Maintenance part. */
+ private final short maintenance;
+
+ /**
+ * Create version.
+ *
+ * @param major Major part.
+ * @param minor Minor part.
+ * @param maintenance Maintenance part.
+ * @return Version.
+ */
+ public static ClientListenerProtocolVersion create(int major, int minor, int maintenance) {
+ return new ClientListenerProtocolVersion((short)major, (short)minor, (short)maintenance);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param major Major part.
+ * @param minor Minor part.
+ * @param maintenance Maintenance part.
+ */
+ private ClientListenerProtocolVersion(short major, short minor, short maintenance) {
+ this.major = major;
+ this.minor = minor;
+ this.maintenance = maintenance;
+ }
+
+ /**
+ * @return Major part.
+ */
+ public short major() {
+ return major;
+ }
+
+ /**
+ * @return Minor part.
+ */
+ public short minor() {
+ return minor;
+ }
+
+ /**
+ * @return Maintenance part.
+ */
+ public short maintenance() {
+ return maintenance;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compareTo(@NotNull ClientListenerProtocolVersion other) {
+ int res = major - other.major;
+
+ if (res == 0)
+ res = minor - other.minor;
+
+ if (res == 0)
+ res = maintenance - other.maintenance;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return 31 * (31 * major + minor) + maintenance;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj != null && obj instanceof ClientListenerProtocolVersion) {
+ ClientListenerProtocolVersion other = (ClientListenerProtocolVersion)obj;
+
+ return F.eq(major, other.major) && F.eq(minor, other.minor) && F.eq(maintenance, other.maintenance);
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ClientListenerProtocolVersion.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
new file mode 100644
index 0000000..9f7d075
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.internal.processors.odbc;
+
+/**
+ * Client listener command request.
+ */
+public interface ClientListenerRequest {
+ /** Handshake request. */
+ public static final int HANDSHAKE = 1;
+
+ /**
+ * @return Request ID.
+ */
+ public long requestId();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestHandler.java
new file mode 100644
index 0000000..e28d0d9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestHandler.java
@@ -0,0 +1,48 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.apache.ignite.internal.binary.BinaryWriterExImpl;
+
+/**
+ * Client listener request handler.
+ */
+public interface ClientListenerRequestHandler {
+ /**
+ * Handle request.
+ *
+ * @param req Request.
+ * @return Response.
+ */
+ public ClientListenerResponse handle(ClientListenerRequest req);
+
+ /**
+ * Handle exception.
+ *
+ * @param e Exception.
+ * @return Error response.
+ */
+ public ClientListenerResponse handleException(Exception e);
+
+ /**
+ * Write successful handshake response.
+ *
+ * @param writer Binary writer.
+ */
+ public void writeHandshake(BinaryWriterExImpl writer);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestNoId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestNoId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestNoId.java
new file mode 100644
index 0000000..40a4485
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequestNoId.java
@@ -0,0 +1,28 @@
+/*
+ * 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.internal.processors.odbc;
+
+/**
+ * Client request with no ID.
+ */
+public abstract class ClientListenerRequestNoId implements ClientListenerRequest {
+ /** {@inheritDoc} */
+ @Override public long requestId() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerResponse.java
new file mode 100644
index 0000000..342062e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerResponse.java
@@ -0,0 +1,76 @@
+/*
+ * 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.internal.processors.odbc;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Client listener response.
+ */
+public abstract class ClientListenerResponse {
+ /** Command succeeded. */
+ public static final int STATUS_SUCCESS = 0;
+
+ /** Command failed. */
+ public static final int STATUS_FAILED = 1;
+
+ /** Success status. */
+ private int status;
+
+ /** Error. */
+ private String err;
+
+ /**
+ * Constructs failed rest response.
+ *
+ * @param status Response status.
+ * @param err Error, {@code null} if success is {@code true}.
+ */
+ public ClientListenerResponse(int status, @Nullable String err) {
+ this.status = status;
+ this.err = err;
+ }
+
+ /**
+ * @return Success flag.
+ */
+ public int status() {
+ return status;
+ }
+
+ /**
+ * @param status Status.
+ */
+ public void status(int status) {
+ this.status = status;
+ }
+
+ /**
+ * @return Error.
+ */
+ public String error() {
+ return err;
+ }
+
+ /**
+ * @param err Error message.
+ */
+ public void error(String err) {
+ this.err = err;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
deleted file mode 100644
index a8e124f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerBufferedParser.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.nio.GridNioParser;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * This class implements stream parser based on {@link SqlListenerNioServerBuffer}.
- * <p>
- * The rule for this parser is that every message sent over the stream is prepended with
- * 4-byte integer header containing message size. So, the stream structure is as follows:
- * <pre>
- * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
- * | MSG_SIZE | MESSAGE | MSG_SIZE | MESSAGE |
- * +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
- * </pre>
- */
-public class SqlListenerBufferedParser implements GridNioParser {
- /** Buffer metadata key. */
- private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
-
- /** {@inheritDoc} */
- @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
- SqlListenerNioServerBuffer nioBuf = ses.meta(BUF_META_KEY);
-
- // Decode for a given session is called per one thread, so there should not be any concurrency issues.
- // However, we make some additional checks.
- if (nioBuf == null) {
- nioBuf = new SqlListenerNioServerBuffer();
-
- SqlListenerNioServerBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
-
- assert old == null;
- }
-
- return nioBuf.read(buf);
- }
-
- /** {@inheritDoc} */
- @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
- byte[] msg0 = (byte[])msg;
-
- ByteBuffer res = ByteBuffer.allocate(msg0.length + 4);
-
- res.order(ByteOrder.LITTLE_ENDIAN);
-
- res.putInt(msg0.length);
- res.put(msg0);
-
- res.flip();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return SqlListenerBufferedParser.class.getSimpleName();
- }
-}
\ No newline at end of file
[19/26] ignite git commit: IGNITE-6327: Added thin client
configuration. This closes #2672.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
index f098383..f252a38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
@@ -26,9 +26,9 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeNameGetRequest;
import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeGetRequest;
import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypePutRequest;
@@ -39,7 +39,7 @@ import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePu
/**
* Thin client message parser.
*/
-public class ClientMessageParser implements SqlListenerMessageParser {
+public class ClientMessageParser implements ClientListenerMessageParser {
/** */
private static final short OP_CACHE_GET = 1;
@@ -74,7 +74,7 @@ public class ClientMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public SqlListenerRequest decode(byte[] msg) {
+ @Override public ClientListenerRequest decode(byte[] msg) {
assert msg != null;
BinaryInputStream inStream = new BinaryHeapInputStream(msg);
@@ -106,7 +106,7 @@ public class ClientMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public byte[] encode(SqlListenerResponse resp) {
+ @Override public byte[] encode(ClientListenerResponse resp) {
BinaryHeapOutputStream outStream = new BinaryHeapOutputStream(32);
BinaryRawWriter writer = marsh.writer(outStream);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java
index c16d481..56d5b0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java
@@ -19,12 +19,12 @@ package org.apache.ignite.internal.processors.platform.client;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
/**
* Thin client request.
*/
-public class ClientRequest implements SqlListenerRequest {
+public class ClientRequest implements ClientListenerRequest {
/** Request id. */
private final long reqId;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
index 30fb1a8..4dcda23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
@@ -19,14 +19,14 @@ package org.apache.ignite.internal.processors.platform.client;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
/**
* Thin client request handler.
*/
-public class ClientRequestHandler implements SqlListenerRequestHandler {
+public class ClientRequestHandler implements ClientListenerRequestHandler {
/** Kernal context. */
private final GridKernalContext ctx;
@@ -42,12 +42,12 @@ public class ClientRequestHandler implements SqlListenerRequestHandler {
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handle(SqlListenerRequest req) {
+ @Override public ClientListenerResponse handle(ClientListenerRequest req) {
return ((ClientRequest)req).process(ctx);
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handleException(Exception e) {
+ @Override public ClientListenerResponse handleException(Exception e) {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientResponse.java
index 6f2e8d6..1089b48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientResponse.java
@@ -18,12 +18,12 @@
package org.apache.ignite.internal.processors.platform.client;
import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
/**
* Thin client response.
*/
-public class ClientResponse extends SqlListenerResponse {
+public class ClientResponse extends ClientListenerResponse {
/** Request id. */
private final long reqId;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 8c9f5e1..d54aac1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -532,6 +532,7 @@ public class PlatformConfigurationUtils {
* @param in Reader.
* @param cfg Configuration.
*/
+ @SuppressWarnings("deprecation")
public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
if (in.readBoolean())
cfg.setClientMode(in.readBoolean());
@@ -983,6 +984,7 @@ public class PlatformConfigurationUtils {
* @param w Writer.
* @param cfg Configuration.
*/
+ @SuppressWarnings("deprecation")
public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfiguration cfg) {
assert w != null;
assert cfg != null;
@@ -1442,6 +1444,7 @@ public class PlatformConfigurationUtils {
* @param in Reader.
* @return Config.
*/
+ @SuppressWarnings("deprecation")
private static SqlConnectorConfiguration readSqlConnectorConfiguration(BinaryRawReader in) {
return new SqlConnectorConfiguration()
.setHost(in.readString())
@@ -1459,6 +1462,7 @@ public class PlatformConfigurationUtils {
*
* @param w Writer.
*/
+ @SuppressWarnings("deprecation")
private static void writeSqlConnectorConfiguration(BinaryRawWriter w, SqlConnectorConfiguration cfg) {
assert w != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
index 181ddce..7ec9587 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
@@ -25,8 +25,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.SqlConnectorConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
@@ -72,7 +72,7 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest {
cfg.setClientFailureDetectionTimeout(200000);
cfg.setClientMode(!igniteInstanceName.equals(getTestIgniteInstanceName(0)));
- cfg.setSqlConnectorConfiguration(new SqlConnectorConfiguration().setPortRange(1000));
+ cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setPortRange(1000));
CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES];
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
index ae3f592..cabeb49 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
@@ -161,7 +161,6 @@ public class OdbcConfigurationValidationSelfTest extends GridCommonAbstractTest
NODE_IDX_GEN.incrementAndGet());
cfg.setLocalHost("127.0.0.1");
- cfg.setSqlConnectorConfiguration(null);
cfg.setOdbcConfiguration(odbcCfg);
cfg.setMarshaller(new BinaryMarshaller());
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java
new file mode 100644
index 0000000..2044949
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java
@@ -0,0 +1,241 @@
+/*
+ * 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.internal.processors.client;
+
+import junit.framework.TestCase;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Client connector configuration validation tests.
+ */
+@SuppressWarnings("deprecation")
+public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAbstractTest {
+ /** Node index generator. */
+ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger();
+
+ /** Cache name. */
+ private static final String CACHE_NAME = "CACHE";
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Test host.
+ *
+ * @throws Exception If failed.
+ */
+ public void testDefault() throws Exception {
+ check(new ClientConnectorConfiguration(), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+ }
+
+ /**
+ * Test host.
+ *
+ * @throws Exception If failed.
+ */
+ public void testHost() throws Exception {
+ check(new ClientConnectorConfiguration().setHost("126.0.0.1"), false);
+
+ check(new ClientConnectorConfiguration().setHost("127.0.0.1"), true);
+ assertJdbc("127.0.0.1", ClientConnectorConfiguration.DFLT_PORT);
+
+ check(new ClientConnectorConfiguration().setHost("0.0.0.0"), true);
+ assertJdbc("0.0.0.0", ClientConnectorConfiguration.DFLT_PORT + 1);
+
+ }
+
+ /**
+ * Test port.
+ *
+ * @throws Exception If failed.
+ */
+ public void testPort() throws Exception {
+ check(new ClientConnectorConfiguration().setPort(-1), false);
+ check(new ClientConnectorConfiguration().setPort(0), false);
+ check(new ClientConnectorConfiguration().setPort(512), false);
+ check(new ClientConnectorConfiguration().setPort(65536), false);
+
+ check(new ClientConnectorConfiguration().setPort(ClientConnectorConfiguration.DFLT_PORT), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+
+ check(new ClientConnectorConfiguration().setPort(ClientConnectorConfiguration.DFLT_PORT + 200), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT + 200);
+ }
+
+
+ /**
+ * Test port.
+ *
+ * @throws Exception If failed.
+ */
+ public void testPortRange() throws Exception {
+ check(new ClientConnectorConfiguration().setPortRange(-1), false);
+
+ check(new ClientConnectorConfiguration().setPortRange(0), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+
+ check(new ClientConnectorConfiguration().setPortRange(10), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT + 1);
+ }
+
+ /**
+ * Test socket buffers.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSocketBuffers() throws Exception {
+ check(new ClientConnectorConfiguration().setSocketSendBufferSize(-4 * 1024), false);
+ check(new ClientConnectorConfiguration().setSocketReceiveBufferSize(-4 * 1024), false);
+
+ check(new ClientConnectorConfiguration().setSocketSendBufferSize(4 * 1024), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+
+ check(new ClientConnectorConfiguration().setSocketReceiveBufferSize(4 * 1024), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT + 1);
+ }
+
+ /**
+ * Test max open cursors per connection.
+ *
+ * @throws Exception If failed.
+ */
+ public void testMaxOpenCusrorsPerConnection() throws Exception {
+ check(new ClientConnectorConfiguration().setMaxOpenCursorsPerConnection(-1), false);
+
+ check(new ClientConnectorConfiguration().setMaxOpenCursorsPerConnection(0), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+
+ check(new ClientConnectorConfiguration().setMaxOpenCursorsPerConnection(100), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT + 1);
+ }
+
+ /**
+ * Test thread pool size.
+ *
+ * @throws Exception If failed.
+ */
+ public void testThreadPoolSize() throws Exception {
+ check(new ClientConnectorConfiguration().setThreadPoolSize(0), false);
+ check(new ClientConnectorConfiguration().setThreadPoolSize(-1), false);
+
+ check(new ClientConnectorConfiguration().setThreadPoolSize(4), true);
+ assertJdbc(null, ClientConnectorConfiguration.DFLT_PORT);
+ }
+
+ /**
+ * Perform check.
+ *
+ * @param sqlCfg SQL configuration.
+ * @param success Success flag. * @throws Exception If failed.
+ */
+ @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"})
+ private void check(ClientConnectorConfiguration sqlCfg, boolean success) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration();
+
+ cfg.setIgniteInstanceName(ClientConnectorConfigurationValidationSelfTest.class.getName() + "-" +
+ NODE_IDX_GEN.incrementAndGet());
+
+ cfg.setLocalHost("127.0.0.1");
+ cfg.setClientConnectorConfiguration(sqlCfg);
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+ spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+ cfg.setDiscoverySpi(spi);
+
+ CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME)
+ .setIndexedTypes(SqlConnectorKey.class, SqlConnectorValue.class);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ if (success)
+ startGrid(cfg.getIgniteInstanceName(), cfg);
+ else {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ startGrid(cfg.getIgniteInstanceName(), cfg);
+
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
+ }
+
+ /**
+ * Make sure that JDBC connection is possible at the given host and port.
+ *
+ * @param host Host.
+ * @param port Port.
+ * @throws Exception If failed.
+ */
+ private void assertJdbc(@Nullable String host, int port) throws Exception {
+ if (host == null)
+ host = "127.0.0.1";
+
+ String connStr = "jdbc:ignite:thin://" + host + ":" + port;
+
+ try (Connection conn = DriverManager.getConnection(connStr)) {
+ conn.setSchema(CACHE_NAME);
+
+ try (Statement stmt = conn.createStatement()) {
+ ResultSet rs = stmt.executeQuery("SELECT 1");
+
+ assertTrue(rs.next());
+
+ TestCase.assertEquals(1, rs.getInt(1));
+ }
+ }
+ }
+
+ /**
+ * Key class.
+ */
+ private static class SqlConnectorKey {
+ @QuerySqlField
+ public int key;
+ }
+
+ /**
+ * Value class.
+ */
+ private static class SqlConnectorValue {
+ @QuerySqlField
+ public int val;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java
index da46b70..4d1b333 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java
@@ -38,8 +38,9 @@ import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
/**
- * ODBC configuration validation tests.
+ * SQL connector configuration validation tests.
*/
+@SuppressWarnings("deprecation")
public class SqlConnectorConfigurationValidationSelfTest extends GridCommonAbstractTest {
/** Node index generator. */
private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index e5e37cc..076468b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -122,6 +122,7 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransform
import org.apache.ignite.internal.processors.cache.query.IgniteCacheQueryCacheDestroySelfTest;
import org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest;
+import org.apache.ignite.internal.processors.client.ClientConnectorConfigurationValidationSelfTest;
import org.apache.ignite.internal.processors.query.h2.IgniteSqlBigIntegerKeyTest;
import org.apache.ignite.internal.processors.query.IgniteQueryDedicatedPoolTest;
import org.apache.ignite.internal.processors.query.IgniteSqlEntryCacheModeAgnosticTest;
@@ -157,6 +158,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite");
suite.addTestSuite(SqlConnectorConfigurationValidationSelfTest.class);
+ suite.addTestSuite(ClientConnectorConfigurationValidationSelfTest.class);
suite.addTestSuite(SqlSchemaSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-default.xml b/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
index 2e7f374..22524d2 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
@@ -28,8 +28,8 @@
<import resource="queries-default.xml"/>
<bean abstract="true" id="queries.cfg" parent="ignite.cfg">
- <property name="sqlConnectorConfiguration">
- <bean class="org.apache.ignite.configuration.SqlConnectorConfiguration">
+ <property name="clientConnectorConfiguration">
+ <bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
<property name="host" value="127.0.0.1"/>
<property name="port" value="11110"/>
<property name="portRange" value="0"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
index 568f685..b98d668 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
@@ -28,7 +28,7 @@
<import resource="queries-default.xml"/>
<bean parent="ignite.cfg">
- <property name="sqlConnectorConfiguration">
+ <property name="clientConnectorConfiguration">
<null/>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
index 5cc6044..29fee23 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
@@ -28,7 +28,7 @@
<import resource="queries-default.xml"/>
<bean parent="ignite.cfg">
- <property name="sqlConnectorConfiguration">
+ <property name="clientConnectorConfiguration">
<null/>
</property>
</bean>
[24/26] ignite git commit: IGNITE-6417 Fixed missed binary
configuration.
Posted by sb...@apache.org.
IGNITE-6417 Fixed missed binary configuration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/40597a03
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/40597a03
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/40597a03
Branch: refs/heads/ignite-6149
Commit: 40597a030b95d3d678d858237054e4af2637d267
Parents: 7c4d0bc
Author: vsisko <vs...@gridgain.com>
Authored: Mon Sep 18 14:09:22 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Sep 18 14:09:22 2017 +0700
----------------------------------------------------------------------
.../apache/ignite/internal/visor/node/VisorGridConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/40597a03/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index 180a729..a716a76 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@ -165,7 +165,7 @@ public class VisorGridConfiguration extends VisorDataTransferObject {
BinaryConfiguration bc = c.getBinaryConfiguration();
if (bc != null)
- binaryCfg = new VisorBinaryConfiguration();
+ binaryCfg = new VisorBinaryConfiguration(bc);
cacheKeyCfgs = VisorCacheKeyConfiguration.list(c.getCacheKeyConfiguration());
[13/26] ignite git commit: IGNITE-6256: DiscoCache always contains
local node.
Posted by sb...@apache.org.
IGNITE-6256: DiscoCache always contains local node.
Signed-off-by: Andrey Gura <ag...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4a88ec3e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4a88ec3e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4a88ec3e
Branch: refs/heads/ignite-6149
Commit: 4a88ec3ec2a6a5d5004187a3424f5832217fda9c
Parents: fe06b59
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Fri Sep 15 16:45:02 2017 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Fri Sep 15 16:49:07 2017 +0300
----------------------------------------------------------------------
.../managers/discovery/GridDiscoveryManager.java | 12 +++++++-----
.../apache/ignite/spi/discovery/tcp/ServerImpl.java | 14 +++++++-------
2 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a88ec3e/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index fa5d053..eefec08 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -775,7 +775,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
topHist.clear();
topSnap.set(new Snapshot(AffinityTopologyVersion.ZERO,
- createDiscoCache(AffinityTopologyVersion.ZERO, ctx.state().clusterState(), locNode, Collections.<ClusterNode>emptySet())));
+ createDiscoCache(AffinityTopologyVersion.ZERO, ctx.state().clusterState(), locNode, Collections.<ClusterNode>singleton(locNode))));
}
else if (type == EVT_CLIENT_NODE_RECONNECTED) {
assert locNode.isClient() : locNode;
@@ -2189,6 +2189,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
DiscoveryDataClusterState state,
ClusterNode loc,
Collection<ClusterNode> topSnapshot) {
+ assert topSnapshot.contains(loc);
+
HashSet<UUID> alives = U.newHashSet(topSnapshot.size());
HashMap<UUID, ClusterNode> nodeMap = U.newHashMap(topSnapshot.size());
@@ -2390,15 +2392,15 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
lastChk = now;
if (!segValid) {
- List<ClusterNode> empty = Collections.emptyList();
-
ClusterNode node = getSpi().getLocalNode();
+ Collection<ClusterNode> locNodeOnlyTop = Collections.singleton(node);
+
discoWrk.addEvent(EVT_NODE_SEGMENTED,
AffinityTopologyVersion.NONE,
node,
- createDiscoCache(AffinityTopologyVersion.NONE, null, node, empty),
- empty,
+ createDiscoCache(AffinityTopologyVersion.NONE, null, node, locNodeOnlyTop),
+ locNodeOnlyTop,
null);
lastSegChkRes.set(false);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a88ec3e/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c227bf7..9433ffb 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -465,7 +465,6 @@ class ServerImpl extends TcpDiscoveryImpl {
U.interrupt(statsPrinter);
U.join(statsPrinter, log);
- Collection<TcpDiscoveryNode> rmts = null;
Collection<TcpDiscoveryNode> nodes = null;
if (!disconnect)
@@ -474,22 +473,23 @@ class ServerImpl extends TcpDiscoveryImpl {
spi.getSpiContext().deregisterPorts();
nodes = ring.visibleNodes();
- rmts = F.view(nodes, F.remoteNodes(locNode.id()));
}
long topVer = ring.topologyVersion();
ring.clear();
- if (rmts != null && !rmts.isEmpty()) {
- // This is restart/disconnection and remote nodes are not empty.
- // We need to fire FAIL event for each.
+ if (nodes != null) {
+ // This is restart/disconnection and we need to fire FAIL event for each remote node.
DiscoverySpiListener lsnr = spi.lsnr;
if (lsnr != null) {
- Collection<ClusterNode> processed = new HashSet<>();
+ Collection<ClusterNode> processed = new HashSet<>(nodes.size());
+
+ for (TcpDiscoveryNode n : nodes) {
+ if(n.isLocal())
+ continue;
- for (TcpDiscoveryNode n : rmts) {
assert n.visible();
processed.add(n);
[20/26] ignite git commit: IGNITE-6327: Added thin client
configuration. This closes #2672.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java
deleted file mode 100644
index 3438d5a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-
-/**
- * SQL listener connection context.
- */
-public interface SqlListenerConnectionContext {
- /**
- * @param ver Version to check.
- * @return {@code true} if version is supported.
- */
- boolean isVersionSupported(SqlListenerProtocolVersion ver);
-
- /**
- * @return Current context version.
- */
- SqlListenerProtocolVersion currentVersion();
-
- /**
- * Initialize from handshake message.
- *
- * @param ver Protocol version.
- * @param reader Reader set to the configuration part of the handshake message.
- */
- void initializeFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader);
-
- /**
- * Handler getter.
- * @return Request handler for the connection.
- */
- SqlListenerRequestHandler handler();
-
- /**
- * Parser getter
- * @return Message parser for the connection.
- */
- SqlListenerMessageParser parser();
-
- /**
- * Called whenever client is disconnected due to correct connection close
- * or due to {@code IOException} during network operations.
- */
- void onDisconnected();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerMessageParser.java
deleted file mode 100644
index c59ea54..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerMessageParser.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-/**
- * SQL listener message parser.
- */
-public interface SqlListenerMessageParser {
- /**
- * Decode request from byte array.
- *
- * @param msg Message.
- * @return Request.
- */
- public SqlListenerRequest decode(byte[] msg);
-
- /**
- * Encode response to byte array.
- *
- * @param resp Response.
- * @return Message.
- */
- public byte[] encode(SqlListenerResponse resp);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
deleted file mode 100644
index 81539dc..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext;
-import org.apache.ignite.internal.processors.odbc.odbc.OdbcConnectionContext;
-import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
-import org.apache.ignite.internal.processors.platform.client.ClientMessageParser;
-import org.apache.ignite.internal.processors.platform.client.ClientRequestHandler;
-import org.apache.ignite.internal.util.GridSpinBusyLock;
-import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * SQL message listener.
- */
-public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]> {
- /** ODBC driver handshake code. */
- public static final byte ODBC_CLIENT = 0;
-
- /** JDBC driver handshake code. */
- public static final byte JDBC_CLIENT = 1;
-
- /** Thin client handshake code. */
- public static final byte THIN_CLIENT = 2;
-
- /** Connection-related metadata key. */
- private static final int CONN_CTX_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
-
- /** Busy lock. */
- private final GridSpinBusyLock busyLock;
-
- /** Kernal context. */
- private final GridKernalContext ctx;
-
- /** Maximum allowed cursors. */
- private final int maxCursors;
-
- /** Logger. */
- private final IgniteLogger log;
-
- /**
- * Constructor.
- *
- * @param ctx Context.
- * @param busyLock Shutdown busy lock.
- * @param maxCursors Maximum allowed cursors.
- */
- public SqlListenerNioListener(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors) {
- this.ctx = ctx;
- this.busyLock = busyLock;
- this.maxCursors = maxCursors;
-
- log = ctx.log(getClass());
- }
-
- /** {@inheritDoc} */
- @Override public void onConnected(GridNioSession ses) {
- if (log.isDebugEnabled())
- log.debug("SQL client connected: " + ses.remoteAddress());
- }
-
- /** {@inheritDoc} */
- @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
- SqlListenerConnectionContext connCtx = ses.meta(CONN_CTX_META_KEY);
-
- if (connCtx != null)
- connCtx.onDisconnected();
-
- if (log.isDebugEnabled()) {
- if (e == null)
- log.debug("SQL client disconnected: " + ses.remoteAddress());
- else
- log.debug("SQL client disconnected due to an error [addr=" + ses.remoteAddress() + ", err=" + e + ']');
- }
- }
-
- /** {@inheritDoc} */
- @Override public void onMessage(GridNioSession ses, byte[] msg) {
- assert msg != null;
-
- SqlListenerConnectionContext connCtx = ses.meta(CONN_CTX_META_KEY);
-
- if (connCtx == null) {
- onHandshake(ses, msg);
-
- return;
- }
-
- SqlListenerMessageParser parser = connCtx.parser();
- SqlListenerRequestHandler handler = connCtx.handler();
-
- SqlListenerRequest req;
-
- try {
- req = parser.decode(msg);
- }
- catch (Exception e) {
- log.error("Failed to parse SQL client request.", e);
-
- ses.close();
-
- return;
- }
-
- assert req != null;
-
- try {
- long startTime = 0;
-
- if (log.isDebugEnabled()) {
- startTime = System.nanoTime();
-
- log.debug("Client request received [reqId=" + req.requestId() + ", addr=" +
- ses.remoteAddress() + ", req=" + req + ']');
- }
-
- SqlListenerResponse resp = handler.handle(req);
-
- if (log.isDebugEnabled()) {
- long dur = (System.nanoTime() - startTime) / 1000;
-
- log.debug("Client request processed [reqId=" + req.requestId() + ", dur(mcs)=" + dur +
- ", resp=" + resp.status() + ']');
- }
-
- byte[] outMsg = parser.encode(resp);
-
- ses.send(outMsg);
- }
- catch (Exception e) {
- log.error("Failed to process client request [req=" + req + ']', e);
-
- ses.send(parser.encode(handler.handleException(e)));
- }
- }
-
- /**
- * Perform handshake.
- *
- * @param ses Session.
- * @param msg Message bytes.
- */
- private void onHandshake(GridNioSession ses, byte[] msg) {
- BinaryInputStream stream = new BinaryHeapInputStream(msg);
-
- BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null, true);
-
- byte cmd = reader.readByte();
-
- if (cmd != SqlListenerRequest.HANDSHAKE) {
- log.error("Unexpected SQL client request (will close session): " + ses.remoteAddress());
-
- ses.close();
-
- return;
- }
-
- short verMajor = reader.readShort();
- short verMinor = reader.readShort();
- short verMaintenance = reader.readShort();
-
- SqlListenerProtocolVersion ver = SqlListenerProtocolVersion.create(verMajor, verMinor, verMaintenance);
-
- byte clientType = reader.readByte();
-
- SqlListenerConnectionContext connCtx = prepareContext(clientType);
-
- String errMsg = null;
-
- if (connCtx.isVersionSupported(ver)) {
- connCtx.initializeFromHandshake(ver, reader);
-
- ses.addMeta(CONN_CTX_META_KEY, connCtx);
- }
- else {
- log.warning("Unsupported version: " + ver.toString());
-
- errMsg = "Unsupported version.";
- }
-
- // Send response.
- BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(8), null, null);
-
- if (errMsg == null)
- connCtx.handler().writeHandshake(writer);
- else {
- SqlListenerProtocolVersion currentVer = connCtx.currentVersion();
-
- // Failed handshake response
- writer.writeBoolean(false);
- writer.writeShort(currentVer.major());
- writer.writeShort(currentVer.minor());
- writer.writeShort(currentVer.maintenance());
- writer.doWriteString(errMsg);
- }
-
- ses.send(writer.array());
- }
-
- /**
- * Prepare context.
- *
- * @param clientType Client type.
- * @return Context.
- */
- private SqlListenerConnectionContext prepareContext(byte clientType) {
- switch (clientType) {
- case ODBC_CLIENT:
- return new OdbcConnectionContext(ctx, busyLock, maxCursors);
-
- case JDBC_CLIENT:
- return new JdbcConnectionContext(ctx, busyLock, maxCursors);
-
- case THIN_CLIENT:
- return new ClientConnectionContext(ctx);
-
- default:
- throw new IgniteException("Unknown client type: " + clientType);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
deleted file mode 100644
index cf8a0ad..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioServerBuffer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.jetbrains.annotations.Nullable;
-
-import java.nio.ByteBuffer;
-
-/**
- * NIO server buffer.
- */
-public class SqlListenerNioServerBuffer {
- /** Current message data. */
- private byte[] data;
-
- /** Count of received bytes of the current message. */
- private int cnt = -4;
-
- /** Current message size. */
- private int msgSize;
-
- /**
- * Reset buffer state.
- */
- public void reset() {
- msgSize = 0;
- cnt = -4;
- data = null;
- }
-
- /**
- * Checks whether the byte array is filled.
- *
- * @return Flag indicating whether byte array is filled or not.
- */
- public boolean isFilled() {
- return cnt > 0 && cnt == msgSize;
- }
-
- /**
- * Get data withing the buffer.
- *
- * @return Data.
- */
- public byte[] data() {
- return data;
- }
-
- /**
- * @param buf Buffer.
- * @return Message bytes or {@code null} if message is not fully read yet.
- * @throws IgniteCheckedException If failed to parse message.
- */
- @Nullable public byte[] read(ByteBuffer buf) throws IgniteCheckedException {
- if (cnt < 0) {
- for (; cnt < 0 && buf.hasRemaining(); cnt++)
- msgSize |= (buf.get() & 0xFF) << (8*(4 + cnt));
-
- if (cnt < 0)
- return null;
-
- // If count is 0 then message size should be inited.
- if (msgSize <= 0)
- throw new IgniteCheckedException("Invalid message size: " + msgSize);
-
- data = new byte[msgSize];
- }
-
- assert msgSize > 0;
- assert cnt >= 0;
-
- int remaining = buf.remaining();
-
- // If there are more bytes in buffer.
- if (remaining > 0) {
- int missing = msgSize - cnt;
-
- // Read only up to message size.
- if (missing > 0) {
- int len = missing < remaining ? missing : remaining;
-
- buf.get(data, cnt, len);
-
- cnt += len;
- }
- }
-
- if (cnt == msgSize) {
- byte[] data0 = data;
-
- reset();
-
- return data0;
- }
- else
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
deleted file mode 100644
index 1b364b1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import java.net.InetAddress;
-import java.nio.ByteOrder;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
-import org.apache.ignite.configuration.SqlConnectorConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.GridProcessorAdapter;
-import org.apache.ignite.internal.util.GridSpinBusyLock;
-import org.apache.ignite.internal.util.HostAndPortRange;
-import org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter;
-import org.apache.ignite.internal.util.nio.GridNioCodecFilter;
-import org.apache.ignite.internal.util.nio.GridNioFilter;
-import org.apache.ignite.internal.util.nio.GridNioServer;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.IgnitePortProtocol;
-import org.apache.ignite.thread.IgniteThreadPoolExecutor;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * SQL processor.
- */
-public class SqlListenerProcessor extends GridProcessorAdapter {
- /** Default number of selectors. */
- private static final int DFLT_SELECTOR_CNT = Math.min(4, Runtime.getRuntime().availableProcessors());
-
- /** Default TCP direct buffer flag. */
- private static final boolean DFLT_TCP_DIRECT_BUF = false;
-
- /** Busy lock. */
- private final GridSpinBusyLock busyLock = new GridSpinBusyLock();
-
- /** TCP Server. */
- private GridNioServer<byte[]> srv;
-
- /** Executor service. */
- private ExecutorService execSvc;
-
- /**
- * @param ctx Kernal context.
- */
- public SqlListenerProcessor(GridKernalContext ctx) {
- super(ctx);
- }
-
- /** {@inheritDoc} */
- @Override public void start() throws IgniteCheckedException {
- IgniteConfiguration cfg = ctx.config();
-
- SqlConnectorConfiguration sqlCfg = prepareConfiguration(cfg);
-
- if (sqlCfg != null) {
- try {
- validateConfiguration(sqlCfg);
-
- // Resolve host.
- String host = sqlCfg.getHost();
-
- if (host == null)
- host = cfg.getLocalHost();
-
- InetAddress hostAddr;
-
- try {
- hostAddr = U.resolveLocalHost(host);
- }
- catch (Exception e) {
- throw new IgniteCheckedException("Failed to resolve SQL connector host: " + host, e);
- }
-
- execSvc = new IgniteThreadPoolExecutor(
- "sql-connector",
- cfg.getIgniteInstanceName(),
- sqlCfg.getThreadPoolSize(),
- sqlCfg.getThreadPoolSize(),
- 0,
- new LinkedBlockingQueue<Runnable>());
-
- Exception lastErr = null;
-
- int portTo = sqlCfg.getPort() + sqlCfg.getPortRange();
-
- if (portTo <= 0) // Handle int overflow.
- portTo = Integer.MAX_VALUE;
-
- for (int port = sqlCfg.getPort(); port <= portTo && port <= 65535; port++) {
- try {
- GridNioFilter[] filters = new GridNioFilter[] {
- new GridNioAsyncNotifyFilter(ctx.igniteInstanceName(), execSvc, log) {
- @Override public void onSessionOpened(GridNioSession ses)
- throws IgniteCheckedException {
- proceedSessionOpened(ses);
- }
- },
- new GridNioCodecFilter(new SqlListenerBufferedParser(), log, false)
- };
-
- int maxOpenCursors = sqlCfg.getMaxOpenCursorsPerConnection();
-
- GridNioServer<byte[]> srv0 = GridNioServer.<byte[]>builder()
- .address(hostAddr)
- .port(port)
- .listener(new SqlListenerNioListener(ctx, busyLock, maxOpenCursors))
- .logger(log)
- .selectorCount(DFLT_SELECTOR_CNT)
- .igniteInstanceName(ctx.igniteInstanceName())
- .serverName("sql-listener")
- .tcpNoDelay(sqlCfg.isTcpNoDelay())
- .directBuffer(DFLT_TCP_DIRECT_BUF)
- .byteOrder(ByteOrder.nativeOrder())
- .socketSendBufferSize(sqlCfg.getSocketSendBufferSize())
- .socketReceiveBufferSize(sqlCfg.getSocketReceiveBufferSize())
- .filters(filters)
- .directMode(false)
- .idleTimeout(Long.MAX_VALUE)
- .build();
-
- srv0.start();
-
- srv = srv0;
-
- ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
-
- if (log.isInfoEnabled())
- log.info("SQL connector processor has started on TCP port " + port);
-
- lastErr = null;
-
- break;
- }
- catch (Exception e) {
- lastErr = e;
- }
- }
-
- assert (srv != null && lastErr == null) || (srv == null && lastErr != null);
-
- if (lastErr != null)
- throw new IgniteCheckedException("Failed to bind to any [host:port] from the range [" +
- "host=" + host + ", portFrom=" + sqlCfg.getPort() + ", portTo=" + portTo +
- ", lastErr=" + lastErr + ']');
- }
- catch (Exception e) {
- throw new IgniteCheckedException("Failed to start SQL connector processor.", e);
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override public void onKernalStop(boolean cancel) {
- if (srv != null) {
- busyLock.block();
-
- srv.stop();
-
- ctx.ports().deregisterPorts(getClass());
-
- if (execSvc != null) {
- U.shutdownNow(getClass(), execSvc, log);
-
- execSvc = null;
- }
-
- if (log.isDebugEnabled())
- log.debug("SQL connector processor stopped.");
- }
- }
-
- /**
- * Prepare connector configuration.
- *
- * @param cfg Ignote configuration.
- * @return Connector configuration.
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings("deprecation")
- @Nullable private SqlConnectorConfiguration prepareConfiguration(IgniteConfiguration cfg)
- throws IgniteCheckedException {
- SqlConnectorConfiguration res = cfg.getSqlConnectorConfiguration();
-
- OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration();
-
- if (odbcCfg != null) {
- if (res == null) {
- // SQL connector is either default or null, so we replace it with ODBC stuff.
- HostAndPortRange hostAndPort = parseOdbcEndpoint(odbcCfg);
-
- res = new SqlConnectorConfiguration();
-
- res.setHost(hostAndPort.host());
- res.setPort(hostAndPort.portFrom());
- res.setPortRange(hostAndPort.portTo() - hostAndPort.portFrom());
- res.setThreadPoolSize(odbcCfg.getThreadPoolSize());
- res.setSocketSendBufferSize(odbcCfg.getSocketSendBufferSize());
- res.setSocketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize());
- res.setMaxOpenCursorsPerConnection(odbcCfg.getMaxOpenCursors());
-
- U.warn(log, "Automatically converted deprecated ODBC configuration to SQL connector configuration: " +
- res);
- }
- else {
- // Non-default SQL connector is set, ignore ODBC.
- U.warn(log, "Deprecated ODBC configuration will be ignored because SQL connector configuration is " +
- "set (either migrate to new SqlConnectorConfiguration or set " +
- "IgniteConfiguration.sqlConnectorConfiguration to null explicitly).");
- }
- }
-
- return res;
- }
-
- /**
- * Validate SQL connector configuration.
- *
- * @param cfg Configuration.
- * @throws IgniteCheckedException If failed.
- */
- private void validateConfiguration(SqlConnectorConfiguration cfg) throws IgniteCheckedException {
- assertParameter(cfg.getPort() > 1024, "port > 1024");
- assertParameter(cfg.getPort() <= 65535, "port <= 65535");
- assertParameter(cfg.getPortRange() >= 0, "portRange > 0");
- assertParameter(cfg.getSocketSendBufferSize() >= 0, "socketSendBufferSize > 0");
- assertParameter(cfg.getSocketReceiveBufferSize() >= 0, "socketReceiveBufferSize > 0");
- assertParameter(cfg.getMaxOpenCursorsPerConnection() >= 0, "maxOpenCursorsPerConnection() >= 0");
- assertParameter(cfg.getThreadPoolSize() > 0, "threadPoolSize > 0");
- }
-
- /**
- * Parse ODBC endpoint.
- *
- * @param odbcCfg ODBC configuration.
- * @return ODBC host and port range.
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings("deprecation")
- private HostAndPortRange parseOdbcEndpoint(OdbcConfiguration odbcCfg) throws IgniteCheckedException {
- HostAndPortRange res;
-
- if (F.isEmpty(odbcCfg.getEndpointAddress())) {
- res = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST,
- OdbcConfiguration.DFLT_TCP_PORT_FROM,
- OdbcConfiguration.DFLT_TCP_PORT_TO
- );
- }
- else {
- res = HostAndPortRange.parse(odbcCfg.getEndpointAddress(),
- OdbcConfiguration.DFLT_TCP_PORT_FROM,
- OdbcConfiguration.DFLT_TCP_PORT_TO,
- "Failed to parse SQL connector endpoint address"
- );
- }
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
deleted file mode 100644
index 690822b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProtocolVersion.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * SQL listener protocol version.
- */
-public class SqlListenerProtocolVersion implements Comparable<SqlListenerProtocolVersion> {
- /** Major part. */
- private final short major;
-
- /** Minor part. */
- private final short minor;
-
- /** Maintenance part. */
- private final short maintenance;
-
- /**
- * Create version.
- *
- * @param major Major part.
- * @param minor Minor part.
- * @param maintenance Maintenance part.
- * @return Version.
- */
- public static SqlListenerProtocolVersion create(int major, int minor, int maintenance) {
- return new SqlListenerProtocolVersion((short)major, (short)minor, (short)maintenance);
- }
-
- /**
- * Constructor.
- *
- * @param major Major part.
- * @param minor Minor part.
- * @param maintenance Maintenance part.
- */
- private SqlListenerProtocolVersion(short major, short minor, short maintenance) {
- this.major = major;
- this.minor = minor;
- this.maintenance = maintenance;
- }
-
- /**
- * @return Major part.
- */
- public short major() {
- return major;
- }
-
- /**
- * @return Minor part.
- */
- public short minor() {
- return minor;
- }
-
- /**
- * @return Maintenance part.
- */
- public short maintenance() {
- return maintenance;
- }
-
- /** {@inheritDoc} */
- @Override public int compareTo(@NotNull SqlListenerProtocolVersion other) {
- int res = major - other.major;
-
- if (res == 0)
- res = minor - other.minor;
-
- if (res == 0)
- res = maintenance - other.maintenance;
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return 31 * (31 * major + minor) + maintenance;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- if (obj != null && obj instanceof SqlListenerProtocolVersion) {
- SqlListenerProtocolVersion other = (SqlListenerProtocolVersion)obj;
-
- return F.eq(major, other.major) && F.eq(minor, other.minor) && F.eq(maintenance, other.maintenance);
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SqlListenerProtocolVersion.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
deleted file mode 100644
index 5b1c5fb..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-/**
- * SQL listener command request.
- */
-public interface SqlListenerRequest {
- /** Handshake request. */
- public static final int HANDSHAKE = 1;
-
- /**
- * @return Request ID.
- */
- public long requestId();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
deleted file mode 100644
index 348054f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-
-/**
- * SQL listener request handler.
- */
-public interface SqlListenerRequestHandler {
- /**
- * Handle request.
- *
- * @param req Request.
- * @return Response.
- */
- public SqlListenerResponse handle(SqlListenerRequest req);
-
- /**
- * Handle exception.
- *
- * @param e Exception.
- * @return Error response.
- */
- public SqlListenerResponse handleException(Exception e);
-
- /**
- * Write successful handshake response.
- *
- * @param writer Binary writer.
- */
- public void writeHandshake(BinaryWriterExImpl writer);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestNoId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestNoId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestNoId.java
deleted file mode 100644
index 68dbc5c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerRequestNoId.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-/**
- * Client request with no ID.
- */
-public abstract class SqlListenerRequestNoId implements SqlListenerRequest {
- /** {@inheritDoc} */
- @Override public long requestId() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerResponse.java
deleted file mode 100644
index e35d8f2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerResponse.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.internal.processors.odbc;
-
-import org.jetbrains.annotations.Nullable;
-
-/**
- * SQL listener response.
- */
-public abstract class SqlListenerResponse {
- /** Command succeeded. */
- public static final int STATUS_SUCCESS = 0;
-
- /** Command failed. */
- public static final int STATUS_FAILED = 1;
-
- /** Success status. */
- private int status;
-
- /** Error. */
- private String err;
-
- /**
- * Constructs failed rest response.
- *
- * @param status Response status.
- * @param err Error, {@code null} if success is {@code true}.
- */
- public SqlListenerResponse(int status, @Nullable String err) {
- this.status = status;
- this.err = err;
- }
-
- /**
- * @return Success flag.
- */
- public int status() {
- return status;
- }
-
- /**
- * @param status Status.
- */
- public void status(int status) {
- this.status = status;
- }
-
- /**
- * @return Error.
- */
- public String error() {
- return err;
- }
-
- /**
- * @param err Error message.
- */
- public void error(String err) {
- this.err = err;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
index 1f13fcf..12be361 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
@@ -21,27 +21,27 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerConnectionContext;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerConnectionContext;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
import org.apache.ignite.internal.util.GridSpinBusyLock;
/**
* ODBC Connection Context.
*/
-public class JdbcConnectionContext implements SqlListenerConnectionContext {
+public class JdbcConnectionContext implements ClientListenerConnectionContext {
/** Version 2.1.0. */
- private static final SqlListenerProtocolVersion VER_2_1_0 = SqlListenerProtocolVersion.create(2, 1, 0);
+ private static final ClientListenerProtocolVersion VER_2_1_0 = ClientListenerProtocolVersion.create(2, 1, 0);
/** Version 2.1.5: added "lazy" flag. */
- private static final SqlListenerProtocolVersion VER_2_1_5 = SqlListenerProtocolVersion.create(2, 1, 5);
+ private static final ClientListenerProtocolVersion VER_2_1_5 = ClientListenerProtocolVersion.create(2, 1, 5);
/** Current version. */
- private static final SqlListenerProtocolVersion CURRENT_VER = VER_2_1_5;
+ private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_1_5;
/** Supported versions. */
- private static final Set<SqlListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
+ private static final Set<ClientListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
/** Context. */
private final GridKernalContext ctx;
@@ -76,17 +76,17 @@ public class JdbcConnectionContext implements SqlListenerConnectionContext {
}
/** {@inheritDoc} */
- @Override public boolean isVersionSupported(SqlListenerProtocolVersion ver) {
+ @Override public boolean isVersionSupported(ClientListenerProtocolVersion ver) {
return SUPPORTED_VERS.contains(ver);
}
/** {@inheritDoc} */
- @Override public SqlListenerProtocolVersion currentVersion() {
+ @Override public ClientListenerProtocolVersion currentVersion() {
return CURRENT_VER;
}
/** {@inheritDoc} */
- @Override public void initializeFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) {
+ @Override public void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) {
assert SUPPORTED_VERS.contains(ver): "Unsupported JDBC protocol version.";
boolean distributedJoins = reader.readBoolean();
@@ -107,12 +107,12 @@ public class JdbcConnectionContext implements SqlListenerConnectionContext {
}
/** {@inheritDoc} */
- @Override public SqlListenerRequestHandler handler() {
+ @Override public ClientListenerRequestHandler handler() {
return handler;
}
/** {@inheritDoc} */
- @Override public SqlListenerMessageParser parser() {
+ @Override public ClientListenerMessageParser parser() {
return parser;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMessageParser.java
index 0f8a3ef..7a9c2ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMessageParser.java
@@ -23,14 +23,14 @@ import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
/**
* JDBC message parser.
*/
-public class JdbcMessageParser implements SqlListenerMessageParser {
+public class JdbcMessageParser implements ClientListenerMessageParser {
/** Kernal context. */
private final GridKernalContext ctx;
@@ -63,7 +63,7 @@ public class JdbcMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public SqlListenerRequest decode(byte[] msg) {
+ @Override public ClientListenerRequest decode(byte[] msg) {
assert msg != null;
BinaryReaderExImpl reader = createReader(msg);
@@ -72,7 +72,7 @@ public class JdbcMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public byte[] encode(SqlListenerResponse msg) {
+ @Override public byte[] encode(ClientListenerResponse msg) {
assert msg != null;
assert msg instanceof JdbcResponse;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequest.java
index ab97dc5..385924c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequest.java
@@ -21,12 +21,12 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestNoId;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestNoId;
/**
* JDBC request.
*/
-public class JdbcRequest extends SqlListenerRequestNoId implements JdbcRawBinarylizable {
+public class JdbcRequest extends ClientListenerRequestNoId implements JdbcRawBinarylizable {
/** Execute sql query request. */
static final byte QRY_EXEC = 2;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
index 378c6cb..4250ba5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
@@ -36,9 +36,9 @@ import org.apache.ignite.internal.IgniteVersionUtils;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.jdbc2.JdbcSqlFieldsQuery;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.odbc.OdbcQueryGetColumnsMetaRequest;
import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
@@ -63,7 +63,7 @@ import static org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequest.QRY_ME
/**
* JDBC request handler.
*/
-public class JdbcRequestHandler implements SqlListenerRequestHandler {
+public class JdbcRequestHandler implements ClientListenerRequestHandler {
/** Query ID sequence. */
private static final AtomicLong QRY_ID_GEN = new AtomicLong();
@@ -130,7 +130,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handle(SqlListenerRequest req0) {
+ @Override public ClientListenerResponse handle(ClientListenerRequest req0) {
assert req0 != null;
assert req0 instanceof JdbcRequest;
@@ -138,7 +138,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
JdbcRequest req = (JdbcRequest)req0;
if (!busyLock.enterBusy())
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to handle JDBC request because node is stopping.");
try {
@@ -177,7 +177,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
return getSchemas((JdbcMetaSchemasRequest)req);
}
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, "Unsupported JDBC request [req=" + req + ']');
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, "Unsupported JDBC request [req=" + req + ']');
}
finally {
busyLock.leaveBusy();
@@ -185,8 +185,8 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handleException(Exception e) {
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ @Override public ClientListenerResponse handleException(Exception e) {
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
/** {@inheritDoc} */
@@ -232,7 +232,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
int cursorCnt = qryCursors.size();
if (maxCursors > 0 && cursorCnt >= maxCursors)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, "Too many opened cursors (either close other " +
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, "Too many opened cursors (either close other " +
"opened cursors or increase the limit through OdbcConfiguration.setMaxOpenCursors()) " +
"[maximum=" + maxCursors + ", current=" + cursorCnt + ']');
@@ -269,7 +269,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
qry.setLazy(lazy);
if (req.pageSize() <= 0)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Invalid fetch size : [fetchSize=" + req.pageSize() + ']');
qry.setPageSize(req.pageSize());
@@ -312,7 +312,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
U.error(log, "Failed to execute SQL query [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -327,7 +327,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.remove(req.queryId());
if (cur == null)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to find query cursor with ID: " + req.queryId());
cur.close();
@@ -339,7 +339,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
U.error(log, "Failed to close SQL query [reqId=" + req.requestId() + ", req=" + req.queryId() + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -354,11 +354,11 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.get(req.queryId());
if (cur == null)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to find query cursor with ID: " + req.queryId());
if (req.pageSize() <= 0)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Invalid fetch size : [fetchSize=" + req.pageSize() + ']');
cur.pageSize(req.pageSize());
@@ -376,7 +376,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to fetch SQL query result [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -389,7 +389,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
JdbcQueryCursor cur = qryCursors.get(req.queryId());
if (cur == null)
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to find query with ID: " + req.queryId());
JdbcQueryMetadataResult res = new JdbcQueryMetadataResult(req.queryId(),
@@ -400,7 +400,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to fetch SQL query result [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -408,7 +408,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Request.
* @return Response.
*/
- private SqlListenerResponse executeBatch(JdbcBatchExecuteRequest req) {
+ private ClientListenerResponse executeBatch(JdbcBatchExecuteRequest req) {
String schemaName = req.schemaName();
if (F.isEmpty(schemaName))
@@ -446,13 +446,13 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
updCnts[successQueries++] = ((Long)items.get(0).get(0)).intValue();
}
- return new JdbcResponse(new JdbcBatchExecuteResult(updCnts, SqlListenerResponse.STATUS_SUCCESS, null));
+ return new JdbcResponse(new JdbcBatchExecuteResult(updCnts, ClientListenerResponse.STATUS_SUCCESS, null));
}
catch (Exception e) {
U.error(log, "Failed to execute batch query [reqId=" + req.requestId() + ", req=" + req + ']', e);
return new JdbcResponse(new JdbcBatchExecuteResult(Arrays.copyOf(updCnts, successQueries),
- SqlListenerResponse.STATUS_FAILED, e.toString()));
+ ClientListenerResponse.STATUS_FAILED, e.toString()));
}
}
@@ -486,7 +486,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get tables metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -528,7 +528,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get columns metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -536,7 +536,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Request.
* @return Response.
*/
- private SqlListenerResponse getIndexesMeta(JdbcMetaIndexesRequest req) {
+ private ClientListenerResponse getIndexesMeta(JdbcMetaIndexesRequest req) {
try {
Collection<JdbcIndexMeta> meta = new HashSet<>();
@@ -558,7 +558,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -566,7 +566,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Request.
* @return Response.
*/
- private SqlListenerResponse getParametersMeta(JdbcMetaParamsRequest req) {
+ private ClientListenerResponse getParametersMeta(JdbcMetaParamsRequest req) {
try {
ParameterMetaData paramMeta = ctx.query().prepareNativeStatement(req.schemaName(), req.sql())
.getParameterMetaData();
@@ -585,7 +585,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -593,7 +593,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Request.
* @return Response.
*/
- private SqlListenerResponse getPrimaryKeys(JdbcMetaPrimaryKeysRequest req) {
+ private ClientListenerResponse getPrimaryKeys(JdbcMetaPrimaryKeysRequest req) {
try {
Collection<JdbcPrimaryKeyMeta> meta = new HashSet<>();
@@ -631,7 +631,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get parameters metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
@@ -639,7 +639,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Request.
* @return Response.
*/
- private SqlListenerResponse getSchemas(JdbcMetaSchemasRequest req) {
+ private ClientListenerResponse getSchemas(JdbcMetaSchemasRequest req) {
try {
String schemaPtrn = req.schemaName();
@@ -657,7 +657,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get schemas metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new JdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ return new JdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcResponse.java
index f039db7..91f26d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcResponse.java
@@ -20,7 +20,7 @@ package org.apache.ignite.internal.processors.odbc.jdbc;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
/**
* SQL listener response.
*/
-public class JdbcResponse extends SqlListenerResponse implements JdbcRawBinarylizable {
+public class JdbcResponse extends ClientListenerResponse implements JdbcRawBinarylizable {
/** Response object. */
@GridToStringInclude
private JdbcResult res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java
index 9b7bcbd..f2450e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java
@@ -21,27 +21,27 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerConnectionContext;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerConnectionContext;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
import org.apache.ignite.internal.util.GridSpinBusyLock;
/**
* ODBC Connection Context.
*/
-public class OdbcConnectionContext implements SqlListenerConnectionContext {
+public class OdbcConnectionContext implements ClientListenerConnectionContext {
/** Version 2.1.0. */
- private static final SqlListenerProtocolVersion VER_2_1_0 = SqlListenerProtocolVersion.create(2, 1, 0);
+ private static final ClientListenerProtocolVersion VER_2_1_0 = ClientListenerProtocolVersion.create(2, 1, 0);
/** Version 2.1.5: added "lazy" flag. */
- private static final SqlListenerProtocolVersion VER_2_1_5 = SqlListenerProtocolVersion.create(2, 1, 5);
+ private static final ClientListenerProtocolVersion VER_2_1_5 = ClientListenerProtocolVersion.create(2, 1, 5);
/** Current version. */
- private static final SqlListenerProtocolVersion CURRENT_VER = VER_2_1_5;
+ private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_1_5;
/** Supported versions. */
- private static final Set<SqlListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
+ private static final Set<ClientListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
/** Context. */
private final GridKernalContext ctx;
@@ -76,17 +76,17 @@ public class OdbcConnectionContext implements SqlListenerConnectionContext {
}
/** {@inheritDoc} */
- @Override public boolean isVersionSupported(SqlListenerProtocolVersion ver) {
+ @Override public boolean isVersionSupported(ClientListenerProtocolVersion ver) {
return SUPPORTED_VERS.contains(ver);
}
/** {@inheritDoc} */
- @Override public SqlListenerProtocolVersion currentVersion() {
+ @Override public ClientListenerProtocolVersion currentVersion() {
return CURRENT_VER;
}
/** {@inheritDoc} */
- @Override public void initializeFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) {
+ @Override public void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) {
assert SUPPORTED_VERS.contains(ver): "Unsupported ODBC protocol version.";
boolean distributedJoins = reader.readBoolean();
@@ -105,12 +105,12 @@ public class OdbcConnectionContext implements SqlListenerConnectionContext {
}
/** {@inheritDoc} */
- @Override public SqlListenerRequestHandler handler() {
+ @Override public ClientListenerRequestHandler handler() {
return handler;
}
/** {@inheritDoc} */
- @Override public SqlListenerMessageParser parser() {
+ @Override public ClientListenerMessageParser parser() {
return parser;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
index e1f3f82..2ab7cee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
@@ -29,16 +29,16 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.SqlListenerUtils;
import org.jetbrains.annotations.NotNull;
/**
* JDBC message parser.
*/
-public class OdbcMessageParser implements SqlListenerMessageParser {
+public class OdbcMessageParser implements ClientListenerMessageParser {
/** Marshaller. */
private final GridBinaryMarshaller marsh;
@@ -71,7 +71,7 @@ public class OdbcMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public SqlListenerRequest decode(byte[] msg) {
+ @Override public ClientListenerRequest decode(byte[] msg) {
assert msg != null;
BinaryInputStream stream = new BinaryHeapInputStream(msg);
@@ -80,7 +80,7 @@ public class OdbcMessageParser implements SqlListenerMessageParser {
byte cmd = reader.readByte();
- SqlListenerRequest res;
+ ClientListenerRequest res;
switch (cmd) {
case OdbcRequest.QRY_EXEC: {
@@ -182,7 +182,7 @@ public class OdbcMessageParser implements SqlListenerMessageParser {
}
/** {@inheritDoc} */
- @Override public byte[] encode(SqlListenerResponse msg0) {
+ @Override public byte[] encode(ClientListenerResponse msg0) {
assert msg0 != null;
assert msg0 instanceof OdbcResponse;
@@ -196,7 +196,7 @@ public class OdbcMessageParser implements SqlListenerMessageParser {
// Writing status.
writer.writeByte((byte) msg.status());
- if (msg.status() != SqlListenerResponse.STATUS_SUCCESS) {
+ if (msg.status() != ClientListenerResponse.STATUS_SUCCESS) {
writer.writeString(msg.error());
return writer.array();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequest.java
index 58ffad6..4b21b79 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequest.java
@@ -17,12 +17,12 @@
package org.apache.ignite.internal.processors.odbc.odbc;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestNoId;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestNoId;
/**
* SQL listener command request.
*/
-public class OdbcRequest extends SqlListenerRequestNoId {
+public class OdbcRequest extends ClientListenerRequestNoId {
/** Execute sql query. */
public static final int QRY_EXEC = 2;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
index 31053c7..b66b1af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
@@ -35,9 +35,9 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.odbc.escape.OdbcEscapeUtils;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
import org.apache.ignite.internal.processors.query.GridQueryIndexing;
@@ -58,7 +58,7 @@ import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.QRY_FE
/**
* SQL query handler.
*/
-public class OdbcRequestHandler implements SqlListenerRequestHandler {
+public class OdbcRequestHandler implements ClientListenerRequestHandler {
/** Query ID sequence. */
private static final AtomicLong QRY_ID_GEN = new AtomicLong();
@@ -119,7 +119,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handle(SqlListenerRequest req0) {
+ @Override public ClientListenerResponse handle(ClientListenerRequest req0) {
assert req0 != null;
OdbcRequest req = (OdbcRequest)req0;
@@ -160,8 +160,8 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
}
/** {@inheritDoc} */
- @Override public SqlListenerResponse handleException(Exception e) {
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, e.toString());
+ @Override public ClientListenerResponse handleException(Exception e) {
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, e.toString());
}
/** {@inheritDoc} */
@@ -215,11 +215,11 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Execute query request.
* @return Response.
*/
- private SqlListenerResponse executeQuery(OdbcQueryExecuteRequest req) {
+ private ClientListenerResponse executeQuery(OdbcQueryExecuteRequest req) {
int cursorCnt = qryCursors.size();
if (maxCursors > 0 && cursorCnt >= maxCursors)
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, "Too many opened cursors (either close other " +
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, "Too many opened cursors (either close other " +
"opened cursors or increase the limit through OdbcConfiguration.setMaxOpenCursors()) " +
"[maximum=" + maxCursors + ", current=" + cursorCnt + ']');
@@ -257,7 +257,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
U.error(log, "Failed to execute SQL query [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
@@ -267,7 +267,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Execute query request.
* @return Response.
*/
- private SqlListenerResponse executeBatchQuery(OdbcQueryExecuteBatchRequest req) {
+ private ClientListenerResponse executeBatchQuery(OdbcQueryExecuteBatchRequest req) {
long rowsAffected = 0;
int currentSet = 0;
@@ -356,14 +356,14 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Execute query request.
* @return Response.
*/
- private SqlListenerResponse closeQuery(OdbcQueryCloseRequest req) {
+ private ClientListenerResponse closeQuery(OdbcQueryCloseRequest req) {
long queryId = req.queryId();
try {
IgniteBiTuple<QueryCursor, Iterator> tuple = qryCursors.get(queryId);
if (tuple == null)
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to find query with ID: " + queryId);
CloseCursor(tuple, queryId);
@@ -377,7 +377,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
U.error(log, "Failed to close SQL query [reqId=" + req.requestId() + ", req=" + queryId + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
@@ -387,13 +387,13 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Execute query request.
* @return Response.
*/
- private SqlListenerResponse fetchQuery(OdbcQueryFetchRequest req) {
+ private ClientListenerResponse fetchQuery(OdbcQueryFetchRequest req) {
try {
long queryId = req.queryId();
IgniteBiTuple<QueryCursor, Iterator> tuple = qryCursors.get(queryId);
if (tuple == null)
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED,
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED,
"Failed to find query with ID: " + queryId);
Iterator iter = tuple.get2();
@@ -426,7 +426,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to fetch SQL query result [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
@@ -436,7 +436,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Get columns metadata request.
* @return Response.
*/
- private SqlListenerResponse getColumnsMeta(OdbcQueryGetColumnsMetaRequest req) {
+ private ClientListenerResponse getColumnsMeta(OdbcQueryGetColumnsMetaRequest req) {
try {
List<OdbcColumnMeta> meta = new ArrayList<>();
@@ -491,7 +491,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get columns metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
@@ -501,7 +501,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Get tables metadata request.
* @return Response.
*/
- private SqlListenerResponse getTablesMeta(OdbcQueryGetTablesMetaRequest req) {
+ private ClientListenerResponse getTablesMeta(OdbcQueryGetTablesMetaRequest req) {
try {
List<OdbcTableMeta> meta = new ArrayList<>();
@@ -539,7 +539,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get tables metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
@@ -549,7 +549,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
* @param req Get params metadata request.
* @return Response.
*/
- private SqlListenerResponse getParamsMeta(OdbcQueryGetParamsMetaRequest req) {
+ private ClientListenerResponse getParamsMeta(OdbcQueryGetParamsMetaRequest req) {
try {
PreparedStatement stmt = ctx.query().getIndexing().prepareNativeStatement(req.schema(), req.query());
@@ -570,7 +570,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler {
catch (Exception e) {
U.error(log, "Failed to get params metadata [reqId=" + req.requestId() + ", req=" + req + ']', e);
- return new OdbcResponse(SqlListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
+ return new OdbcResponse(ClientListenerResponse.STATUS_FAILED, OdbcUtils.retrieveH2ErrorMessage(e));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcResponse.java
index e1b5b30..4e40da3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcResponse.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.odbc.odbc;
-import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
+import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
/**
* SQL listener response.
*/
-public class OdbcResponse extends SqlListenerResponse {
+public class OdbcResponse extends ClientListenerResponse {
/** Response object. */
@GridToStringInclude
private final Object obj;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fd82212/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
index d4ea0be..6a3e98e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
@@ -19,17 +19,17 @@ package org.apache.ignite.internal.processors.platform.client;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
-import org.apache.ignite.internal.processors.odbc.SqlListenerConnectionContext;
-import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion;
-import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
+import org.apache.ignite.internal.processors.odbc.ClientListenerConnectionContext;
+import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion;
+import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
/**
* Thin Client connection context.
*/
-public class ClientConnectionContext implements SqlListenerConnectionContext {
+public class ClientConnectionContext implements ClientListenerConnectionContext {
/** Version 1.0.0. */
- private static final SqlListenerProtocolVersion VER_1_0_0 = SqlListenerProtocolVersion.create(1, 0, 0);
+ private static final ClientListenerProtocolVersion VER_1_0_0 = ClientListenerProtocolVersion.create(1, 0, 0);
/** Message parser. */
private final ClientMessageParser parser;
@@ -50,27 +50,27 @@ public class ClientConnectionContext implements SqlListenerConnectionContext {
}
/** {@inheritDoc} */
- @Override public boolean isVersionSupported(SqlListenerProtocolVersion ver) {
+ @Override public boolean isVersionSupported(ClientListenerProtocolVersion ver) {
return VER_1_0_0.equals(ver);
}
/** {@inheritDoc} */
- @Override public SqlListenerProtocolVersion currentVersion() {
+ @Override public ClientListenerProtocolVersion currentVersion() {
return VER_1_0_0;
}
/** {@inheritDoc} */
- @Override public void initializeFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) {
+ @Override public void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) {
// No-op.
}
/** {@inheritDoc} */
- @Override public SqlListenerRequestHandler handler() {
+ @Override public ClientListenerRequestHandler handler() {
return handler;
}
/** {@inheritDoc} */
- @Override public SqlListenerMessageParser parser() {
+ @Override public ClientListenerMessageParser parser() {
return parser;
}
[12/26] ignite git commit: IGNITE-6394: Fixed creation of off-heap
matrix with size over 2 Gb (int overflow in
DenseOffHeapMatrixStorage.allocateMemory)
Posted by sb...@apache.org.
IGNITE-6394: Fixed creation of off-heap matrix with size over 2 Gb
(int overflow in DenseOffHeapMatrixStorage.allocateMemory)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fe06b598
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fe06b598
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fe06b598
Branch: refs/heads/ignite-6149
Commit: fe06b5983fb7edf7ea36d7881a22ba6d5a97ee00
Parents: 39b9030
Author: YuriBabak <y....@gmail.com>
Authored: Fri Sep 15 16:41:11 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Fri Sep 15 16:41:11 2017 +0300
----------------------------------------------------------------------
.../ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe06b598/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index 6749488..37801d5 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -210,7 +210,7 @@ public class DenseOffHeapMatrixStorage implements MatrixStorage {
/** */
private void allocateMemory(int rows, int cols) {
- ptr = GridUnsafe.allocateMemory(rows * cols * Double.BYTES);
+ ptr = GridUnsafe.allocateMemory((long)rows * cols * Double.BYTES);
ptrInitHash = Long.hashCode(ptr);
}
[03/26] ignite git commit: IGNITE-6277 Added ability to convert WAL
to human readable form - Fixes #2605.
Posted by sb...@apache.org.
IGNITE-6277 Added ability to convert WAL to human readable form - Fixes #2605.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/319aa840
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/319aa840
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/319aa840
Branch: refs/heads/ignite-6149
Commit: 319aa840201f907c0a31fceb17837dfd2ba43fc1
Parents: 91cf66e
Author: EdShangGG <es...@gridgain.com>
Authored: Fri Sep 15 11:59:48 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Sep 15 11:59:48 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/pagemem/PageIdUtils.java | 13 +++
.../pagemem/wal/record/CheckpointRecord.java | 6 ++
.../internal/pagemem/wal/record/DataEntry.java | 1 +
.../internal/pagemem/wal/record/DataRecord.java | 2 +-
.../wal/record/MemoryRecoveryRecord.java | 7 ++
.../pagemem/wal/record/PageSnapshot.java | 23 +++++-
.../internal/pagemem/wal/record/TxRecord.java | 6 ++
.../delta/DataPageInsertFragmentRecord.java | 13 ++-
.../wal/record/delta/DataPageInsertRecord.java | 6 ++
.../wal/record/delta/DataPageRemoveRecord.java | 2 +-
.../delta/DataPageSetFreeListPageRecord.java | 6 ++
.../wal/record/delta/DataPageUpdateRecord.java | 6 ++
.../wal/record/delta/FixCountRecord.java | 9 +++
.../record/delta/FixLeftmostChildRecord.java | 9 +++
.../pagemem/wal/record/delta/FixRemoveId.java | 6 ++
.../wal/record/delta/InitNewPageRecord.java | 2 -
.../wal/record/delta/InnerReplaceRecord.java | 6 ++
.../pagemem/wal/record/delta/InsertRecord.java | 2 +-
.../pagemem/wal/record/delta/MergeRecord.java | 2 +-
.../wal/record/delta/MetaPageAddRootRecord.java | 9 +++
.../wal/record/delta/MetaPageCutRootRecord.java | 6 ++
.../wal/record/delta/MetaPageInitRecord.java | 6 ++
.../delta/MetaPageInitRootInlineRecord.java | 7 +-
.../record/delta/MetaPageInitRootRecord.java | 6 ++
.../delta/MetaPageUpdateLastAllocatedIndex.java | 6 ++
...aPageUpdateLastSuccessfulFullSnapshotId.java | 6 ++
.../MetaPageUpdateLastSuccessfulSnapshotId.java | 6 ++
.../delta/MetaPageUpdateNextSnapshotId.java | 6 ++
.../MetaPageUpdatePartitionDataRecord.java | 2 +-
.../wal/record/delta/NewRootInitRecord.java | 6 ++
.../delta/PageListMetaResetCountRecord.java | 6 ++
.../delta/PagesListInitNewPageRecord.java | 4 +-
.../record/delta/PagesListRemovePageRecord.java | 3 +-
.../record/delta/PagesListSetNextRecord.java | 6 ++
.../delta/PagesListSetPreviousRecord.java | 6 ++
.../record/delta/PartitionDestroyRecord.java | 6 ++
.../record/delta/PartitionMetaStateRecord.java | 6 ++
.../pagemem/wal/record/delta/RecycleRecord.java | 15 ++++
.../pagemem/wal/record/delta/RemoveRecord.java | 2 +-
.../pagemem/wal/record/delta/ReplaceRecord.java | 6 ++
.../record/delta/SplitExistingPageRecord.java | 2 +-
.../record/delta/SplitForwardPageRecord.java | 24 ++++++
.../record/delta/TrackingPageDeltaRecord.java | 14 +++-
.../distributed/dht/GridDhtTxPrepareFuture.java | 3 +-
.../cache/persistence/file/FileIODecorator.java | 1 -
.../freelist/io/PagesListMetaIO.java | 21 +++++
.../freelist/io/PagesListNodeIO.java | 16 ++++
.../cache/persistence/tree/io/BPlusIO.java | 12 +++
.../cache/persistence/tree/io/BPlusMetaIO.java | 12 +++
.../cache/persistence/tree/io/DataPageIO.java | 25 +++++-
.../cache/persistence/tree/io/PageIO.java | 27 +++++++
.../cache/persistence/tree/io/PageMetaIO.java | 14 ++++
.../tree/io/PagePartitionCountersIO.java | 27 +++++++
.../tree/io/PagePartitionMetaIO.java | 19 +++++
.../persistence/tree/io/TrackingPageIO.java | 31 ++++++++
.../wal/FileWriteAheadLogManager.java | 6 ++
.../reader/StandaloneWalRecordsIterator.java | 2 +-
.../persistence/wal/record/HeaderRecord.java | 6 ++
.../wal/serializer/RecordV1Serializer.java | 21 ++++-
.../database/IgniteDbAbstractTest.java | 6 --
modules/dev-utils/pom.xml | 50 ++++++++++++
.../development/utils/IgniteWalConverter.java | 83 ++++++++++++++++++++
pom.xml | 1 +
63 files changed, 643 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
index 6f4ba93..d47f2de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
@@ -200,4 +200,17 @@ public final class PageIdUtils {
public static long changeType(long pageId, byte type) {
return pageId(partId(pageId), type, pageIndex(pageId));
}
+
+ /**
+ * @param pageId Page id.
+ */
+ public static String toDetailString(long pageId) {
+ return "pageId=" + pageId +
+ "(offset=" + itemId(pageId) +
+ ", flags=" + Integer.toBinaryString(flag(pageId)) +
+ ", partId=" + partId(pageId) +
+ ", index=" + pageIndex(pageId) +
+ ")"
+ ;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/CheckpointRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/CheckpointRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/CheckpointRecord.java
index 807bb83..3ef4f74 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/CheckpointRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/CheckpointRecord.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
/**
@@ -119,4 +120,9 @@ public class CheckpointRecord extends WALRecord {
public WALPointer checkpointMark() {
return cpMark;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CheckpointRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
index 066f2d7..9ebf306 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
*/
public class DataEntry {
/** */
+ @GridToStringInclude
protected int cacheId;
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
index d2747f1..c6322c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
@@ -65,6 +65,6 @@ public class DataRecord extends WALRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(DataRecord.class, this, super.toString());
+ return S.toString(DataRecord.class, this, "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java
index 99248d7..8843eee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.pagemem.wal.record;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
/**
* Marker that we start memory recovering
*/
@@ -43,4 +45,9 @@ public class MemoryRecoveryRecord extends WALRecord {
public long time() {
return time;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MemoryRecoveryRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/PageSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/PageSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/PageSnapshot.java
index 5fea842..6ee96a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/PageSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/PageSnapshot.java
@@ -17,10 +17,14 @@
package org.apache.ignite.internal.pagemem.wal.record;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Arrays;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -76,6 +80,21 @@ public class PageSnapshot extends WALRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(PageSnapshot.class, this, super.toString());
+ ByteBuffer buf = ByteBuffer.allocateDirect(pageData.length);
+ buf.order(ByteOrder.nativeOrder());
+ buf.put(pageData);
+
+ long addr = GridUnsafe.bufferAddress(buf);
+
+ try {
+ return "PageSnapshot [fullPageId = " + fullPageId() + ", page = [\n"
+ + PageIO.printPage(addr, pageData.length)
+ + "],\nsuper = ["
+ + super.toString() + "]]";
+ }
+ catch (IgniteCheckedException e) {
+ return "Error during call'toString' of PageSnapshot [fullPageId=" + fullPageId() +
+ ", pageData = " + Arrays.toString(pageData) + ", super=" + super.toString() + "]";
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
index 6aa899c..2fbcf4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.pagemem.wal.record;
import java.util.UUID;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -126,4 +127,9 @@ public class TxRecord extends WALRecord {
public UUID[] participatingNodeId() {
return participatingNodeIds;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TxRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertFragmentRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertFragmentRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertFragmentRecord.java
index 3b2ced1..e07c388 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertFragmentRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertFragmentRecord.java
@@ -20,15 +20,18 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
- * Insert fragment to data page record.
+ * Insert fragment (part of big object which is bigger than page size) to data page record.
*/
public class DataPageInsertFragmentRecord extends PageDeltaRecord {
/** Link to the last entry fragment. */
private final long lastLink;
/** Actual fragment data. */
+ @GridToStringExclude
private final byte[] payload;
/**
@@ -81,4 +84,12 @@ public class DataPageInsertFragmentRecord extends PageDeltaRecord {
public long lastLink() {
return lastLink;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DataPageInsertFragmentRecord.class, this,
+ "payloadSize", payload.length,
+ "super", super.toString()
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertRecord.java
index e480cc8..f315058 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageInsertRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Insert into data page.
@@ -63,4 +64,9 @@ public class DataPageInsertRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.DATA_PAGE_INSERT_RECORD;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DataPageInsertRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageRemoveRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageRemoveRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageRemoveRecord.java
index b80600c..484ec87 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageRemoveRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageRemoveRecord.java
@@ -62,6 +62,6 @@ public class DataPageRemoveRecord extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(DataPageRemoveRecord.class, this, super.toString());
+ return S.toString(DataPageRemoveRecord.class, this, "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageSetFreeListPageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageSetFreeListPageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageSetFreeListPageRecord.java
index a7fd31f..0ade484 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageSetFreeListPageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageSetFreeListPageRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.DATA_PAGE_SET_FREE_LIST_PAGE;
@@ -59,4 +60,9 @@ public class DataPageSetFreeListPageRecord extends PageDeltaRecord {
@Override public RecordType type() {
return DATA_PAGE_SET_FREE_LIST_PAGE;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DataPageSetFreeListPageRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageUpdateRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageUpdateRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageUpdateRecord.java
index 6207f41..8ea2981 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageUpdateRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/DataPageUpdateRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Update existing record in data page.
@@ -76,4 +77,9 @@ public class DataPageUpdateRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.DATA_PAGE_UPDATE_RECORD;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DataPageUpdateRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixCountRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixCountRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixCountRecord.java
index 80e06ad..2e2733a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixCountRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixCountRecord.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Fix elements count record.
@@ -51,7 +52,15 @@ public class FixCountRecord extends PageDeltaRecord {
return RecordType.BTREE_FIX_COUNT;
}
+ /**
+ *
+ */
public int count() {
return cnt;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(FixCountRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixLeftmostChildRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixLeftmostChildRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixLeftmostChildRecord.java
index a34e8e3..64aa5ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixLeftmostChildRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixLeftmostChildRecord.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusInnerIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Fix leftmost child.
@@ -52,7 +53,15 @@ public class FixLeftmostChildRecord extends PageDeltaRecord {
return RecordType.BTREE_FIX_LEFTMOST_CHILD;
}
+ /**
+ *
+ */
public long rightId() {
return rightId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(FixLeftmostChildRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixRemoveId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixRemoveId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixRemoveId.java
index 1ec845d..5cf3641 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixRemoveId.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/FixRemoveId.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Fix remove ID record.
@@ -59,4 +60,9 @@ public class FixRemoveId extends PageDeltaRecord {
public long removeId() {
return rmvId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(FixRemoveId.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InitNewPageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InitNewPageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InitNewPageRecord.java
index 15bd2da..c177a04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InitNewPageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InitNewPageRecord.java
@@ -89,8 +89,6 @@ public class InitNewPageRecord extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(InitNewPageRecord.class, this,
- "ioType", ioType,
- "ioVer", ioVer,
"newPageId", U.hexLong(newPageId),
"super", super.toString());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InnerReplaceRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InnerReplaceRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InnerReplaceRecord.java
index 6e6879d..f216a48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InnerReplaceRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InnerReplaceRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Inner replace on remove.
@@ -93,4 +94,9 @@ public class InnerReplaceRecord<L> extends PageDeltaRecord {
public long removeId() {
return rmvId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(InnerReplaceRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InsertRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InsertRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InsertRecord.java
index f6ebe87..b19d8b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InsertRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/InsertRecord.java
@@ -105,6 +105,6 @@ public class InsertRecord<L> extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(InsertRecord.class, this, "rightId", U.hexLong(rightId), "parent", super.toString());
+ return S.toString(InsertRecord.class, this, "rightId", U.hexLong(rightId), "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MergeRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MergeRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MergeRecord.java
index 2d481d1..c30b918 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MergeRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MergeRecord.java
@@ -92,6 +92,6 @@ public class MergeRecord<L> extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(MergeRecord.class, this, "prntId", U.hexLong(prntId), "rightId", U.hexLong(rightId),
- "parent", super.toString());
+ "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageAddRootRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageAddRootRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageAddRootRecord.java
index ce9e06b..4972155 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageAddRootRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageAddRootRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* New root in meta page.
@@ -51,7 +52,15 @@ public class MetaPageAddRootRecord extends PageDeltaRecord {
return RecordType.BTREE_META_PAGE_ADD_ROOT;
}
+ /**
+ *
+ */
public long rootId() {
return rootId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageAddRootRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageCutRootRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageCutRootRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageCutRootRecord.java
index 1e93ab9..5b896f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageCutRootRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageCutRootRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -44,4 +45,9 @@ public class MetaPageCutRootRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.BTREE_META_PAGE_CUT_ROOT;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageCutRootRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRecord.java
index b1e701a..ca995bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRecord.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -85,4 +86,9 @@ public class MetaPageInitRecord extends InitNewPageRecord {
@Override public RecordType type() {
return RecordType.META_PAGE_INIT;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageInitRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootInlineRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootInlineRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootInlineRecord.java
index 2b82444..0d3c155 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootInlineRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootInlineRecord.java
@@ -20,12 +20,12 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
*/
public class MetaPageInitRootInlineRecord extends MetaPageInitRootRecord {
-
/** */
private final int inlineSize;
@@ -59,4 +59,9 @@ public class MetaPageInitRootInlineRecord extends MetaPageInitRootRecord {
@Override public RecordType type() {
return RecordType.BTREE_META_PAGE_INIT_ROOT2;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageInitRootInlineRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootRecord.java
index ebdf3d4..78a7e4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageInitRootRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Initialize new meta page.
@@ -58,4 +59,9 @@ public class MetaPageInitRootRecord extends PageDeltaRecord {
public long rootId() {
return rootId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageInitRootRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastAllocatedIndex.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastAllocatedIndex.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastAllocatedIndex.java
index 11b2a67..39f6a03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastAllocatedIndex.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastAllocatedIndex.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -58,5 +59,10 @@ public class MetaPageUpdateLastAllocatedIndex extends PageDeltaRecord {
public int lastAllocatedIndex() {
return lastAllocatedIdx;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageUpdateLastAllocatedIndex.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulFullSnapshotId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulFullSnapshotId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulFullSnapshotId.java
index 03f945f..f8884a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulFullSnapshotId.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulFullSnapshotId.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -55,5 +56,10 @@ public class MetaPageUpdateLastSuccessfulFullSnapshotId extends PageDeltaRecord
public long lastSuccessfulFullSnapshotId() {
return lastSuccessfulFullSnapshotId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageUpdateLastSuccessfulFullSnapshotId.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulSnapshotId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulSnapshotId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulSnapshotId.java
index 07798bb..0d7648f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulSnapshotId.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateLastSuccessfulSnapshotId.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -66,5 +67,10 @@ public class MetaPageUpdateLastSuccessfulSnapshotId extends PageDeltaRecord {
public long lastSuccessfulSnapshotTag() {
return lastSuccessfulSnapshotTag;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageUpdateLastSuccessfulSnapshotId.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java
index e2d1267..2046ecd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -55,5 +56,10 @@ public class MetaPageUpdateNextSnapshotId extends PageDeltaRecord {
public long nextSnapshotId() {
return nextSnapshotId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MetaPageUpdateNextSnapshotId.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java
index a6ed7c5..bafbf47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java
@@ -129,6 +129,6 @@ public class MetaPageUpdatePartitionDataRecord extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(MetaPageUpdatePartitionDataRecord.class, this);
+ return S.toString(MetaPageUpdatePartitionDataRecord.class, this, "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/NewRootInitRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/NewRootInitRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/NewRootInitRecord.java
index f39f91c..4b8f747 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/NewRootInitRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/NewRootInitRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusInnerIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Initialize new root page.
@@ -112,4 +113,9 @@ public class NewRootInitRecord<L> extends PageDeltaRecord {
public byte[] rowBytes() {
return rowBytes;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(NewRootInitRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PageListMetaResetCountRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PageListMetaResetCountRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PageListMetaResetCountRecord.java
index 9c12380..af20bcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PageListMetaResetCountRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PageListMetaResetCountRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.freelist.io.PagesListMetaIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Delta record for page-list meta count reset
@@ -44,4 +45,9 @@ public class PageListMetaResetCountRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.PAGE_LIST_META_RESET_COUNT_RECORD;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PageListMetaResetCountRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListInitNewPageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListInitNewPageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListInitNewPageRecord.java
index ee83b8b..b2512aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListInitNewPageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListInitNewPageRecord.java
@@ -95,6 +95,8 @@ public class PagesListInitNewPageRecord extends InitNewPageRecord {
@Override public String toString() {
return S.toString(PagesListInitNewPageRecord.class, this,
"prevPageId", U.hexLong(prevPageId),
- "addDataPageId", U.hexLong(addDataPageId));
+ "addDataPageId", U.hexLong(addDataPageId),
+ "super", super.toString()
+ );
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListRemovePageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListRemovePageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListRemovePageRecord.java
index 8f2cd72..56d48bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListRemovePageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListRemovePageRecord.java
@@ -69,6 +69,7 @@ public class PagesListRemovePageRecord extends PageDeltaRecord {
return S.toString(PagesListRemovePageRecord.class, this,
"rmvdPageId", U.hexLong(rmvdPageId),
"pageId", U.hexLong(pageId()),
- "grpId", groupId());
+ "grpId", groupId(),
+ "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetNextRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetNextRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetNextRecord.java
index f46ac8e..8ab9485 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetNextRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetNextRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.freelist.io.PagesListNodeIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -57,4 +58,9 @@ public class PagesListSetNextRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.PAGES_LIST_SET_NEXT;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PagesListSetNextRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetPreviousRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetPreviousRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetPreviousRecord.java
index cc27077..21a2055 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetPreviousRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PagesListSetPreviousRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.freelist.io.PagesListNodeIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -57,4 +58,9 @@ public class PagesListSetPreviousRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.PAGES_LIST_SET_PREVIOUS;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PagesListSetPreviousRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionDestroyRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionDestroyRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionDestroyRecord.java
index 834dc58..9daa0ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionDestroyRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionDestroyRecord.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -70,4 +71,9 @@ public class PartitionDestroyRecord extends WALRecord {
public void partitionId(int partId) {
this.partId = partId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PartitionDestroyRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionMetaStateRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionMetaStateRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionMetaStateRecord.java
index 8ab794c..f4dab90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionMetaStateRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/PartitionMetaStateRecord.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
*
@@ -79,4 +80,9 @@ public class PartitionMetaStateRecord extends WALRecord {
public long updateCounter() {
return updateCounter;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PartitionMetaStateRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RecycleRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RecycleRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RecycleRecord.java
index b505e4d..7790460 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RecycleRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RecycleRecord.java
@@ -20,12 +20,16 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Recycle index page.
*/
public class RecycleRecord extends PageDeltaRecord {
/** */
+ @GridToStringExclude
private long newPageId;
/**
@@ -49,7 +53,18 @@ public class RecycleRecord extends PageDeltaRecord {
return RecordType.BTREE_PAGE_RECYCLE;
}
+ /**
+ *
+ */
public long newPageId() {
return newPageId;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(RecycleRecord.class, this,
+ "newPageId", U.hexLong(newPageId),
+ "super", super.toString()
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RemoveRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RemoveRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RemoveRecord.java
index 53f9cb0..8ea8c05 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RemoveRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/RemoveRecord.java
@@ -77,6 +77,6 @@ public class RemoveRecord extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(RemoveRecord.class, this, super.toString());
+ return S.toString(RemoveRecord.class, this, "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/ReplaceRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/ReplaceRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/ReplaceRecord.java
index 2fbc0dd..67d43ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/ReplaceRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/ReplaceRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Replace.
@@ -83,4 +84,9 @@ public class ReplaceRecord<L> extends PageDeltaRecord {
public byte[] rowBytes() {
return rowBytes;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ReplaceRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitExistingPageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitExistingPageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitExistingPageRecord.java
index 87638a6..2c88257 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitExistingPageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitExistingPageRecord.java
@@ -71,6 +71,6 @@ public class SplitExistingPageRecord extends PageDeltaRecord {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(SplitExistingPageRecord.class, this, "fwId", U.hexLong(fwdId), "parent", super.toString());
+ return S.toString(SplitExistingPageRecord.class, this, "fwId", U.hexLong(fwdId), "super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitForwardPageRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitForwardPageRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitForwardPageRecord.java
index 7f855f7..8f61e75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitForwardPageRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/SplitForwardPageRecord.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Split forward page record.
@@ -89,27 +90,50 @@ public class SplitForwardPageRecord extends PageDeltaRecord {
return RecordType.BTREE_FORWARD_PAGE_SPLIT;
}
+ /**
+ *
+ */
public long forwardId() {
return fwdId;
}
+ /**
+ *
+ */
public int ioType() {
return ioType;
}
+ /**
+ *
+ */
public int ioVersion() {
return ioVer;
}
+ /**
+ *
+ */
public long sourcePageId() {
return srcPageId;
}
+ /**
+ *
+ */
public int middleIndex() {
return mid;
}
+ /**
+ *
+ */
public int count() {
return cnt;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(SplitForwardPageRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/TrackingPageDeltaRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/TrackingPageDeltaRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/TrackingPageDeltaRecord.java
index 3d88e8c..089eb9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/TrackingPageDeltaRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/TrackingPageDeltaRecord.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.pagemem.wal.record.delta;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.TrackingPageIO;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Delta record for updates in tracking pages
@@ -37,14 +38,14 @@ public class TrackingPageDeltaRecord extends PageDeltaRecord {
/**
* @param grpId Cache group id.
* @param pageId Page id.
- * @param nextSnapshotId
- * @param lastSuccessfulSnapshotId
+ * @param nextSnapshotTag next snapshot tag
+ * @param lastSuccessfulSnapshotId last successful snapshot id
*/
- public TrackingPageDeltaRecord(int grpId, long pageId, long pageIdToMark, long nextSnapshotId, long lastSuccessfulSnapshotId) {
+ public TrackingPageDeltaRecord(int grpId, long pageId, long pageIdToMark, long nextSnapshotTag, long lastSuccessfulSnapshotId) {
super(grpId, pageId);
this.pageIdToMark = pageIdToMark;
- this.nextSnapshotId = nextSnapshotId;
+ this.nextSnapshotId = nextSnapshotTag;
this.lastSuccessfulSnapshotId = lastSuccessfulSnapshotId;
}
@@ -82,4 +83,9 @@ public class TrackingPageDeltaRecord extends PageDeltaRecord {
@Override public RecordType type() {
return RecordType.TRACKING_PAGE_DELTA;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TrackingPageDeltaRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index e048696..00ce1d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1508,7 +1508,8 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
try {
List<ClusterNode> dhtNodes = dht.topology().nodes(cached.partition(), tx.topologyVersion());
- assert !dhtNodes.isEmpty() && dhtNodes.get(0).id().equals(cctx.localNodeId()) : dhtNodes;
+ assert !dhtNodes.isEmpty() && dhtNodes.get(0).id().equals(cctx.localNodeId()) :
+ "localNode = " + cctx.localNodeId() + ", dhtNodes = " + dhtNodes;
if (log.isDebugEnabled())
log.debug("Mapping entry to DHT nodes [nodes=" + U.toShortString(dhtNodes) +
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIODecorator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIODecorator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIODecorator.java
index 3e80ef8..5311590 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIODecorator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIODecorator.java
@@ -24,7 +24,6 @@ import java.nio.ByteBuffer;
* Decorator class for File I/O
*/
public class FileIODecorator implements FileIO {
-
/** File I/O delegate */
private final FileIO delegate;
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
index 1490a5c..3c33241 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
@@ -17,12 +17,15 @@
package org.apache.ignite.internal.processors.cache.persistence.freelist.io;
+import java.util.HashMap;
import java.util.Map;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
import org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
import org.apache.ignite.internal.util.GridLongList;
+import org.apache.ignite.internal.util.GridStringBuilder;
/**
*
@@ -183,4 +186,22 @@ public class PagesListMetaIO extends PageIO {
private int offset(int idx) {
return ITEMS_OFF + ITEM_SIZE * idx;
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ int cnt = getCount(addr);
+
+ sb.a("PagesListMeta [\n\tnextMetaPageId=").appendHex(getNextMetaPageId(addr))
+ .a(",\n\tcount=").a(cnt)
+ .a(",\n\tbucketData={");
+
+ Map<Integer, GridLongList> bucketsData = new HashMap<>(cnt);
+
+ getBucketsData(addr, bucketsData);
+
+ for (Map.Entry<Integer, GridLongList> e : bucketsData.entrySet())
+ sb.a("\n\t\tbucket=").a(e.getKey()).a(", list=").a(e.getValue());
+
+ sb.a("\n\t}\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListNodeIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListNodeIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListNodeIO.java
index 9197d56..a93cdf3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListNodeIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListNodeIO.java
@@ -17,9 +17,11 @@
package org.apache.ignite.internal.processors.cache.persistence.freelist.io;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.GridStringBuilder;
import static org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler.copyMemory;
@@ -228,4 +230,18 @@ public class PagesListNodeIO extends PageIO {
public boolean isEmpty(long pageAddr) {
return getCount(pageAddr) == 0;
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("PagesListNode [\n\tpreviousPageId=").appendHex(getPreviousId(addr))
+ .a(",\n\tnextPageId=").appendHex(getNextId(addr))
+ .a(",\n\tcount=").a(getCount(addr))
+ .a(",\n\tpages={")
+ ;
+
+ for (int i = 0; i < getCount(addr); i++)
+ sb.a("\n\t\t").a(getAt(addr, i));
+
+ sb.a("\n\t}\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusIO.java
index 4c2b2e0..5e1cb81 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusIO.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.persistence.tree.io;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
+import org.apache.ignite.internal.util.GridStringBuilder;
import org.apache.ignite.lang.IgniteInClosure;
/**
@@ -400,4 +401,15 @@ public abstract class BPlusIO<L> extends PageIO {
public void visit(long pageAddr, IgniteInClosure<L> c) {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("BPlusIO [\n\tcanGetRow=").a(canGetRow)
+ .a(",\n\tleaf=").a(leaf)
+ .a(",\n\titemSize=").a(itemSize)
+ .a(",\n\tcnt=").a(getCount(addr))
+ .a(",\n\tforward=").appendHex(getForward(addr))
+ .a(",\n\tremoveId=").appendHex(getRemoveId(addr))
+ .a("\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusMetaIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusMetaIO.java
index 6f430c1..afa3c9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusMetaIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/BPlusMetaIO.java
@@ -17,8 +17,10 @@
package org.apache.ignite.internal.processors.cache.persistence.tree.io;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.util.GridStringBuilder;
/**
* IO routines for B+Tree meta pages.
@@ -179,4 +181,14 @@ public class BPlusMetaIO extends PageIO {
public int getInlineSize(long pageAddr) {
return getVersion() > 1 ? PageUtils.getShort(pageAddr, inlineSizeOff) : 0;
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("BPlusMeta [\n\tlevelsCnt=").a(getLevelsCount(addr))
+ .a(",\n\trootLvl=").a(getRootLevel(addr))
+ .a(",\n\tinlineSize=").a(getInlineSize(addr))
+ .a("\n]")
+ ;
+ //TODO print firstPageIds by level
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
index e177d83..e6876a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.GridStringBuilder;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.jetbrains.annotations.Nullable;
@@ -352,14 +353,25 @@ public class DataPageIO extends PageIO {
* @return String representation.
*/
private String printPageLayout(long pageAddr, int pageSize) {
+ SB b = new SB();
+
+ printPageLayout(pageAddr, pageSize, b);
+
+ return b.toString();
+ }
+
+ /**
+ * @param pageAddr Page address.
+ * @param pageSize Page size.
+ * @param b B.
+ */
+ private void printPageLayout(long pageAddr, int pageSize, GridStringBuilder b) {
int directCnt = getDirectCount(pageAddr);
int indirectCnt = getIndirectCount(pageAddr);
int free = getRealFreeSpace(pageAddr);
boolean valid = directCnt >= indirectCnt;
- SB b = new SB();
-
b.appendHex(PageIO.getPageId(pageAddr)).a(" [");
int entriesSize = 0;
@@ -419,8 +431,6 @@ public class DataPageIO extends PageIO {
b.a("]");
assert valid : b.toString();
-
- return b.toString();
}
/**
@@ -1432,6 +1442,13 @@ public class DataPageIO extends PageIO {
PageUtils.putBytes(pageAddr, dataOff, payload);
}
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("DataPageIO [\n");
+ printPageLayout(addr, 0, sb);
+ sb.a("\n]");
+ }
+
/**
* Defines closure interface for applying computations to data page items.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
index da9b818..11250ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.pagemem.PageIdUtils;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.pagemem.PageUtils;
import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
@@ -37,6 +38,7 @@ import org.apache.ignite.internal.processors.cache.tree.DataInnerIO;
import org.apache.ignite.internal.processors.cache.tree.DataLeafIO;
import org.apache.ignite.internal.processors.cache.tree.PendingEntryInnerIO;
import org.apache.ignite.internal.processors.cache.tree.PendingEntryLeafIO;
+import org.apache.ignite.internal.util.GridStringBuilder;
/**
* Base format for all the page types.
@@ -552,4 +554,29 @@ public abstract class PageIO {
public static boolean isDataPageType(int type) {
return type == T_DATA;
}
+
+ /**
+ * @param addr Address.
+ * @param pageSize
+ * @param sb Sb.
+ */
+ protected abstract void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException ;
+
+ /**
+ * @param addr Address.
+ */
+ public static String printPage(long addr, int pageSize) throws IgniteCheckedException {
+ PageIO io = getPageIO(addr);
+
+ GridStringBuilder sb = new GridStringBuilder("Header [\n\ttype=");
+
+ sb.a(getType(addr)).a(" (").a(io.getClass().getSimpleName())
+ .a("),\n\tver=").a(getVersion(addr)).a(",\n\tcrc=").a(getCrc(addr))
+ .a(",\n\t").a(PageIdUtils.toDetailString(getPageId(addr)))
+ .a("\n],\n");
+
+ io.printPage(addr, pageSize, sb);
+
+ return sb.toString();
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageMetaIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageMetaIO.java
index becd3e4..d2921ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageMetaIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageMetaIO.java
@@ -18,7 +18,9 @@
package org.apache.ignite.internal.processors.cache.persistence.tree.io;
import java.nio.ByteBuffer;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.util.GridStringBuilder;
import org.jetbrains.annotations.NotNull;
/**
@@ -226,4 +228,16 @@ public class PageMetaIO extends PageIO {
public int getCandidatePageCount(long pageAddr) {
return PageUtils.getInt(pageAddr, CANDIDATE_PAGE_COUNT_OFF);
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("PageMeta[\n\ttreeRoot=").a(getReuseListRoot(addr))
+ .a(",\n\tlastSuccessfulFullSnapshotId=").a(getLastSuccessfulFullSnapshotId(addr))
+ .a(",\n\tlastSuccessfulSnapshotId=").a(getLastSuccessfulSnapshotId(addr))
+ .a(",\n\tnextSnapshotTag=").a(getNextSnapshotTag(addr))
+ .a(",\n\tlastSuccessfulSnapshotTag=").a(getLastSuccessfulSnapshotTag(addr))
+ .a(",\n\tlastAllocatedPageCount=").a(getLastAllocatedPageCount(addr))
+ .a(",\n\tcandidatePageCount=").a(getCandidatePageCount(addr))
+ .a("\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionCountersIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionCountersIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionCountersIO.java
index d5b81c1..4803b44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionCountersIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionCountersIO.java
@@ -18,8 +18,11 @@
package org.apache.ignite.internal.processors.cache.persistence.tree.io;
+import java.util.HashMap;
import java.util.Map;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.util.GridStringBuilder;
/**
*
@@ -139,10 +142,17 @@ public class PagePartitionCountersIO extends PageIO {
return getLastFlag(pageAddr);
}
+ /**
+ * @param pageAddr Page address.
+ */
private boolean getLastFlag(long pageAddr) {
return PageUtils.getByte(pageAddr, LAST_FLAG_OFF) == LAST_FLAG;
}
+ /**
+ * @param pageAddr Page address.
+ * @param last Last.
+ */
private void setLastFlag(long pageAddr, boolean last) {
PageUtils.putByte(pageAddr, LAST_FLAG_OFF, last ? LAST_FLAG : ~LAST_FLAG);
}
@@ -172,4 +182,21 @@ public class PagePartitionCountersIO extends PageIO {
private int getCapacity(int pageSize) {
return (pageSize - ITEMS_OFF) / ITEM_SIZE;
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("PagePartitionCounters [\n\tcount=").a(getCount(addr))
+ .a(",\n\tlastFlag=").a(getLastFlag(addr))
+ .a(",\n\tnextCountersPageId=").appendHex(getNextCountersPageId(addr))
+ .a(",\n\tsize={");
+
+ Map<Integer, Long> sizes = new HashMap<>();
+
+ readCacheSizes(addr, sizes);
+
+ for (Map.Entry<Integer, Long> e : sizes.entrySet())
+ sb.a("\n\t\t").a(e.getKey()).a("=").a(e.getValue());
+
+ sb.a("\n\t}\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIO.java
index 88dbf9c..9a50e5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PagePartitionMetaIO.java
@@ -18,7 +18,10 @@
package org.apache.ignite.internal.processors.cache.persistence.tree.io;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+import org.apache.ignite.internal.util.GridStringBuilder;
/**
*
@@ -160,4 +163,20 @@ public class PagePartitionMetaIO extends PageMetaIO {
public void setCountersPageId(long pageAddr, long metaPageId) {
PageUtils.putLong(pageAddr, NEXT_PART_META_PAGE_OFF, metaPageId);
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long pageAddr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ super.printPage(pageAddr, pageSize, sb);
+
+ byte state = getPartitionState(pageAddr);
+
+ sb
+ .a(",\nPagePartitionMeta[\n\tsize=").a(getSize(pageAddr))
+ .a(",\n\tupdateCounter=").a(getUpdateCounter(pageAddr))
+ .a(",\n\tglobalRemoveId=").a(getGlobalRemoveId(pageAddr))
+ .a(",\n\tpartitionState=").a(state).a("(").a(GridDhtPartitionState.fromOrdinal(state)).a(")")
+ .a(",\n\tcountersPageId=").a(getCountersPageId(pageAddr))
+ .a("\n]")
+ ;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIO.java
index 2051778..1bd70f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIO.java
@@ -18,8 +18,11 @@
package org.apache.ignite.internal.processors.cache.persistence.tree.io;
import java.nio.ByteBuffer;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageIdUtils;
import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.jetbrains.annotations.Nullable;
/**
@@ -178,6 +181,13 @@ public class TrackingPageIO extends PageIO {
}
/**
+ * @param addr Address.
+ */
+ long getLastSnapshotTag(long addr) {
+ return GridUnsafe.getLong(addr + LAST_SNAPSHOT_TAG_OFFSET);
+ }
+
+ /**
* Check that pageId was marked as changed between previous snapshot finish and current snapshot start.
*
* @param buf Buffer.
@@ -335,4 +345,25 @@ public class TrackingPageIO extends PageIO {
return -1;
}
+
+ /** {@inheritDoc} */
+ @Override protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException {
+ sb.a("TrackingPage [\n\tlastSnapshotTag=").a(getLastSnapshotTag(addr))
+ .a(",\n\tleftHalf={")
+ .a("\n\t\tsize=").a(GridUnsafe.getShort(addr + SIZE_FIELD_OFFSET))
+ .a("\n\t\tdata={");
+
+ for (int i = 0; i < (countOfPageToTrack(pageSize) >> 3); i += 2)
+ sb.appendHex(GridUnsafe.getShort(addr + BITMAP_OFFSET + i));
+
+ sb.a("}\n\t},\n\trightHalf={")
+ .a("\n\t\tsize=").a(GridUnsafe.getShort(addr + BITMAP_OFFSET + (countOfPageToTrack(pageSize) >> 3)))
+ .a("\n\t\tdata={");
+
+ for (int i = 0; i < (countOfPageToTrack(pageSize) >> 3); i += 2)
+ sb.appendHex(GridUnsafe.getShort(addr + BITMAP_OFFSET + (countOfPageToTrack(pageSize) >> 3)
+ + SIZE_FIELD_SIZE + i));
+
+ sb.a("}\n\t}\n]");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index a9327a0..d2e85f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -70,6 +70,7 @@ import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -2336,6 +2337,11 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
@Override public FileWALPointer position() {
return (FileWALPointer) super.position();
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(FakeRecord.class, this, "super", super.toString());
+ }
}
/**
[25/26] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-6149
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-6149
# Conflicts:
# modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9e216836
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9e216836
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9e216836
Branch: refs/heads/ignite-6149
Commit: 9e216836e439c1438721760e4d758fe58352033e
Parents: 7815a97 40597a0
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 18 11:19:47 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 18 11:19:47 2017 +0300
----------------------------------------------------------------------
README.md | 192 ++---
README.txt | 1 +
.../jdbc2/JdbcDynamicIndexAbstractSelfTest.java | 39 +-
.../jdbc2/JdbcInsertStatementSelfTest.java | 9 +-
.../ignite/jdbc/JdbcErrorsAbstractSelfTest.java | 158 +++++
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 2 +
.../jdbc/thin/JdbcThinConnectionSelfTest.java | 2 +-
.../JdbcThinDynamicIndexAbstractSelfTest.java | 4 +-
.../jdbc/thin/JdbcThinErrorsSelfTest.java | 467 +++++++++++++
.../thin/JdbcThinInsertStatementSelfTest.java | 2 +-
.../jdbc/thin/JdbcThinNoDefaultSchemaTest.java | 2 +-
.../jdbc/thin/JdbcThinResultSetSelfTest.java | 2 +-
.../jdbc/thin/JdbcThinStatementSelfTest.java | 26 +-
.../java/org/apache/ignite/IgniteServices.java | 44 +-
.../ClientConnectorConfiguration.java | 275 ++++++++
.../configuration/IgniteConfiguration.java | 37 +-
.../ignite/configuration/OdbcConfiguration.java | 4 +-
.../SqlConnectorConfiguration.java | 7 +-
.../ignite/internal/GridKernalContext.java | 5 +-
.../ignite/internal/GridKernalContextImpl.java | 11 +-
.../apache/ignite/internal/IgniteKernal.java | 4 +-
.../ignite/internal/IgniteServicesImpl.java | 13 +-
.../ignite/internal/MarshallerContextImpl.java | 30 +-
.../internal/MarshallerMappingFileStore.java | 13 +-
.../internal/jdbc/thin/JdbcThinConnection.java | 67 +-
.../jdbc/thin/JdbcThinDatabaseMetadata.java | 142 ++--
.../jdbc/thin/JdbcThinPreparedStatement.java | 54 +-
.../internal/jdbc/thin/JdbcThinResultSet.java | 111 ++-
.../internal/jdbc/thin/JdbcThinStatement.java | 43 +-
.../internal/jdbc/thin/JdbcThinTcpIo.java | 258 ++-----
.../internal/jdbc/thin/JdbcThinUtils.java | 4 +-
.../discovery/GridDiscoveryManager.java | 12 +-
.../ignite/internal/pagemem/PageIdUtils.java | 13 +
.../pagemem/wal/record/CheckpointRecord.java | 6 +
.../internal/pagemem/wal/record/DataEntry.java | 21 +-
.../internal/pagemem/wal/record/DataRecord.java | 6 +-
.../pagemem/wal/record/LazyDataEntry.java | 38 +-
.../wal/record/MemoryRecoveryRecord.java | 7 +
.../pagemem/wal/record/PageSnapshot.java | 23 +-
.../internal/pagemem/wal/record/TxRecord.java | 11 +-
.../pagemem/wal/record/UnwrapDataEntry.java | 118 ++++
.../delta/DataPageInsertFragmentRecord.java | 13 +-
.../wal/record/delta/DataPageInsertRecord.java | 6 +
.../wal/record/delta/DataPageRemoveRecord.java | 2 +-
.../delta/DataPageSetFreeListPageRecord.java | 6 +
.../wal/record/delta/DataPageUpdateRecord.java | 6 +
.../wal/record/delta/FixCountRecord.java | 9 +
.../record/delta/FixLeftmostChildRecord.java | 9 +
.../pagemem/wal/record/delta/FixRemoveId.java | 6 +
.../wal/record/delta/InitNewPageRecord.java | 2 -
.../wal/record/delta/InnerReplaceRecord.java | 6 +
.../pagemem/wal/record/delta/InsertRecord.java | 2 +-
.../pagemem/wal/record/delta/MergeRecord.java | 2 +-
.../wal/record/delta/MetaPageAddRootRecord.java | 9 +
.../wal/record/delta/MetaPageCutRootRecord.java | 6 +
.../wal/record/delta/MetaPageInitRecord.java | 6 +
.../delta/MetaPageInitRootInlineRecord.java | 7 +-
.../record/delta/MetaPageInitRootRecord.java | 6 +
.../delta/MetaPageUpdateLastAllocatedIndex.java | 6 +
...aPageUpdateLastSuccessfulFullSnapshotId.java | 6 +
.../MetaPageUpdateLastSuccessfulSnapshotId.java | 6 +
.../delta/MetaPageUpdateNextSnapshotId.java | 6 +
.../MetaPageUpdatePartitionDataRecord.java | 2 +-
.../wal/record/delta/NewRootInitRecord.java | 6 +
.../delta/PageListMetaResetCountRecord.java | 6 +
.../delta/PagesListInitNewPageRecord.java | 4 +-
.../record/delta/PagesListRemovePageRecord.java | 3 +-
.../record/delta/PagesListSetNextRecord.java | 6 +
.../delta/PagesListSetPreviousRecord.java | 6 +
.../record/delta/PartitionDestroyRecord.java | 6 +
.../record/delta/PartitionMetaStateRecord.java | 6 +
.../pagemem/wal/record/delta/RecycleRecord.java | 15 +
.../pagemem/wal/record/delta/RemoveRecord.java | 2 +-
.../pagemem/wal/record/delta/ReplaceRecord.java | 6 +
.../record/delta/SplitExistingPageRecord.java | 2 +-
.../record/delta/SplitForwardPageRecord.java | 24 +
.../record/delta/TrackingPageDeltaRecord.java | 14 +-
.../cache/binary/BinaryMetadataFileStore.java | 29 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 18 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 3 +-
.../cache/persistence/file/FileIODecorator.java | 1 -
.../freelist/io/PagesListMetaIO.java | 21 +
.../freelist/io/PagesListNodeIO.java | 16 +
.../cache/persistence/tree/io/BPlusIO.java | 12 +
.../cache/persistence/tree/io/BPlusMetaIO.java | 12 +
.../cache/persistence/tree/io/DataPageIO.java | 25 +-
.../cache/persistence/tree/io/PageIO.java | 27 +
.../cache/persistence/tree/io/PageMetaIO.java | 14 +
.../tree/io/PagePartitionCountersIO.java | 27 +
.../tree/io/PagePartitionMetaIO.java | 19 +
.../persistence/tree/io/TrackingPageIO.java | 31 +
.../wal/AbstractWalRecordsIterator.java | 29 +-
.../wal/FileWriteAheadLogManager.java | 16 +-
.../cache/persistence/wal/RecordSerializer.java | 5 +
.../wal/reader/IgniteWalIteratorFactory.java | 129 +++-
.../wal/reader/StandaloneGridKernalContext.java | 120 +++-
.../reader/StandaloneIgnitePluginProcessor.java | 6 +-
.../reader/StandaloneNoopCommunicationSpi.java | 83 +++
.../wal/reader/StandaloneNoopDiscoverySpi.java | 127 ++++
.../reader/StandaloneWalRecordsIterator.java | 145 +++-
.../persistence/wal/record/HeaderRecord.java | 6 +
.../wal/serializer/RecordV1Serializer.java | 26 +-
.../cache/query/IgniteQueryErrorCode.java | 48 +-
.../odbc/ClientListenerBufferedParser.java | 81 +++
.../odbc/ClientListenerConnectionContext.java | 62 ++
.../odbc/ClientListenerMessageParser.java | 39 ++
.../odbc/ClientListenerNioListener.java | 245 +++++++
.../odbc/ClientListenerNioServerBuffer.java | 114 +++
.../odbc/ClientListenerProcessor.java | 308 ++++++++
.../odbc/ClientListenerProtocolVersion.java | 116 +++
.../processors/odbc/ClientListenerRequest.java | 31 +
.../odbc/ClientListenerRequestHandler.java | 48 ++
.../odbc/ClientListenerRequestNoId.java | 28 +
.../processors/odbc/ClientListenerResponse.java | 76 ++
.../odbc/SqlListenerBufferedParser.java | 81 ---
.../odbc/SqlListenerConnectionContext.java | 62 --
.../odbc/SqlListenerMessageParser.java | 39 --
.../processors/odbc/SqlListenerNioListener.java | 248 -------
.../odbc/SqlListenerNioServerBuffer.java | 114 ---
.../processors/odbc/SqlListenerProcessor.java | 278 --------
.../odbc/SqlListenerProtocolVersion.java | 116 ---
.../processors/odbc/SqlListenerRequest.java | 31 -
.../odbc/SqlListenerRequestHandler.java | 48 --
.../processors/odbc/SqlListenerRequestNoId.java | 28 -
.../processors/odbc/SqlListenerResponse.java | 76 --
.../internal/processors/odbc/SqlStateCode.java | 69 ++
.../odbc/jdbc/JdbcConnectionContext.java | 28 +-
.../processors/odbc/jdbc/JdbcMessageParser.java | 12 +-
.../processors/odbc/jdbc/JdbcRequest.java | 4 +-
.../odbc/jdbc/JdbcRequestHandler.java | 98 ++-
.../processors/odbc/jdbc/JdbcResponse.java | 4 +-
.../odbc/odbc/OdbcConnectionContext.java | 28 +-
.../processors/odbc/odbc/OdbcMessageParser.java | 16 +-
.../processors/odbc/odbc/OdbcRequest.java | 4 +-
.../odbc/odbc/OdbcRequestHandler.java | 46 +-
.../processors/odbc/odbc/OdbcResponse.java | 4 +-
.../client/ClientConnectionContext.java | 22 +-
.../platform/client/ClientMessageParser.java | 12 +-
.../platform/client/ClientRequest.java | 4 +-
.../platform/client/ClientRequestHandler.java | 12 +-
.../platform/client/ClientResponse.java | 4 +-
.../utils/PlatformConfigurationUtils.java | 4 +
.../processors/query/IgniteSQLException.java | 84 ++-
.../GridServiceDeploymentCompoundFuture.java | 129 +---
.../service/GridServiceProcessor.java | 64 +-
.../service/PreparedConfigurations.java | 8 +-
.../visor/node/VisorGridConfiguration.java | 2 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 14 +-
.../distributed/IgniteCache150ClientsTest.java | 4 +-
.../IgniteCacheSystemTransactionsSelfTest.java | 18 +
.../db/wal/reader/IgniteWalReaderTest.java | 698 +++++++++++++++++--
.../db/wal/reader/IndexedObject.java | 79 +++
.../db/wal/reader/MockWalIteratorFactory.java | 14 +-
.../database/IgniteDbAbstractTest.java | 6 -
.../OdbcConfigurationValidationSelfTest.java | 1 -
...ServiceDeploymentCompoundFutureSelfTest.java | 121 +---
...GridServiceProcessorBatchDeploySelfTest.java | 137 +---
modules/dev-utils/pom.xml | 50 ++
.../development/utils/IgniteWalConverter.java | 86 +++
.../query/h2/DmlStatementsProcessor.java | 79 ++-
.../query/h2/sql/GridSqlQueryParser.java | 35 +-
...onnectorConfigurationValidationSelfTest.java | 241 +++++++
.../query/h2/sql/GridQueryParsingTest.java | 2 +-
...onnectorConfigurationValidationSelfTest.java | 3 +-
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../matrix/DenseOffHeapMatrixStorage.java | 2 +-
.../odbc-test/config/queries-test-default.xml | 4 +-
.../odbc-test/config/queries-test-noodbc-32.xml | 2 +-
.../odbc-test/config/queries-test-noodbc.xml | 2 +-
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 1 -
.../Apache.Ignite.Core.Tests.csproj | 6 +
.../Binary/BinaryFooterTest.cs | 2 +-
.../Client/CacheTest.cs | 200 ++++++
.../Client/CacheTestNoMeta.cs | 159 +++++
.../Client/ClientConnectionTest.cs | 146 ++++
.../Client/IgniteClientConfigurationTest.cs | 42 ++
.../Apache.Ignite.Core.Tests/Client/Person.cs | 48 ++
.../Client/RawSocketTest.cs | 164 +++++
.../Compute/AbstractTaskTest.cs | 2 -
.../Compute/BinarizableClosureTaskTest.cs | 1 -
.../IgniteConfigurationTest.cs | 2 +
.../Plugin/TestIgnitePluginConfiguration.cs | 1 -
.../Apache.Ignite.Core.csproj | 9 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 9 +-
.../Client/Cache/ICacheClient.cs | 59 ++
.../Apache.Ignite.Core/Client/IIgniteClient.cs | 44 ++
.../Client/IgniteClientConfiguration.cs | 104 +++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 4 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 17 +
.../Impl/Binary/BinaryProcessorClient.cs | 113 +++
.../Impl/Binary/BinaryUtils.cs | 16 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 4 +-
.../Impl/Client/Cache/CacheClient.cs | 160 +++++
.../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 32 +
.../Impl/Client/ClientProtocolVersion.cs | 119 ++++
.../Impl/Client/ClientSocket.cs | 263 +++++++
.../Impl/Client/IgniteClient.cs | 152 ++++
.../Impl/Cluster/ClusterGroupImpl.cs | 2 +-
.../Impl/Compute/ComputeJobHolder.cs | 2 +-
.../Impl/Deployment/PeerAssemblyResolver.cs | 4 +-
.../Impl/Deployment/PeerLoadingObjectHolder.cs | 2 +-
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 7 +-
.../Apache.Ignite.Core/Impl/IIgniteInternal.cs | 13 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 10 +-
.../Datagrid/MultiTieredCacheExample.cs | 2 -
.../Misc/LifecycleExample.cs | 1 -
.../ant/beautifier/GridJavadocAntTask.java | 8 +-
.../list-of-registered-users.controller.js | 22 +-
parent/pom.xml | 4 +
pom.xml | 1 +
210 files changed, 7366 insertions(+), 2631 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e216836/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e216836/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e216836/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
index 9e50f41,11250ef..e38cc85
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/PageIO.java
@@@ -35,10 -36,9 +36,11 @@@ import org.apache.ignite.internal.proce
import org.apache.ignite.internal.processors.cache.tree.CacheIdAwarePendingEntryLeafIO;
import org.apache.ignite.internal.processors.cache.tree.DataInnerIO;
import org.apache.ignite.internal.processors.cache.tree.DataLeafIO;
+import org.apache.ignite.internal.processors.cache.tree.MvccDataInnerIO;
+import org.apache.ignite.internal.processors.cache.tree.MvccDataLeafIO;
import org.apache.ignite.internal.processors.cache.tree.PendingEntryInnerIO;
import org.apache.ignite.internal.processors.cache.tree.PendingEntryLeafIO;
+ import org.apache.ignite.internal.util.GridStringBuilder;
/**
* Base format for all the page types.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e216836/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
----------------------------------------------------------------------
[11/26] ignite git commit: IGNITE-6235 Added ability to handle
CacheObject from DataRecord in standalone WAL iterator - Fixes #2620.
Posted by sb...@apache.org.
IGNITE-6235 Added ability to handle CacheObject from DataRecord in standalone WAL iterator - Fixes #2620.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/39b90301
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/39b90301
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/39b90301
Branch: refs/heads/ignite-6149
Commit: 39b903013f564f4229ff3284e22e46001a4f9b46
Parents: 8936a0d
Author: dpavlov <dp...@gridgain.com>
Authored: Fri Sep 15 14:47:03 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Sep 15 14:47:03 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/MarshallerContextImpl.java | 30 +-
.../internal/MarshallerMappingFileStore.java | 13 +-
.../internal/pagemem/wal/record/DataEntry.java | 20 +-
.../internal/pagemem/wal/record/DataRecord.java | 4 +-
.../pagemem/wal/record/LazyDataEntry.java | 38 +-
.../internal/pagemem/wal/record/TxRecord.java | 5 +-
.../pagemem/wal/record/UnwrapDataEntry.java | 118 ++++
.../cache/binary/BinaryMetadataFileStore.java | 29 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 18 +-
.../wal/AbstractWalRecordsIterator.java | 29 +-
.../wal/FileWriteAheadLogManager.java | 10 +-
.../cache/persistence/wal/RecordSerializer.java | 5 +
.../wal/reader/IgniteWalIteratorFactory.java | 129 +++-
.../wal/reader/StandaloneGridKernalContext.java | 116 ++-
.../reader/StandaloneIgnitePluginProcessor.java | 6 +-
.../reader/StandaloneNoopCommunicationSpi.java | 83 +++
.../wal/reader/StandaloneNoopDiscoverySpi.java | 127 ++++
.../reader/StandaloneWalRecordsIterator.java | 143 +++-
.../wal/serializer/RecordV1Serializer.java | 5 +
.../db/wal/reader/IgniteWalReaderTest.java | 698 +++++++++++++++++--
.../db/wal/reader/IndexedObject.java | 79 +++
.../db/wal/reader/MockWalIteratorFactory.java | 14 +-
modules/dev-utils/pom.xml | 2 +-
.../development/utils/IgniteWalConverter.java | 5 +-
.../ant/beautifier/GridJavadocAntTask.java | 8 +-
parent/pom.xml | 4 +
26 files changed, 1584 insertions(+), 154 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 0b3f220..f57bda7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -18,8 +18,8 @@
package org.apache.ignite.internal;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.AbstractMap;
@@ -37,6 +37,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
@@ -88,6 +89,12 @@ public class MarshallerContextImpl implements MarshallerContext {
private boolean clientNode;
/**
+ * Marshaller mapping file store directory. {@code null} used for standard folder, in this case folder is calculated
+ * from work directory. Non null value may be used to setup custom directory from outside
+ */
+ @Nullable private File marshallerMappingFileStoreDir;
+
+ /**
* Initializes context.
*
* @param plugins Plugins.
@@ -491,7 +498,10 @@ public class MarshallerContextImpl implements MarshallerContext {
IgniteConfiguration cfg = ctx.config();
String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
- fileStore = new MarshallerMappingFileStore(workDir, ctx.log(MarshallerMappingFileStore.class));
+ final IgniteLogger fileStoreLog = ctx.log(MarshallerMappingFileStore.class);
+ fileStore = marshallerMappingFileStoreDir == null ?
+ new MarshallerMappingFileStore(workDir, fileStoreLog) :
+ new MarshallerMappingFileStore(fileStoreLog, marshallerMappingFileStoreDir);
this.transport = transport;
closProc = ctx.closure();
clientNode = ctx.clientNode();
@@ -537,6 +547,22 @@ public class MarshallerContextImpl implements MarshallerContext {
}
/**
+ * @return custom marshaller mapping files directory. Used for standalone WAL iteration
+ */
+ @Nullable public File getMarshallerMappingFileStoreDir() {
+ return marshallerMappingFileStoreDir;
+ }
+
+ /**
+ * Sets custom marshaller mapping files directory. Used for standalone WAL iteration
+ *
+ * @param marshallerMappingFileStoreDir directory with type name mappings
+ */
+ public void setMarshallerMappingFileStoreDir(@Nullable final File marshallerMappingFileStoreDir) {
+ this.marshallerMappingFileStoreDir = marshallerMappingFileStoreDir;
+ }
+
+ /**
*
*/
static final class CombinedMap extends AbstractMap<Integer, MappedName>
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/MarshallerMappingFileStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerMappingFileStore.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerMappingFileStore.java
index e4a844e..eabbdb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerMappingFileStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerMappingFileStore.java
@@ -51,13 +51,14 @@ final class MarshallerMappingFileStore {
/** */
private final IgniteLogger log;
- /** */
+ /** Marshaller mapping directory */
private final File workDir;
/** */
private final String FILE_EXTENSION = ".classname";
/**
+ * @param igniteWorkDir Ignite work directory
* @param log Logger.
*/
MarshallerMappingFileStore(String igniteWorkDir, IgniteLogger log) throws IgniteCheckedException {
@@ -66,6 +67,16 @@ final class MarshallerMappingFileStore {
}
/**
+ * Creates marshaller mapping file store with custom predefined work directory
+ * @param log logger.
+ * @param marshallerMappingFileStoreDir custom marshaller work directory
+ */
+ MarshallerMappingFileStore(final IgniteLogger log, final File marshallerMappingFileStoreDir) {
+ this.workDir = marshallerMappingFileStoreDir;
+ this.log = log;
+ }
+
+ /**
* @param platformId Platform id.
* @param typeId Type id.
* @param typeName Type name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
index 9ebf306..d4e0b9f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataEntry.java
@@ -20,41 +20,39 @@ package org.apache.ignite.internal.pagemem.wal.record;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
- *
+ * Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation} in WAL log.
*/
public class DataEntry {
- /** */
+ /** Cache ID. */
@GridToStringInclude
protected int cacheId;
- /** */
+ /** Cache object key */
protected KeyCacheObject key;
- /** */
+ /** Cache object value */
protected CacheObject val;
- /** */
+ /** Entry operation performed */
@GridToStringInclude
protected GridCacheOperation op;
- /** */
+ /** Near transaction version. */
protected GridCacheVersion nearXidVer;
- /** */
+ /** Write version. */
@GridToStringInclude
protected GridCacheVersion writeVer;
- /** */
+ /** Expire time. */
protected long expireTime;
- /** */
+ /** Partition ID. */
@GridToStringInclude
protected int partId;
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
index c6322c3..0e92383 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java
@@ -23,7 +23,9 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
- *
+ * Logical data record with cache operation description.
+ * This record contains information about operation we want to do.
+ * Contains operation type (put, remove) and (Key, Value, Version) for each {@link DataEntry}
*/
public class DataRecord extends WALRecord {
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java
index 98db831..0ad87d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java
@@ -28,29 +28,36 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
/**
- *
+ * Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}. <br>
+ * This Data entry was not converted to key, value pair during record deserialization.
*/
public class LazyDataEntry extends DataEntry {
/** */
private GridCacheSharedContext cctx;
- /** */
+ /** Data Entry key type code. See {@link CacheObject} for built-in value type codes */
private byte keyType;
- /** */
+ /** Key value bytes. */
private byte[] keyBytes;
- /** */
+ /** Data Entry Value type code. See {@link CacheObject} for built-in value type codes */
private byte valType;
- /** */
+ /** Value value bytes. */
private byte[] valBytes;
/**
+ * @param cctx Shared context.
* @param cacheId Cache ID.
+ * @param keyType Object type code for Key.
+ * @param keyBytes Data Entry Key value bytes.
+ * @param valType Object type code for Value.
+ * @param valBytes Data Entry Value value bytes.
* @param op Operation.
* @param nearXidVer Near transaction version.
* @param writeVer Write version.
+ * @param expireTime Expire time.
* @param partId Partition ID.
* @param partCnt Partition counter.
*/
@@ -113,4 +120,25 @@ public class LazyDataEntry extends DataEntry {
return val;
}
+
+ /** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */
+ public byte getKeyType() {
+ return keyType;
+ }
+
+ /** @return Key value bytes. */
+ public byte[] getKeyBytes() {
+ return keyBytes;
+ }
+
+ /** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */
+ public byte getValType() {
+ return valType;
+ }
+
+ /** @return Value value bytes. */
+ public byte[] getValBytes() {
+ return valBytes;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
index 2fbcf4f..9bb747b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/TxRecord.java
@@ -22,7 +22,8 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
- *
+ * Logical data record indented for transaction (tx) related actions.<br>
+ * This record is marker of begin, prepare, commit, and rollback transactions.
*/
public class TxRecord extends WALRecord {
/**
@@ -58,7 +59,7 @@ public class TxRecord extends WALRecord {
/** */
private TxAction action;
- /** */
+ /** Global transaction identifier within cluster, assigned by transaction coordinator */
private GridCacheVersion nearXidVer;
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java
new file mode 100644
index 0000000..678539d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java
@@ -0,0 +1,118 @@
+/*
+ * 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.internal.pagemem.wal.record;
+
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
+import org.apache.ignite.internal.processors.cache.GridCacheOperation;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+
+/**
+ * Data Entry for automatic unwrapping key and value from Data Entry
+ */
+public class UnwrapDataEntry extends DataEntry {
+ /** Cache object value context. Context is used for unwrapping objects. */
+ private final CacheObjectValueContext cacheObjValCtx;
+
+ /** Keep binary. This flag disables converting of non primitive types (BinaryObjects) */
+ private boolean keepBinary;
+
+ /**
+ * @param cacheId Cache ID.
+ * @param key Key.
+ * @param val Value.
+ * @param op Operation.
+ * @param nearXidVer Near transaction version.
+ * @param writeVer Write version.
+ * @param expireTime Expire time.
+ * @param partId Partition ID.
+ * @param partCnt Partition counter.
+ * @param cacheObjValCtx cache object value context for unwrapping objects.
+ * @param keepBinary disable unwrapping for non primitive objects, Binary Objects would be returned instead
+ */
+ public UnwrapDataEntry(
+ final int cacheId,
+ final KeyCacheObject key,
+ final CacheObject val,
+ final GridCacheOperation op,
+ final GridCacheVersion nearXidVer,
+ final GridCacheVersion writeVer,
+ final long expireTime,
+ final int partId,
+ final long partCnt,
+ final CacheObjectValueContext cacheObjValCtx,
+ final boolean keepBinary) {
+ super(cacheId, key, val, op, nearXidVer, writeVer, expireTime, partId, partCnt);
+ this.cacheObjValCtx = cacheObjValCtx;
+ this.keepBinary = keepBinary;
+ }
+
+ /**
+ * Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used
+ * in key, call of this method requires classes to be available in classpath
+ *
+ * @return Key which was placed into cache. Or null if failed
+ */
+ public Object unwrappedKey() {
+ try {
+ if (keepBinary && key instanceof BinaryObject)
+ return key;
+ Object unwrapped = key.value(cacheObjValCtx, false);
+ if (unwrapped instanceof BinaryObject) {
+ if (keepBinary)
+ return unwrapped;
+ unwrapped = ((BinaryObject)unwrapped).deserialize();
+ }
+ return unwrapped;
+ }
+ catch (Exception e) {
+ cacheObjValCtx.kernalContext().log(UnwrapDataEntry.class)
+ .error("Unable to convert key [" + key + "]", e);
+ return null;
+ }
+ }
+
+ /**
+ * Unwraps value value from cache value object into primitive boxed type or source class. If client classes were
+ * used in key, call of this method requires classes to be available in classpath
+ *
+ * @return Value which was placed into cache. Or null if failed
+ */
+ public Object unwrappedValue() {
+ try {
+ if (keepBinary && val instanceof BinaryObject)
+ return val;
+ return val.value(cacheObjValCtx, false);
+ }
+ catch (Exception e) {
+ cacheObjValCtx.kernalContext().log(UnwrapDataEntry.class)
+ .error("Unable to convert value [" + value() + "]", e);
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return getClass().getSimpleName() + "[k = " + unwrappedKey() + ", v = [ "
+ + unwrappedValue()
+ + "], super = ["
+ + super.toString() + "]]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java
index e682593..2d4114f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java
@@ -25,6 +25,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryMetadata;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
/**
* Class handles saving/restoring binary metadata to/from disk.
@@ -49,8 +50,14 @@ class BinaryMetadataFileStore {
* @param metadataLocCache Metadata locale cache.
* @param ctx Context.
* @param log Logger.
+ * @param binaryMetadataFileStoreDir Path to binary metadata store configured by user, should include binary_meta and consistentId
*/
- BinaryMetadataFileStore(ConcurrentMap<Integer, BinaryMetadataHolder> metadataLocCache, GridKernalContext ctx, IgniteLogger log) throws IgniteCheckedException {
+ BinaryMetadataFileStore(
+ final ConcurrentMap<Integer, BinaryMetadataHolder> metadataLocCache,
+ final GridKernalContext ctx,
+ final IgniteLogger log,
+ @Nullable final File binaryMetadataFileStoreDir) throws IgniteCheckedException {
+
this.metadataLocCache = metadataLocCache;
this.ctx = ctx;
this.log = log;
@@ -58,14 +65,18 @@ class BinaryMetadataFileStore {
if (!ctx.config().isPersistentStoreEnabled())
return;
- String consId = U.maskForFileName(ctx.discovery().consistentId().toString());
-
- workDir = new File(U.resolveWorkDirectory(
- ctx.config().getWorkDirectory(),
- "binary_meta",
- false
- ),
- consId);
+ if (binaryMetadataFileStoreDir != null)
+ workDir = binaryMetadataFileStoreDir;
+ else {
+ String consId = U.maskForFileName(ctx.discovery().consistentId().toString());
+
+ workDir = new File(U.resolveWorkDirectory(
+ ctx.config().getWorkDirectory(),
+ "binary_meta",
+ false
+ ),
+ consId);
+ }
U.ensureDirectory(workDir, "directory for serialized binary metadata", log);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 5b43f8f..0b85d2b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.cache.binary;
+import java.io.File;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
@@ -109,6 +110,13 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** */
private BinaryMetadataFileStore metadataFileStore;
+ /**
+ * Custom folder specifying local folder for {@link #metadataFileStore}.<br>
+ * {@code null} means no specific folder is configured. <br>
+ * In this case folder for metadata is composed from work directory and consistentId <br>
+ */
+ @Nullable private File binaryMetadataFileStoreDir;
+
/** */
@GridToStringExclude
private IgniteBinary binaries;
@@ -147,7 +155,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (ctx.clientNode())
ctx.event().addLocalEventListener(clientDisconLsnr, EVT_CLIENT_NODE_DISCONNECTED);
- metadataFileStore = new BinaryMetadataFileStore(metadataLocCache, ctx, log);
+ metadataFileStore = new BinaryMetadataFileStore(metadataLocCache, ctx, log, binaryMetadataFileStoreDir);
transport = new BinaryMetadataTransport(metadataLocCache, metadataFileStore, ctx, log);
@@ -906,4 +914,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
}
}
+
+ /**
+ * Sets path to binary metadata store configured by user, should include binary_meta and consistentId
+ * @param binaryMetadataFileStoreDir path to binary_meta
+ */
+ public void setBinaryMetadataFileStoreDir(@Nullable File binaryMetadataFileStoreDir) {
+ this.binaryMetadataFileStoreDir = binaryMetadataFileStoreDir;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
index db949c3..2749d5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
@@ -65,8 +65,11 @@ public abstract class AbstractWalRecordsIterator
/** Logger */
@NotNull protected final IgniteLogger log;
- /** Shared context for creating serializer of required version and grid name access */
- @NotNull private final GridCacheSharedContext sharedCtx;
+ /**
+ * Shared context for creating serializer of required version and grid name access. Also cacheObjects processor from
+ * this context may be used to covert Data entry key and value from its binary representation into objects.
+ */
+ @NotNull protected final GridCacheSharedContext sharedCtx;
/** Serializer of current version to read headers. */
@NotNull private final RecordSerializer serializer;
@@ -78,10 +81,11 @@ public abstract class AbstractWalRecordsIterator
private final ByteBufferExpander buf;
/**
- * @param log Logger
- * @param sharedCtx Shared context
+ * @param log Logger.
+ * @param sharedCtx Shared context.
* @param serializer Serializer of current version to read headers.
- * @param bufSize buffer for reading records size
+ * @param ioFactory ioFactory for file IO access.
+ * @param bufSize buffer for reading records size.
*/
protected AbstractWalRecordsIterator(
@NotNull final IgniteLogger log,
@@ -210,7 +214,7 @@ public abstract class AbstractWalRecordsIterator
ptr.length(rec.size());
// cast using diamond operator here can break compile for 7
- return new IgniteBiTuple<>((WALPointer)ptr, rec);
+ return new IgniteBiTuple<>((WALPointer)ptr, postProcessRecord(rec));
}
catch (IOException | IgniteCheckedException e) {
if (!(e instanceof SegmentEofException))
@@ -220,6 +224,17 @@ public abstract class AbstractWalRecordsIterator
}
/**
+ * Performs final conversions with record loaded from WAL.
+ * To be overridden by subclasses if any processing required.
+ *
+ * @param rec record to post process.
+ * @return post processed record.
+ */
+ @NotNull protected WALRecord postProcessRecord(@NotNull final WALRecord rec) {
+ return rec;
+ }
+
+ /**
* Handler for record deserialization exception
* @param e problem from records reading
* @param ptr file pointer was accessed
@@ -260,7 +275,7 @@ public abstract class AbstractWalRecordsIterator
int ver = ((HeaderRecord)rec).version();
- RecordSerializer ser = FileWriteAheadLogManager.forVersion(sharedCtx, ver);
+ RecordSerializer ser = FileWriteAheadLogManager.forVersion(sharedCtx, ver, serializer.writePointer());
if (start != null && desc.idx == start.index())
in.seek(start.fileOffset());
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index d2e85f1..18584a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -1010,12 +1010,20 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
* @return Entry serializer.
*/
static RecordSerializer forVersion(GridCacheSharedContext cctx, int ver) throws IgniteCheckedException {
+ return forVersion(cctx, ver, false);
+ }
+
+ /**
+ * @param ver Serializer version.
+ * @return Entry serializer.
+ */
+ static RecordSerializer forVersion(GridCacheSharedContext cctx, int ver, boolean writePointer) throws IgniteCheckedException {
if (ver <= 0)
throw new IgniteCheckedException("Failed to create a serializer (corrupted WAL file).");
switch (ver) {
case 1:
- return new RecordV1Serializer(cctx);
+ return new RecordV1Serializer(cctx, writePointer);
default:
throw new IgniteCheckedException("Failed to create a serializer with the given version " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/RecordSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/RecordSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/RecordSerializer.java
index 1ea7fa6..12e16a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/RecordSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/RecordSerializer.java
@@ -54,4 +54,9 @@ public interface RecordSerializer {
* @return Read entry.
*/
public WALRecord readRecord(FileInput in, WALPointer expPtr) throws IOException, IgniteCheckedException;
+
+ /**
+ * Flag to write (or not) wal pointer to record
+ */
+ public boolean writePointer();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
index 4e3998b..3a34e28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
@@ -21,11 +21,13 @@ import java.io.File;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.pagemem.wal.WALIterator;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Factory for creating iterator over WAL files
@@ -33,17 +35,90 @@ import org.jetbrains.annotations.NotNull;
public class IgniteWalIteratorFactory {
/** Logger. */
private final IgniteLogger log;
- /** Page size, in standalone iterator mode this value can't be taken from memory configuration */
+
+ /** Page size, in standalone iterator mode this value can't be taken from memory configuration. */
private final int pageSize;
+
+ /**
+ * Folder specifying location of metadata File Store. {@code null} means no specific folder is configured. <br>
+ * This folder should be specified for converting data entries into BinaryObjects
+ */
+ @Nullable private File binaryMetadataFileStoreDir;
+
+ /**
+ * Folder specifying location of marshaller mapping file store. {@code null} means no specific folder is configured. <br>
+ * This folder should be specified for converting data entries into BinaryObjects.
+ * Providing {@code null} will disable unmarshall for non primitive objects, BinaryObjects will be provided
+ */
+ @Nullable private File marshallerMappingFileStoreDir;
+
+ /** Keep binary. This flag disables converting of non primitive types (BinaryObjects) */
+ private boolean keepBinary;
+
/** Factory to provide I/O interfaces for read/write operations with files */
private final FileIOFactory ioFactory;
/**
- * Creates WAL files iterator factory
+ * Creates WAL files iterator factory.
+ * WAL iterator supports automatic converting from CacheObjects and KeyCacheObject into BinaryObjects
+ *
* @param log Logger.
- * @param pageSize Page size, size is validated
+ * @param pageSize Page size which was used in Ignite Persistent Data store to read WAL from, size is validated
+ * according its boundaries.
+ * @param binaryMetadataFileStoreDir folder specifying location of metadata File Store. Should include "binary_meta"
+ * subfolder and consistent ID subfolder. Note Consistent ID should be already masked and should not contain special
+ * symbols. Providing {@code null} means no specific folder is configured. <br>
+ * @param marshallerMappingFileStoreDir Folder specifying location of marshaller mapping file store. Should include
+ * "marshaller" subfolder. Providing {@code null} will disable unmarshall for non primitive objects,
+ * BinaryObjects will be provided
+ * @param keepBinary {@code true} disables complex object unmarshall into source classes
*/
- public IgniteWalIteratorFactory(@NotNull IgniteLogger log, @NotNull FileIOFactory ioFactory, int pageSize) {
+ public IgniteWalIteratorFactory(
+ @NotNull final IgniteLogger log,
+ final int pageSize,
+ @Nullable final File binaryMetadataFileStoreDir,
+ @Nullable final File marshallerMappingFileStoreDir,
+ final boolean keepBinary) {
+ this.log = log;
+ this.pageSize = pageSize;
+ this.binaryMetadataFileStoreDir = binaryMetadataFileStoreDir;
+ this.marshallerMappingFileStoreDir = marshallerMappingFileStoreDir;
+ this.keepBinary = keepBinary;
+ this.ioFactory = new PersistentStoreConfiguration().getFileIOFactory();
+ new MemoryConfiguration().setPageSize(pageSize); // just for validate
+ }
+
+ /**
+ * Creates WAL files iterator factory.
+ * WAL iterator supports automatic converting from CacheObjects and KeyCacheObject into BinaryObjects
+ *
+ * @param log Logger.
+ * @param pageSize Page size which was used in Ignite Persistent Data store to read WAL from, size is validated
+ * according its boundaries.
+ * @param binaryMetadataFileStoreDir folder specifying location of metadata File Store. Should include "binary_meta"
+ * subfolder and consistent ID subfolder. Note Consistent ID should be already masked and should not contain special
+ * symbols. Providing {@code null} means no specific folder is configured. <br>
+ * @param marshallerMappingFileStoreDir Folder specifying location of marshaller mapping file store. Should include
+ * "marshaller" subfolder. Providing {@code null} will disable unmarshall for non primitive objects, BinaryObjects
+ * will be provided
+ */
+ public IgniteWalIteratorFactory(
+ @NotNull final IgniteLogger log,
+ final int pageSize,
+ @Nullable final File binaryMetadataFileStoreDir,
+ @Nullable final File marshallerMappingFileStoreDir) {
+ this(log, pageSize, binaryMetadataFileStoreDir, marshallerMappingFileStoreDir, false);
+ }
+
+ /**
+ * Creates WAL files iterator factory. This constructor does not allow WAL iterators access to data entries key and value.
+ *
+ * @param log Logger.
+ * @param ioFactory Custom factory for non-standard file API to be used in WAL reading.
+ * @param pageSize Page size which was used in Ignite Persistent Data store to read WAL from, size is validated
+ * according its boundaries.
+ */
+ public IgniteWalIteratorFactory(@NotNull final IgniteLogger log, @NotNull final FileIOFactory ioFactory, int pageSize) {
this.log = log;
this.pageSize = pageSize;
this.ioFactory = ioFactory;
@@ -51,48 +126,72 @@ public class IgniteWalIteratorFactory {
}
/**
+ * Creates WAL files iterator factory. This constructor does not allow WAL iterators access to data entries key and
+ * value.
+ *
+ * @param log Logger.
+ * @param pageSize Page size which was used in Ignite Persistent Data store to read WAL from, size is validated
+ * according its boundaries.
+ */
+ public IgniteWalIteratorFactory(@NotNull final IgniteLogger log, final int pageSize) {
+ this(log, new PersistentStoreConfiguration().getFileIOFactory(), pageSize);
+ }
+
+ /**
* Creates iterator for (archive) directory scan mode.
* Note in this mode total scanned files at end of iteration may be wider that initial files in directory.
* This mode does not support work directory scan because work directory contains unpredictable number in file name.
* Such file may broke iteration.
*
- * @param walDirWithConsistentId directory with WAL files. Should already contain node consistent ID as subfolder
+ * @param walDirWithConsistentId directory with WAL files. Should already contain node consistent ID as subfolder.
+ * Note: 'Consistent ID'-based subfolder name (if any) should not contain special symbols.
* @return closable WAL records iterator, should be closed when non needed
* @throws IgniteCheckedException if failed to read folder
*/
- public WALIterator iteratorArchiveDirectory(@NotNull final File walDirWithConsistentId) throws IgniteCheckedException {
- return new StandaloneWalRecordsIterator(walDirWithConsistentId, log, prepareSharedCtx(), ioFactory);
+ public WALIterator iteratorArchiveDirectory(
+ @NotNull final File walDirWithConsistentId) throws IgniteCheckedException {
+ return new StandaloneWalRecordsIterator(walDirWithConsistentId, log, prepareSharedCtx(), ioFactory, keepBinary);
}
/**
* Creates iterator for file by file scan mode.
* This method may be used only for archive folder (not for work).
* In this mode only provided WAL segments will be scanned. New WAL files created during iteration will be ignored
- * @param files files to scan. Order it not important, but is significant to provide all segments without omissions
+ *
+ * @param files files to scan. Order is not important, but it is significant to provide all segments without omissions.
+ * Parameter should contain direct file links to '.wal' files from archive directory.
+ * 'Consistent ID'-based subfolder name (if any) should not contain special symbols.
+ * Special symbols should be already masked.
+ *
* @return closable WAL records iterator, should be closed when non needed
* @throws IgniteCheckedException if failed to read files
*/
- public WALIterator iteratorArchiveFiles(@NotNull final File ...files) throws IgniteCheckedException {
- return new StandaloneWalRecordsIterator(log, prepareSharedCtx(), ioFactory, false, files);
+ public WALIterator iteratorArchiveFiles(@NotNull final File... files) throws IgniteCheckedException {
+ return new StandaloneWalRecordsIterator(log, prepareSharedCtx(), ioFactory, false, keepBinary, files);
}
/**
* Creates iterator for file by file scan mode.
* This method may be used for work folder, file indexes are scanned from the file context.
* In this mode only provided WAL segments will be scanned. New WAL files created during iteration will be ignored.
- * @param files files to scan. Order it not important, but is significant to provide all segments without omissions
+ *
+ * @param files files to scan. Order is not important, but it is significant to provide all segments without omissions.
+ * Parameter should contain direct file links to '.wal' files from work directory.
+ * 'Consistent ID'-based subfolder name (if any) should not contain special symbols.
+ * Special symbols should be already masked.
+ *
* @return closable WAL records iterator, should be closed when non needed
* @throws IgniteCheckedException if failed to read files
*/
- public WALIterator iteratorWorkFiles(@NotNull final File ...files) throws IgniteCheckedException {
- return new StandaloneWalRecordsIterator(log, prepareSharedCtx(), ioFactory, true, files);
+ public WALIterator iteratorWorkFiles(@NotNull final File... files) throws IgniteCheckedException {
+ return new StandaloneWalRecordsIterator(log, prepareSharedCtx(), ioFactory, true, keepBinary, files);
}
/**
* @return fake shared context required for create minimal services for record reading
*/
- @NotNull private GridCacheSharedContext prepareSharedCtx() {
- final GridKernalContext kernalCtx = new StandaloneGridKernalContext(log);
+ @NotNull private GridCacheSharedContext prepareSharedCtx() throws IgniteCheckedException {
+ final GridKernalContext kernalCtx = new StandaloneGridKernalContext(log, binaryMetadataFileStoreDir, marshallerMappingFileStoreDir);
final StandaloneIgniteCacheDatabaseSharedManager dbMgr = new StandaloneIgniteCacheDatabaseSharedManager();
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
index 8752eaa..c2afdef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.cache.persistence.wal.reader;
+import java.io.File;
+import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -25,11 +27,14 @@ import java.util.concurrent.ExecutorService;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
import org.apache.ignite.internal.GridComponent;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.GridKernalGateway;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager;
import org.apache.ignite.internal.managers.collision.GridCollisionManager;
import org.apache.ignite.internal.managers.communication.GridIoManager;
@@ -41,6 +46,7 @@ import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
import org.apache.ignite.internal.processors.cluster.ClusterProcessor;
@@ -73,6 +79,7 @@ import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions;
import org.apache.ignite.internal.util.IgniteExceptionRegistry;
import org.apache.ignite.internal.util.StripedExecutor;
+import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.PluginNotFoundException;
import org.apache.ignite.plugin.PluginProvider;
import org.apache.ignite.thread.IgniteStripedThreadPoolExecutor;
@@ -83,16 +90,36 @@ import org.jetbrains.annotations.Nullable;
* Dummy grid kernal context
*/
public class StandaloneGridKernalContext implements GridKernalContext {
- /** */
+ /** Config for fake Ignite instance. */
+ private final IgniteConfiguration cfg;
+
+ /** Logger. */
private IgniteLogger log;
- /** */
+ /** Empty plugin processor. */
private IgnitePluginProcessor pluginProc;
/**
+ * Cache object processor. Used for converting cache objects and keys into binary objects. Null means there is no
+ * convert is configured. All entries in this case will be lazy data entries.
+ */
+ @Nullable private IgniteCacheObjectProcessor cacheObjProcessor;
+
+ /** Marshaller context implementation. */
+ private MarshallerContextImpl marshallerContext;
+
+ /**
* @param log Logger.
+ * @param binaryMetadataFileStoreDir folder specifying location of metadata File Store.
+ * {@code null} means no specific folder is configured. <br>
+ *
+ * @param marshallerMappingFileStoreDir folder specifying location of marshaller mapping file store.
+ * {@code null} means no specific folder is configured.
+ * Providing {@code null} will disable unmarshall for non primitive objects, BinaryObjects will be provided <br>
*/
- StandaloneGridKernalContext(IgniteLogger log) {
+ StandaloneGridKernalContext(IgniteLogger log,
+ @Nullable final File binaryMetadataFileStoreDir,
+ @Nullable final File marshallerMappingFileStoreDir) throws IgniteCheckedException {
this.log = log;
try {
@@ -102,6 +129,56 @@ public class StandaloneGridKernalContext implements GridKernalContext {
catch (IgniteCheckedException e) {
throw new IllegalStateException("Must not fail on empty providers list.", e);
}
+
+ this.marshallerContext = new MarshallerContextImpl(null);
+ this.cfg = prepareIgniteConfiguration();
+ this.cacheObjProcessor = binaryMetadataFileStoreDir != null ? binaryProcessor(this, binaryMetadataFileStoreDir) : null;
+
+ if (marshallerMappingFileStoreDir != null) {
+ marshallerContext.setMarshallerMappingFileStoreDir(marshallerMappingFileStoreDir);
+ marshallerContext.onMarshallerProcessorStarted(this, null);
+ }
+ }
+
+ /**
+ * Creates binary processor which allows to convert WAL records into objects
+ *
+ * @param ctx kernal context
+ * @param binaryMetadataFileStoreDir folder specifying location of metadata File Store
+ *
+ * {@code null} means no specific folder is configured. <br> In this case folder for metadata is composed from work
+ * directory and consistentId
+ * @return Cache object processor able to restore data records content into binary objects
+ * @throws IgniteCheckedException Throws in case of initialization errors.
+ */
+ private IgniteCacheObjectProcessor binaryProcessor(
+ final GridKernalContext ctx,
+ final File binaryMetadataFileStoreDir) throws IgniteCheckedException {
+
+ final CacheObjectBinaryProcessorImpl processor = new CacheObjectBinaryProcessorImpl(ctx);
+ processor.setBinaryMetadataFileStoreDir(binaryMetadataFileStoreDir);
+ processor.start();
+ return processor;
+ }
+
+ /**
+ * @return Ignite configuration which allows to start requied processors for WAL reader
+ */
+ private IgniteConfiguration prepareIgniteConfiguration() {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setDiscoverySpi(new StandaloneNoopDiscoverySpi());
+ cfg.setCommunicationSpi(new StandaloneNoopCommunicationSpi());
+
+ final Marshaller marshaller = new BinaryMarshaller();
+ cfg.setMarshaller(marshaller);
+
+ PersistentStoreConfiguration pstCfg = new PersistentStoreConfiguration();
+ cfg.setPersistentStoreConfiguration(pstCfg);
+
+ marshaller.setContext(marshallerContext);
+
+ return cfg;
}
/** {@inheritDoc} */
@@ -141,12 +218,21 @@ public class StandaloneGridKernalContext implements GridKernalContext {
/** {@inheritDoc} */
@Override public IgniteEx grid() {
- return null;
+ final IgniteEx kernal = new IgniteKernal();
+ try {
+ Field fieldCfg = kernal.getClass().getDeclaredField("cfg");
+ fieldCfg.setAccessible(true);
+ fieldCfg.set(kernal, cfg);
+ }
+ catch (NoSuchFieldException | IllegalAccessException e) {
+ log.error("", e);
+ }
+ return kernal;
}
/** {@inheritDoc} */
@Override public IgniteConfiguration config() {
- return null;
+ return cfg;
}
/** {@inheritDoc} */
@@ -251,7 +337,7 @@ public class StandaloneGridKernalContext implements GridKernalContext {
/** {@inheritDoc} */
@Override public PoolProcessor pools() {
- return null;
+ return new PoolProcessor(this);
}
/** {@inheritDoc} */
@@ -276,7 +362,7 @@ public class StandaloneGridKernalContext implements GridKernalContext {
/** {@inheritDoc} */
@Override public IgniteCacheObjectProcessor cacheObjects() {
- return null;
+ return cacheObjProcessor;
}
/** {@inheritDoc} */
@@ -301,12 +387,16 @@ public class StandaloneGridKernalContext implements GridKernalContext {
/** {@inheritDoc} */
@Override public GridIoManager io() {
- return null;
+ return new GridIoManager(this);
}
/** {@inheritDoc} */
@Override public GridDiscoveryManager discovery() {
- return null;
+ return new GridDiscoveryManager(StandaloneGridKernalContext.this) {
+ @Override public Object consistentId() {
+ return ""; // some non null value is required
+ }
+ };
}
/** {@inheritDoc} */
@@ -350,7 +440,8 @@ public class StandaloneGridKernalContext implements GridKernalContext {
}
/** {@inheritDoc} */
- @Override public void markSegmented() { }
+ @Override public void markSegmented() {
+ }
/** {@inheritDoc} */
@Override public boolean segmented() {
@@ -358,7 +449,8 @@ public class StandaloneGridKernalContext implements GridKernalContext {
}
/** {@inheritDoc} */
- @Override public void printMemoryStats() { }
+ @Override public void printMemoryStats() {
+ }
/** {@inheritDoc} */
@Override public boolean isDaemon() {
@@ -487,7 +579,7 @@ public class StandaloneGridKernalContext implements GridKernalContext {
/** {@inheritDoc} */
@Override public MarshallerContextImpl marshallerContext() {
- return null;
+ return marshallerContext;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneIgnitePluginProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneIgnitePluginProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneIgnitePluginProcessor.java
index 838fc85..78588ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneIgnitePluginProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneIgnitePluginProcessor.java
@@ -25,14 +25,14 @@ import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
import org.apache.ignite.plugin.PluginProvider;
/**
- *
+ * No operation, empty plugin processor for creating WAL iterator without node start up
*/
-public class StandaloneIgnitePluginProcessor extends IgnitePluginProcessor {
+class StandaloneIgnitePluginProcessor extends IgnitePluginProcessor {
/**
* @param ctx Kernal context.
* @param cfg Ignite configuration.
*/
- public StandaloneIgnitePluginProcessor(GridKernalContext ctx, IgniteConfiguration cfg) throws IgniteCheckedException {
+ StandaloneIgnitePluginProcessor(GridKernalContext ctx, IgniteConfiguration cfg) throws IgniteCheckedException {
super(ctx, cfg, Collections.<PluginProvider>emptyList());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopCommunicationSpi.java
new file mode 100644
index 0000000..2029647
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopCommunicationSpi.java
@@ -0,0 +1,83 @@
+/*
+ * 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.internal.processors.cache.persistence.wal.reader;
+
+import java.io.Serializable;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.IgniteSpiNoop;
+import org.apache.ignite.spi.communication.CommunicationListener;
+import org.apache.ignite.spi.communication.CommunicationSpi;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * No-operation SPI for standalone WAL reader
+ */
+@IgniteSpiNoop
+public class StandaloneNoopCommunicationSpi extends IgniteSpiAdapter implements CommunicationSpi {
+ /** {@inheritDoc} */
+ @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void spiStop() throws IgniteSpiException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(ClusterNode destNode, Serializable msg) throws IgniteSpiException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getSentMessagesCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getSentBytesCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getReceivedMessagesCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getReceivedBytesCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getOutboundMessagesQueueSize() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void resetMetrics() {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setListener(@Nullable CommunicationListener lsnr) {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopDiscoverySpi.java
new file mode 100644
index 0000000..3946c4f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneNoopDiscoverySpi.java
@@ -0,0 +1,127 @@
+/*
+ * 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.internal.processors.cache.persistence.wal.reader;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.IgniteSpiNoop;
+import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider;
+import org.apache.ignite.spi.discovery.DiscoverySpi;
+import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
+import org.apache.ignite.spi.discovery.DiscoverySpiDataExchange;
+import org.apache.ignite.spi.discovery.DiscoverySpiListener;
+import org.apache.ignite.spi.discovery.DiscoverySpiNodeAuthenticator;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * No-operation SPI for standalone WAL reader
+ */
+@IgniteSpiNoop
+public class StandaloneNoopDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
+ /** {@inheritDoc} */
+ @Nullable @Override public Serializable consistentId() throws IgniteSpiException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> getRemoteNodes() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode getLocalNode() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public ClusterNode getNode(UUID nodeId) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean pingNode(UUID nodeId) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNodeAttributes(Map<String, Object> attrs, IgniteProductVersion ver) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setListener(@Nullable DiscoverySpiListener lsnr) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setDataExchange(DiscoverySpiDataExchange exchange) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setMetricsProvider(DiscoveryMetricsProvider metricsProvider) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void disconnect() throws IgniteSpiException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setAuthenticator(DiscoverySpiNodeAuthenticator auth) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getGridStartTime() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void failNode(UUID nodeId, @Nullable String warning) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClientMode() throws IllegalStateException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void spiStop() throws IgniteSpiException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
index 5bbd7da..900aab5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
@@ -28,8 +28,16 @@ import java.util.Collections;
import java.util.List;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
+import org.apache.ignite.internal.pagemem.wal.record.DataRecord;
+import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry;
+import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
import org.apache.ignite.internal.processors.cache.persistence.wal.AbstractWalRecordsIterator;
@@ -39,6 +47,7 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointe
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
import org.apache.ignite.internal.processors.cache.persistence.wal.SegmentEofException;
import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.util.typedef.F;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -77,49 +86,61 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
*/
private boolean workDir;
+ /** Keep binary. This flag disables converting of non primitive types (BinaryObjects) */
+ private boolean keepBinary;
+
/**
* Creates iterator in directory scan mode
- *
- * @param walFilesDir Wal files directory. Should already contain node consistent ID as subfolder
+ * @param walFilesDir Wal files directory. Should already contain node consistent ID as subfolder
* @param log Logger.
- * @param sharedCtx Shared context.
+ * @param sharedCtx Shared context. Cache processor is to be configured if Cache Object Key & Data Entry is
+ * required.
* @param ioFactory File I/O factory.
+ * @param keepBinary Keep binary. This flag disables converting of non primitive types
+ * (BinaryObjects will be used instead)
*/
StandaloneWalRecordsIterator(
- @NotNull File walFilesDir,
- @NotNull IgniteLogger log,
- @NotNull GridCacheSharedContext sharedCtx,
- @NotNull FileIOFactory ioFactory) throws IgniteCheckedException {
+ @NotNull final File walFilesDir,
+ @NotNull final IgniteLogger log,
+ @NotNull final GridCacheSharedContext sharedCtx,
+ @NotNull final FileIOFactory ioFactory,
+ final boolean keepBinary) throws IgniteCheckedException {
super(log,
sharedCtx,
new RecordV1Serializer(sharedCtx, true),
ioFactory,
BUF_SIZE);
+ this.keepBinary = keepBinary;
init(walFilesDir, false, null);
advance();
}
/**
* Creates iterator in file-by-file iteration mode. Directory
- *
- * @param log Logger.
- * @param sharedCtx Shared context.
+ * @param log Logger.
+ * @param sharedCtx Shared context. Cache processor is to be configured if Cache Object Key & Data Entry is
+ * required.
* @param ioFactory File I/O factory.
* @param workDir Work directory is scanned, false - archive
+ * @param keepBinary Keep binary. This flag disables converting of non primitive types
+ * (BinaryObjects will be used instead)
* @param walFiles Wal files.
*/
StandaloneWalRecordsIterator(
- @NotNull IgniteLogger log,
- @NotNull GridCacheSharedContext sharedCtx,
- @NotNull FileIOFactory ioFactory,
- boolean workDir,
- @NotNull File... walFiles) throws IgniteCheckedException {
+ @NotNull final IgniteLogger log,
+ @NotNull final GridCacheSharedContext sharedCtx,
+ @NotNull final FileIOFactory ioFactory,
+ final boolean workDir,
+ final boolean keepBinary,
+ @NotNull final File... walFiles) throws IgniteCheckedException {
super(log,
sharedCtx,
- new RecordV1Serializer(sharedCtx),
+ new RecordV1Serializer(sharedCtx, true),
ioFactory,
BUF_SIZE);
+
this.workDir = workDir;
+ this.keepBinary = keepBinary;
init(null, workDir, walFiles);
advance();
}
@@ -244,6 +265,96 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
}
/** {@inheritDoc} */
+ @NotNull @Override protected WALRecord postProcessRecord(@NotNull final WALRecord rec) {
+ final GridKernalContext kernalCtx = sharedCtx.kernalContext();
+ final IgniteCacheObjectProcessor processor = kernalCtx.cacheObjects();
+
+ if (processor != null && rec.type() == WALRecord.RecordType.DATA_RECORD) {
+ try {
+ return postProcessDataRecord((DataRecord)rec, kernalCtx, processor);
+ }
+ catch (Exception e) {
+ log.error("Failed to perform post processing for data record ", e);
+ }
+ }
+ return super.postProcessRecord(rec);
+ }
+
+ /**
+ * Performs post processing of lazy data record, converts it to unwrap record.
+ *
+ * @param dataRec data record to post process records.
+ * @param kernalCtx kernal context.
+ * @param processor processor to convert binary form from WAL into CacheObject/BinaryObject.
+ * @return post-processed record.
+ * @throws IgniteCheckedException if failed.
+ */
+ @NotNull private WALRecord postProcessDataRecord(
+ @NotNull final DataRecord dataRec,
+ final GridKernalContext kernalCtx,
+ final IgniteCacheObjectProcessor processor) throws IgniteCheckedException {
+ final CacheObjectContext fakeCacheObjCtx = new CacheObjectContext(kernalCtx,
+ null, null, false, false, false);
+
+ final List<DataEntry> entries = dataRec.writeEntries();
+ final List<DataEntry> postProcessedEntries = new ArrayList<>(entries.size());
+
+ for (DataEntry dataEntry : entries) {
+ final DataEntry postProcessedEntry = postProcessDataEntry(processor, fakeCacheObjCtx, dataEntry);
+
+ postProcessedEntries.add(postProcessedEntry);
+ }
+ return new DataRecord(postProcessedEntries);
+ }
+
+ /**
+ * Converts entry or lazy data entry into unwrapped entry
+ * @param processor cache object processor for de-serializing objects.
+ * @param fakeCacheObjCtx cache object context for de-serializing binary and unwrapping objects.
+ * @param dataEntry entry to process
+ * @return post precessed entry
+ * @throws IgniteCheckedException if failed
+ */
+ @NotNull
+ private DataEntry postProcessDataEntry(
+ final IgniteCacheObjectProcessor processor,
+ final CacheObjectContext fakeCacheObjCtx,
+ final DataEntry dataEntry) throws IgniteCheckedException {
+
+ final KeyCacheObject key;
+ final CacheObject val;
+ final File marshallerMappingFileStoreDir =
+ fakeCacheObjCtx.kernalContext().marshallerContext().getMarshallerMappingFileStoreDir();
+
+ if (dataEntry instanceof LazyDataEntry) {
+ final LazyDataEntry lazyDataEntry = (LazyDataEntry)dataEntry;
+ key = processor.toKeyCacheObject(fakeCacheObjCtx,
+ lazyDataEntry.getKeyType(),
+ lazyDataEntry.getKeyBytes());
+ val = processor.toCacheObject(fakeCacheObjCtx,
+ lazyDataEntry.getValType(),
+ lazyDataEntry.getValBytes());
+ }
+ else {
+ key = dataEntry.key();
+ val = dataEntry.value();
+ }
+
+ return new UnwrapDataEntry(
+ dataEntry.cacheId(),
+ key,
+ val,
+ dataEntry.op(),
+ dataEntry.nearXidVersion(),
+ dataEntry.writeVersion(),
+ dataEntry.expireTime(),
+ dataEntry.partitionId(),
+ dataEntry.partitionCounter(),
+ fakeCacheObjCtx,
+ keepBinary || marshallerMappingFileStoreDir == null);
+ }
+
+ /** {@inheritDoc} */
@Override protected void handleRecordException(
@NotNull final Exception e,
@Nullable final FileWALPointer ptr) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
index 91e1f00..b78e2e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
@@ -163,6 +163,11 @@ public class RecordV1Serializer implements RecordSerializer {
}
/** {@inheritDoc} */
+ @Override public boolean writePointer() {
+ return writePointer;
+ }
+
+ /** {@inheritDoc} */
@SuppressWarnings("CastConflictsWithInstanceof")
@Override public void writeRecord(WALRecord record, ByteBuffer buf) throws IgniteCheckedException {
assert record.size() > 0 && buf.remaining() >= record.size() : record.size();
[04/26] ignite git commit: ignite-6137: CAS logic fix in async commit
This closes #2496.
Posted by sb...@apache.org.
ignite-6137: CAS logic fix in async commit
This closes #2496.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8610471e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8610471e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8610471e
Branch: refs/heads/ignite-6149
Commit: 8610471ed8d28c600268407be1a2d6ddfbf45f6c
Parents: 91cf66e
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 15 13:49:56 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 15 13:49:56 2017 +0300
----------------------------------------------------------------------
.../cache/distributed/near/GridNearTxLocal.java | 2 +-
.../IgniteCacheSystemTransactionsSelfTest.java | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8610471e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index c55276c..058a3ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -3218,7 +3218,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements AutoClosea
GridNearTxFinishFuture fut = commitFut;
- if (fut == null &&
+ if (fut != null ||
!COMMIT_FUT_UPD.compareAndSet(this, null, fut = new GridNearTxFinishFuture<>(cctx, this, true)))
return commitFut;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8610471e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
index e667c49..eb19873 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
@@ -33,8 +33,10 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.transactions.Transaction;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
/**
* Tests that system transactions do not interact with user transactions.
@@ -105,6 +107,22 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf
/**
* @throws Exception If failed.
*/
+ public void testGridNearTxLocalDuplicateAsyncCommit() throws Exception {
+ IgniteKernal ignite = (IgniteKernal)grid(0);
+
+ IgniteInternalCache<Object, Object> utilityCache = ignite.context().cache().utilityCache();
+
+ try (GridNearTxLocal itx = utilityCache.txStartEx(OPTIMISTIC, SERIALIZABLE)) {
+ utilityCache.put("1", "1");
+
+ itx.commitNearTxLocalAsync();
+ itx.commitNearTxLocalAsync().get();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
private void checkTransactionsCommitted() throws Exception {
for (int i = 0; i < gridCount(); i++) {
IgniteKernal kernal = (IgniteKernal)grid(i);
[07/26] ignite git commit: IGNITE-6368: Initial .NET part of thin
client. This closes #2670.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerAssemblyResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerAssemblyResolver.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerAssemblyResolver.cs
index e22e325..a9e07d9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerAssemblyResolver.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerAssemblyResolver.cs
@@ -147,9 +147,9 @@ namespace Apache.Ignite.Core.Impl.Deployment
var func = new GetAssemblyFunc();
var req = new AssemblyRequest(assemblyName);
- foreach (var node in GetDotNetNodes(ignite, originNodeId))
+ foreach (var node in GetDotNetNodes(ignite.GetIgnite(), originNodeId))
{
- var compute = ignite.GetCluster().ForNodeIds(node).GetCompute();
+ var compute = ignite.GetIgnite().GetCluster().ForNodeIds(node).GetCompute();
var result = ComputeApplySafe(compute, func, req);
if (result != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerLoadingObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerLoadingObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerLoadingObjectHolder.cs
index c3546bc..21aa4fb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerLoadingObjectHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Deployment/PeerLoadingObjectHolder.cs
@@ -82,7 +82,7 @@ namespace Apache.Ignite.Core.Impl.Deployment
{
var writer0 = (BinaryWriter) writer.GetRawWriter();
- writer0.WriteGuid(writer0.Marshaller.Ignite.GetCluster().GetLocalNode().Id);
+ writer0.WriteGuid(writer0.Marshaller.Ignite.GetIgnite().GetCluster().GetLocalNode().Id);
writer0.WriteString(_object.GetType().AssemblyQualifiedName);
writer0.WriteObjectDetached(_object);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
index 14ba666..aa28073 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -139,10 +139,11 @@ namespace Apache.Ignite.Core.Impl
if (match.Success && Exs.TryGetValue(match.Groups[1].Value, out innerCtor))
{
return ctor(clsName, msg,
- innerCtor(match.Groups[1].Value, match.Groups[2].Value, innerException, ignite), ignite);
+ innerCtor(match.Groups[1].Value, match.Groups[2].Value, innerException, ignite.GetIgnite()),
+ ignite.GetIgnite());
}
- return ctor(clsName, msg, innerException, ignite);
+ return ctor(clsName, msg, innerException, ignite.GetIgnite());
}
if (ClsNoClsDefFoundErr.Equals(clsName, StringComparison.OrdinalIgnoreCase))
@@ -163,7 +164,7 @@ namespace Apache.Ignite.Core.Impl
if (ctor != null)
{
- return ctor(clsName, msg, innerException, ignite);
+ return ctor(clsName, msg, innerException, ignite.GetIgnite());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IIgniteInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IIgniteInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IIgniteInternal.cs
index 5fd6faa..c2169ed 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IIgniteInternal.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IIgniteInternal.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl
{
using System;
+ using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Datastream;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Cluster;
@@ -27,7 +28,7 @@ namespace Apache.Ignite.Core.Impl
/// <summary>
/// Internal Ignite interface.
/// </summary>
- internal interface IIgniteInternal : IIgnite
+ internal interface IIgniteInternal
{
/// <summary>
/// Gets the binary processor.
@@ -65,5 +66,15 @@ namespace Apache.Ignite.Core.Impl
/// Gets the data streamer.
/// </summary>
IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName, bool keepBinary);
+
+ /// <summary>
+ /// Gets the public Ignite API.
+ /// </summary>
+ IIgnite GetIgnite();
+
+ /// <summary>
+ /// Gets the binary API.
+ /// </summary>
+ IBinary GetBinary();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a00052e9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 59dfe2a..1b42462 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Core.Impl
/// <summary>
/// Native Ignite wrapper.
/// </summary>
- internal class Ignite : PlatformTargetAdapter, ICluster, IIgniteInternal
+ internal class Ignite : PlatformTargetAdapter, ICluster, IIgniteInternal, IIgnite
{
/// <summary>
/// Operation codes for PlatformProcessorImpl calls.
@@ -579,6 +579,14 @@ namespace Apache.Ignite.Core.Impl
return new DataStreamerImpl<TK, TV>(streamerTarget, _marsh, cacheName, keepBinary);
}
+ /// <summary>
+ /// Gets the public Ignite interface.
+ /// </summary>
+ public IIgnite GetIgnite()
+ {
+ return this;
+ }
+
/** <inheritdoc /> */
public IBinary GetBinary()
{
[17/26] ignite git commit: Updated Ignite description
Posted by sb...@apache.org.
Updated Ignite description
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2da8861a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2da8861a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2da8861a
Branch: refs/heads/ignite-6149
Commit: 2da8861a252a8d5b68f75aae07ed394b52cc1390
Parents: cb4195f
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 15 10:01:41 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 15 10:01:41 2017 -0700
----------------------------------------------------------------------
README.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2da8861a/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index a968ca1..b6b5987 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,18 @@ with powerful <b>SQL</b>, <b>key-value</b> and <b>processing</b> APIs.
## Durable Memory
Ignite's durable memory component treats RAM not just as a caching layer but as a complete fully functional storage layer. This means that users can turn the persistence on and off as needed. If the persistence is off, then Ignite can act as a distributed **in-memory database** or **in-memory data grid**, depending on whether you prefer to use SQL or key-value APIs. If the persistence is turned on, then Ignite becomes a distributed, **horizontally scalable database** that guarantees full data consistency and is resilient to full cluster failures.
+## Ignite Persistence
+
+Ignite Native Persistence is a distributed ACID and SQL-compliant disk store that transparently integrates with Ignite's Durable Memory as an optional disk layer storing data and indexes on SSD, Flash, 3D XPoint, and other types of non-volatile storages.
+
+With the Ignite Persistence enabled, you no longer need to keep all the data and indexes in memory or warm it up after a node or cluster restart because the Durable Memory is tightly coupled with persistence and treats it as a secondary memory tier. This implies that if a subset of data or an index is missing in RAM, the Durable Memory will take it from the disk.
+
+<p align="center">
+ <a href="https://apacheignite.readme.io/docs/distributed-persistent-store">
+ <img src="https://ignite.apache.org/images/check_pointing-2.png" width="400px"/>
+ </a>
+</p>
+
## ACID Compliance
Data stored in Ignite is ACID-compliant both in memory and on disk, making Ignite a **strongly consistent** system. Ignite transactions work across the network and can span multiple servers.
@@ -34,18 +46,6 @@ Most traditional databases work in a client-server fashion, meaning that data mu
## Scalability and Durability
Ignite is an elastic, horizontally scalable distributed system that supports adding and removing cluster nodes on demand. Ignite also allows for storing multiple copies of the data, making it resilient to partial cluster failures. If the persistence is enabled, then data stored in Ignite will also survive full cluster failures. Cluster restarts in Ignite can be very fast, as the data becomes operational instantaneously directly from disk. As a result, the data does not need to be preloaded in-memory to begin processing, and Ignite caches will lazily warm up resuming the in memory performance.
-## Ignite Persistence
-
-Ignite Native Persistence is a distributed ACID and SQL-compliant disk store that transparently integrates with Ignite's Durable Memory as an optional disk layer storing data and indexes on SSD, Flash, 3D XPoint, and other types of non-volatile storages.
-
-With the Ignite Persistence enabled, you no longer need to keep all the data and indexes in memory or warm it up after a node or cluster restart because the Durable Memory is tightly coupled with persistence and treats it as a secondary memory tier. This implies that if a subset of data or an index is missing in RAM, the Durable Memory will take it from the disk.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/distributed-persistent-store">
- <img src="https://ignite.apache.org/images/check_pointing-2.png" width="400px"/>
- </a>
-</p>
-
## Ignite Facts
<b>Is Ignite a persistent or pure in-memory storage?</b><br/>
[16/26] ignite git commit: Updated Ignite description
Posted by sb...@apache.org.
Updated Ignite description
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cb4195fa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cb4195fa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cb4195fa
Branch: refs/heads/ignite-6149
Commit: cb4195fabb637c405b40fd613f1abbeae93a70bd
Parents: 1b5ca44
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 15 09:59:24 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 15 09:59:24 2017 -0700
----------------------------------------------------------------------
README.md | 172 --------------------------------------------------------
README.txt | 1 +
2 files changed, 1 insertion(+), 172 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb4195fa/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index d018878..a968ca1 100644
--- a/README.md
+++ b/README.md
@@ -46,178 +46,6 @@ With the Ignite Persistence enabled, you no longer need to keep all the data and
</a>
</p>
-## Advanced Clustering
-
-Ignite nodes can automatically discover each other. This helps to scale the cluster when needed, without having to restart the whole cluster. Developers can also leverage from Ignite’s hybrid cloud support that allows establishing connection between private cloud and public clouds such as Amazon Web Services, providing them with best of both worlds.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/cluster">
- <img src="https://ignite.apache.org/images/advanced-clustering.png" />
- </a>
-</p>
-
-Apache Ignite can be deployed on:
-* AWS
-* Docker
-* Google Cloud
-* Kubernetes
-* Mesos
-* YARN
-
-## Data Grid (JCache)
-
-Ignite data grid is an in-memory distributed key-value store which can be viewed as a distributed partitioned hash map, with every cluster node owning a portion of the overall data. This way the more cluster nodes we add, the more data we can cache.
-
-Unlike other key-value stores, Ignite determines data locality using a pluggable hashing algorithm. Every client can determine which node a key belongs to by plugging it into a hashing function, without a need for any special mapping servers or name nodes.
-
-Ignite data grid supports local, replicated, and partitioned data sets and allows to freely cross query between these data sets using standard SQL syntax. Ignite supports standard SQL for querying in-memory data including support for distributed SQL joins.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/data-grid">
- <img src="https://ignite.apache.org/images/in-memory-data-grid.jpg" />
- </a>
-</p>
-
-Our data grid offers many features, some of which are:
-
-* Primary & Backup Copies
-* Near Caches
-* Cache queries and SQL queries
-* Continuous Queries
-* Transactions
-* Off-Heap Memory
-* Affinity Collocation
-* Persistent Store
-* Automatic Persistence
-* Data Loading
-* Eviction and Expiry Policies
-* Data Rebalancing
-* Web Session Clustering
-* Hibernate L2 Cache
-* JDBC Driver
-* Spring Caching
-* Topology Validation
-
-## SQL Grid
-Apache Ignite incorporates distributed SQL database capabilities as a part of its platform. The database is horizontally scalable, fault tolerant and SQL ANSI-99 compliant. It supports all SQL, DDL, and DML commands including SELECT, UPDATE, INSERT, MERGE, and DELETE queries. It also provides support for a subset of DDL commands relevant for distributed databases.
-
-With Ignite Durable Memory architecture, data as well as indexes can be stored both in memory and, optionally, on disk. This allows executing distributed SQL operations across different memory layers achieving in-memory performance with the durability of disk.
-
-You can interact with Apache Ignite using the SQL language via natively developed APIs for Java, .NET and C++, or via the Ignite JDBC or ODBC drivers. This provides a true cross-platform connectivity from languages such as PHP, Ruby and more.
-
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/distributed-sql">
- <img src="https://ignite.apache.org/images/ignite-distributed-database.png" vspace="15" width="400px"/>
- </a>
-</p>
-
-
-## Compute Grid
-
-Distributed computations are performed in parallel fashion to gain high performance, low latency, and linear scalability. Ignite compute grid provides a set of simple APIs that allow users distribute computations and data processing across multiple computers in the cluster. Distributed parallel processing is based on the ability to take any computation and execute it on any set of cluster nodes and return the results back.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/compute-grid">
- <img src="https://ignite.apache.org/images/in_memory_compute.png" vspace="15"/>
- </a>
-</p>
-
-We support these features, amongst others:
-
-* Distributed Closure Execution
-* MapReduce & ForkJoin Processing
-* Continuous Mapping
-* Clustered Executor Service
-* Per-Node Shared State
-* Collocation of Compute and Data
-* Load Balancing
-* Fault Tolerance
-* Job State Checkpointing
-* Job Scheduling
-
-## Service Grid
-
-Service Grid allows for deployments of arbitrary user-defined services on the cluster. You can implement and deploy any service, such as custom counters, ID generators, hierarchical maps, etc.
-
-Ignite allows you to control how many instances of your service should be deployed on each cluster node and will automatically ensure proper deployment and fault tolerance of all the services.
-
-<p align="center">
- <a href="https://apacheignite.readme.io/docs/service-grid">
- <img src="https://ignite.apache.org/images/ignite_service.png" vspace="15"/>
- </a>
-</p>
-
-## Ignite File System
-
-Ignite File System (IGFS) is an in-memory file system allowing work with files and directories over existing cache infrastructure. IGFS can either work as purely in-memory file system, or delegate to another file system (e.g. various Hadoop file system implementations) acting as a caching layer.
-
-In addition, IGFS provides API to execute map-reduce tasks over file system data.
-
-## Distributed Data Structures
-
-Ignite supports complex data structures in a distributed fashion:
-
-* Queues and sets: ordinary, bounded, collocated, non-collocated
-* Atomic types: `AtomicLong` and `AtomicReference`
-* `CountDownLatch`
-* ID Generators
-
-## Distributed Messaging
-
-Distributed messaging allows for topic based cluster-wide communication between all nodes. Messages with a specified message topic can be distributed to all or sub-group of nodes that have subscribed to that topic.
-
-Ignite messaging is based on publish-subscribe paradigm where publishers and subscribers are connected together by a common topic. When one of the nodes sends a message A for topic T, it is published on all nodes that have subscribed to T.
-
-## Distributed Events
-
-Distributed events allow applications to receive notifications when a variety of events occur in the distributed grid environment. You can automatically get notified for task executions, read, write or query operations occurring on local or remote nodes within the cluster.
-
-## Hadoop Accelerator
-
-Our Hadoop Accelerator provides a set of components allowing for in-memory Hadoop job execution and file system operations.
-
-### MapReduce
-
-An alternate high-performant implementation of job tracker which replaces standard Hadoop MapReduce. Use it to boost your Hadoop MapReduce job execution performance.
-
-<p align="center">
- <a href="https://apacheignite-fs.readme.io/docs/map-reduce">
- <img src="https://ignite.apache.org/images/hadoop-mapreduce.png" vspace="15" height="400"/>
- </a>
-</p>
-
-### IGFS - In-Memory File System
-
-A Hadoop-compliant IGFS File System implementation over which Hadoop can run over in plug-n-play fashion and significantly reduce I/O and improve both, latency and throughput.
-
-<p align="center">
- <a href="https://apacheignite-fs.readme.io/docs/in-memory-file-system">
- <img src="https://ignite.apache.org/images/ignite_filesystem.png" height="300" vspace="15"/>
- </a>
-</p>
-
-### Secondary File System
-
-An implementation of `SecondaryFileSystem`. This implementation can be injected into existing IGFS allowing for read-through and write-through behavior over any other Hadoop FileSystem implementation (e.g. HDFS). Use it if you want your IGFS to become an in-memory caching layer over disk-based HDFS or any other Hadoop-compliant file system.
-
-### Supported Hadoop distributions
-
-* Apache Hadoop
-* Cloudera CDH
-* Hortonworks HDP
-* Apache BigTop
-
-## Spark Shared RDDs
-
-Apache Ignite provides an implementation of Spark RDD abstraction which allows to easily share state in memory across Spark jobs. The main difference between native Spark `RDD` and `IgniteRDD` is that Ignite RDD provides a shared in-memory view on data across different Spark jobs, workers, or applications, while native Spark RDD cannot be seen by other Spark jobs or applications.
-
-<p align="center">
- <a href="https://apacheignite-fs.readme.io/docs/ignite-for-spark">
- <img src="https://ignite.apache.org/images/spark-ignite-rdd.png" height="400" vspace="15" />
- </a>
-</p>
-
## Ignite Facts
<b>Is Ignite a persistent or pure in-memory storage?</b><br/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb4195fa/README.txt
----------------------------------------------------------------------
diff --git a/README.txt b/README.txt
index 9133f2c..9d91e01 100644
--- a/README.txt
+++ b/README.txt
@@ -8,6 +8,7 @@ The main feature set of Ignite In-Memory Data Fabric includes:
* Advanced Clustering
* Compute Grid
* Data Grid
+* Distributed SQL
* Service Grid
* IGFS - Ignite File System
* Distributed Data Structures
[02/26] ignite git commit: IGNITE-6277 Added ability to convert WAL
to human readable form - Fixes #2605.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
index cd0f8ab..5bbd7da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
@@ -92,7 +92,7 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
@NotNull FileIOFactory ioFactory) throws IgniteCheckedException {
super(log,
sharedCtx,
- new RecordV1Serializer(sharedCtx),
+ new RecordV1Serializer(sharedCtx, true),
ioFactory,
BUF_SIZE);
init(walFilesDir, false, null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/record/HeaderRecord.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/record/HeaderRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/record/HeaderRecord.java
index 3fc5637..4fa6232 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/record/HeaderRecord.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/record/HeaderRecord.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.persistence.wal.record;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Header record.
@@ -47,4 +48,9 @@ public class HeaderRecord extends WALRecord {
@Override public RecordType type() {
return RecordType.HEADER_RECORD;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HeaderRecord.class, this, "super", super.toString());
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
index 663fe0c..91e1f00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java
@@ -136,11 +136,22 @@ public class RecordV1Serializer implements RecordSerializer {
/** Skip CRC calculation/check flag */
private boolean skipCrc = IgniteSystemProperties.getBoolean(IGNITE_PDS_SKIP_CRC, false);
+ /** Write pointer. */
+ private final boolean writePointer;
+
/**
* @param cctx Cache shared context.
*/
public RecordV1Serializer(GridCacheSharedContext cctx) {
+ this(cctx, false);
+ }
+
+ /**
+ * @param cctx Cache shared context.
+ */
+ public RecordV1Serializer(GridCacheSharedContext cctx, boolean writePointer) {
this.cctx = cctx;
+ this.writePointer = writePointer;
co = cctx.kernalContext().cacheObjects();
pageSize = cctx.database().pageSize();
@@ -674,7 +685,15 @@ public class RecordV1Serializer implements RecordSerializer {
assert res != null;
- res.size((int)(in0.position() - startPos + CRC_SIZE)); // Account for CRC which will be read afterwards.
+ int size = (int) (in0.position() - startPos + CRC_SIZE);
+
+ res.size(size); // Account for CRC which will be read afterwards.
+
+ if (writePointer && expPtr instanceof FileWALPointer) {
+ FileWALPointer ptr = (FileWALPointer) expPtr;
+
+ res.position(new FileWALPointer(ptr.index(), ptr.fileOffset(), size));
+ }
return res;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
index d50b8e8..16fcb45 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
@@ -165,12 +165,6 @@ public abstract class IgniteDbAbstractTest extends GridCommonAbstractTest {
@Override protected void beforeTest() throws Exception {
deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-// long seed = System.currentTimeMillis();
-//
-// info("Seed: " + seed + "L");
-//
-// BPlusTree.rnd = new Random(seed);
-
startGrids(gridCount());
if (withClientNearCache()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/dev-utils/pom.xml
----------------------------------------------------------------------
diff --git a/modules/dev-utils/pom.xml b/modules/dev-utils/pom.xml
new file mode 100644
index 0000000..2ab0683
--- /dev/null
+++ b/modules/dev-utils/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-dev-utils</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
----------------------------------------------------------------------
diff --git a/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java b/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
new file mode 100644
index 0000000..d0f0a2b
--- /dev/null
+++ b/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
@@ -0,0 +1,83 @@
+/*
+ * 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.development.utils;
+
+import java.io.File;
+import org.apache.ignite.internal.pagemem.wal.WALIterator;
+import org.apache.ignite.internal.pagemem.wal.WALPointer;
+import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
+import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
+import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasInnerIO;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasLeafIO;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2InnerIO;
+import org.apache.ignite.internal.processors.query.h2.database.io.H2LeafIO;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.logger.NullLogger;
+
+/**
+ * Print WAL log data in human-readable form.
+ */
+public class IgniteWalConverter {
+ /**
+ * @param args Args.
+ */
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2)
+ throw new IllegalArgumentException("\nYou need to provide:\n" +
+ "\t1. Size of pages (1024, 2048, etc).\n" +
+ "\t2. Path to dir with wal files.\n" +
+ "\t3. (Optional) Path to dir with archive wal files.");
+
+ PageIO.registerH2(H2InnerIO.VERSIONS, H2LeafIO.VERSIONS);
+ H2ExtrasInnerIO.register();
+ H2ExtrasLeafIO.register();
+
+ final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(new NullLogger(),
+ new RandomAccessFileIOFactory(), new Integer(args[0]));
+
+ final File walWorkDirWithConsistentId = new File(args[1]);
+
+ final File[] workFiles = walWorkDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);
+
+ if (workFiles == null)
+ throw new IllegalArgumentException("No .wal files in dir: " + args[1]);
+
+ try (WALIterator stIt = factory.iteratorWorkFiles(workFiles)) {
+ while (stIt.hasNextX()) {
+ IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
+
+ System.out.println("[W] " + next.get2());
+ }
+ }
+
+ if (args.length >= 3) {
+ final File walArchiveDirWithConsistentId = new File(args[2]);
+
+ try (WALIterator stIt = factory.iteratorArchiveDirectory(walArchiveDirWithConsistentId)) {
+ while (stIt.hasNextX()) {
+ IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
+
+ System.out.println("[A] " + next.get2());
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/319aa840/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 49048db..cfa266d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,7 @@
<module>modules/apache-license-gen</module>
<module>modules/tools</module>
<module>modules/core</module>
+ <module>modules/dev-utils</module>
<module>modules/hadoop</module>
<module>modules/extdata/p2p</module>
<module>modules/extdata/uri</module>
[10/26] ignite git commit: IGNITE-6235 Added ability to handle
CacheObject from DataRecord in standalone WAL iterator - Fixes #2620.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java
index ca54e6f..10e637b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java
@@ -17,20 +17,31 @@
package org.apache.ignite.internal.processors.cache.persistence.db.wal.reader;
+import java.io.Externalizable;
import java.io.File;
-import java.util.Arrays;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.Cache;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.MemoryConfiguration;
@@ -42,15 +53,23 @@ import org.apache.ignite.events.EventType;
import org.apache.ignite.events.WalSegmentArchivedEvent;
import org.apache.ignite.internal.pagemem.wal.WALIterator;
import org.apache.ignite.internal.pagemem.wal.WALPointer;
+import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
+import org.apache.ignite.internal.pagemem.wal.record.DataRecord;
+import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry;
+import org.apache.ignite.internal.pagemem.wal.record.TxRecord;
+import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
-import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory;
-import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_ARCHIVED;
@@ -64,6 +83,9 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
/** Cache name. */
private static final String CACHE_NAME = "cache0";
+ /** additional cache for testing different combinations of types in WAL */
+ private static final String CACHE_ADDL_NAME = "cache1";
+
/** Fill wal with some data before iterating. Should be true for non local run */
private static final boolean fillWalBeforeTest = true;
@@ -89,12 +111,12 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
final IgniteConfiguration cfg = super.getConfiguration(gridName);
- final CacheConfiguration<Integer, IgniteWalReaderTest.IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME);
+ final CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME);
- ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+ ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
- ccfg.setIndexedTypes(Integer.class, IgniteWalReaderTest.IndexedObject.class);
+ ccfg.setIndexedTypes(Integer.class, IndexedObject.class);
cfg.setCacheConfiguration(ccfg);
@@ -125,12 +147,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
pCfg.setWalAutoArchiveAfterInactivity(archiveIncompleteSegmentAfterInactivityMs);
cfg.setPersistentStoreConfiguration(pCfg);
-
- final BinaryConfiguration binCfg = new BinaryConfiguration();
-
- binCfg.setCompactFooter(false);
-
- cfg.setBinaryConfiguration(binCfg);
return cfg;
}
@@ -164,25 +180,29 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
public void testFillWalAndReadRecords() throws Exception {
final int cacheObjectsToWrite = 10000;
+ final String consistentId;
if (fillWalBeforeTest) {
final Ignite ignite0 = startGrid("node0");
ignite0.active(true);
+ consistentId = U.maskForFileName(ignite0.cluster().localNode().consistentId().toString());
+
putDummyRecords(ignite0, cacheObjectsToWrite);
stopGrid("node0");
}
+ else
+ consistentId = "127_0_0_1_47500";
- final File db = U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false);
+ final String workDir = U.defaultWorkDirectory();
+ final File db = U.resolveWorkDirectory(workDir, "db", false);
final File wal = new File(db, "wal");
final File walArchive = new File(wal, "archive");
- final String consistentId = "127_0_0_1_47500";
- final FileIOFactory fileIOFactory = getConfiguration("").getPersistentStoreConfiguration().getFileIOFactory();
- final MockWalIteratorFactory mockItFactory = new MockWalIteratorFactory(log, fileIOFactory, PAGE_SIZE, consistentId, WAL_SEGMENTS);
+ final MockWalIteratorFactory mockItFactory = new MockWalIteratorFactory(log, PAGE_SIZE, consistentId, WAL_SEGMENTS);
final WALIterator it = mockItFactory.iterator(wal, walArchive);
- final int cntUsingMockIter = iterateAndCount(it);
+ final int cntUsingMockIter = iterateAndCount(it, false);
log.info("Total records loaded " + cntUsingMockIter);
assert cntUsingMockIter > 0;
@@ -191,7 +211,11 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
final File walArchiveDirWithConsistentId = new File(walArchive, consistentId);
final File walWorkDirWithConsistentId = new File(wal, consistentId);
- final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log, fileIOFactory, PAGE_SIZE);
+ final File binaryMeta = U.resolveWorkDirectory(workDir, "binary_meta", false);
+ final File binaryMetaWithConsId = new File(binaryMeta, consistentId);
+ final File marshaller = U.resolveWorkDirectory(workDir, "marshaller", false);
+
+ final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log, PAGE_SIZE, binaryMetaWithConsId, marshaller);
final int cntArchiveDir = iterateAndCount(factory.iteratorArchiveDirectory(walArchiveDirWithConsistentId));
log.info("Total records loaded using directory : " + cntArchiveDir);
@@ -209,44 +233,59 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
assert cntUsingMockIter >= cntArchiveDir
: "Mock based reader loaded " + cntUsingMockIter + " records but standalone has loaded only " + cntArchiveDir;
-
final File[] workFiles = walWorkDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);
- int cntWork = 0;
- try (WALIterator stIt = factory.iteratorWorkFiles(workFiles)) {
- while (stIt.hasNextX()) {
- IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
- if (dumpRecords)
- log.info("Work. Record: " + next.get2());
- cntWork++;
- }
- }
+ final int cntWork = iterateAndCount(factory.iteratorWorkFiles(workFiles));
+
log.info("Total records loaded from work: " + cntWork);
assert cntWork + cntArchiveFileByFile == cntUsingMockIter
: "Work iterator loaded [" + cntWork + "] " +
"Archive iterator loaded [" + cntArchiveFileByFile + "]; " +
"mock iterator [" + cntUsingMockIter + "]";
-
}
/**
+ * Iterates on records and closes iterator
+ *
* @param walIter iterator to count, will be closed
* @return count of records
* @throws IgniteCheckedException if failed to iterate
*/
private int iterateAndCount(WALIterator walIter) throws IgniteCheckedException {
- int cntUsingMockIter = 0;
+ return iterateAndCount(walIter, true);
+ }
+
+ /**
+ * Iterates on records and closes iterator
+ *
+ * @param walIter iterator to count, will be closed
+ * @param touchEntries access data within entries
+ * @return count of records
+ * @throws IgniteCheckedException if failed to iterate
+ */
+ private int iterateAndCount(WALIterator walIter, boolean touchEntries) throws IgniteCheckedException {
+ int cnt = 0;
- try(WALIterator it = walIter) {
+ try (WALIterator it = walIter) {
while (it.hasNextX()) {
- IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();
+ final IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();
+ final WALRecord walRecord = next.get2();
+ if (touchEntries && walRecord.type() == WALRecord.RecordType.DATA_RECORD) {
+ final DataRecord record = (DataRecord)walRecord;
+ for (DataEntry entry : record.writeEntries()) {
+ final KeyCacheObject key = entry.key();
+ final CacheObject val = entry.value();
+ if (dumpRecords)
+ log.info("Op: " + entry.op() + ", Key: " + key + ", Value: " + val);
+ }
+ }
if (dumpRecords)
- log.info("Record: " + next.get2());
- cntUsingMockIter++;
+ log.info("Record: " + walRecord);
+ cnt++;
}
}
- return cntUsingMockIter;
+ return cnt;
}
/**
@@ -278,7 +317,7 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
}
}, EVT_WAL_SEGMENT_ARCHIVED);
- putDummyRecords(ignite, 150);
+ putDummyRecords(ignite, 500);
stopGrid("node0");
assert evtRecorded.get();
@@ -298,6 +337,29 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
}
/**
+ * Puts provided number of records to fill WAL under transactions
+ *
+ * @param ignite ignite instance
+ * @param recordsToWrite count
+ * @param txCnt transactions to run. If number is less then records count, txCnt records will be written
+ */
+ private IgniteCache<Object, Object> txPutDummyRecords(Ignite ignite, int recordsToWrite, int txCnt) {
+ IgniteCache<Object, Object> cache0 = ignite.cache(CACHE_NAME);
+ int keysPerTx = recordsToWrite / txCnt;
+ if (keysPerTx == 0)
+ keysPerTx = 1;
+ for (int t = 0; t < txCnt; t++) {
+ try (Transaction tx = ignite.transactions().txStart()) {
+ for (int i = t * keysPerTx; i < (t + 1) * keysPerTx; i++)
+ cache0.put(i, new IndexedObject(i));
+
+ tx.commit();
+ }
+ }
+ return cache0;
+ }
+
+ /**
* Tests time out based WAL segment archiving
*
* @throws Exception if failure occurs
@@ -339,24 +401,518 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
assert recordedAfterSleep;
}
- /** Test object for placing into grid in this test */
- private static class IndexedObject {
+ /**
+ * Removes entry by key and value from map (java 8 map method copy)
+ *
+ * @param m map to remove from.
+ * @param key key to remove.
+ * @param val value to remove.
+ * @return true if remove was successful
+ */
+ private boolean remove(Map m, Object key, Object val) {
+ Object curVal = m.get(key);
+ if (!Objects.equals(curVal, val) ||
+ (curVal == null && !m.containsKey(key)))
+ return false;
+ m.remove(key);
+ return true;
+ }
+
+ /**
+ * Places records under transaction, checks its value using WAL
+ *
+ * @throws Exception if failed.
+ */
+ public void testTxFillWalAndExtractDataRecords() throws Exception {
+ final int cntEntries = 1000;
+ final int txCnt = 100;
+
+ final Map<Object, Object> ctrlMap = new HashMap<>();
+ final String consistentId;
+ if (fillWalBeforeTest) {
+ final Ignite ignite0 = startGrid("node0");
+
+ ignite0.active(true);
+
+ final IgniteCache<Object, Object> entries = txPutDummyRecords(ignite0, cntEntries, txCnt);
+
+ for (Cache.Entry<Object, Object> next : entries) {
+ ctrlMap.put(next.getKey(), next.getValue());
+ }
+
+ consistentId = U.maskForFileName(ignite0.cluster().localNode().consistentId().toString());
+
+ stopGrid("node0");
+ }
+ else
+ consistentId = "127_0_0_1_47500";
+
+ final String workDir = U.defaultWorkDirectory();
+ final File binaryMeta = U.resolveWorkDirectory(workDir, "binary_meta", false);
+ final File binaryMetaWithConsId = new File(binaryMeta, consistentId);
+ final File marshallerMapping = U.resolveWorkDirectory(workDir, "marshaller", false);
+
+ final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log,
+ PAGE_SIZE,
+ binaryMetaWithConsId,
+ marshallerMapping);
+
+ final BiConsumer<Object, Object> objConsumer = new BiConsumer<Object, Object>() {
+ @Override public void accept(Object key, Object val) {
+ boolean rmv = remove(ctrlMap, key, val);
+ if (!rmv)
+ log.error("Unable to remove Key and value from control Map K:[" + key + "] V: [" + val + "]");
+
+ if (val instanceof IndexedObject) {
+ IndexedObject indexedObj = (IndexedObject)val;
+ assertEquals(indexedObj.iVal, indexedObj.jVal);
+ assertEquals(indexedObj.iVal, key);
+ for (byte datum : indexedObj.getData()) {
+ assert datum >= 'A' && datum <= 'A' + 10;
+ }
+ }
+ }
+ };
+ scanIterateAndCount(factory, workDir, consistentId, cntEntries, txCnt, objConsumer, null);
+
+ assert ctrlMap.isEmpty() : " Control Map is not empty after reading entries " + ctrlMap;
+ }
+
+ /**
+ * Scan WAL and WAL archive for logical records and its entries.
+ *
+ * @param factory WAL iterator factory.
+ * @param workDir Ignite work directory.
+ * @param consistentId consistent ID.
+ * @param expCntEntries minimum expected entries count to find.
+ * @param expTxCnt minimum expected transaction count to find.
+ * @param objConsumer object handler, called for each object found in logical data records.
+ * @param dataRecordHnd data handler record
+ * @throws IgniteCheckedException if failed.
+ */
+ private void scanIterateAndCount(
+ final IgniteWalIteratorFactory factory,
+ final String workDir,
+ final String consistentId,
+ final int expCntEntries,
+ final int expTxCnt,
+ @Nullable final BiConsumer<Object, Object> objConsumer,
+ @Nullable final Consumer<DataRecord> dataRecordHnd) throws IgniteCheckedException {
+
+ final File db = U.resolveWorkDirectory(workDir, "db", false);
+ final File wal = new File(db, "wal");
+ final File walArchive = new File(wal, "archive");
+
+ final File walArchiveDirWithConsistentId = new File(walArchive, consistentId);
+
+ final File[] files = walArchiveDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);
+
+ assert files != null : "Can't iterate over files [" + walArchiveDirWithConsistentId + "] Directory is N/A";
+ final WALIterator iter = factory.iteratorArchiveFiles(files);
+
+ final Map<GridCacheVersion, Integer> cntArch = iterateAndCountDataRecord(iter, objConsumer, dataRecordHnd);
+
+ int txCntObservedArch = cntArch.size();
+ if (cntArch.containsKey(null))
+ txCntObservedArch -= 1; // exclude non transactional updates
+ final int entriesArch = valuesSum(cntArch.values());
+
+ log.info("Total tx found loaded using archive directory (file-by-file): " + txCntObservedArch);
+
+ final File walWorkDirWithConsistentId = new File(wal, consistentId);
+ final File[] workFiles = walWorkDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);
+
+ final WALIterator tuples = factory.iteratorWorkFiles(workFiles);
+ final Map<GridCacheVersion, Integer> cntWork = iterateAndCountDataRecord(tuples, objConsumer, dataRecordHnd);
+ int txCntObservedWork = cntWork.size();
+ if (cntWork.containsKey(null))
+ txCntObservedWork -= 1; // exclude non transactional updates
+
+ final int entriesWork = valuesSum(cntWork.values());
+ log.info("Archive directory: Tx found " + txCntObservedWork + " entries " + entriesWork);
+
+ assert entriesArch + entriesWork >= expCntEntries;
+ assert txCntObservedWork + txCntObservedArch >= expTxCnt;
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testFillWalWithDifferentTypes() throws Exception {
+ int cntEntries = 0;
+ final String consistentId;
+
+ final Map<Object, Object> ctrlMap = new HashMap<>();
+ final Map<Object, Object> ctrlMapForBinaryObjects = new HashMap<>();
+ final Collection<String> ctrlStringsToSearch = new HashSet<>();
+ final Collection<String> ctrlStringsForBinaryObjSearch = new HashSet<>();
+ if (fillWalBeforeTest) {
+ final Ignite ignite0 = startGrid("node0");
+ ignite0.active(true);
+
+ final IgniteCache<Object, Object> addlCache = ignite0.getOrCreateCache(CACHE_ADDL_NAME);
+ addlCache.put("1", "2");
+ addlCache.put(1, 2);
+ addlCache.put(1L, 2L);
+ addlCache.put(TestEnum.A, "Enum_As_Key");
+ addlCache.put("Enum_As_Value", TestEnum.B);
+ addlCache.put(TestEnum.C, TestEnum.C);
+
+ addlCache.put("Serializable", new TestSerializable(42));
+ addlCache.put(new TestSerializable(42), "Serializable_As_Key");
+ addlCache.put("Externalizable", new TestExternalizable(42));
+ addlCache.put(new TestExternalizable(42), "Externalizable_As_Key");
+ addlCache.put(292, new IndexedObject(292));
+
+ final String search1 = "SomeUnexpectedStringValueAsKeyToSearch";
+ ctrlStringsToSearch.add(search1);
+ ctrlStringsForBinaryObjSearch.add(search1);
+ addlCache.put(search1, "SearchKey");
+
+ String search2 = "SomeTestStringContainerToBePrintedLongLine";
+ final TestStringContainerToBePrinted val = new TestStringContainerToBePrinted(search2);
+ ctrlStringsToSearch.add(val.toString()); //will validate original toString() was called
+ ctrlStringsForBinaryObjSearch.add(search2);
+ addlCache.put("SearchValue", val);
+
+ String search3 = "SomeTestStringContainerToBePrintedLongLine2";
+ final TestStringContainerToBePrinted key = new TestStringContainerToBePrinted(search3);
+ ctrlStringsToSearch.add(key.toString()); //will validate original toString() was called
+ ctrlStringsForBinaryObjSearch.add(search3); //validate only string itself
+ addlCache.put(key, "SearchKey");
+
+ cntEntries = addlCache.size();
+ for (Cache.Entry<Object, Object> next : addlCache) {
+ ctrlMap.put(next.getKey(), next.getValue());
+ }
+
+ for (Cache.Entry<Object, Object> next : addlCache) {
+ ctrlMapForBinaryObjects.put(next.getKey(), next.getValue());
+ }
+
+ consistentId = U.maskForFileName(ignite0.cluster().localNode().consistentId().toString());
+
+ stopGrid("node0");
+ }
+ else
+ consistentId = "127_0_0_1_47500";
+
+ final String workDir = U.defaultWorkDirectory();
+
+ final File binaryMeta = U.resolveWorkDirectory(workDir, "binary_meta", false);
+ final File binaryMetaWithConsId = new File(binaryMeta, consistentId);
+ final File marshallerMapping = U.resolveWorkDirectory(workDir, "marshaller", false);
+
+ final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log, PAGE_SIZE,
+ binaryMetaWithConsId,
+ marshallerMapping);
+ final BiConsumer<Object, Object> objConsumer = new BiConsumer<Object, Object>() {
+ @Override public void accept(Object key, Object val) {
+ log.info("K: [" + key + ", " +
+ (key != null ? key.getClass().getName() : "?") + "]" +
+ " V: [" + val + ", " +
+ (val != null ? val.getClass().getName() : "?") + "]");
+ boolean rmv = remove(ctrlMap, key, val);
+ if (!rmv) {
+ String msg = "Unable to remove pair from control map " + "K: [" + key + "] V: [" + val + "]";
+ log.error(msg);
+ }
+ assert !(val instanceof BinaryObject);
+ }
+ };
+
+ final Consumer<DataRecord> toStrChecker = new Consumer<DataRecord>() {
+ @Override public void accept(DataRecord record) {
+ String strRepresentation = record.toString();
+ for (Iterator<String> iter = ctrlStringsToSearch.iterator(); iter.hasNext(); ) {
+ final String next = iter.next();
+ if (strRepresentation.contains(next)) {
+ iter.remove();
+ break;
+ }
+ }
+ }
+ };
+ scanIterateAndCount(factory, workDir, consistentId, cntEntries, 0, objConsumer, toStrChecker);
+
+ assert ctrlMap.isEmpty() : " Control Map is not empty after reading entries: " + ctrlMap;
+ assert ctrlStringsToSearch.isEmpty() : " Control Map for strings in entries is not empty after" +
+ " reading records: " + ctrlStringsToSearch;
+
+ //Validate same WAL log with flag binary objects only
+ final IgniteWalIteratorFactory keepBinFactory = new IgniteWalIteratorFactory(log, PAGE_SIZE,
+ binaryMetaWithConsId,
+ marshallerMapping,
+ true);
+ final BiConsumer<Object, Object> binObjConsumer = new BiConsumer<Object, Object>() {
+ @Override public void accept(Object key, Object val) {
+ log.info("K(KeepBinary): [" + key + ", " +
+ (key != null ? key.getClass().getName() : "?") + "]" +
+ " V(KeepBinary): [" + val + ", " +
+ (val != null ? val.getClass().getName() : "?") + "]");
+ boolean rmv = remove(ctrlMapForBinaryObjects, key, val);
+ if (!rmv) {
+ if (key instanceof BinaryObject) {
+ BinaryObject keyBinObj = (BinaryObject)key;
+ String binaryObjTypeName = keyBinObj.type().typeName();
+ if (Objects.equals(TestStringContainerToBePrinted.class.getName(), binaryObjTypeName)) {
+ String data = keyBinObj.field("data");
+ rmv = ctrlMapForBinaryObjects.remove(new TestStringContainerToBePrinted(data)) != null;
+ }
+ else if (Objects.equals(TestSerializable.class.getName(), binaryObjTypeName)) {
+ Integer iVal = keyBinObj.field("iVal");
+ rmv = ctrlMapForBinaryObjects.remove(new TestSerializable(iVal)) != null;
+ }
+ else if (Objects.equals(TestEnum.class.getName(), binaryObjTypeName)) {
+ TestEnum key1 = TestEnum.values()[keyBinObj.enumOrdinal()];
+ rmv = ctrlMapForBinaryObjects.remove(key1) != null;
+ }
+ }
+ else if (val instanceof BinaryObject) {
+ //don't compare BO values, just remove by key
+ rmv = ctrlMapForBinaryObjects.remove(key) != null;
+ }
+ }
+ if (!rmv)
+ log.error("Unable to remove pair from control map " + "K: [" + key + "] V: [" + val + "]");
+
+ if (val instanceof BinaryObject) {
+ BinaryObject binaryObj = (BinaryObject)val;
+ String binaryObjTypeName = binaryObj.type().typeName();
+ if (Objects.equals(IndexedObject.class.getName(), binaryObjTypeName)) {
+ assertEquals(binaryObj.field("iVal").toString(),
+ binaryObj.field("jVal").toString());
+
+ byte data[] = binaryObj.field("data");
+ for (byte datum : data) {
+ assert datum >= 'A' && datum <= 'A' + 10;
+ }
+ }
+ }
+ }
+ };
+
+ final Consumer<DataRecord> binObjToStringChecker = new Consumer<DataRecord>() {
+ @Override public void accept(DataRecord record) {
+ String strRepresentation = record.toString();
+ for (Iterator<String> iter = ctrlStringsForBinaryObjSearch.iterator(); iter.hasNext(); ) {
+ final String next = iter.next();
+ if (strRepresentation.contains(next)) {
+ iter.remove();
+ break;
+ }
+ }
+ }
+ };
+ scanIterateAndCount(keepBinFactory, workDir, consistentId, cntEntries, 0, binObjConsumer, binObjToStringChecker);
+
+ assert ctrlMapForBinaryObjects.isEmpty() : " Control Map is not empty after reading entries: " + ctrlMapForBinaryObjects;
+ assert ctrlStringsForBinaryObjSearch.isEmpty() : " Control Map for strings in entries is not empty after" +
+ " reading records: " + ctrlStringsForBinaryObjSearch;
+
+ }
+
+ /**
+ * @param values collection with numbers
+ * @return sum of numbers
+ */
+ private int valuesSum(Iterable<Integer> values) {
+ int sum = 0;
+ for (Integer next : values) {
+ if (next != null)
+ sum += next;
+ }
+ return sum;
+ }
+
+ /**
+ * Iterates over data records, checks each DataRecord and its entries, finds out all transactions in WAL
+ *
+ * @param walIter iterator to use
+ * @return count of data records observed for each global TX ID. Contains null for non tx updates
+ * @throws IgniteCheckedException if failure
+ */
+ private Map<GridCacheVersion, Integer> iterateAndCountDataRecord(
+ final WALIterator walIter,
+ @Nullable final BiConsumer<Object, Object> cacheObjHnd,
+ @Nullable final Consumer<DataRecord> dataRecordHnd) throws IgniteCheckedException {
+
+ final Map<GridCacheVersion, Integer> entriesUnderTxFound = new HashMap<>();
+
+ try (WALIterator stIt = walIter) {
+ while (stIt.hasNextX()) {
+ final IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
+ final WALRecord walRecord = next.get2();
+
+ if (walRecord.type() == WALRecord.RecordType.DATA_RECORD && walRecord instanceof DataRecord) {
+ final DataRecord dataRecord = (DataRecord)walRecord;
+
+ if (dataRecordHnd != null)
+ dataRecordHnd.accept(dataRecord);
+ final List<DataEntry> entries = dataRecord.writeEntries();
+
+ for (DataEntry entry : entries) {
+ final GridCacheVersion globalTxId = entry.nearXidVersion();
+ Object unwrappedKeyObj;
+ Object unwrappedValObj;
+ if (entry instanceof UnwrapDataEntry) {
+ UnwrapDataEntry unwrapDataEntry = (UnwrapDataEntry)entry;
+ unwrappedKeyObj = unwrapDataEntry.unwrappedKey();
+ unwrappedValObj = unwrapDataEntry.unwrappedValue();
+ }
+ else if (entry instanceof LazyDataEntry) {
+ unwrappedKeyObj = null;
+ unwrappedValObj = null;
+ //can't check value
+ }
+ else {
+ final CacheObject val = entry.value();
+
+ unwrappedValObj = val instanceof BinaryObject ? val : val.value(null, false);
+
+ final CacheObject key = entry.key();
+
+ unwrappedKeyObj = key instanceof BinaryObject ? key : key.value(null, false);
+ }
+ log.info("//Entry operation " + entry.op() + "; cache Id" + entry.cacheId() + "; " +
+ "under transaction: " + globalTxId +
+ //; entry " + entry +
+ "; Key: " + unwrappedKeyObj +
+ "; Value: " + unwrappedValObj);
+
+ if (cacheObjHnd != null && unwrappedKeyObj != null || unwrappedValObj != null)
+ cacheObjHnd.accept(unwrappedKeyObj, unwrappedValObj);
+
+ final Integer entriesUnderTx = entriesUnderTxFound.get(globalTxId);
+ entriesUnderTxFound.put(globalTxId, entriesUnderTx == null ? 1 : entriesUnderTx + 1);
+ }
+ }
+ else if (walRecord.type() == WALRecord.RecordType.TX_RECORD && walRecord instanceof TxRecord) {
+ final TxRecord txRecord = (TxRecord)walRecord;
+ final GridCacheVersion globalTxId = txRecord.nearXidVersion();
+
+ log.info("//Tx Record, action: " + txRecord.action() +
+ "; nearTxVersion" + globalTxId);
+ }
+ }
+ }
+ return entriesUnderTxFound;
+ }
+
+ /**
+ * Represents an operation that accepts a single input argument and returns no
+ * result.
+ *
+ * @param <T>
+ */
+ private interface Consumer<T> {
+ /**
+ * Performs this operation on the given argument.
+ *
+ * @param t the input argument
+ */
+ public void accept(T t);
+ }
+
+ /**
+ * Represents an operation that accepts two input arguments and returns no
+ * result.
+ *
+ * @param <T>
+ */
+ private interface BiConsumer<T, U> {
+ /**
+ * Performs this operation on the given argument.
+ *
+ * @param t the input argument
+ */
+ public void accept(T t, U u);
+ }
+
+ /** Enum for cover binaryObject enum save/load */
+ enum TestEnum {
+ /** */A, /** */B, /** */C
+ }
+
+ /** Special class to test WAL reader resistance to Serializable interface */
+ static class TestSerializable implements Serializable {
/** */
- @QuerySqlField(index = true)
+ private static final long serialVersionUID = 0L;
+
+ /** I value. */
private int iVal;
- /** Data filled with recognizable pattern */
- private byte[] data;
+ /**
+ * Creates test object
+ *
+ * @param iVal I value.
+ */
+ TestSerializable(int iVal) {
+ this.iVal = iVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "TestSerializable{" +
+ "iVal=" + iVal +
+ '}';
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TestSerializable that = (TestSerializable)o;
+
+ return iVal == that.iVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return iVal;
+ }
+ }
+
+ /** Special class to test WAL reader resistance to Serializable interface */
+ static class TestExternalizable implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** I value. */
+ private int iVal;
+
+ /** Noop ctor for unmarshalling */
+ public TestExternalizable() {
+
+ }
/**
- * @param iVal Integer value.
+ * Creates test object with provided value
+ *
+ * @param iVal I value.
*/
- private IndexedObject(int iVal) {
+ public TestExternalizable(int iVal) {
this.iVal = iVal;
- int sz = 40000;
- data = new byte[sz];
- for (int i = 0; i < sz; i++)
- data[i] = (byte)('A' + (i % 10));
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "TestExternalizable{" +
+ "iVal=" + iVal +
+ '}';
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(iVal);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ iVal = in.readInt();
}
/** {@inheritDoc} */
@@ -366,23 +922,53 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
if (o == null || getClass() != o.getClass())
return false;
- IndexedObject obj = (IndexedObject)o;
+ TestExternalizable that = (TestExternalizable)o;
+
+ return iVal == that.iVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return iVal;
+ }
+ }
+
+ /** Container class to test toString of data records */
+ static class TestStringContainerToBePrinted {
+ /** */
+ private String data;
- if (iVal != obj.iVal)
+ /**
+ * Creates container
+ *
+ * @param data value to be searched in to String
+ */
+ public TestStringContainerToBePrinted(String data) {
+ this.data = data;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
return false;
- return Arrays.equals(data, obj.data);
+
+ TestStringContainerToBePrinted printed = (TestStringContainerToBePrinted)o;
+
+ return data != null ? data.equals(printed.data) : printed.data == null;
}
/** {@inheritDoc} */
@Override public int hashCode() {
- int res = iVal;
- res = 31 * res + Arrays.hashCode(data);
- return res;
+ return data != null ? data.hashCode() : 0;
}
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(IgniteWalReaderTest.IndexedObject.class, this);
+ return "TestStringContainerToBePrinted{" +
+ "data='" + data + '\'' +
+ '}';
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IndexedObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IndexedObject.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IndexedObject.java
new file mode 100644
index 0000000..78fa63a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IndexedObject.java
@@ -0,0 +1,79 @@
+/*
+ * 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.internal.processors.cache.persistence.db.wal.reader;
+
+import java.util.Arrays;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/** Test object for placing into grid in this test */
+class IndexedObject {
+ /** I value. */
+ @QuerySqlField(index = true)
+ int iVal;
+
+ /** J value = I value. */
+ @QuerySqlField(index = true)
+ int jVal;
+
+ /** Data filled with recognizable pattern */
+ private byte[] data;
+
+ /**
+ * @param iVal Integer value.
+ */
+ IndexedObject(int iVal) {
+ this.iVal = iVal;
+ this.jVal = iVal;
+ int sz = 1024;
+ data = new byte[sz];
+ for (int i = 0; i < sz; i++)
+ data[i] = (byte)('A' + (i % 10));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ IndexedObject obj = (IndexedObject)o;
+
+ if (iVal != obj.iVal)
+ return false;
+ return Arrays.equals(data, obj.data);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = iVal;
+ res = 31 * res + Arrays.hashCode(data);
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IndexedObject.class, this);
+ }
+
+ /** @return bytes data */
+ public byte[] getData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/MockWalIteratorFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/MockWalIteratorFactory.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/MockWalIteratorFactory.java
index ef162d2..f90ae37 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/MockWalIteratorFactory.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/MockWalIteratorFactory.java
@@ -43,9 +43,6 @@ public class MockWalIteratorFactory {
/** Logger. */
private final IgniteLogger log;
- /** */
- private final FileIOFactory ioFactory;
-
/** Page size. */
private final int pageSize;
@@ -62,9 +59,8 @@ public class MockWalIteratorFactory {
* @param consistentId Consistent id.
* @param segments Segments.
*/
- public MockWalIteratorFactory(@Nullable IgniteLogger log, FileIOFactory ioFactory, int pageSize, String consistentId, int segments) {
+ public MockWalIteratorFactory(@Nullable IgniteLogger log, int pageSize, String consistentId, int segments) {
this.log = log == null ? Mockito.mock(IgniteLogger.class) : log;
- this.ioFactory = ioFactory;
this.pageSize = pageSize;
this.consistentId = consistentId;
this.segments = segments;
@@ -72,8 +68,8 @@ public class MockWalIteratorFactory {
/**
* Creates iterator
- * @param wal WAL directory without node id
- * @param walArchive WAL archive without node id
+ * @param wal WAL directory without node consistent id
+ * @param walArchive WAL archive without node consistent id
* @return iterator
* @throws IgniteCheckedException if IO failed
*/
@@ -85,7 +81,9 @@ public class MockWalIteratorFactory {
when(persistentCfg1.getWalSegments()).thenReturn(segments);
when(persistentCfg1.getTlbSize()).thenReturn(PersistentStoreConfiguration.DFLT_TLB_SIZE);
when(persistentCfg1.getWalRecordIteratorBufferSize()).thenReturn(PersistentStoreConfiguration.DFLT_WAL_RECORD_ITERATOR_BUFFER_SIZE);
- when(persistentCfg1.getFileIOFactory()).thenReturn(ioFactory);
+
+ final FileIOFactory fileIOFactory = new PersistentStoreConfiguration().getFileIOFactory();
+ when(persistentCfg1.getFileIOFactory()).thenReturn(fileIOFactory);
final IgniteConfiguration cfg = Mockito.mock(IgniteConfiguration.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/dev-utils/pom.xml
----------------------------------------------------------------------
diff --git a/modules/dev-utils/pom.xml b/modules/dev-utils/pom.xml
index 2ab0683..40e58b8 100644
--- a/modules/dev-utils/pom.xml
+++ b/modules/dev-utils/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-dev-utils</artifactId>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.3.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
----------------------------------------------------------------------
diff --git a/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java b/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
index d0f0a2b..b7c3cb7 100644
--- a/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
+++ b/modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverter.java
@@ -51,7 +51,10 @@ public class IgniteWalConverter {
H2ExtrasLeafIO.register();
final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(new NullLogger(),
- new RandomAccessFileIOFactory(), new Integer(args[0]));
+ Integer.parseInt(args[0]),
+ null,
+ null,
+ false);
final File walWorkDirWithConsistentId = new File(args[1]);
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/modules/tools/src/main/java/org/apache/ignite/tools/ant/beautifier/GridJavadocAntTask.java
----------------------------------------------------------------------
diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/ant/beautifier/GridJavadocAntTask.java b/modules/tools/src/main/java/org/apache/ignite/tools/ant/beautifier/GridJavadocAntTask.java
index 611af41..a7723b9 100644
--- a/modules/tools/src/main/java/org/apache/ignite/tools/ant/beautifier/GridJavadocAntTask.java
+++ b/modules/tools/src/main/java/org/apache/ignite/tools/ant/beautifier/GridJavadocAntTask.java
@@ -174,9 +174,13 @@ public class GridJavadocAntTask extends MatchingTask {
Jerry otherPackages =
doc.find("div.contentContainer table.overviewSummary caption span:contains('Other Packages')");
- if (otherPackages.size() > 0)
+ if (otherPackages.size() > 0) {
+ System.err.println("[ERROR]: 'Other Packages' section should not be present, but found: " +
+ doc.html());
throw new IllegalArgumentException("'Other Packages' section should not be present, " +
- "all packages should have corresponding documentation groups: " + file);
+ "all packages should have corresponding documentation groups: " + file + ";" +
+ "Please add packages description to parent/pom.xml into <plugin>(maven-javadoc-plugin) / <configuration> / <groups>");
+ }
}
else if (!isViewHtml(file)) {
// Try to find a class description block.
http://git-wip-us.apache.org/repos/asf/ignite/blob/39b90301/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 19d3498..4ee4310 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -456,6 +456,10 @@
<title>RocketMQ integration</title>
<packages>org.apache.ignite.rocketmq*</packages>
</group>
+ <group>
+ <title>Ignite Development Utils</title>
+ <packages>org.apache.ignite.development.utils*</packages>
+ </group>
</groups>
<header>
<![CDATA[