You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/09/14 11:11:10 UTC
[01/28] ignite git commit: IGNITE-1396: Hidden .Net platform API for
a while.
Repository: ignite
Updated Branches:
refs/heads/ignite-971 ee0041f8b -> fcfc37908
IGNITE-1396: Hidden .Net platform API for a while.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d96e0d24
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d96e0d24
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d96e0d24
Branch: refs/heads/ignite-971
Commit: d96e0d2410ee8dfa94af93b0b6aa6517dd2dedde
Parents: 45df2a7
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Sep 10 11:41:19 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 10 11:41:19 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableContext.java | 6 +-
.../dotnet/PlatformDotNetConfiguration.java | 119 +++++++++
.../PlatformDotNetPortableConfiguration.java | 228 +++++++++++++++++
...PlatformDotNetPortableTypeConfiguration.java | 248 +++++++++++++++++++
.../dotnet/PlatformDotNetConfiguration.java | 119 ---------
.../PlatformDotNetPortableConfiguration.java | 228 -----------------
...PlatformDotNetPortableTypeConfiguration.java | 248 -------------------
.../PlatformDotNetConfigurationClosure.java | 1 -
.../dotnet/PlatformDotNetConfigurationEx.java | 1 -
.../Config/Compute/compute-standalone.xml | 8 +-
.../Config/cache-portables.xml | 4 +-
.../Config/cache-query.xml | 4 +-
.../native-client-test-cache-affinity.xml | 6 +-
13 files changed, 609 insertions(+), 611 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 52df2a0..c64adc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -61,9 +61,9 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration;
import org.apache.ignite.portable.PortableException;
import org.apache.ignite.portable.PortableIdMapper;
import org.apache.ignite.portable.PortableInvalidClassException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java
new file mode 100644
index 0000000..fac69fb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.PlatformConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMarshalAware;
+import org.apache.ignite.portable.PortableRawReader;
+import org.apache.ignite.portable.PortableRawWriter;
+import org.apache.ignite.portable.PortableReader;
+import org.apache.ignite.portable.PortableWriter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Mirror of .Net class Configuration.cs
+ */
+public class PlatformDotNetConfiguration implements PlatformConfiguration, PortableMarshalAware {
+ /** */
+ private PlatformDotNetPortableConfiguration portableCfg;
+
+ /** */
+ private List<String> assemblies;
+
+ /**
+ * Default constructor.
+ */
+ public PlatformDotNetConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param cfg Configuration to copy.
+ */
+ public PlatformDotNetConfiguration(PlatformDotNetConfiguration cfg) {
+ if (cfg.getPortableConfiguration() != null)
+ portableCfg = new PlatformDotNetPortableConfiguration(cfg.getPortableConfiguration());
+
+ if (cfg.getAssemblies() != null)
+ assemblies = new ArrayList<>(cfg.getAssemblies());
+ }
+
+ /**
+ * @return Configuration.
+ */
+ public PlatformDotNetPortableConfiguration getPortableConfiguration() {
+ return portableCfg;
+ }
+
+ /**
+ * @param portableCfg Configuration.
+ */
+ public void setPortableConfiguration(PlatformDotNetPortableConfiguration portableCfg) {
+ this.portableCfg = portableCfg;
+ }
+
+ /**
+ * @return Assemblies.
+ */
+ public List<String> getAssemblies() {
+ return assemblies;
+ }
+
+ /**
+ *
+ * @param assemblies Assemblies.
+ */
+ public void setAssemblies(List<String> assemblies) {
+ this.assemblies = assemblies;
+ }
+
+ /**
+ * @return Configuration copy.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private PlatformDotNetConfiguration copy() {
+ return new PlatformDotNetConfiguration(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ PortableRawWriter rawWriter = writer.rawWriter();
+
+ rawWriter.writeObject(portableCfg);
+ rawWriter.writeCollection(assemblies);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ PortableRawReader rawReader = reader.rawReader();
+
+ portableCfg = rawReader.readObject();
+ assemblies = (List<String>)rawReader.<String>readCollection();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformDotNetConfiguration.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java
new file mode 100644
index 0000000..a9b6022
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java
@@ -0,0 +1,228 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMarshalAware;
+import org.apache.ignite.portable.PortableRawReader;
+import org.apache.ignite.portable.PortableRawWriter;
+import org.apache.ignite.portable.PortableReader;
+import org.apache.ignite.portable.PortableWriter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Mirror of .Net class PortableConfiguration.cs
+ */
+public class PlatformDotNetPortableConfiguration implements PortableMarshalAware {
+ /** Type cfgs. */
+ private Collection<PlatformDotNetPortableTypeConfiguration> typesCfg;
+
+ /** Types. */
+ private Collection<String> types;
+
+ /** Default name mapper. */
+ private String dfltNameMapper;
+
+ /** Default id mapper. */
+ private String dfltIdMapper;
+
+ /** Default serializer. */
+ private String dfltSerializer;
+
+ /** Default metadata enabled. */
+ private boolean dfltMetadataEnabled = true;
+
+ /** Whether to cache deserialized value in IGridPortableObject */
+ private boolean dfltKeepDeserialized = true;
+
+ /**
+ * Default constructor.
+ */
+ public PlatformDotNetPortableConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ * @param cfg configuration to copy.
+ */
+ public PlatformDotNetPortableConfiguration(PlatformDotNetPortableConfiguration cfg) {
+ if (cfg.getTypesConfiguration() != null) {
+ typesCfg = new ArrayList<>();
+
+ for (PlatformDotNetPortableTypeConfiguration typeCfg : cfg.getTypesConfiguration())
+ typesCfg.add(new PlatformDotNetPortableTypeConfiguration(typeCfg));
+ }
+
+ if (cfg.getTypes() != null)
+ types = new ArrayList<>(cfg.getTypes());
+
+ dfltNameMapper = cfg.getDefaultNameMapper();
+ dfltIdMapper = cfg.getDefaultIdMapper();
+ dfltSerializer = cfg.getDefaultSerializer();
+ dfltMetadataEnabled = cfg.isDefaultMetadataEnabled();
+ dfltKeepDeserialized = cfg.isDefaultKeepDeserialized();
+ }
+
+ /**
+ * @return Type cfgs.
+ */
+ public Collection<PlatformDotNetPortableTypeConfiguration> getTypesConfiguration() {
+ return typesCfg;
+ }
+
+ /**
+ * @param typesCfg New type cfgs.
+ */
+ public void setTypesConfiguration(Collection<PlatformDotNetPortableTypeConfiguration> typesCfg) {
+ this.typesCfg = typesCfg;
+ }
+
+ /**
+ * @return Types.
+ */
+ public Collection<String> getTypes() {
+ return types;
+ }
+
+ /**
+ * @param types New types.
+ */
+ public void setTypes(Collection<String> types) {
+ this.types = types;
+ }
+
+ /**
+ * @return Default name mapper.
+ */
+ public String getDefaultNameMapper() {
+ return dfltNameMapper;
+ }
+
+ /**
+ * @param dfltNameMapper New default name mapper.
+ */
+ public void setDefaultNameMapper(String dfltNameMapper) {
+ this.dfltNameMapper = dfltNameMapper;
+ }
+
+ /**
+ * @return Default id mapper.
+ */
+ public String getDefaultIdMapper() {
+ return dfltIdMapper;
+ }
+
+ /**
+ * @param dfltIdMapper New default id mapper.
+ */
+ public void setDefaultIdMapper(String dfltIdMapper) {
+ this.dfltIdMapper = dfltIdMapper;
+ }
+
+ /**
+ * @return Default serializer.
+ */
+ public String getDefaultSerializer() {
+ return dfltSerializer;
+ }
+
+ /**
+ * @param dfltSerializer New default serializer.
+ */
+ public void setDefaultSerializer(String dfltSerializer) {
+ this.dfltSerializer = dfltSerializer;
+ }
+
+ /**
+ * Gets default metadata enabled flag. See {@link #setDefaultMetadataEnabled(boolean)} for more information.
+ *
+ * @return Default metadata enabled flag.
+ */
+ public boolean isDefaultMetadataEnabled() {
+ return dfltMetadataEnabled;
+ }
+
+ /**
+ * Sets default metadata enabled flag. When set to {@code true} all portable types will save it's metadata to
+ * cluster.
+ * <p />
+ * Can be overridden for particular type using
+ * {@link PlatformDotNetPortableTypeConfiguration#setMetadataEnabled(Boolean)}.
+ *
+ * @param dfltMetadataEnabled Default metadata enabled flag.
+ */
+ public void setDefaultMetadataEnabled(boolean dfltMetadataEnabled) {
+ this.dfltMetadataEnabled = dfltMetadataEnabled;
+ }
+
+ /**
+ * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ */
+ public boolean isDefaultKeepDeserialized() {
+ return dfltKeepDeserialized;
+ }
+
+ /**
+ * Sets default keep deserialized flag.
+ * <p />
+ * Can be overridden for particular type using
+ * {@link PlatformDotNetPortableTypeConfiguration#setKeepDeserialized(Boolean)}.
+ *
+ * @param keepDeserialized Keep deserialized flag.
+ */
+ public void setDefaultKeepDeserialized(boolean keepDeserialized) {
+ this.dfltKeepDeserialized = keepDeserialized;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ PortableRawWriter rawWriter = writer.rawWriter();
+
+ rawWriter.writeCollection(typesCfg);
+ rawWriter.writeCollection(types);
+ rawWriter.writeString(dfltNameMapper);
+ rawWriter.writeString(dfltIdMapper);
+ rawWriter.writeString(dfltSerializer);
+ rawWriter.writeBoolean(dfltMetadataEnabled);
+ rawWriter.writeBoolean(dfltKeepDeserialized);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ PortableRawReader rawReader = reader.rawReader();
+
+ typesCfg = rawReader.readCollection();
+ types = rawReader.readCollection();
+ dfltNameMapper = rawReader.readString();
+ dfltIdMapper = rawReader.readString();
+ dfltSerializer = rawReader.readString();
+ dfltMetadataEnabled = rawReader.readBoolean();
+ dfltKeepDeserialized = rawReader.readBoolean();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformDotNetPortableConfiguration.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
new file mode 100644
index 0000000..d7f1ab1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
@@ -0,0 +1,248 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMarshalAware;
+import org.apache.ignite.portable.PortableRawReader;
+import org.apache.ignite.portable.PortableRawWriter;
+import org.apache.ignite.portable.PortableReader;
+import org.apache.ignite.portable.PortableWriter;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Mirror of .Net class GridDotNetPortableTypeConfiguration.cs
+ */
+public class PlatformDotNetPortableTypeConfiguration implements PortableMarshalAware {
+ /** Assembly name. */
+ private String assemblyName;
+
+ /** Type name. */
+ private String typeName;
+
+ /** Name mapper. */
+ private String nameMapper;
+
+ /** Id mapper. */
+ private String idMapper;
+
+ /** Serializer. */
+ private String serializer;
+
+ /** Affinity key field name. */
+ private String affinityKeyFieldName;
+
+ /** Metadata enabled. */
+ private Boolean metadataEnabled;
+
+ /** Whether to cache deserialized value in IGridPortableObject. */
+ private Boolean keepDeserialized;
+
+ /**
+ * Default constructor.
+ */
+ public PlatformDotNetPortableTypeConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ * @param cfg configuration to copy.
+ */
+ public PlatformDotNetPortableTypeConfiguration(PlatformDotNetPortableTypeConfiguration cfg) {
+ assemblyName = cfg.getAssemblyName();
+ typeName = cfg.getTypeName();
+ nameMapper = cfg.getNameMapper();
+ idMapper = cfg.getIdMapper();
+ serializer = cfg.getSerializer();
+ affinityKeyFieldName = cfg.getAffinityKeyFieldName();
+ metadataEnabled = cfg.getMetadataEnabled();
+ keepDeserialized = cfg.isKeepDeserialized();
+ }
+
+ /**
+ * @return Assembly name.
+ */
+ public String getAssemblyName() {
+ return assemblyName;
+ }
+
+ /**
+ * @param assemblyName New assembly name.
+ */
+ public void setAssemblyName(String assemblyName) {
+ this.assemblyName = assemblyName;
+ }
+
+ /**
+ * @return Type name.
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+
+ /**
+ * @param typeName New type name.
+ */
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ /**
+ * @return Name mapper.
+ */
+ public String getNameMapper() {
+ return nameMapper;
+ }
+
+ /**
+ * @param nameMapper New name mapper.
+ */
+ public void setNameMapper(String nameMapper) {
+ this.nameMapper = nameMapper;
+ }
+
+ /**
+ * @return Id mapper.
+ */
+ public String getIdMapper() {
+ return idMapper;
+ }
+
+ /**
+ * @param idMapper New id mapper.
+ */
+ public void setIdMapper(String idMapper) {
+ this.idMapper = idMapper;
+ }
+
+ /**
+ * @return Serializer.
+ */
+ public String getSerializer() {
+ return serializer;
+ }
+
+ /**
+ * @param serializer New serializer.
+ */
+ public void setSerializer(String serializer) {
+ this.serializer = serializer;
+ }
+
+ /**
+ * Gets metadata enabled flag. See {@link #setMetadataEnabled(Boolean)} for more information.
+ *
+ * @return Metadata enabled flag.
+ */
+ public Boolean getMetadataEnabled() {
+ return metadataEnabled;
+ }
+
+ /**
+ * Sets metadata enabled flag.
+ * <p />
+ * When set to {@code null} default value taken from
+ * {@link PlatformDotNetPortableConfiguration#isDefaultMetadataEnabled()} will be used.
+ *
+ * @param metadataEnabled New metadata enabled.
+ */
+ public void setMetadataEnabled(Boolean metadataEnabled) {
+ this.metadataEnabled = metadataEnabled;
+ }
+
+ /**
+ * @return Affinity key field name.
+ */
+ public String getAffinityKeyFieldName() {
+ return affinityKeyFieldName;
+ }
+
+ /**
+ * @param affinityKeyFieldName Affinity key field name.
+ */
+ public void setAffinityKeyFieldName(String affinityKeyFieldName) {
+ this.affinityKeyFieldName = affinityKeyFieldName;
+ }
+
+ /**
+ * Gets keep deserialized flag.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ * @deprecated Use {@link #getKeepDeserialized()} instead.
+ */
+ @Deprecated
+ @Nullable public Boolean isKeepDeserialized() {
+ return keepDeserialized;
+ }
+
+ /**
+ * Gets keep deserialized flag. See {@link #setKeepDeserialized(Boolean)} for more information.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ */
+ @Nullable public Boolean getKeepDeserialized() {
+ return keepDeserialized;
+ }
+
+ /**
+ * Sets keep deserialized flag.
+ * <p />
+ * When set to {@code null} default value taken from
+ * {@link PlatformDotNetPortableConfiguration#isDefaultKeepDeserialized()} will be used.
+ *
+ * @param keepDeserialized Keep deserialized flag.
+ */
+ public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
+ this.keepDeserialized = keepDeserialized;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ PortableRawWriter rawWriter = writer.rawWriter();
+
+ rawWriter.writeString(assemblyName);
+ rawWriter.writeString(typeName);
+ rawWriter.writeString(nameMapper);
+ rawWriter.writeString(idMapper);
+ rawWriter.writeString(serializer);
+ rawWriter.writeString(affinityKeyFieldName);
+ rawWriter.writeObject(metadataEnabled);
+ rawWriter.writeObject(keepDeserialized);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ PortableRawReader rawReader = reader.rawReader();
+
+ assemblyName = rawReader.readString();
+ typeName = rawReader.readString();
+ nameMapper = rawReader.readString();
+ idMapper = rawReader.readString();
+ serializer = rawReader.readString();
+ affinityKeyFieldName = rawReader.readString();
+ metadataEnabled = rawReader.readObject();
+ keepDeserialized = rawReader.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformDotNetPortableTypeConfiguration.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
deleted file mode 100644
index bbeee3b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
+++ /dev/null
@@ -1,119 +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.platform.dotnet;
-
-import org.apache.ignite.internal.processors.platform.PlatformConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableMarshalAware;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableRawWriter;
-import org.apache.ignite.portable.PortableReader;
-import org.apache.ignite.portable.PortableWriter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Mirror of .Net class Configuration.cs
- */
-public class PlatformDotNetConfiguration implements PlatformConfiguration, PortableMarshalAware {
- /** */
- private PlatformDotNetPortableConfiguration portableCfg;
-
- /** */
- private List<String> assemblies;
-
- /**
- * Default constructor.
- */
- public PlatformDotNetConfiguration() {
- // No-op.
- }
-
- /**
- * Copy constructor.
- *
- * @param cfg Configuration to copy.
- */
- public PlatformDotNetConfiguration(PlatformDotNetConfiguration cfg) {
- if (cfg.getPortableConfiguration() != null)
- portableCfg = new PlatformDotNetPortableConfiguration(cfg.getPortableConfiguration());
-
- if (cfg.getAssemblies() != null)
- assemblies = new ArrayList<>(cfg.getAssemblies());
- }
-
- /**
- * @return Configuration.
- */
- public PlatformDotNetPortableConfiguration getPortableConfiguration() {
- return portableCfg;
- }
-
- /**
- * @param portableCfg Configuration.
- */
- public void setPortableConfiguration(PlatformDotNetPortableConfiguration portableCfg) {
- this.portableCfg = portableCfg;
- }
-
- /**
- * @return Assemblies.
- */
- public List<String> getAssemblies() {
- return assemblies;
- }
-
- /**
- *
- * @param assemblies Assemblies.
- */
- public void setAssemblies(List<String> assemblies) {
- this.assemblies = assemblies;
- }
-
- /**
- * @return Configuration copy.
- */
- @SuppressWarnings("UnusedDeclaration")
- private PlatformDotNetConfiguration copy() {
- return new PlatformDotNetConfiguration(this);
- }
-
- /** {@inheritDoc} */
- @Override public void writePortable(PortableWriter writer) throws PortableException {
- PortableRawWriter rawWriter = writer.rawWriter();
-
- rawWriter.writeObject(portableCfg);
- rawWriter.writeCollection(assemblies);
- }
-
- /** {@inheritDoc} */
- @Override public void readPortable(PortableReader reader) throws PortableException {
- PortableRawReader rawReader = reader.rawReader();
-
- portableCfg = rawReader.readObject();
- assemblies = (List<String>)rawReader.<String>readCollection();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PlatformDotNetConfiguration.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
deleted file mode 100644
index 644a8e6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
+++ /dev/null
@@ -1,228 +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.platform.dotnet;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableMarshalAware;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableRawWriter;
-import org.apache.ignite.portable.PortableReader;
-import org.apache.ignite.portable.PortableWriter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * Mirror of .Net class PortableConfiguration.cs
- */
-public class PlatformDotNetPortableConfiguration implements PortableMarshalAware {
- /** Type cfgs. */
- private Collection<PlatformDotNetPortableTypeConfiguration> typesCfg;
-
- /** Types. */
- private Collection<String> types;
-
- /** Default name mapper. */
- private String dfltNameMapper;
-
- /** Default id mapper. */
- private String dfltIdMapper;
-
- /** Default serializer. */
- private String dfltSerializer;
-
- /** Default metadata enabled. */
- private boolean dfltMetadataEnabled = true;
-
- /** Whether to cache deserialized value in IGridPortableObject */
- private boolean dfltKeepDeserialized = true;
-
- /**
- * Default constructor.
- */
- public PlatformDotNetPortableConfiguration() {
- // No-op.
- }
-
- /**
- * Copy constructor.
- * @param cfg configuration to copy.
- */
- public PlatformDotNetPortableConfiguration(PlatformDotNetPortableConfiguration cfg) {
- if (cfg.getTypesConfiguration() != null) {
- typesCfg = new ArrayList<>();
-
- for (PlatformDotNetPortableTypeConfiguration typeCfg : cfg.getTypesConfiguration())
- typesCfg.add(new PlatformDotNetPortableTypeConfiguration(typeCfg));
- }
-
- if (cfg.getTypes() != null)
- types = new ArrayList<>(cfg.getTypes());
-
- dfltNameMapper = cfg.getDefaultNameMapper();
- dfltIdMapper = cfg.getDefaultIdMapper();
- dfltSerializer = cfg.getDefaultSerializer();
- dfltMetadataEnabled = cfg.isDefaultMetadataEnabled();
- dfltKeepDeserialized = cfg.isDefaultKeepDeserialized();
- }
-
- /**
- * @return Type cfgs.
- */
- public Collection<PlatformDotNetPortableTypeConfiguration> getTypesConfiguration() {
- return typesCfg;
- }
-
- /**
- * @param typesCfg New type cfgs.
- */
- public void setTypesConfiguration(Collection<PlatformDotNetPortableTypeConfiguration> typesCfg) {
- this.typesCfg = typesCfg;
- }
-
- /**
- * @return Types.
- */
- public Collection<String> getTypes() {
- return types;
- }
-
- /**
- * @param types New types.
- */
- public void setTypes(Collection<String> types) {
- this.types = types;
- }
-
- /**
- * @return Default name mapper.
- */
- public String getDefaultNameMapper() {
- return dfltNameMapper;
- }
-
- /**
- * @param dfltNameMapper New default name mapper.
- */
- public void setDefaultNameMapper(String dfltNameMapper) {
- this.dfltNameMapper = dfltNameMapper;
- }
-
- /**
- * @return Default id mapper.
- */
- public String getDefaultIdMapper() {
- return dfltIdMapper;
- }
-
- /**
- * @param dfltIdMapper New default id mapper.
- */
- public void setDefaultIdMapper(String dfltIdMapper) {
- this.dfltIdMapper = dfltIdMapper;
- }
-
- /**
- * @return Default serializer.
- */
- public String getDefaultSerializer() {
- return dfltSerializer;
- }
-
- /**
- * @param dfltSerializer New default serializer.
- */
- public void setDefaultSerializer(String dfltSerializer) {
- this.dfltSerializer = dfltSerializer;
- }
-
- /**
- * Gets default metadata enabled flag. See {@link #setDefaultMetadataEnabled(boolean)} for more information.
- *
- * @return Default metadata enabled flag.
- */
- public boolean isDefaultMetadataEnabled() {
- return dfltMetadataEnabled;
- }
-
- /**
- * Sets default metadata enabled flag. When set to {@code true} all portable types will save it's metadata to
- * cluster.
- * <p />
- * Can be overridden for particular type using
- * {@link PlatformDotNetPortableTypeConfiguration#setMetadataEnabled(Boolean)}.
- *
- * @param dfltMetadataEnabled Default metadata enabled flag.
- */
- public void setDefaultMetadataEnabled(boolean dfltMetadataEnabled) {
- this.dfltMetadataEnabled = dfltMetadataEnabled;
- }
-
- /**
- * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information.
- *
- * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
- */
- public boolean isDefaultKeepDeserialized() {
- return dfltKeepDeserialized;
- }
-
- /**
- * Sets default keep deserialized flag.
- * <p />
- * Can be overridden for particular type using
- * {@link PlatformDotNetPortableTypeConfiguration#setKeepDeserialized(Boolean)}.
- *
- * @param keepDeserialized Keep deserialized flag.
- */
- public void setDefaultKeepDeserialized(boolean keepDeserialized) {
- this.dfltKeepDeserialized = keepDeserialized;
- }
-
- /** {@inheritDoc} */
- @Override public void writePortable(PortableWriter writer) throws PortableException {
- PortableRawWriter rawWriter = writer.rawWriter();
-
- rawWriter.writeCollection(typesCfg);
- rawWriter.writeCollection(types);
- rawWriter.writeString(dfltNameMapper);
- rawWriter.writeString(dfltIdMapper);
- rawWriter.writeString(dfltSerializer);
- rawWriter.writeBoolean(dfltMetadataEnabled);
- rawWriter.writeBoolean(dfltKeepDeserialized);
- }
-
- /** {@inheritDoc} */
- @Override public void readPortable(PortableReader reader) throws PortableException {
- PortableRawReader rawReader = reader.rawReader();
-
- typesCfg = rawReader.readCollection();
- types = rawReader.readCollection();
- dfltNameMapper = rawReader.readString();
- dfltIdMapper = rawReader.readString();
- dfltSerializer = rawReader.readString();
- dfltMetadataEnabled = rawReader.readBoolean();
- dfltKeepDeserialized = rawReader.readBoolean();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PlatformDotNetPortableConfiguration.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
deleted file mode 100644
index b6fdbde..0000000
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.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.platform.dotnet;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableMarshalAware;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableRawWriter;
-import org.apache.ignite.portable.PortableReader;
-import org.apache.ignite.portable.PortableWriter;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Mirror of .Net class GridDotNetPortableTypeConfiguration.cs
- */
-public class PlatformDotNetPortableTypeConfiguration implements PortableMarshalAware {
- /** Assembly name. */
- private String assemblyName;
-
- /** Type name. */
- private String typeName;
-
- /** Name mapper. */
- private String nameMapper;
-
- /** Id mapper. */
- private String idMapper;
-
- /** Serializer. */
- private String serializer;
-
- /** Affinity key field name. */
- private String affinityKeyFieldName;
-
- /** Metadata enabled. */
- private Boolean metadataEnabled;
-
- /** Whether to cache deserialized value in IGridPortableObject. */
- private Boolean keepDeserialized;
-
- /**
- * Default constructor.
- */
- public PlatformDotNetPortableTypeConfiguration() {
- // No-op.
- }
-
- /**
- * Copy constructor.
- * @param cfg configuration to copy.
- */
- public PlatformDotNetPortableTypeConfiguration(PlatformDotNetPortableTypeConfiguration cfg) {
- assemblyName = cfg.getAssemblyName();
- typeName = cfg.getTypeName();
- nameMapper = cfg.getNameMapper();
- idMapper = cfg.getIdMapper();
- serializer = cfg.getSerializer();
- affinityKeyFieldName = cfg.getAffinityKeyFieldName();
- metadataEnabled = cfg.getMetadataEnabled();
- keepDeserialized = cfg.isKeepDeserialized();
- }
-
- /**
- * @return Assembly name.
- */
- public String getAssemblyName() {
- return assemblyName;
- }
-
- /**
- * @param assemblyName New assembly name.
- */
- public void setAssemblyName(String assemblyName) {
- this.assemblyName = assemblyName;
- }
-
- /**
- * @return Type name.
- */
- public String getTypeName() {
- return typeName;
- }
-
- /**
- * @param typeName New type name.
- */
- public void setTypeName(String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * @return Name mapper.
- */
- public String getNameMapper() {
- return nameMapper;
- }
-
- /**
- * @param nameMapper New name mapper.
- */
- public void setNameMapper(String nameMapper) {
- this.nameMapper = nameMapper;
- }
-
- /**
- * @return Id mapper.
- */
- public String getIdMapper() {
- return idMapper;
- }
-
- /**
- * @param idMapper New id mapper.
- */
- public void setIdMapper(String idMapper) {
- this.idMapper = idMapper;
- }
-
- /**
- * @return Serializer.
- */
- public String getSerializer() {
- return serializer;
- }
-
- /**
- * @param serializer New serializer.
- */
- public void setSerializer(String serializer) {
- this.serializer = serializer;
- }
-
- /**
- * Gets metadata enabled flag. See {@link #setMetadataEnabled(Boolean)} for more information.
- *
- * @return Metadata enabled flag.
- */
- public Boolean getMetadataEnabled() {
- return metadataEnabled;
- }
-
- /**
- * Sets metadata enabled flag.
- * <p />
- * When set to {@code null} default value taken from
- * {@link PlatformDotNetPortableConfiguration#isDefaultMetadataEnabled()} will be used.
- *
- * @param metadataEnabled New metadata enabled.
- */
- public void setMetadataEnabled(Boolean metadataEnabled) {
- this.metadataEnabled = metadataEnabled;
- }
-
- /**
- * @return Affinity key field name.
- */
- public String getAffinityKeyFieldName() {
- return affinityKeyFieldName;
- }
-
- /**
- * @param affinityKeyFieldName Affinity key field name.
- */
- public void setAffinityKeyFieldName(String affinityKeyFieldName) {
- this.affinityKeyFieldName = affinityKeyFieldName;
- }
-
- /**
- * Gets keep deserialized flag.
- *
- * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
- * @deprecated Use {@link #getKeepDeserialized()} instead.
- */
- @Deprecated
- @Nullable public Boolean isKeepDeserialized() {
- return keepDeserialized;
- }
-
- /**
- * Gets keep deserialized flag. See {@link #setKeepDeserialized(Boolean)} for more information.
- *
- * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
- */
- @Nullable public Boolean getKeepDeserialized() {
- return keepDeserialized;
- }
-
- /**
- * Sets keep deserialized flag.
- * <p />
- * When set to {@code null} default value taken from
- * {@link PlatformDotNetPortableConfiguration#isDefaultKeepDeserialized()} will be used.
- *
- * @param keepDeserialized Keep deserialized flag.
- */
- public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
- this.keepDeserialized = keepDeserialized;
- }
-
- /** {@inheritDoc} */
- @Override public void writePortable(PortableWriter writer) throws PortableException {
- PortableRawWriter rawWriter = writer.rawWriter();
-
- rawWriter.writeString(assemblyName);
- rawWriter.writeString(typeName);
- rawWriter.writeString(nameMapper);
- rawWriter.writeString(idMapper);
- rawWriter.writeString(serializer);
- rawWriter.writeString(affinityKeyFieldName);
- rawWriter.writeObject(metadataEnabled);
- rawWriter.writeObject(keepDeserialized);
- }
-
- /** {@inheritDoc} */
- @Override public void readPortable(PortableReader reader) throws PortableException {
- PortableRawReader rawReader = reader.rawReader();
-
- assemblyName = rawReader.readString();
- typeName = rawReader.readString();
- nameMapper = rawReader.readString();
- idMapper = rawReader.readString();
- serializer = rawReader.readString();
- affinityKeyFieldName = rawReader.readString();
- metadataEnabled = rawReader.readObject();
- keepDeserialized = rawReader.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PlatformDotNetPortableTypeConfiguration.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6c3128a..6e03dfe 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -37,7 +37,6 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
import org.apache.ignite.portable.PortableException;
import org.apache.ignite.portable.PortableMetadata;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
index eaf0997..11e0476 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
@@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.PlatformConfigurationEx;
import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
index bd34958..617c889 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
@@ -54,9 +54,9 @@
</property>
<property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration">
<property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration">
<property name="types">
<list>
<value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
@@ -70,10 +70,10 @@
</property>
<property name="typesConfiguration">
<list>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
<property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
</bean>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
<property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
</bean>
</list>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
index 84f9e5a..ea8a4f5 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
@@ -30,9 +30,9 @@
<property name="connectorConfiguration"><null/></property>
<property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration">
<property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration">
<property name="types">
<list>
<value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
index 787a921..ce45725 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
@@ -30,9 +30,9 @@
<property name="connectorConfiguration"><null/></property>
<property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration">
<property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration">
<property name="types">
<list>
<value>Apache.Ignite.Core.Tests.Cache.Query.QueryPerson</value>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d96e0d24/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
index f08018d..f0dd111 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
@@ -27,12 +27,12 @@
<property name="connectorConfiguration"><null/></property>
<property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration">
<property name="portableConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration">
<property name="typesConfiguration">
<list>
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+ <bean class="org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
<property name="typeName"
value="Apache.Ignite.Core.Tests.Cache.CacheAffinityTest+AffinityTestKey"/>
<property name="affinityKeyFieldName" value="_affKey"/>
[14/28] ignite git commit: ignite-1028 (cherry picked from commit
395b320)
Posted by sb...@apache.org.
ignite-1028
(cherry picked from commit 395b320)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70ad5ba7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70ad5ba7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70ad5ba7
Branch: refs/heads/ignite-971
Commit: 70ad5ba7721e58f0ac18d3c76fd00b3854df4387
Parents: f02fca6
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 11 12:06:32 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 11 14:02:21 2015 +0300
----------------------------------------------------------------------
.../internal/util/GridSpiCloseableIteratorWrapper.java | 5 +++++
.../processors/cache/GridCacheP2PUndeploySelfTest.java | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/70ad5ba7/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpiCloseableIteratorWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpiCloseableIteratorWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpiCloseableIteratorWrapper.java
index 5c76cbd..afc574f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpiCloseableIteratorWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpiCloseableIteratorWrapper.java
@@ -54,4 +54,9 @@ public class GridSpiCloseableIteratorWrapper<T> extends GridCloseableIteratorAda
@Override protected void onClose() throws IgniteCheckedException {
iter.close();
}
+
+ /** {@inheritDoc} */
+ @Override protected void onRemove() throws IgniteCheckedException {
+ iter.remove();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70ad5ba7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
index ba52c2f..2c8c748 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
@@ -81,7 +81,11 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest {
cfg.setMarshaller(new JdkMarshaller());
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ FileSwapSpaceSpi swap = new FileSwapSpaceSpi();
+
+ swap.setWriteBufferSize(1);
+
+ cfg.setSwapSpaceSpi(swap);
CacheConfiguration repCacheCfg = defaultCacheConfiguration();
@@ -233,6 +237,8 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest {
cache2.localEvict(ImmutableSet.of(2, 3, 4));
+ U.sleep(100); //Time to store entries to disk.
+
long swapSize = size(cacheName, grid2);
info("Swap size: " + swapSize);
[17/28] ignite git commit: Modified TODO due to GG -> Ignite ticket
migration.
Posted by sb...@apache.org.
Modified TODO due to GG -> Ignite ticket migration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/12b0f2bb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/12b0f2bb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/12b0f2bb
Branch: refs/heads/ignite-971
Commit: 12b0f2bb8123517456a27b302743bf8df3edd113
Parents: cbc8877
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 11 15:19:50 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 11 15:19:50 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/platform/events/PlatformEvents.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/12b0f2bb/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
index 997c019..8585526 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
@@ -141,7 +141,7 @@ public class PlatformEvents extends PlatformAbstractTarget {
throws IgniteCheckedException {
switch (type) {
case OP_RECORD_LOCAL:
- // TODO: GG-10244
+ // TODO: IGNITE-1410.
return TRUE;
case OP_ENABLE_LOCAL:
[04/28] ignite git commit: Topology validator javadoc fix (cherry
picked from commit 9601736)
Posted by sb...@apache.org.
Topology validator javadoc fix
(cherry picked from commit 9601736)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d36db7bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d36db7bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d36db7bf
Branch: refs/heads/ignite-971
Commit: d36db7bf8683c0641ea809963b95dfa7e10176f6
Parents: 978c4ed
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 10 13:06:12 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 10 13:08:27 2015 +0300
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 41 +-------------------
.../ignite/configuration/TopologyValidator.java | 24 +++++++++++-
2 files changed, 25 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36db7bf/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 643804f..9fb56bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1785,26 +1785,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/**
* Gets topology validator.
* <p>
- * Topology validator checks whether the new topology is valid for specific cache at each topology change.
- * Topology is always valid in case no topology validator used.
- * <p>
- * In case topology is valid for specific cache all operations on this cache are allowed.
- * <p>
- * In case topology is not valid for specific cache all update operations on this cache are restricted:
- * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
- * <p>{@link IgniteException} will be thrown at transaction commit attempt.
+ * See {@link TopologyValidator} for details.
*
- * <p>
- * Usage example
- * <p>
- * Following validator allows to put data only in case topology contains exactly 2 nodes:
- * <pre>{@code
- * new TopologyValidator() {
- * public boolean validate(Collection<ClusterNode> nodes) {
- * return nodes.size() == 2;
- * }
- * }
- * }</pre>
* @return validator.
*/
public TopologyValidator getTopologyValidator() {
@@ -1814,26 +1796,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/**
* Sets topology validator.
* <p>
- * Topology validator checks whether the new topology is valid for specific cache at each topology change.
- * Topology is always valid in case no topology validator used.
- * <p>
- * In case topology is valid for specific cache all operations on this cache are allowed.
- * <p>
- * In case topology is not valid for specific cache all update operations on this cache are restricted:
- * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
- * <p>{@link IgniteException} will be thrown at transaction commit attempt.
- *
- * <p>
- * Usage example
- * <p>
- * Following validator allows to put data only in case topology contains exactly 2 nodes:
- * <pre>{@code
- * new TopologyValidator() {
- * public boolean validate(Collection<ClusterNode> nodes) {
- * return nodes.size() == 2;
- * }
- * }
- * }</pre>
+ * See {@link TopologyValidator} for details.
*
* @param topValidator validator.
* @return {@code this} for chaining.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36db7bf/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
index 49c06a0..874fc69 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
@@ -19,10 +19,32 @@ package org.apache.ignite.configuration;
import java.io.Serializable;
import java.util.Collection;
+import javax.cache.CacheException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
/**
- * Topology validator.
+ * Topology validator checks whether the new topology is valid for specific cache at each topology change.
+ * <p>
+ * Topology is always valid in case no topology validator used.
+ * <p>
+ * In case topology is valid for specific cache all operations on this cache are allowed.
+ * <p>
+ * In case topology is not valid for specific cache all update operations on this cache are restricted:
+ * <ul>
+ * <li>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.</li>
+ * <li>{@link IgniteException} will be thrown at transaction commit attempt.</li>
+ * </ul>
+ * Usage example
+ * <p>
+ * Following validator allows to put data only in case topology contains exactly 2 nodes:
+ * <pre>{@code
+ * new TopologyValidator() {
+ * public boolean validate(Collection<ClusterNode> nodes) {
+ * return nodes.size() == 2;
+ * }
+ * }
+ * }</pre>
*/
public interface TopologyValidator extends Serializable {
/**
[20/28] ignite git commit: ignite-1250 JDBC driver: migration to
embedded Ignite client node
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java
new file mode 100644
index 0000000..5092b42
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java
@@ -0,0 +1,1520 @@
+/*
+ * 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.jdbc2;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * JDBC result set implementation.
+ */
+public class JdbcResultSet implements ResultSet {
+ /** Uuid. */
+ private final UUID uuid;
+
+ /** Statement. */
+ private final JdbcStatement stmt;
+
+ /** Table names. */
+ private final List<String> tbls;
+
+ /** Column names. */
+ private final List<String> cols;
+
+ /** Class names. */
+ private final List<String> types;
+
+ /** Rows cursor iterator. */
+ private Iterator<List<?>> it;
+
+ /** Finished flag. */
+ private boolean finished;
+
+ /** Current position. */
+ private int pos;
+
+ /** Current. */
+ private List<Object> curr;
+
+ /** Closed flag. */
+ private boolean closed;
+
+ /** Was {@code NULL} flag. */
+ private boolean wasNull;
+
+ /** Fetch size. */
+ private int fetchSize;
+
+ /**
+ * Creates new result set with predefined fields.
+ * Result set created with this constructor will
+ * never execute remote tasks.
+ *
+ * @param uuid Query UUID.
+ * @param stmt Statement.
+ * @param tbls Table names.
+ * @param cols Column names.
+ * @param types Types.
+ * @param fields Fields.
+ */
+ JdbcResultSet(@Nullable UUID uuid, JdbcStatement stmt, List<String> tbls, List<String> cols,
+ List<String> types, Collection<List<?>> fields, boolean finished) {
+ assert stmt != null;
+ assert tbls != null;
+ assert cols != null;
+ assert types != null;
+ assert fields != null;
+
+ this.uuid = uuid;
+ this.stmt = stmt;
+ this.tbls = tbls;
+ this.cols = cols;
+ this.types = types;
+ this.finished = finished;
+
+ this.it = fields.iterator();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public boolean next() throws SQLException {
+ ensureNotClosed();
+
+ if (it == null || (stmt.getMaxRows() > 0 && pos >= stmt.getMaxRows())) {
+ curr = null;
+
+ return false;
+ }
+ else if (it.hasNext()) {
+ curr = new ArrayList<>(it.next());
+
+ pos++;
+
+ if (finished && !it.hasNext())
+ it = null;
+
+ return true;
+ }
+ else if (!finished) {
+ JdbcConnection conn = (JdbcConnection)stmt.getConnection();
+
+ Ignite ignite = conn.ignite();
+
+ UUID nodeId = conn.nodeId();
+
+ boolean loc = nodeId == null;
+
+ JdbcQueryTask qryTask = new JdbcQueryTask(loc ? ignite : null, conn.cacheName(),
+ null, loc, null, fetchSize, uuid, conn.isLocalQuery(), conn.isCollocatedQuery());
+
+ try {
+ JdbcQueryTask.QueryResult res =
+ loc ? qryTask.call() : ignite.compute(ignite.cluster().forNodeId(nodeId)).call(qryTask);
+
+ finished = res.isFinished();
+
+ it = res.getRows().iterator();
+
+ return next();
+ }
+ catch (Exception e) {
+ throw new SQLException("Failed to query Ignite.", e);
+ }
+ }
+
+ it = null;
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws SQLException {
+ if (uuid != null)
+ stmt.resSets.remove(this);
+
+ closeInternal();
+ }
+
+ /**
+ * Marks result set as closed.
+ * If this result set is associated with locally executed query then query cursor will also closed.
+ */
+ void closeInternal() throws SQLException {
+ if (((JdbcConnection)stmt.getConnection()).nodeId() == null)
+ JdbcQueryTask.remove(uuid);
+
+ closed = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean wasNull() throws SQLException {
+ return wasNull;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, String.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(int colIdx) throws SQLException {
+ Boolean val = getTypedValue(colIdx, Boolean.class);
+
+ return val != null ? val : false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte getByte(int colIdx) throws SQLException {
+ Byte val = getTypedValue(colIdx, Byte.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public short getShort(int colIdx) throws SQLException {
+ Short val = getTypedValue(colIdx, Short.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(int colIdx) throws SQLException {
+ Integer val = getTypedValue(colIdx, Integer.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getLong(int colIdx) throws SQLException {
+ Long val = getTypedValue(colIdx, Long.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public float getFloat(int colIdx) throws SQLException {
+ Float val = getTypedValue(colIdx, Float.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double getDouble(int colIdx) throws SQLException {
+ Double val = getTypedValue(colIdx, Double.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigDecimal getBigDecimal(int colIdx, int scale) throws SQLException {
+ return getTypedValue(colIdx, BigDecimal.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] getBytes(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, byte[].class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Date getDate(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, Date.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Time getTime(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, Time.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Timestamp getTimestamp(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, Timestamp.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getAsciiStream(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getUnicodeStream(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getBinaryStream(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Stream are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(String colLb) throws SQLException {
+ return getTypedValue(colLb, String.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(String colLb) throws SQLException {
+ Boolean val = getTypedValue(colLb, Boolean.class);
+
+ return val != null ? val : false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte getByte(String colLb) throws SQLException {
+ Byte val = getTypedValue(colLb, Byte.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public short getShort(String colLb) throws SQLException {
+ Short val = getTypedValue(colLb, Short.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(String colLb) throws SQLException {
+ Integer val = getTypedValue(colLb, Integer.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getLong(String colLb) throws SQLException {
+ Long val = getTypedValue(colLb, Long.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public float getFloat(String colLb) throws SQLException {
+ Float val = getTypedValue(colLb, Float.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double getDouble(String colLb) throws SQLException {
+ Double val = getTypedValue(colLb, Double.class);
+
+ return val != null ? val : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigDecimal getBigDecimal(String colLb, int scale) throws SQLException {
+ return getTypedValue(colLb, BigDecimal.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] getBytes(String colLb) throws SQLException {
+ return getTypedValue(colLb, byte[].class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Date getDate(String colLb) throws SQLException {
+ return getTypedValue(colLb, Date.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Time getTime(String colLb) throws SQLException {
+ return getTypedValue(colLb, Time.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Timestamp getTimestamp(String colLb) throws SQLException {
+ return getTypedValue(colLb, Timestamp.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getAsciiStream(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getUnicodeStream(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream getBinaryStream(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLWarning getWarnings() throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearWarnings() throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getCursorName() throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSetMetaData getMetaData() throws SQLException {
+ ensureNotClosed();
+
+ return new JdbcResultSetMetadata(tbls, cols, types);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getObject(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, Object.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getObject(String colLb) throws SQLException {
+ return getTypedValue(colLb, Object.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int findColumn(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ int idx = cols.indexOf(colLb.toUpperCase());
+
+ if (idx == -1)
+ throw new SQLException("Column not found: " + colLb);
+
+ return idx + 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reader getCharacterStream(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reader getCharacterStream(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigDecimal getBigDecimal(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, BigDecimal.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigDecimal getBigDecimal(String colLb) throws SQLException {
+ return getTypedValue(colLb, BigDecimal.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isBeforeFirst() throws SQLException {
+ ensureNotClosed();
+
+ return pos < 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isAfterLast() throws SQLException {
+ ensureNotClosed();
+
+ return finished && it == null && curr == null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isFirst() throws SQLException {
+ ensureNotClosed();
+
+ return pos == 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isLast() throws SQLException {
+ ensureNotClosed();
+
+ return finished && it == null && curr != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void beforeFirst() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void afterLast() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean first() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean last() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getRow() throws SQLException {
+ ensureNotClosed();
+
+ return isAfterLast() ? 0 : pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean absolute(int row) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean relative(int rows) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean previous() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLException("Result set is forward-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setFetchDirection(int direction) throws SQLException {
+ ensureNotClosed();
+
+ if (direction != FETCH_FORWARD)
+ throw new SQLFeatureNotSupportedException("Only forward direction is supported");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getFetchDirection() throws SQLException {
+ ensureNotClosed();
+
+ return FETCH_FORWARD;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setFetchSize(int fetchSize) throws SQLException {
+ ensureNotClosed();
+
+ if (fetchSize <= 0)
+ throw new SQLException("Fetch size must be greater than zero.");
+
+ this.fetchSize = fetchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getFetchSize() throws SQLException {
+ ensureNotClosed();
+
+ return fetchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getType() throws SQLException {
+ ensureNotClosed();
+
+ return stmt.getResultSetType();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getConcurrency() throws SQLException {
+ ensureNotClosed();
+
+ return CONCUR_READ_ONLY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean rowUpdated() throws SQLException {
+ ensureNotClosed();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean rowInserted() throws SQLException {
+ ensureNotClosed();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean rowDeleted() throws SQLException {
+ ensureNotClosed();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNull(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBoolean(int colIdx, boolean x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateByte(int colIdx, byte x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateShort(int colIdx, short x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateInt(int colIdx, int x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateLong(int colIdx, long x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateFloat(int colIdx, float x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateDouble(int colIdx, double x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBigDecimal(int colIdx, BigDecimal x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateString(int colIdx, String x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBytes(int colIdx, byte[] x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateDate(int colIdx, Date x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateTime(int colIdx, Time x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateTimestamp(int colIdx, Timestamp x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(int colIdx, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(int colIdx, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(int colIdx, Reader x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateObject(int colIdx, Object x, int scaleOrLen) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateObject(int colIdx, Object x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNull(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBoolean(String colLb, boolean x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateByte(String colLb, byte x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateShort(String colLb, short x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateInt(String colLb, int x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateLong(String colLb, long x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateFloat(String colLb, float x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateDouble(String colLb, double x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBigDecimal(String colLb, BigDecimal x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateString(String colLb, String x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBytes(String colLb, byte[] x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateDate(String colLb, Date x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateTime(String colLb, Time x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateTimestamp(String colLb, Timestamp x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(String colLb, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(String colLb, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(String colLb, Reader reader, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateObject(String colLb, Object x, int scaleOrLen) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateObject(String colLb, Object x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void insertRow() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateRow() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteRow() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void refreshRow() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Row refreshing is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancelRowUpdates() throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void moveToInsertRow() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void moveToCurrentRow() throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statement getStatement() throws SQLException {
+ ensureNotClosed();
+
+ return stmt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getObject(int colIdx, Map<String, Class<?>> map) throws SQLException {
+ return getTypedValue(colIdx, Object.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ref getRef(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Blob getBlob(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Clob getClob(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Array getArray(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getObject(String colLb, Map<String, Class<?>> map) throws SQLException {
+ return getTypedValue(colLb, Object.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Ref getRef(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Blob getBlob(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Clob getClob(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Array getArray(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Date getDate(int colIdx, Calendar cal) throws SQLException {
+ return getTypedValue(colIdx, Date.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Date getDate(String colLb, Calendar cal) throws SQLException {
+ return getTypedValue(colLb, Date.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Time getTime(int colIdx, Calendar cal) throws SQLException {
+ return getTypedValue(colIdx, Time.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Time getTime(String colLb, Calendar cal) throws SQLException {
+ return getTypedValue(colLb, Time.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Timestamp getTimestamp(int colIdx, Calendar cal) throws SQLException {
+ return getTypedValue(colIdx, Timestamp.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Timestamp getTimestamp(String colLb, Calendar cal) throws SQLException {
+ return getTypedValue(colLb, Timestamp.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public URL getURL(int colIdx) throws SQLException {
+ return getTypedValue(colIdx, URL.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public URL getURL(String colLb) throws SQLException {
+ return getTypedValue(colLb, URL.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateRef(int colIdx, Ref x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateRef(String colLb, Ref x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(int colIdx, Blob x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(String colLb, Blob x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(int colIdx, Clob x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(String colLb, Clob x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateArray(int colIdx, Array x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateArray(String colLb, Array x) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public RowId getRowId(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public RowId getRowId(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateRowId(int colIdx, RowId x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateRowId(String colLb, RowId x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getHoldability() throws SQLException {
+ ensureNotClosed();
+
+ return HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() throws SQLException {
+ return closed;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNString(int colIdx, String nStr) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNString(String colLb, String nStr) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(int colIdx, NClob nClob) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(String colLb, NClob nClob) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public NClob getNClob(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public NClob getNClob(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLXML getSQLXML(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLXML getSQLXML(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateSQLXML(int colIdx, SQLXML xmlObj) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateSQLXML(String colLb, SQLXML xmlObj) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getNString(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getNString(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reader getNCharacterStream(int colIdx) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reader getNCharacterStream(String colLb) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNCharacterStream(int colIdx, Reader x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNCharacterStream(String colLb, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(int colIdx, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(int colIdx, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(int colIdx, Reader x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(String colLb, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(String colLb, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(String colLb, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(int colIdx, InputStream inputStream, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(String colLb, InputStream inputStream, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(int colIdx, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(String colLb, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(int colIdx, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(String colLb, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNCharacterStream(int colIdx, Reader x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNCharacterStream(String colLb, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(int colIdx, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(int colIdx, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(int colIdx, Reader x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateAsciiStream(String colLb, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBinaryStream(String colLb, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateCharacterStream(String colLb, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(int colIdx, InputStream inputStream) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateBlob(String colLb, InputStream inputStream) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(int colIdx, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateClob(String colLb, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(int colIdx, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateNClob(String colLb, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> iface) throws SQLException {
+ if (!isWrapperFor(iface))
+ throw new SQLException("Result set is not a wrapper for " + iface.getName());
+
+ return (T)this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface != null && iface == ResultSet.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T getObject(int colIdx, Class<T> type) throws SQLException {
+ return getTypedValue(colIdx, type);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T getObject(String colLb, Class<T> type) throws SQLException {
+ return getTypedValue(colLb, type);
+ }
+
+ /**
+ * Gets casted field value by label.
+ *
+ * @param colLb Column label.
+ * @param cls Value class.
+ * @return Casted field value.
+ * @throws SQLException In case of error.
+ */
+ private <T> T getTypedValue(String colLb, Class<T> cls) throws SQLException {
+ ensureNotClosed();
+ ensureHasCurrentRow();
+
+ String name = colLb.toUpperCase();
+
+ Integer idx = stmt.fieldsIdxs.get(name);
+
+ int colIdx;
+
+ if (idx != null)
+ colIdx = idx;
+ else {
+ colIdx = cols.indexOf(name) + 1;
+
+ if (colIdx <= 0)
+ throw new SQLException("Invalid column label: " + colLb);
+
+ stmt.fieldsIdxs.put(name, colIdx);
+ }
+
+ return getTypedValue(colIdx, cls);
+ }
+
+ /**
+ * Gets casted field value by index.
+ *
+ * @param colIdx Column index.
+ * @param cls Value class.
+ * @return Casted field value.
+ * @throws SQLException In case of error.
+ */
+ @SuppressWarnings("unchecked")
+ private <T> T getTypedValue(int colIdx, Class<T> cls) throws SQLException {
+ ensureNotClosed();
+ ensureHasCurrentRow();
+
+ try {
+ T val = cls == String.class ? (T)String.valueOf(curr.get(colIdx - 1)) : (T)curr.get(colIdx - 1);
+
+ wasNull = val == null;
+
+ return val;
+ }
+ catch (IndexOutOfBoundsException ignored) {
+ throw new SQLException("Invalid column index: " + colIdx);
+ }
+ catch (ClassCastException ignored) {
+ throw new SQLException("Value is an not instance of " + cls.getName());
+ }
+ }
+
+ /**
+ * Ensures that result set is not closed.
+ *
+ * @throws SQLException If result set is closed.
+ */
+ private void ensureNotClosed() throws SQLException {
+ if (closed)
+ throw new SQLException("Result set is closed.");
+ }
+
+ /**
+ * Ensures that result set is positioned on a row.
+ *
+ * @throws SQLException If result set is not positioned on a row.
+ */
+ private void ensureHasCurrentRow() throws SQLException {
+ if (curr == null)
+ throw new SQLException("Result set is not positioned on a row.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java
new file mode 100644
index 0000000..ce8c269
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSetMetadata.java
@@ -0,0 +1,171 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.*;
+import java.util.*;
+
+/**
+ * JDBC result set metadata implementation.
+ */
+public class JdbcResultSetMetadata implements ResultSetMetaData {
+ /** Column width. */
+ private static final int COL_WIDTH = 30;
+
+ /** Table names. */
+ private final List<String> tbls;
+
+ /** Column names. */
+ private final List<String> cols;
+
+ /** Class names. */
+ private final List<String> types;
+
+ /**
+ * @param tbls Table names.
+ * @param cols Column names.
+ * @param types Types.
+ */
+ JdbcResultSetMetadata(List<String> tbls, List<String> cols, List<String> types) {
+ assert cols != null;
+ assert types != null;
+
+ this.tbls = tbls;
+ this.cols = cols;
+ this.types = types;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getColumnCount() throws SQLException {
+ return cols.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isAutoIncrement(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isCaseSensitive(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isSearchable(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isCurrency(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int isNullable(int col) throws SQLException {
+ return columnNullable;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isSigned(int col) throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getColumnDisplaySize(int col) throws SQLException {
+ return COL_WIDTH;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getColumnLabel(int col) throws SQLException {
+ return cols.get(col - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getColumnName(int col) throws SQLException {
+ return cols.get(col - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSchemaName(int col) throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getPrecision(int col) throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getScale(int col) throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getTableName(int col) throws SQLException {
+ return tbls != null ? tbls.get(col - 1) : "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getCatalogName(int col) throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getColumnType(int col) throws SQLException {
+ return JdbcUtils.type(types.get(col - 1));
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getColumnTypeName(int col) throws SQLException {
+ return JdbcUtils.typeName(types.get(col - 1));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isReadOnly(int col) throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWritable(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isDefinitelyWritable(int col) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getColumnClassName(int col) throws SQLException {
+ return types.get(col - 1);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> iface) throws SQLException {
+ if (!isWrapperFor(iface))
+ throw new SQLException("Result set meta data is not a wrapper for " + iface.getName());
+
+ return (T)this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface == ResultSetMetaData.class;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java
new file mode 100644
index 0000000..f4a3e1d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStatement.java
@@ -0,0 +1,456 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.FETCH_FORWARD;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+
+/**
+ * JDBC statement implementation.
+ */
+public class JdbcStatement implements Statement {
+ /** Default fetch size. */
+ private static final int DFLT_FETCH_SIZE = 1024;
+
+ /** Connection. */
+ private final JdbcConnection conn;
+
+ /** Closed flag. */
+ private boolean closed;
+
+ /** Rows limit. */
+ private int maxRows;
+
+ /** Current result set. */
+ private ResultSet rs;
+
+ /** Query arguments. */
+ protected Object[] args;
+
+ /** Fetch size. */
+ private int fetchSize = DFLT_FETCH_SIZE;
+
+ /** Result sets. */
+ final Set<JdbcResultSet> resSets = new HashSet<>();
+
+ /** Fields indexes. */
+ Map<String, Integer> fieldsIdxs = new HashMap<>();
+
+ /**
+ * Creates new statement.
+ *
+ * @param conn Connection.
+ */
+ JdbcStatement(JdbcConnection conn) {
+ assert conn != null;
+
+ this.conn = conn;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet executeQuery(String sql) throws SQLException {
+ ensureNotClosed();
+
+ rs = null;
+
+ if (sql == null || sql.isEmpty())
+ throw new SQLException("SQL query is empty");
+
+ Ignite ignite = conn.ignite();
+
+ UUID nodeId = conn.nodeId();
+
+ UUID uuid = UUID.randomUUID();
+
+ boolean loc = nodeId == null;
+
+ JdbcQueryTask qryTask = new JdbcQueryTask(loc ? ignite : null, conn.cacheName(),
+ sql, loc, args, fetchSize, uuid, conn.isLocalQuery(), conn.isCollocatedQuery());
+
+ try {
+ JdbcQueryTask.QueryResult res =
+ loc ? qryTask.call() : ignite.compute(ignite.cluster().forNodeId(nodeId)).call(qryTask);
+
+ JdbcResultSet rs = new JdbcResultSet(uuid, this, res.getTbls(), res.getCols(), res.getTypes(),
+ res.getRows(), res.isFinished());
+
+ rs.setFetchSize(fetchSize);
+
+ resSets.add(rs);
+
+ return rs;
+ }
+ catch (Exception e) {
+ throw new SQLException("Failed to query Ignite.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public int executeUpdate(String sql) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws SQLException {
+ conn.statements.remove(this);
+
+ closeInternal();
+ }
+
+ /**
+ * Marks statement as closed and closes all result sets.
+ */
+ void closeInternal() throws SQLException {
+ for (Iterator<JdbcResultSet> it = resSets.iterator(); it.hasNext(); ) {
+ JdbcResultSet rs = it.next();
+
+ rs.closeInternal();
+
+ it.remove();
+ }
+
+ closed = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxFieldSize() throws SQLException {
+ ensureNotClosed();
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setMaxFieldSize(int max) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Field size limitation is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxRows() throws SQLException {
+ ensureNotClosed();
+
+ return maxRows;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setMaxRows(int maxRows) throws SQLException {
+ ensureNotClosed();
+
+ this.maxRows = maxRows;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setEscapeProcessing(boolean enable) throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getQueryTimeout() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Query timeout is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setQueryTimeout(int timeout) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Query timeout is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Cancellation is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLWarning getWarnings() throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearWarnings() throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setCursorName(String name) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean execute(String sql) throws SQLException {
+ ensureNotClosed();
+
+ rs = executeQuery(sql);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getResultSet() throws SQLException {
+ ensureNotClosed();
+
+ ResultSet rs0 = rs;
+
+ rs = null;
+
+ return rs0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getUpdateCount() throws SQLException {
+ ensureNotClosed();
+
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getMoreResults() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Multiple open results are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setFetchDirection(int direction) throws SQLException {
+ ensureNotClosed();
+
+ if (direction != FETCH_FORWARD)
+ throw new SQLFeatureNotSupportedException("Only forward direction is supported");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getFetchDirection() throws SQLException {
+ ensureNotClosed();
+
+ return FETCH_FORWARD;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setFetchSize(int fetchSize) throws SQLException {
+ ensureNotClosed();
+
+ if (fetchSize < 0)
+ throw new SQLException("Fetch size must be greater or equal zero.");
+
+ this.fetchSize = fetchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getFetchSize() throws SQLException {
+ ensureNotClosed();
+
+ return fetchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getResultSetConcurrency() throws SQLException {
+ ensureNotClosed();
+
+ return CONCUR_READ_ONLY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getResultSetType() throws SQLException {
+ ensureNotClosed();
+
+ return TYPE_FORWARD_ONLY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void addBatch(String sql) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearBatch() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] executeBatch() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Connection getConnection() throws SQLException {
+ ensureNotClosed();
+
+ return conn;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getMoreResults(int curr) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Multiple open results are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getGeneratedKeys() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int executeUpdate(String sql, int[] colIndexes) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int executeUpdate(String sql, String[] colNames) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+ ensureNotClosed();
+
+ if (autoGeneratedKeys == RETURN_GENERATED_KEYS)
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+
+ return execute(sql);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean execute(String sql, int[] colIndexes) throws SQLException {
+ ensureNotClosed();
+
+ if (colIndexes != null && colIndexes.length > 0)
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+
+ return execute(sql);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean execute(String sql, String[] colNames) throws SQLException {
+ ensureNotClosed();
+
+ if (colNames != null && colNames.length > 0)
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+
+ return execute(sql);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getResultSetHoldability() throws SQLException {
+ ensureNotClosed();
+
+ return HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() throws SQLException {
+ return closed;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setPoolable(boolean poolable) throws SQLException {
+ ensureNotClosed();
+
+ if (poolable)
+ throw new SQLFeatureNotSupportedException("Pooling is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isPoolable() throws SQLException {
+ ensureNotClosed();
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> iface) throws SQLException {
+ if (!isWrapperFor(iface))
+ throw new SQLException("Statement is not a wrapper for " + iface.getName());
+
+ return (T)this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface != null && iface == Statement.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void closeOnCompletion() throws SQLException {
+ throw new SQLFeatureNotSupportedException("closeOnCompletion is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isCloseOnCompletion() throws SQLException {
+ ensureNotClosed();
+
+ return false;
+ }
+
+ /**
+ * Ensures that statement is not closed.
+ *
+ * @throws SQLException If statement is closed.
+ */
+ protected void ensureNotClosed() throws SQLException {
+ if (closed)
+ throw new SQLException("Statement is closed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java
new file mode 100644
index 0000000..b519340
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcUtils.java
@@ -0,0 +1,155 @@
+/*
+ * 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.jdbc2;
+
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Date;
+
+import static java.sql.Types.BIGINT;
+import static java.sql.Types.BINARY;
+import static java.sql.Types.BOOLEAN;
+import static java.sql.Types.DATE;
+import static java.sql.Types.DOUBLE;
+import static java.sql.Types.FLOAT;
+import static java.sql.Types.INTEGER;
+import static java.sql.Types.OTHER;
+import static java.sql.Types.SMALLINT;
+import static java.sql.Types.TIME;
+import static java.sql.Types.TIMESTAMP;
+import static java.sql.Types.TINYINT;
+import static java.sql.Types.VARCHAR;
+
+/**
+ * Utility methods for JDBC driver.
+ */
+public class JdbcUtils {
+ /**
+ * Converts Java class name to type from {@link Types}.
+ *
+ * @param cls Java class name.
+ * @return Type from {@link Types}.
+ */
+ public static int type(String cls) {
+ if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls))
+ return BOOLEAN;
+ else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls))
+ return TINYINT;
+ else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls))
+ return SMALLINT;
+ else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls))
+ return INTEGER;
+ else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls))
+ return BIGINT;
+ else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls))
+ return FLOAT;
+ else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls))
+ return DOUBLE;
+ else if (String.class.getName().equals(cls))
+ return VARCHAR;
+ else if (byte[].class.getName().equals(cls))
+ return BINARY;
+ else if (Time.class.getName().equals(cls))
+ return TIME;
+ else if (Timestamp.class.getName().equals(cls))
+ return TIMESTAMP;
+ else if (Date.class.getName().equals(cls) || java.sql.Date.class.getName().equals(cls))
+ return DATE;
+ else
+ return OTHER;
+ }
+
+ /**
+ * Converts Java class name to SQL type name.
+ *
+ * @param cls Java class name.
+ * @return SQL type name.
+ */
+ public static String typeName(String cls) {
+ if (Boolean.class.getName().equals(cls) || boolean.class.getName().equals(cls))
+ return "BOOLEAN";
+ else if (Byte.class.getName().equals(cls) || byte.class.getName().equals(cls))
+ return "TINYINT";
+ else if (Short.class.getName().equals(cls) || short.class.getName().equals(cls))
+ return "SMALLINT";
+ else if (Integer.class.getName().equals(cls) || int.class.getName().equals(cls))
+ return "INTEGER";
+ else if (Long.class.getName().equals(cls) || long.class.getName().equals(cls))
+ return "BIGINT";
+ else if (Float.class.getName().equals(cls) || float.class.getName().equals(cls))
+ return "FLOAT";
+ else if (Double.class.getName().equals(cls) || double.class.getName().equals(cls))
+ return "DOUBLE";
+ else if (String.class.getName().equals(cls))
+ return "VARCHAR";
+ else if (byte[].class.getName().equals(cls))
+ return "BINARY";
+ else if (Time.class.getName().equals(cls))
+ return "TIME";
+ else if (Timestamp.class.getName().equals(cls))
+ return "TIMESTAMP";
+ else if (Date.class.getName().equals(cls) || java.sql.Date.class.getName().equals(cls))
+ return "DATE";
+ else
+ return "OTHER";
+ }
+
+ /**
+ * Determines whether type is nullable.
+ *
+ * @param name Column name.
+ * @param cls Java class name.
+ * @return {@code True} if nullable.
+ */
+ public static boolean nullable(String name, String cls) {
+ return !"_KEY".equalsIgnoreCase(name) &&
+ !"_VAL".equalsIgnoreCase(name) &&
+ !(boolean.class.getName().equals(cls) ||
+ byte.class.getName().equals(cls) ||
+ short.class.getName().equals(cls) ||
+ int.class.getName().equals(cls) ||
+ long.class.getName().equals(cls) ||
+ float.class.getName().equals(cls) ||
+ double.class.getName().equals(cls));
+ }
+
+ /**
+ * Checks whether type of the object is SQL-complaint.
+ *
+ * @param obj Object.
+ * @return Whether type of the object is SQL-complaint.
+ */
+ public static boolean sqlType(Object obj) {
+ return obj == null ||
+ obj instanceof BigDecimal ||
+ obj instanceof Boolean ||
+ obj instanceof Byte ||
+ obj instanceof byte[] ||
+ obj instanceof java.util.Date ||
+ obj instanceof Double ||
+ obj instanceof Float ||
+ obj instanceof Integer ||
+ obj instanceof Long ||
+ obj instanceof Short ||
+ obj instanceof String ||
+ obj instanceof URL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index dd8c3f3..70c32e5 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -254,6 +254,15 @@ org.apache.ignite.internal.executor.GridExecutorService
org.apache.ignite.internal.executor.GridExecutorService$1
org.apache.ignite.internal.executor.GridExecutorService$TaskTerminateListener
org.apache.ignite.internal.igfs.common.IgfsIpcCommand
+org.apache.ignite.internal.interop.InteropAwareEventFilter
+org.apache.ignite.internal.interop.InteropBootstrapFactory
+org.apache.ignite.internal.interop.InteropException
+org.apache.ignite.internal.interop.InteropNoCallbackException
+org.apache.ignite.internal.jdbc2.JdbcConnection$JdbcConnectionValidationTask
+org.apache.ignite.internal.jdbc2.JdbcDatabaseMetadata$UpdateMetadataTask
+org.apache.ignite.internal.jdbc2.JdbcQueryTask
+org.apache.ignite.internal.jdbc2.JdbcQueryTask$1
+org.apache.ignite.internal.jdbc2.JdbcQueryTask$QueryResult
org.apache.ignite.internal.managers.GridManagerAdapter$1$1
org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager$CheckpointSet
org.apache.ignite.internal.managers.checkpoint.GridCheckpointRequest
@@ -426,7 +435,8 @@ org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$Ex
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$MessageHandler
org.apache.ignite.internal.processors.cache.GridCacheProcessor$2
org.apache.ignite.internal.processors.cache.GridCacheProcessor$3
-org.apache.ignite.internal.processors.cache.GridCacheProcessor$5
+org.apache.ignite.internal.processors.cache.GridCacheProcessor$4
+org.apache.ignite.internal.processors.cache.GridCacheProcessor$6
org.apache.ignite.internal.processors.cache.GridCacheProcessor$LocalAffinityFunction
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl
org.apache.ignite.internal.processors.cache.GridCacheReturn
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/benchmark-query.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-query.properties b/modules/yardstick/config/benchmark-query.properties
index 1a75926..486d00e 100644
--- a/modules/yardstick/config/benchmark-query.properties
+++ b/modules/yardstick/config/benchmark-query.properties
@@ -21,7 +21,7 @@
# JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
-JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" \
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \
-XX:+UseParNewGC \
-XX:+UseConcMarkSweepGC \
-XX:+UseTLAB \
@@ -64,5 +64,6 @@ CONFIGS="\
-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds sql-query-join-offheap-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds sql-query-put-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds sql-query-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite://127.0.0.1/query -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite://127.0.0.1/query -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite:cfg://cache=query@config/ignite-jdbc-config.xml -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup\
"
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/ignite-base-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-base-config.xml b/modules/yardstick/config/ignite-base-config.xml
index c77cc9a..6e94b3c 100644
--- a/modules/yardstick/config/ignite-base-config.xml
+++ b/modules/yardstick/config/ignite-base-config.xml
@@ -25,7 +25,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="base-ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" abstract="true">
- <property name="peerClassLoadingEnabled" value="false"/>
+ <property name="peerClassLoadingEnabled" value="true"/>
<property name="metricsLogFrequency" value="5000"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/yardstick/config/ignite-jdbc-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-jdbc-config.xml b/modules/yardstick/config/ignite-jdbc-config.xml
new file mode 100644
index 0000000..9428858
--- /dev/null
+++ b/modules/yardstick/config/ignite-jdbc-config.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<!--
+ Ignite Spring configuration file.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="clientMode" value="true"/>
+
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+ <property name="requireSerializable" value="false"/>
+ </bean>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47549</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
[03/28] ignite git commit: ignite-1381: fixed unmarshalling of
Externalizable objects
Posted by sb...@apache.org.
ignite-1381: fixed unmarshalling of Externalizable objects
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/978c4edc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/978c4edc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/978c4edc
Branch: refs/heads/ignite-971
Commit: 978c4edc155ace34fffbc1f28586a4a9d4dde3a6
Parents: ec5c795
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 10 12:22:55 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 10 12:22:55 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableReaderExImpl.java | 3 -
...idPortableMarshallerCtxDisabledSelfTest.java | 168 ++++++++++++++++---
.../GridPortableMarshallerSelfTest.java | 1 -
3 files changed, 148 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/978c4edc/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index 83ccb65..4ad125a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -2157,9 +2157,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
if (desc == null)
throw new PortableInvalidClassException("Unknown type ID: " + typeId);
- // Skip clsName field if any.
- rawOff += clsNameLen;
-
obj = desc.read(this);
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/978c4edc/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index 08dba92..bd9612c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -17,11 +17,20 @@
package org.apache.ignite.internal.portable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.MarshallerContextAdapter;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMarshalAware;
import org.apache.ignite.portable.PortableMetadata;
+import org.apache.ignite.portable.PortableReader;
+import org.apache.ignite.portable.PortableWriter;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
/**
@@ -50,36 +59,42 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
- SimpleObject obj0 = new SimpleObject();
+ SimpleObject simpleObj = new SimpleObject();
- obj0.b = 2;
- obj0.bArr = new byte[] {2, 3, 4, 5, 5};
- obj0.c = 'A';
- obj0.enumVal = TestEnum.D;
- obj0.objArr = new Object[] {"hello", "world", "from", "me"};
- obj0.enumArr = new TestEnum[] {TestEnum.C, TestEnum.B};
+ simpleObj.b = 2;
+ simpleObj.bArr = new byte[] {2, 3, 4, 5, 5};
+ simpleObj.c = 'A';
+ simpleObj.enumVal = TestEnum.D;
+ simpleObj.objArr = new Object[] {"hello", "world", "from", "me"};
+ simpleObj.enumArr = new TestEnum[] {TestEnum.C, TestEnum.B};
- byte[] arr = marsh.marshal(obj0);
+ SimpleObject otherObj = new SimpleObject();
- SimpleObject obj2 = marsh.unmarshal(arr, null);
+ otherObj.b = 3;
+ otherObj.bArr = new byte[] {5, 3, 4};
- assertEquals(obj0.b, obj2.b);
- assertEquals(obj0.c, obj2.c);
- assertEquals(obj0.enumVal, obj2.enumVal);
+ simpleObj.otherObj = otherObj;
- for (int i = 0; i < obj0.bArr.length; i++)
- assertEquals(obj0.bArr[i], obj2.bArr[i]);
+ assertEquals(simpleObj, marsh.unmarshal(marsh.marshal(simpleObj), null));
- for (int i = 0; i < obj0.objArr.length; i++)
- assertEquals(obj0.objArr[i], obj2.objArr[i]);
+ SimplePortable simplePortable = new SimplePortable();
- for (int i = 0; i < obj0.enumArr.length; i++)
- assertEquals(obj0.enumArr[i], obj2.enumArr[i]);
+ simplePortable.str = "portable";
+ simplePortable.arr = new long[] {100, 200, 300};
+
+ assertEquals(simplePortable, marsh.unmarshal(marsh.marshal(simplePortable), null));
+
+ SimpleExternalizable simpleExtr = new SimpleExternalizable();
+
+ simpleExtr.str = "externalizable";
+ simpleExtr.arr = new long[] {20000, 300000, 400000};
+
+ assertEquals(simpleExtr, marsh.unmarshal(marsh.marshal(simpleExtr), null));
}
/**
- * Marshaller context with no storage. Platform has to work in such environment as well by marshalling class name
- * of a portable object.
+ * Marshaller context with no storage. Platform has to work in such environment as well by marshalling class name of
+ * a portable object.
*/
private static class MarshallerContextWithNoStorage extends MarshallerContextAdapter {
/** */
@@ -124,5 +139,118 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
/** */
private TestEnum[] enumArr;
+
+ private SimpleObject otherObj;
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ SimpleObject object = (SimpleObject)o;
+
+ if (b != object.b)
+ return false;
+
+ if (c != object.c)
+ return false;
+
+ if (!Arrays.equals(bArr, object.bArr))
+ return false;
+
+ // Probably incorrect - comparing Object[] arrays with Arrays.equals
+ if (!Arrays.equals(objArr, object.objArr))
+ return false;
+
+ if (enumVal != object.enumVal)
+ return false;
+
+ // Probably incorrect - comparing Object[] arrays with Arrays.equals
+ if (!Arrays.equals(enumArr, object.enumArr))
+ return false;
+
+ return !(otherObj != null ? !otherObj.equals(object.otherObj) : object.otherObj != null);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SimplePortable implements PortableMarshalAware {
+ /** */
+ private String str;
+
+ /** */
+ private long[] arr;
+
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ writer.writeString("str", str);
+ writer.writeLongArray("longArr", arr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ str = reader.readString("str");
+ arr = reader.readLongArray("longArr");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ SimplePortable that = (SimplePortable)o;
+
+ if (str != null ? !str.equals(that.str) : that.str != null)
+ return false;
+
+ return Arrays.equals(arr, that.arr);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SimpleExternalizable implements Externalizable {
+ /** */
+ private String str;
+
+ /** */
+ private long[] arr;
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(str);
+ out.writeObject(arr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ str = in.readUTF();
+ arr = (long[])in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ SimpleExternalizable that = (SimpleExternalizable)o;
+
+ if (str != null ? !str.equals(that.str) : that.str != null)
+ return false;
+
+ return Arrays.equals(arr, that.arr);
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/978c4edc/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index 4545a58..21fc81c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -34,7 +34,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.UUID;
[23/28] ignite git commit: ignite-1250 JDBC driver: migration to
embedded Ignite client node
Posted by sb...@apache.org.
ignite-1250 JDBC driver: migration to embedded Ignite client node
Signed-off-by: Valentin Kulichenko <va...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ebb9e2e9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ebb9e2e9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ebb9e2e9
Branch: refs/heads/ignite-971
Commit: ebb9e2e9d3e05ba65c06ec301bee040b3a74fd3b
Parents: 1ff4a52
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Sep 11 18:32:54 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Sep 11 18:32:54 2015 -0700
----------------------------------------------------------------------
modules/clients/pom.xml | 7 +
modules/clients/src/test/config/jdbc-config.xml | 55 +
.../jdbc2/JdbcComplexQuerySelfTest.java | 316 ++++
.../internal/jdbc2/JdbcConnectionSelfTest.java | 268 +++
.../internal/jdbc2/JdbcEmptyCacheSelfTest.java | 140 ++
.../internal/jdbc2/JdbcLocalCachesSelfTest.java | 156 ++
.../internal/jdbc2/JdbcMetadataSelfTest.java | 334 ++++
.../jdbc2/JdbcPreparedStatementSelfTest.java | 730 +++++++++
.../internal/jdbc2/JdbcResultSetSelfTest.java | 751 +++++++++
.../internal/jdbc2/JdbcStatementSelfTest.java | 292 ++++
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 11 +
.../org/apache/ignite/IgniteJdbcDriver.java | 281 +++-
.../apache/ignite/IgniteSystemProperties.java | 5 +-
.../ignite/internal/jdbc/JdbcConnection.java | 4 +
.../internal/jdbc/JdbcConnectionInfo.java | 91 --
.../internal/jdbc/JdbcDatabaseMetadata.java | 4 +
.../internal/jdbc/JdbcPreparedStatement.java | 4 +
.../ignite/internal/jdbc/JdbcResultSet.java | 4 +
.../internal/jdbc/JdbcResultSetMetadata.java | 4 +
.../ignite/internal/jdbc/JdbcStatement.java | 4 +
.../apache/ignite/internal/jdbc/JdbcUtils.java | 4 +
.../ignite/internal/jdbc2/JdbcConnection.java | 777 +++++++++
.../internal/jdbc2/JdbcDatabaseMetadata.java | 1401 ++++++++++++++++
.../internal/jdbc2/JdbcPreparedStatement.java | 411 +++++
.../ignite/internal/jdbc2/JdbcQueryTask.java | 361 +++++
.../ignite/internal/jdbc2/JdbcResultSet.java | 1520 ++++++++++++++++++
.../internal/jdbc2/JdbcResultSetMetadata.java | 171 ++
.../ignite/internal/jdbc2/JdbcStatement.java | 456 ++++++
.../apache/ignite/internal/jdbc2/JdbcUtils.java | 155 ++
.../resources/META-INF/classnames.properties | 12 +-
.../yardstick/config/benchmark-query.properties | 5 +-
modules/yardstick/config/ignite-base-config.xml | 2 +-
modules/yardstick/config/ignite-jdbc-config.xml | 55 +
33 files changed, 8606 insertions(+), 185 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index 61f6694..6e690dc 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -56,6 +56,13 @@
<dependency>
<groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/config/jdbc-config.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/config/jdbc-config.xml b/modules/clients/src/test/config/jdbc-config.xml
new file mode 100644
index 0000000..980eaf1
--- /dev/null
+++ b/modules/clients/src/test/config/jdbc-config.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<!--
+ Ignite Spring configuration file.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="clientMode" value="true"/>
+
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+ <property name="requireSerializable" value="false"/>
+ </bean>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47549</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="peerClassLoadingEnabled" value="true"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java
new file mode 100644
index 0000000..d126d34
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java
@@ -0,0 +1,316 @@
+/*
+ * 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.jdbc2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.query.annotations.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.sql.*;
+
+import static org.apache.ignite.IgniteJdbcDriver.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Tests for complex queries (joins, etc.).
+ */
+public class JdbcComplexQuerySelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** JDBC URL. */
+ private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** Statement. */
+ private Statement stmt;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<?,?> cache = defaultCacheConfiguration();
+
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setAtomicityMode(TRANSACTIONAL);
+ cache.setIndexedTypes(String.class, Organization.class, AffinityKey.class, Person.class);
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(3);
+
+ IgniteCache<String, Organization> orgCache = grid(0).cache(null);
+
+ assert orgCache != null;
+
+ orgCache.put("o1", new Organization(1, "A"));
+ orgCache.put("o2", new Organization(2, "B"));
+
+ IgniteCache<AffinityKey<String>, Person> personCache = grid(0).cache(null);
+
+ assert personCache != null;
+
+ personCache.put(new AffinityKey<>("p1", "o1"), new Person(1, "John White", 25, 1));
+ personCache.put(new AffinityKey<>("p2", "o1"), new Person(2, "Joe Black", 35, 1));
+ personCache.put(new AffinityKey<>("p3", "o2"), new Person(3, "Mike Green", 40, 2));
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ stmt = DriverManager.getConnection(BASE_URL).createStatement();
+
+ assert stmt != null;
+ assert !stmt.isClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ if (stmt != null) {
+ stmt.getConnection().close();
+ stmt.close();
+
+ assert stmt.isClosed();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoin() throws Exception {
+ ResultSet rs = stmt.executeQuery(
+ "select p.id, p.name, o.name as orgName from Person p, Organization o where p.orgId = o.id");
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt("id");
+
+ if (id == 1) {
+ assert "John White".equals(rs.getString("name"));
+ assert "A".equals(rs.getString("orgName"));
+ }
+ else if (id == 2) {
+ assert "Joe Black".equals(rs.getString("name"));
+ assert "A".equals(rs.getString("orgName"));
+ }
+ else if (id == 3) {
+ assert "Mike Green".equals(rs.getString("name"));
+ assert "B".equals(rs.getString("orgName"));
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 3;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWithoutAlias() throws Exception {
+ ResultSet rs = stmt.executeQuery(
+ "select p.id, p.name, o.name from Person p, Organization o where p.orgId = o.id");
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt(1);
+
+ if (id == 1) {
+ assert "John White".equals(rs.getString("name"));
+ assert "John White".equals(rs.getString(2));
+ assert "A".equals(rs.getString(3));
+ }
+ else if (id == 2) {
+ assert "Joe Black".equals(rs.getString("name"));
+ assert "Joe Black".equals(rs.getString(2));
+ assert "A".equals(rs.getString(3));
+ }
+ else if (id == 3) {
+ assert "Mike Green".equals(rs.getString("name"));
+ assert "Mike Green".equals(rs.getString(2));
+ assert "B".equals(rs.getString(3));
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 3;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIn() throws Exception {
+ ResultSet rs = stmt.executeQuery("select name from Person where age in (25, 35)");
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assert "John White".equals(rs.getString("name")) ||
+ "Joe Black".equals(rs.getString("name"));
+
+ cnt++;
+ }
+
+ assert cnt == 2;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBetween() throws Exception {
+ ResultSet rs = stmt.executeQuery("select name from Person where age between 24 and 36");
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assert "John White".equals(rs.getString("name")) ||
+ "Joe Black".equals(rs.getString("name"));
+
+ cnt++;
+ }
+
+ assert cnt == 2;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCalculatedValue() throws Exception {
+ ResultSet rs = stmt.executeQuery("select age * 2 from Person");
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assert rs.getInt(1) == 50 ||
+ rs.getInt(1) == 70 ||
+ rs.getInt(1) == 80;
+
+ cnt++;
+ }
+
+ assert cnt == 3;
+ }
+
+ /**
+ * Person.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Person implements Serializable {
+ /** ID. */
+ @QuerySqlField
+ private final int id;
+
+ /** Name. */
+ @QuerySqlField(index = false)
+ private final String name;
+
+ /** Age. */
+ @QuerySqlField
+ private final int age;
+
+ /** Organization ID. */
+ @QuerySqlField
+ private final int orgId;
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ * @param age Age.
+ * @param orgId Organization ID.
+ */
+ private Person(int id, String name, int age, int orgId) {
+ assert !F.isEmpty(name);
+ assert age > 0;
+ assert orgId > 0;
+
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ this.orgId = orgId;
+ }
+ }
+
+ /**
+ * Organization.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Organization implements Serializable {
+ /** ID. */
+ @QuerySqlField
+ private final int id;
+
+ /** Name. */
+ @QuerySqlField(index = false)
+ private final String name;
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ private Organization(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
new file mode 100644
index 0000000..951890e
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
@@ -0,0 +1,268 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+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 static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
+
+/**
+ * Connection test.
+ */
+public class JdbcConnectionSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Custom cache name. */
+ private static final String CUSTOM_CACHE_NAME = "custom-cache";
+
+ /** Ignite configuration URL. */
+ private static final String CFG_URL = "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** Grid count. */
+ private static final int GRID_CNT = 2;
+
+ /** Daemon node flag. */
+ private boolean daemon;
+
+ /** Client node flag. */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setCacheConfiguration(cacheConfiguration(null), cacheConfiguration(CUSTOM_CACHE_NAME));
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setDaemon(daemon);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /**
+ * @param name Cache name.
+ * @return Cache configuration.
+ * @throws Exception In case of error.
+ */
+ private CacheConfiguration cacheConfiguration(@Nullable String name) throws Exception {
+ CacheConfiguration cfg = defaultCacheConfiguration();
+
+ cfg.setName(name);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(GRID_CNT);
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDefaults() throws Exception {
+ String url = CFG_URL_PREFIX + CFG_URL;
+
+ try (Connection conn = DriverManager.getConnection(url)) {
+ assertNotNull(conn);
+ }
+
+ try (Connection conn = DriverManager.getConnection(url + '/')) {
+ assertNotNull(conn);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNodeId() throws Exception {
+ String url = CFG_URL_PREFIX + "nodeId=" + grid(0).localNode().id() + '@' + CFG_URL;
+
+ try (Connection conn = DriverManager.getConnection(url)) {
+ assertNotNull(conn);
+ }
+
+ url = CFG_URL_PREFIX + "cache=" + CUSTOM_CACHE_NAME + ":nodeId=" + grid(0).localNode().id() + '@' + CFG_URL;
+
+ try (Connection conn = DriverManager.getConnection(url)) {
+ assertNotNull(conn);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testWrongNodeId() throws Exception {
+ UUID wrongId = UUID.randomUUID();
+
+ final String url = CFG_URL_PREFIX + "nodeId=" + wrongId + '@' + CFG_URL;
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Connection conn = DriverManager.getConnection(url)) {
+ return conn;
+ }
+ }
+ },
+ SQLException.class,
+ "Failed to establish connection with node (is it a server node?): " + wrongId
+ );
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientNodeId() throws Exception {
+ client = true;
+
+ IgniteEx client = (IgniteEx)startGrid();
+
+ UUID clientId = client.localNode().id();
+
+ final String url = CFG_URL_PREFIX + "nodeId=" + clientId + '@' + CFG_URL;
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Connection conn = DriverManager.getConnection(url)) {
+ return conn;
+ }
+ }
+ },
+ SQLException.class,
+ "Failed to establish connection with node (is it a server node?): " + clientId
+ );
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDaemonNodeId() throws Exception {
+ daemon = true;
+
+ IgniteEx daemon = startGrid(GRID_CNT);
+
+ UUID daemonId = daemon.localNode().id();
+
+ final String url = CFG_URL_PREFIX + "nodeId=" + daemonId + '@' + CFG_URL;
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Connection conn = DriverManager.getConnection(url)) {
+ return conn;
+ }
+ }
+ },
+ SQLException.class,
+ "Failed to establish connection with node (is it a server node?): " + daemonId
+ );
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCustomCache() throws Exception {
+ String url = CFG_URL_PREFIX + "cache=" + CUSTOM_CACHE_NAME + '@' + CFG_URL;
+
+ try (Connection conn = DriverManager.getConnection(url)) {
+ assertNotNull(conn);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testWrongCache() throws Exception {
+ final String url = CFG_URL_PREFIX + "cache=wrongCacheName@" + CFG_URL;
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Connection conn = DriverManager.getConnection(url)) {
+ return conn;
+ }
+ }
+ },
+ SQLException.class,
+ "Client is invalid. Probably cache name is wrong."
+ );
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClose() throws Exception {
+ String url = CFG_URL_PREFIX + CFG_URL;
+
+ try(final Connection conn = DriverManager.getConnection(url)) {
+ assertNotNull(conn);
+ assertFalse(conn.isClosed());
+
+ conn.close();
+
+ assertTrue(conn.isClosed());
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ conn.isValid(2);
+
+ return null;
+ }
+ },
+ SQLException.class,
+ "Connection is closed."
+ );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java
new file mode 100644
index 0000000..adf1368
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.jdbc2;
+
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.sql.*;
+
+import static org.apache.ignite.IgniteJdbcDriver.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Tests for empty cache.
+ */
+public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Cache name. */
+ private static final String CACHE_NAME = "cache";
+
+ /** JDBC URL. */
+ private static final String BASE_URL =
+ CFG_URL_PREFIX + "cache=" + CACHE_NAME + "@modules/clients/src/test/config/jdbc-config.xml";
+
+ /** Statement. */
+ private Statement stmt;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cache = defaultCacheConfiguration();
+
+ cache.setName(CACHE_NAME);
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(
+ Byte.class, Byte.class
+ );
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid();
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ stmt = DriverManager.getConnection(BASE_URL).createStatement();
+
+ assert stmt != null;
+ assert !stmt.isClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ if (stmt != null) {
+ stmt.getConnection().close();
+ stmt.close();
+
+ assert stmt.isClosed();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSelectNumber() throws Exception {
+ ResultSet rs = stmt.executeQuery("select 1");
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assert rs.getInt(1) == 1;
+ assert "1".equals(rs.getString(1));
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSelectString() throws Exception {
+ ResultSet rs = stmt.executeQuery("select 'str'");
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assertEquals("str", rs.getString(1));
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java
new file mode 100644
index 0000000..a8988f9
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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.jdbc2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.sql.*;
+import java.util.*;
+
+import static org.apache.ignite.IgniteJdbcDriver.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Test JDBC with several local caches.
+ */
+public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Cache name. */
+ private static final String CACHE_NAME = "cache";
+
+ /** JDBC URL. */
+ private static final String BASE_URL =
+ CFG_URL_PREFIX + "cache=" + CACHE_NAME + "@modules/clients/src/test/config/jdbc-config.xml";
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cache = defaultCacheConfiguration();
+
+ cache.setName(CACHE_NAME);
+ cache.setCacheMode(LOCAL);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(
+ String.class, Integer.class
+ );
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(2);
+
+ IgniteCache<Object, Object> cache1 = grid(0).cache(CACHE_NAME);
+
+ assert cache1 != null;
+
+ cache1.put("key1", 1);
+ cache1.put("key2", 2);
+
+ IgniteCache<Object, Object> cache2 = grid(1).cache(CACHE_NAME);
+
+ assert cache2 != null;
+
+ cache2.put("key1", 3);
+ cache2.put("key2", 4);
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCache1() throws Exception {
+ Properties cfg = new Properties();
+
+ cfg.setProperty(PROP_NODE_ID, grid(0).localNode().id().toString());
+
+ Connection conn = null;
+
+ try {
+ conn = DriverManager.getConnection(BASE_URL, cfg);
+
+ ResultSet rs = conn.createStatement().executeQuery("select _val from Integer order by _val");
+
+ int cnt = 0;
+
+ while (rs.next())
+ assertEquals(++cnt, rs.getInt(1));
+
+ assertEquals(2, cnt);
+ }
+ finally {
+ if (conn != null)
+ conn.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCache2() throws Exception {
+ Properties cfg = new Properties();
+
+ cfg.setProperty(PROP_NODE_ID, grid(1).localNode().id().toString());
+
+ Connection conn = null;
+
+ try {
+ conn = DriverManager.getConnection(BASE_URL, cfg);
+
+ ResultSet rs = conn.createStatement().executeQuery("select _val from Integer order by _val");
+
+ int cnt = 0;
+
+ while (rs.next())
+ assertEquals(++cnt + 2, rs.getInt(1));
+
+ assertEquals(2, cnt);
+ }
+ finally {
+ if (conn != null)
+ conn.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java
new file mode 100644
index 0000000..f601dbc
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java
@@ -0,0 +1,334 @@
+/*
+ * 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.jdbc2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.query.annotations.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+import static java.sql.Types.*;
+import static org.apache.ignite.IgniteJdbcDriver.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Metadata tests.
+ */
+public class JdbcMetadataSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** JDBC URL. */
+ private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<?,?> cache = defaultCacheConfiguration();
+
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(String.class, Organization.class, AffinityKey.class, Person.class);
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ IgniteCache<String, Organization> orgCache = grid(0).cache(null);
+
+ orgCache.put("o1", new Organization(1, "A"));
+ orgCache.put("o2", new Organization(2, "B"));
+
+ IgniteCache<AffinityKey<String>, Person> personCache = grid(0).cache(null);
+
+ personCache.put(new AffinityKey<>("p1", "o1"), new Person("John White", 25, 1));
+ personCache.put(new AffinityKey<>("p2", "o1"), new Person("Joe Black", 35, 1));
+ personCache.put(new AffinityKey<>("p3", "o2"), new Person("Mike Green", 40, 2));
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testResultSetMetaData() throws Exception {
+ try (Connection conn = DriverManager.getConnection(BASE_URL)) {
+ Statement stmt = conn.createStatement();
+
+ ResultSet rs = stmt.executeQuery(
+ "select p.name, o.id as orgId from Person p, Organization o where p.orgId = o.id");
+
+ assertNotNull(rs);
+
+ ResultSetMetaData meta = rs.getMetaData();
+
+ assertNotNull(meta);
+
+ assertEquals(2, meta.getColumnCount());
+
+ assertTrue("Person".equalsIgnoreCase(meta.getTableName(1)));
+ assertTrue("name".equalsIgnoreCase(meta.getColumnName(1)));
+ assertTrue("name".equalsIgnoreCase(meta.getColumnLabel(1)));
+ assertEquals(VARCHAR, meta.getColumnType(1));
+ assertEquals("VARCHAR", meta.getColumnTypeName(1));
+ assertEquals("java.lang.String", meta.getColumnClassName(1));
+
+ assertTrue("Organization".equalsIgnoreCase(meta.getTableName(2)));
+ assertTrue("orgId".equalsIgnoreCase(meta.getColumnName(2)));
+ assertTrue("orgId".equalsIgnoreCase(meta.getColumnLabel(2)));
+ assertEquals(INTEGER, meta.getColumnType(2));
+ assertEquals("INTEGER", meta.getColumnTypeName(2));
+ assertEquals("java.lang.Integer", meta.getColumnClassName(2));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetTables() throws Exception {
+ try (Connection conn = DriverManager.getConnection(BASE_URL)) {
+ DatabaseMetaData meta = conn.getMetaData();
+
+ Collection<String> names = new ArrayList<>(2);
+
+ names.add("PERSON");
+ names.add("ORGANIZATION");
+
+ ResultSet rs = meta.getTables("", "PUBLIC", "%", new String[]{"TABLE"});
+
+ assertNotNull(rs);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ assertEquals("TABLE", rs.getString("TABLE_TYPE"));
+ assertTrue(names.remove(rs.getString("TABLE_NAME")));
+
+ cnt++;
+ }
+
+ assertTrue(names.isEmpty());
+ assertEquals(2, cnt);
+
+ names.add("PERSON");
+ names.add("ORGANIZATION");
+
+ rs = meta.getTables("", "PUBLIC", "%", null);
+
+ assertNotNull(rs);
+
+ cnt = 0;
+
+ while (rs.next()) {
+ assertEquals("TABLE", rs.getString("TABLE_TYPE"));
+ assertTrue(names.remove(rs.getString("TABLE_NAME")));
+
+ cnt++;
+ }
+
+ assertTrue(names.isEmpty());
+ assertEquals(2, cnt);
+
+ rs = meta.getTables("", "PUBLIC", "", new String[]{"WRONG"});
+
+ assertFalse(rs.next());
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetColumns() throws Exception {
+ try (Connection conn = DriverManager.getConnection(BASE_URL)) {
+ DatabaseMetaData meta = conn.getMetaData();
+
+ ResultSet rs = meta.getColumns("", "PUBLIC", "Person", "%");
+
+ assertNotNull(rs);
+
+ Collection<String> names = new ArrayList<>(2);
+
+ names.add("NAME");
+ names.add("AGE");
+ names.add("ORGID");
+ names.add("_KEY");
+ names.add("_VAL");
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ String name = rs.getString("COLUMN_NAME");
+
+ assertTrue(names.remove(name));
+
+ if ("NAME".equals(name)) {
+ assertEquals(VARCHAR, rs.getInt("DATA_TYPE"));
+ assertEquals("VARCHAR", rs.getString("TYPE_NAME"));
+ assertEquals(1, rs.getInt("NULLABLE"));
+ } else if ("AGE".equals(name) || "ORGID".equals(name)) {
+ assertEquals(INTEGER, rs.getInt("DATA_TYPE"));
+ assertEquals("INTEGER", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ }
+ if ("_KEY".equals(name)) {
+ assertEquals(OTHER, rs.getInt("DATA_TYPE"));
+ assertEquals("OTHER", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ }
+ if ("_VAL".equals(name)) {
+ assertEquals(OTHER, rs.getInt("DATA_TYPE"));
+ assertEquals("OTHER", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ }
+
+ cnt++;
+ }
+
+ assertTrue(names.isEmpty());
+ assertEquals(5, cnt);
+
+ rs = meta.getColumns("", "PUBLIC", "Organization", "%");
+
+ assertNotNull(rs);
+
+ names.add("ID");
+ names.add("NAME");
+ names.add("_KEY");
+ names.add("_VAL");
+
+ cnt = 0;
+
+ while (rs.next()) {
+ String name = rs.getString("COLUMN_NAME");
+
+ assertTrue(names.remove(name));
+
+ if ("id".equals(name)) {
+ assertEquals(INTEGER, rs.getInt("DATA_TYPE"));
+ assertEquals("INTEGER", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ } else if ("name".equals(name)) {
+ assertEquals(VARCHAR, rs.getInt("DATA_TYPE"));
+ assertEquals("VARCHAR", rs.getString("TYPE_NAME"));
+ assertEquals(1, rs.getInt("NULLABLE"));
+ }
+ if ("_KEY".equals(name)) {
+ assertEquals(VARCHAR, rs.getInt("DATA_TYPE"));
+ assertEquals("VARCHAR", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ }
+ if ("_VAL".equals(name)) {
+ assertEquals(OTHER, rs.getInt("DATA_TYPE"));
+ assertEquals("OTHER", rs.getString("TYPE_NAME"));
+ assertEquals(0, rs.getInt("NULLABLE"));
+ }
+
+ cnt++;
+ }
+
+ assertTrue(names.isEmpty());
+ assertEquals(4, cnt);
+ }
+ }
+
+ /**
+ * Person.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Person implements Serializable {
+ /** Name. */
+ @QuerySqlField(index = false)
+ private final String name;
+
+ /** Age. */
+ @QuerySqlField
+ private final int age;
+
+ /** Organization ID. */
+ @QuerySqlField
+ private final int orgId;
+
+ /**
+ * @param name Name.
+ * @param age Age.
+ * @param orgId Organization ID.
+ */
+ private Person(String name, int age, int orgId) {
+ assert !F.isEmpty(name);
+ assert age > 0;
+ assert orgId > 0;
+
+ this.name = name;
+ this.age = age;
+ this.orgId = orgId;
+ }
+ }
+
+ /**
+ * Organization.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Organization implements Serializable {
+ /** ID. */
+ @QuerySqlField
+ private final int id;
+
+ /** Name. */
+ @QuerySqlField(index = false)
+ private final String name;
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ private Organization(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
new file mode 100644
index 0000000..ea586b2
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
@@ -0,0 +1,730 @@
+/*
+ * 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.jdbc2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.query.annotations.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.math.*;
+import java.net.*;
+import java.sql.*;
+import java.util.Date;
+
+import static java.sql.Types.*;
+import static org.apache.ignite.IgniteJdbcDriver.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Prepared statement test.
+ */
+public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** JDBC URL. */
+ private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** Connection. */
+ private Connection conn;
+
+ /** Statement. */
+ private PreparedStatement stmt;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<?,?> cache = defaultCacheConfiguration();
+
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(
+ Integer.class, TestObject.class
+ );
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ IgniteCache<Integer, TestObject> cache = grid(0).cache(null);
+
+ assert cache != null;
+
+ TestObject o = new TestObject(1);
+
+ o.boolVal = true;
+ o.byteVal = 1;
+ o.shortVal = 1;
+ o.intVal = 1;
+ o.longVal = 1L;
+ o.floatVal = 1.0f;
+ o.doubleVal = 1.0d;
+ o.bigVal = new BigDecimal(1);
+ o.strVal = "str";
+ o.arrVal = new byte[] {1};
+ o.dateVal = new Date(1);
+ o.timeVal = new Time(1);
+ o.tsVal = new Timestamp(1);
+ o.urlVal = new URL("http://abc.com/");
+
+ cache.put(1, o);
+ cache.put(2, new TestObject(2));
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ conn = DriverManager.getConnection(BASE_URL);
+
+ assert conn != null;
+ assert !conn.isClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ if (stmt != null) {
+ stmt.close();
+
+ assert stmt.isClosed();
+ }
+
+ if (conn != null) {
+ conn.close();
+
+ assert conn.isClosed();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBoolean() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where boolVal is not distinct from ?");
+
+ stmt.setBoolean(1, true);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, BOOLEAN);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByte() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where byteVal is not distinct from ?");
+
+ stmt.setByte(1, (byte)1);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, TINYINT);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where shortVal is not distinct from ?");
+
+ stmt.setShort(1, (short)1);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, SMALLINT);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInteger() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where intVal is not distinct from ?");
+
+ stmt.setInt(1, 1);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, INTEGER);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLong() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where longVal is not distinct from ?");
+
+ stmt.setLong(1, 1L);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, BIGINT);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where floatVal is not distinct from ?");
+
+ stmt.setFloat(1, 1.0f);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, FLOAT);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where doubleVal is not distinct from ?");
+
+ stmt.setDouble(1, 1.0d);
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, DOUBLE);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBigDecimal() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where bigVal is not distinct from ?");
+
+ stmt.setBigDecimal(1, new BigDecimal(1));
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, OTHER);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testString() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where strVal is not distinct from ?");
+
+ stmt.setString(1, "str");
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, VARCHAR);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testArray() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where arrVal is not distinct from ?");
+
+ stmt.setBytes(1, new byte[] {1});
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, BINARY);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDate() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where dateVal is not distinct from ?");
+
+ stmt.setObject(1, new Date(1));
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, DATE);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTime() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where timeVal is not distinct from ?");
+
+ stmt.setTime(1, new Time(1));
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, TIME);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestamp() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where tsVal is not distinct from ?");
+
+ stmt.setTimestamp(1, new Timestamp(1));
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, TIMESTAMP);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUrl() throws Exception {
+ stmt = conn.prepareStatement("select * from TestObject where urlVal is not distinct from ?");
+
+ stmt.setURL(1, new URL("http://abc.com/"));
+
+ ResultSet rs = stmt.executeQuery();
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 1;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setNull(1, DATALINK);
+
+ rs = stmt.executeQuery();
+
+ cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0)
+ assert rs.getInt("id") == 2;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * Test object.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class TestObject implements Serializable {
+ /** */
+ @QuerySqlField(index = false)
+ private final int id;
+
+ /** */
+ @QuerySqlField
+ private Boolean boolVal;
+
+ /** */
+ @QuerySqlField
+ private Byte byteVal;
+
+ /** */
+ @QuerySqlField
+ private Short shortVal;
+
+ /** */
+ @QuerySqlField
+ private Integer intVal;
+
+ /** */
+ @QuerySqlField
+ private Long longVal;
+
+ /** */
+ @QuerySqlField
+ private Float floatVal;
+
+ /** */
+ @QuerySqlField
+ private Double doubleVal;
+
+ /** */
+ @QuerySqlField
+ private BigDecimal bigVal;
+
+ /** */
+ @QuerySqlField
+ private String strVal;
+
+ /** */
+ @QuerySqlField
+ private byte[] arrVal;
+
+ /** */
+ @QuerySqlField
+ private Date dateVal;
+
+ /** */
+ @QuerySqlField
+ private Time timeVal;
+
+ /** */
+ @QuerySqlField
+ private Timestamp tsVal;
+
+ /** */
+ @QuerySqlField
+ private URL urlVal;
+
+ /**
+ * @param id ID.
+ */
+ private TestObject(int id) {
+ this.id = id;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
new file mode 100644
index 0000000..3607f53
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
@@ -0,0 +1,751 @@
+/*
+ * 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.jdbc2;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+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 static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Result set test.
+ */
+@SuppressWarnings("FloatingPointEquality")
+public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** JDBC URL. */
+ private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** SQL query. */
+ private static final String SQL =
+ "select id, boolVal, byteVal, shortVal, intVal, longVal, floatVal, " +
+ "doubleVal, bigVal, strVal, arrVal, dateVal, timeVal, tsVal, urlVal, f1, f2, f3, _val " +
+ "from TestObject where id = 1";
+
+ /** Statement. */
+ private Statement stmt;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<?,?> cache = defaultCacheConfiguration();
+
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(
+ Integer.class, TestObject.class
+ );
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ IgniteCache<Integer, TestObject> cache = grid(0).cache(null);
+
+ assert cache != null;
+
+ TestObject o = createObjectWithData(1);
+
+ cache.put(1, o);
+ cache.put(2, new TestObject(2));
+ cache.put(3, new TestObject(3));
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ stmt = DriverManager.getConnection(BASE_URL).createStatement();
+
+ assert stmt != null;
+ assert !stmt.isClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ if (stmt != null) {
+ stmt.getConnection().close();
+ stmt.close();
+
+ assert stmt.isClosed();
+ }
+ }
+
+ /**
+ * @param id ID.
+ * @return Object.
+ * @throws MalformedURLException If URL in incorrect.
+ */
+ @SuppressWarnings("deprecation")
+ private TestObject createObjectWithData(int id) throws MalformedURLException {
+ TestObject o = new TestObject(id);
+
+ o.boolVal = true;
+ o.byteVal = 1;
+ o.shortVal = 1;
+ o.intVal = 1;
+ o.longVal = 1L;
+ o.floatVal = 1.0f;
+ o.doubleVal = 1.0d;
+ o.bigVal = new BigDecimal(1);
+ o.strVal = "str";
+ o.arrVal = new byte[] {1};
+ o.dateVal = new Date(1, 1, 1);
+ o.timeVal = new Time(1, 1, 1);
+ o.tsVal = new Timestamp(1);
+ o.urlVal = new URL("http://abc.com/");
+
+ return o;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBoolean() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getBoolean("boolVal");
+ assert rs.getBoolean(2);
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByte() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getByte("byteVal") == 1;
+ assert rs.getByte(3) == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getShort("shortVal") == 1;
+ assert rs.getShort(4) == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInteger() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getInt("intVal") == 1;
+ assert rs.getInt(5) == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLong() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getLong("longVal") == 1;
+ assert rs.getLong(6) == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getFloat("floatVal") == 1.0;
+ assert rs.getFloat(7) == 1.0;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getDouble("doubleVal") == 1.0;
+ assert rs.getDouble(8) == 1.0;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBigDecimal() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getBigDecimal("bigVal").intValue() == 1;
+ assert rs.getBigDecimal(9).intValue() == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testString() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert "str".equals(rs.getString("strVal"));
+ assert "str".equals(rs.getString(10));
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testArray() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert Arrays.equals(rs.getBytes("arrVal"), new byte[] {1});
+ assert Arrays.equals(rs.getBytes(11), new byte[] {1});
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("deprecation")
+ public void testDate() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getDate("dateVal").equals(new Date(1, 1, 1));
+ assert rs.getDate(12).equals(new Date(1, 1, 1));
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("deprecation")
+ public void testTime() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getTime("timeVal").equals(new Time(1, 1, 1));
+ assert rs.getTime(13).equals(new Time(1, 1, 1));
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestamp() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert rs.getTimestamp("tsVal").getTime() == 1;
+ assert rs.getTimestamp(14).getTime() == 1;
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUrl() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ if (cnt == 0) {
+ assert "http://abc.com/".equals(rs.getURL("urlVal").toString());
+ assert "http://abc.com/".equals(rs.getURL(15).toString());
+ }
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObject() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ TestObjectField f1 = new TestObjectField(100, "AAAA");
+ TestObjectField f2 = new TestObjectField(500, "BBBB");
+
+ TestObject o = createObjectWithData(1);
+
+ assertTrue(rs.next());
+
+ assertEquals(f1.toString(), rs.getObject("f1"));
+ assertEquals(f1.toString(), rs.getObject(16));
+
+ assertEquals(f2.toString(), rs.getObject("f2"));
+ assertEquals(f2.toString(), rs.getObject(17));
+
+ assertNull(rs.getObject("f3"));
+ assertTrue(rs.wasNull());
+ assertNull(rs.getObject(18));
+ assertTrue(rs.wasNull());
+
+ assertEquals(o.toString(), rs.getObject("_val"));
+ assertEquals(o.toString(), rs.getObject(19));
+
+ assertFalse(rs.next());
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNavigation() throws Exception {
+ ResultSet rs = stmt.executeQuery("select * from TestObject where id > 0");
+
+ assertTrue(rs.isBeforeFirst());
+ assertFalse(rs.isAfterLast());
+ assertFalse(rs.isFirst());
+ assertFalse(rs.isLast());
+ assertEquals(0, rs.getRow());
+
+ assertTrue(rs.next());
+
+ assertFalse(rs.isBeforeFirst());
+ assertFalse(rs.isAfterLast());
+ assertTrue(rs.isFirst());
+ assertFalse(rs.isLast());
+ assertEquals(1, rs.getRow());
+
+ assertTrue(rs.next());
+
+ assertFalse(rs.isBeforeFirst());
+ assertFalse(rs.isAfterLast());
+ assertFalse(rs.isFirst());
+ assertFalse(rs.isLast());
+ assertEquals(2, rs.getRow());
+
+ assertTrue(rs.next());
+
+ assertFalse(rs.isBeforeFirst());
+ assertFalse(rs.isAfterLast());
+ assertFalse(rs.isFirst());
+ assertTrue(rs.isLast());
+ assertEquals(3, rs.getRow());
+
+ assertFalse(rs.next());
+
+ assertFalse(rs.isBeforeFirst());
+ assertTrue(rs.isAfterLast());
+ assertFalse(rs.isFirst());
+ assertFalse(rs.isLast());
+ assertEquals(0, rs.getRow());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFetchSize() throws Exception {
+ stmt.setFetchSize(1);
+
+ ResultSet rs = stmt.executeQuery("select * from TestObject where id > 0");
+
+ assertTrue(rs.next());
+ assertTrue(rs.next());
+ assertTrue(rs.next());
+
+ stmt.setFetchSize(0);
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFindColumn() throws Exception {
+ final ResultSet rs = stmt.executeQuery(SQL);
+
+ assertNotNull(rs);
+ assertTrue(rs.next());
+
+ assert rs.findColumn("id") == 1;
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ rs.findColumn("wrong");
+
+ return null;
+ }
+ },
+ SQLException.class,
+ "Column not found: wrong"
+ );
+ }
+
+ /**
+ * Test object.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class TestObject implements Serializable {
+ /** */
+ @QuerySqlField
+ private final int id;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Boolean boolVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Byte byteVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Short shortVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Integer intVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Long longVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Float floatVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Double doubleVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private BigDecimal bigVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private String strVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private byte[] arrVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Date dateVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Time timeVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private Timestamp tsVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private URL urlVal;
+
+ /** */
+ @QuerySqlField(index = false)
+ private TestObjectField f1 = new TestObjectField(100, "AAAA");
+
+ /** */
+ @QuerySqlField(index = false)
+ private TestObjectField f2 = new TestObjectField(500, "BBBB");
+
+ /** */
+ @QuerySqlField(index = false)
+ private TestObjectField f3;
+
+ /**
+ * @param id ID.
+ */
+ private TestObject(int id) {
+ this.id = id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TestObject.class, this);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"BigDecimalEquals", "EqualsHashCodeCalledOnUrl", "RedundantIfStatement"})
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ TestObject that = (TestObject)o;
+
+ if (id != that.id) return false;
+ if (!Arrays.equals(arrVal, that.arrVal)) return false;
+ if (bigVal != null ? !bigVal.equals(that.bigVal) : that.bigVal != null) return false;
+ if (boolVal != null ? !boolVal.equals(that.boolVal) : that.boolVal != null) return false;
+ if (byteVal != null ? !byteVal.equals(that.byteVal) : that.byteVal != null) return false;
+ if (dateVal != null ? !dateVal.equals(that.dateVal) : that.dateVal != null) return false;
+ if (doubleVal != null ? !doubleVal.equals(that.doubleVal) : that.doubleVal != null) return false;
+ if (f1 != null ? !f1.equals(that.f1) : that.f1 != null) return false;
+ if (f2 != null ? !f2.equals(that.f2) : that.f2 != null) return false;
+ if (f3 != null ? !f3.equals(that.f3) : that.f3 != null) return false;
+ if (floatVal != null ? !floatVal.equals(that.floatVal) : that.floatVal != null) return false;
+ if (intVal != null ? !intVal.equals(that.intVal) : that.intVal != null) return false;
+ if (longVal != null ? !longVal.equals(that.longVal) : that.longVal != null) return false;
+ if (shortVal != null ? !shortVal.equals(that.shortVal) : that.shortVal != null) return false;
+ if (strVal != null ? !strVal.equals(that.strVal) : that.strVal != null) return false;
+ if (timeVal != null ? !timeVal.equals(that.timeVal) : that.timeVal != null) return false;
+ if (tsVal != null ? !tsVal.equals(that.tsVal) : that.tsVal != null) return false;
+ if (urlVal != null ? !urlVal.equals(that.urlVal) : that.urlVal != null) return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("EqualsHashCodeCalledOnUrl")
+ @Override public int hashCode() {
+ int res = id;
+
+ res = 31 * res + (boolVal != null ? boolVal.hashCode() : 0);
+ res = 31 * res + (byteVal != null ? byteVal.hashCode() : 0);
+ res = 31 * res + (shortVal != null ? shortVal.hashCode() : 0);
+ res = 31 * res + (intVal != null ? intVal.hashCode() : 0);
+ res = 31 * res + (longVal != null ? longVal.hashCode() : 0);
+ res = 31 * res + (floatVal != null ? floatVal.hashCode() : 0);
+ res = 31 * res + (doubleVal != null ? doubleVal.hashCode() : 0);
+ res = 31 * res + (bigVal != null ? bigVal.hashCode() : 0);
+ res = 31 * res + (strVal != null ? strVal.hashCode() : 0);
+ res = 31 * res + (arrVal != null ? Arrays.hashCode(arrVal) : 0);
+ res = 31 * res + (dateVal != null ? dateVal.hashCode() : 0);
+ res = 31 * res + (timeVal != null ? timeVal.hashCode() : 0);
+ res = 31 * res + (tsVal != null ? tsVal.hashCode() : 0);
+ res = 31 * res + (urlVal != null ? urlVal.hashCode() : 0);
+ res = 31 * res + (f1 != null ? f1.hashCode() : 0);
+ res = 31 * res + (f2 != null ? f2.hashCode() : 0);
+ res = 31 * res + (f3 != null ? f3.hashCode() : 0);
+
+ return res;
+ }
+ }
+
+ /**
+ * Test object field.
+ */
+ @SuppressWarnings("PackageVisibleField")
+ private static class TestObjectField implements Serializable {
+ /** */
+ final int a;
+
+ /** */
+ final String b;
+
+ /**
+ * @param a A.
+ * @param b B.
+ */
+ private TestObjectField(int a, String b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ TestObjectField that = (TestObjectField)o;
+
+ return a == that.a && !(b != null ? !b.equals(that.b) : that.b != null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = a;
+
+ res = 31 * res + (b != null ? b.hashCode() : 0);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TestObjectField.class, this);
+ }
+ }
+}
[12/28] ignite git commit: ignite-1399
Posted by sb...@apache.org.
ignite-1399
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/18752a6f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/18752a6f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/18752a6f
Branch: refs/heads/ignite-971
Commit: 18752a6f86e55946dbd0a0b67992e08d85ef80ef
Parents: d26f746
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 11 12:25:45 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 11 12:25:45 2015 +0300
----------------------------------------------------------------------
pom.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/18752a6f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d026b30..fc609a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -301,6 +301,11 @@
<chmod dir="${basedir}/target/release-package" perm="755" includes="**/*.sh" />
+ <!-- hotfix according to https://issues.apache.org/jira/browse/IGNITE-1399. Remove at 1.5 -->
+ <move todir="${basedir}/target/temp/release-package/libs/optional/ignite-platform">
+ <fileset dir="${basedir}/target/release-package/libs/optional/ignite-platform"/>
+ </move>
+
<zip destfile="${basedir}/target/bin/${ignite.zip.pattern}.zip" encoding="UTF-8">
<zipfileset dir="${basedir}/target/release-package" prefix="${ignite.zip.pattern}" filemode="755">
<include name="**/*.sh" />
@@ -317,6 +322,11 @@
<exclude name="**/missing" />
</zipfileset>
</zip>
+
+ <!-- hotfix according to https://issues.apache.org/jira/browse/IGNITE-1399. Remove at 1.5 -->
+ <move todir="${basedir}/target/release-package/libs/optional/ignite-platform">
+ <fileset dir="${basedir}/target/temp/release-package/libs/optional/ignite-platform"/>
+ </move>
</target>
</configuration>
</execution>
[18/28] ignite git commit: Removed several obsolete .Net tests.
Posted by sb...@apache.org.
Removed several obsolete .Net tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a66400aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a66400aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a66400aa
Branch: refs/heads/ignite-971
Commit: a66400aa5adc48e465435ff77814789b9947c42e
Parents: 12b0f2b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 11 15:24:27 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 11 15:24:27 2015 +0300
----------------------------------------------------------------------
.../Cache/CacheAbstractTest.cs | 71 +-------------------
1 file changed, 1 insertion(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a66400aa/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 24d2b73..6af877e 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -2467,76 +2467,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.IsNull(err);
}
-
- //// TODO [Test]
- //public void TestCacheEntryGetSetRemove()
- //{
- // TestCacheEntryGetSetRemove(false);
- //}
-
- //// TODO [Test]
- //public void TestCacheEntryGetSetRemoveAsync()
- //{
- // TestCacheEntryGetSetRemove(true);
- //}
-
- //private void TestCacheEntryGetSetRemove(bool async)
- //{
- // IGridCache cache = Cache();
-
- // int key = PrimaryKeyForCache(cache);
-
- // IGridCacheEntry<int, int> e = cache.Entry(key);
-
- // Assert.IsNotNull(e);
-
- // if (async)
- // {
- // IGridFuture<int> fut = e.GetAsync();
-
- // Assert.IsNull(fut.Result);
-
- // Assert.IsTrue(fut.IsDone);
-
- // fut = e.SetAsync(10);
-
- // Assert.IsNull(fut.Result);
-
- // Assert.IsTrue(fut.IsDone);
-
- // fut = e.GetAsync();
-
- // Assert.AreEqual(10, fut.Result);
-
- // Assert.IsTrue(fut.IsDone);
- // }
- // else
- // {
- // Assert.IsNull(e.Get());
-
- // Assert.IsNull(e.Set(10));
-
- // Assert.AreEqual(10, e.Get());
- // }
-
- // Assert.AreEqual(10, cache.Get(key));
-
- // if (async)
- // {
- // IGridFuture<int> fut = e.RemoveAsync();
-
- // Assert.AreEqual(10, fut.Result);
-
- // Assert.IsTrue(fut.IsDone);
- // }
- // else
- // Assert.AreEqual(10, e.Remove());
-
- // Assert.IsNull(e.Get());
-
- // Assert.IsNull(cache.Get(key));
- //}
-
+
/**
* Test tries to provoke garbage collection for .Net future before it was completed to verify
* futures pinning works.
[05/28] ignite git commit: Removed platform CPP example ocnfig.
Posted by sb...@apache.org.
Removed platform CPP example ocnfig.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/071586e2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/071586e2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/071586e2
Branch: refs/heads/ignite-971
Commit: 071586e26d55e3f0af4e8c4fc42d407f30ad58d8
Parents: d36db7b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Sep 10 15:01:33 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 10 15:01:33 2015 +0300
----------------------------------------------------------------------
examples/config/platform/cpp/example-cache.xml | 87 ---------------------
1 file changed, 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/071586e2/examples/config/platform/cpp/example-cache.xml
----------------------------------------------------------------------
diff --git a/examples/config/platform/cpp/example-cache.xml b/examples/config/platform/cpp/example-cache.xml
deleted file mode 100644
index d720a98..0000000
--- a/examples/config/platform/cpp/example-cache.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?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.
--->
-
-<!--
- GridGain Spring configuration file to startup grid cache.
-
- When starting a standalone GridGain node, you need to execute the following command:
- {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/example-cache-dotnet.xml
-
- When starting GridGain from Java IDE, pass path to this file to GridGain:
- GridGain.start("examples/config/example-cache-dotnet.xml");
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Set to true to enable distributed class loading for examples, default is false. -->
- <property name="peerClassLoadingEnabled" value="true"/>
-
- <property name="cacheConfiguration">
- <list>
- <!--
- Partitioned cache example configuration with portable objects enabled.
- Used in .NET example that is available only in enterprise edition.
- -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
- <!--
- Partitioned cache example configuration.
- Used in .NET cache store example that is available only in enterprise edition.
- -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="tx"/>
- <property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="backups" value="1"/>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <!--
- GridGain provides several options for automatic discovery that can be used
- instead os static IP based discovery. For information on all options refer
- to our documentation: http://doc.gridgain.org/latest/Automatic+Node+Discovery
- -->
- <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
- <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
[27/28] ignite git commit: ignite-971 Fix offheap to swap eviction.
Posted by sb...@apache.org.
ignite-971 Fix offheap to swap eviction.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/25bea53a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/25bea53a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/25bea53a
Branch: refs/heads/ignite-971
Commit: 25bea53a1a488d072070b6f5becb3cf3cc2ad412
Parents: 716972f
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 14 10:11:37 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 14 11:56:08 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheSwapManager.java | 15 ++-
.../util/offheap/GridOffHeapPartitionedMap.java | 1 +
.../IgniteCachePutRetryAbstractSelfTest.java | 111 +++++++++++++++----
.../dht/IgniteCachePutRetryAtomicSelfTest.java | 2 +
...gniteCachePutRetryTransactionalSelfTest.java | 42 ++++---
...eAtomicInvalidPartitionHandlingSelfTest.java | 98 +++++++++++++---
6 files changed, 211 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 389d63d..9b6381e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -111,6 +111,9 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
/** Values to be evicted from offheap to swap. */
private ThreadLocal<Collection<IgniteBiTuple<byte[], byte[]>>> offheapEvicts = new ThreadLocal<>();
+ /** First offheap eviction warning flag. */
+ private volatile boolean firstEvictWarn;
+
/**
* @param enabled Flag to indicate if swap is enabled.
*/
@@ -180,9 +183,6 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
}
- /** First offheap eviction warning flag. */
- private volatile boolean firstEvictWarn;
-
/**
* Initializes off-heap space.
*/
@@ -564,6 +564,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
/**
* @param key Key to read.
+ * @param keyBytes Key bytes.
* @param part Key partition.
* @param entryLocked {@code True} if cache entry is locked.
* @param readOffheap Read offheap flag.
@@ -1050,10 +1051,10 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
/**
- * @param key Key to remove.
+ * @param key Key to move from offheap to swap.
* @param entry Serialized swap entry.
* @param part Partition.
- * @param ver Expected version.
+ * @param ver Expected entry version.
* @return {@code True} if removed.
* @throws IgniteCheckedException If failed.
*/
@@ -1347,9 +1348,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
* @param entry Entry bytes.
* @throws IgniteCheckedException If failed.
*/
- public void writeToSwap(int part, KeyCacheObject key, byte[] entry) throws IgniteCheckedException {
- assert swapEnabled;
-
+ private void writeToSwap(int part, KeyCacheObject key, byte[] entry) throws IgniteCheckedException {
checkIteratorQueue();
swapMgr.write(spaceName,
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java
index 5e03677..c1e1bfa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java
@@ -113,6 +113,7 @@ public interface GridOffHeapPartitionedMap {
/**
* Removes value from off-heap map without returning it.
+ *
* @param part Partition.
* @param hash Hash.
* @param keyBytes Key bytes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index 8a72bb9..c0478bb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -28,6 +28,7 @@ import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CachePartialUpdateException;
import org.apache.ignite.configuration.AtomicConfiguration;
@@ -36,23 +37,34 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.testframework.GridTestUtils.TestMemoryMode;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
/**
*
*/
-public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected int gridCount() {
- return 4;
- }
+public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final long DURATION = 60_000;
+
+ /** */
+ protected static final int GRID_CNT = 4;
/**
* @return Keys count for the test.
@@ -61,14 +73,22 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
return 10_000;
}
- /** {@inheritDoc} */
- @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
- CacheConfiguration cfg = super.cacheConfiguration(gridName);
+ /**
+ * @param memMode Memory mode.
+ * @return Cache configuration.
+ * @throws Exception If failed.
+ */
+ protected CacheConfiguration cacheConfiguration(TestMemoryMode memMode) throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+ cfg.setAtomicityMode(atomicityMode());
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setAtomicWriteOrderMode(writeOrderMode());
cfg.setBackups(1);
cfg.setRebalanceMode(SYNC);
+ GridTestUtils.setMemoryMode(null, cfg, memMode, 100, 1024);
+
return cfg;
}
@@ -76,15 +96,45 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
AtomicConfiguration acfg = new AtomicConfiguration();
acfg.setBackups(1);
cfg.setAtomicConfiguration(acfg);
+ cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+
return cfg;
}
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(GRID_CNT);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ ignite(0).destroyCache(null);
+ }
+
+ /**
+ * @return Cache atomicity mode.
+ */
+ protected abstract CacheAtomicityMode atomicityMode();
+
/**
* @return Write order mode.
*/
@@ -96,47 +146,64 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
* @throws Exception If failed.
*/
public void testPut() throws Exception {
- checkRetry(Test.PUT);
+ checkRetry(Test.PUT, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testPutAll() throws Exception {
- checkRetry(Test.PUT_ALL);
+ checkRetry(Test.PUT_ALL, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testPutAsync() throws Exception {
- checkRetry(Test.PUT_ASYNC);
+ checkRetry(Test.PUT_ASYNC, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testInvoke() throws Exception {
- checkRetry(Test.INVOKE);
+ checkRetry(Test.INVOKE, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testInvokeAll() throws Exception {
- checkRetry(Test.INVOKE_ALL);
+ checkRetry(Test.INVOKE_ALL, TestMemoryMode.HEAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllOffheapSwap() throws Exception {
+ checkRetry(Test.INVOKE_ALL, TestMemoryMode.OFFHEAP_EVICT_SWAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllOffheapTiered() throws Exception {
+ checkRetry(Test.INVOKE_ALL, TestMemoryMode.OFFHEAP_TIERED);
}
/**
* @param test Test type.
+ * @param memMode Memory mode.
* @throws Exception If failed.
*/
- private void checkRetry(Test test) throws Exception {
+ private void checkRetry(Test test, TestMemoryMode memMode) throws Exception {
+ ignite(0).createCache(cacheConfiguration(memMode));
+
final AtomicBoolean finished = new AtomicBoolean();
int keysCnt = keysCount();
- IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ IgniteInternalFuture<Object> fut = runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
while (!finished.get()) {
stopGrid(3);
@@ -155,10 +222,12 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
int iter = 0;
try {
- if (atomicityMode() == ATOMIC)
- assertEquals(writeOrderMode(), cache.getConfiguration(CacheConfiguration.class).getAtomicWriteOrderMode());
+ if (atomicityMode() == ATOMIC) {
+ assertEquals(writeOrderMode(),
+ cache.getConfiguration(CacheConfiguration.class).getAtomicWriteOrderMode());
+ }
- long stopTime = System.currentTimeMillis() + 60_000;
+ long stopTime = System.currentTimeMillis() + DURATION;
switch (test) {
case PUT: {
@@ -288,7 +357,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
for (int i = 0; i < keysCnt; i++)
assertEquals((Integer)iter, cache.get(i));
- for (int i = 0; i < gridCount(); i++) {
+ for (int i = 0; i < GRID_CNT; i++) {
IgniteKernal ignite = (IgniteKernal)grid(i);
Collection<?> futs = ignite.context().cache().context().mvcc().atomicFutures();
@@ -318,7 +387,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCacheAbstr
private void checkFailsWithNoRetries(boolean async) throws Exception {
final AtomicBoolean finished = new AtomicBoolean();
- IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ IgniteInternalFuture<Object> fut = runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
while (!finished.get()) {
stopGrid(3);
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java
index 9d84609..17d0af1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java
@@ -47,6 +47,8 @@ public class IgniteCachePutRetryAtomicSelfTest extends IgniteCachePutRetryAbstra
* @throws Exception If failed.
*/
public void testPutInsideTransaction() throws Exception {
+ ignite(0).createCache(cacheConfiguration(GridTestUtils.TestMemoryMode.HEAP));
+
CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
ccfg.setName("tx-cache");
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
index 7c66efc..40bb4f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
@@ -31,12 +31,13 @@ import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.testframework.GridTestUtils.TestMemoryMode;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
/**
*
@@ -50,11 +51,6 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
return TRANSACTIONAL;
}
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
/**
* @throws Exception If failed.
*/
@@ -63,7 +59,7 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
IgniteAtomicLong atomic = ignite(0).atomicLong("TestAtomic", 0, true);
- IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ IgniteInternalFuture<Object> fut = runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
while (!finished.get()) {
stopGrid(3);
@@ -92,15 +88,34 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
}
}
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
+ /**
+ * @throws Exception If failed.
+ */
public void testExplicitTransactionRetries() throws Exception {
+ explicitTransactionRetries(TestMemoryMode.HEAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExplicitTransactionRetriesOffheapSwap() throws Exception {
+ explicitTransactionRetries(TestMemoryMode.OFFHEAP_EVICT_SWAP);
+ }
+
+ /**
+ * @param memMode Memory mode.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public void explicitTransactionRetries(TestMemoryMode memMode) throws Exception {
+ ignite(0).createCache(cacheConfiguration(memMode));
+
final AtomicInteger idx = new AtomicInteger();
int threads = 8;
final AtomicReferenceArray<Exception> err = new AtomicReferenceArray<>(threads);
- IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ IgniteInternalFuture<Long> fut = runMultiThreadedAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
int th = idx.getAndIncrement();
int base = th * FACTOR;
@@ -115,8 +130,7 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
if (i > 0 && i % 500 == 0)
info("Done: " + i);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
err.set(th, e);
}
@@ -142,7 +156,7 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
}
// Verify contents of the cache.
- for (int g = 0; g < gridCount(); g++) {
+ for (int g = 0; g < GRID_CNT; g++) {
IgniteCache<Object, Object> cache = ignite(g).cache(null);
for (int th = 0; th < threads; th++) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/25bea53a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
index c598e97..3913957 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -65,6 +66,7 @@ import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.testframework.GridTestUtils.TestMemoryMode;
/**
* Test GridDhtInvalidPartitionException handling in ATOMIC cache during restarts.
@@ -83,19 +85,26 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
/** Write sync. */
private CacheWriteSynchronizationMode writeSync;
+ /** Memory mode. */
+ private TestMemoryMode memMode;
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER).setForceServerMode(true));
- cfg.setCacheConfiguration(cacheConfiguration());
+ CacheConfiguration ccfg = cacheConfiguration();
+
+ cfg.setCacheConfiguration(ccfg);
cfg.setCommunicationSpi(new DelayCommunicationSpi());
if (testClientNode() && getTestGridName(0).equals(gridName))
cfg.setClientMode(true);
+ GridTestUtils.setMemoryMode(cfg, ccfg, memMode, 100, 1024);
+
return cfg;
}
@@ -137,53 +146,99 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
* @throws Exception If failed.
*/
public void testClockFullSync() throws Exception {
- checkRestarts(CLOCK, FULL_SYNC);
+ checkRestarts(CLOCK, FULL_SYNC, TestMemoryMode.HEAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClockFullSyncSwap() throws Exception {
+ checkRestarts(CLOCK, FULL_SYNC, TestMemoryMode.SWAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClockFullSyncOffheapTiered() throws Exception {
+ checkRestarts(CLOCK, FULL_SYNC, TestMemoryMode.OFFHEAP_TIERED);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClockFullSyncOffheapSwap() throws Exception {
+ checkRestarts(CLOCK, FULL_SYNC, TestMemoryMode.OFFHEAP_EVICT_SWAP);
}
/**
* @throws Exception If failed.
*/
public void testClockPrimarySync() throws Exception {
- checkRestarts(CLOCK, PRIMARY_SYNC);
+ checkRestarts(CLOCK, PRIMARY_SYNC, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testClockFullAsync() throws Exception {
- checkRestarts(CLOCK, FULL_ASYNC);
+ checkRestarts(CLOCK, FULL_ASYNC, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testPrimaryFullSync() throws Exception {
- checkRestarts(PRIMARY, FULL_SYNC);
+ checkRestarts(PRIMARY, FULL_SYNC, TestMemoryMode.HEAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryFullSyncSwap() throws Exception {
+ checkRestarts(PRIMARY, FULL_SYNC, TestMemoryMode.SWAP);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryFullSyncOffheapTiered() throws Exception {
+ checkRestarts(PRIMARY, FULL_SYNC, TestMemoryMode.OFFHEAP_TIERED);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryFullSyncOffheapSwap() throws Exception {
+ checkRestarts(PRIMARY, FULL_SYNC, TestMemoryMode.OFFHEAP_EVICT_SWAP);
}
/**
* @throws Exception If failed.
*/
public void testPrimaryPrimarySync() throws Exception {
- checkRestarts(PRIMARY, PRIMARY_SYNC);
+ checkRestarts(PRIMARY, PRIMARY_SYNC, TestMemoryMode.HEAP);
}
/**
* @throws Exception If failed.
*/
public void testPrimaryFullAsync() throws Exception {
- checkRestarts(PRIMARY, FULL_ASYNC);
+ checkRestarts(PRIMARY, FULL_ASYNC, TestMemoryMode.HEAP);
}
/**
* @param writeOrder Write order to check.
* @param writeSync Write synchronization mode to check.
+ * @param memMode Memory mode.
* @throws Exception If failed.
*/
- private void checkRestarts(CacheAtomicWriteOrderMode writeOrder, CacheWriteSynchronizationMode writeSync)
+ private void checkRestarts(CacheAtomicWriteOrderMode writeOrder,
+ CacheWriteSynchronizationMode writeSync,
+ TestMemoryMode memMode)
throws Exception {
this.writeOrder = writeOrder;
this.writeSync = writeSync;
+ this.memMode = memMode;
final int gridCnt = 6;
@@ -227,16 +282,16 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
for (int i = 0; i < gridCnt; i++) {
ClusterNode locNode = grid(i).localNode();
- GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache();
+ IgniteCache<Object, Object> cache = grid(i).cache(null);
- GridCacheEntryEx entry = c.peekEx(key);
+ Object val = cache.localPeek(key);
if (affNodes.contains(locNode)) {
- if (entry == null)
+ if (val == null)
return false;
}
else
- assertNull(entry);
+ assertNull(val);
}
it.remove();
@@ -323,7 +378,20 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache();
- GridCacheEntryEx entry = c.peekEx(k);
+ GridCacheEntryEx entry = null;
+
+ if (memMode == TestMemoryMode.HEAP)
+ entry = c.peekEx(k);
+ else {
+ try {
+ entry = c.entryEx(k);
+
+ entry.unswap();
+ }
+ catch (GridDhtInvalidPartitionException e) {
+ // Skip key.
+ }
+ }
for (int r = 0; r < 10; r++) {
try {
@@ -383,7 +451,7 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
*/
private static class DelayCommunicationSpi extends TcpCommunicationSpi {
/** {@inheritDoc} */
- @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC)
throws IgniteSpiException {
try {
if (delayMessage((GridIoMessage)msg))
@@ -393,7 +461,7 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
throw new IgniteSpiException(e);
}
- super.sendMessage(node, msg, ackClosure);
+ super.sendMessage(node, msg, ackC);
}
/**
[21/28] ignite git commit: ignite-1250 JDBC driver: migration to
embedded Ignite client node
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDatabaseMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDatabaseMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDatabaseMetadata.java
new file mode 100644
index 0000000..98a2563
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDatabaseMetadata.java
@@ -0,0 +1,1401 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+import static java.sql.Connection.TRANSACTION_NONE;
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.RowIdLifetime.ROWID_UNSUPPORTED;
+
+/**
+ * JDBC database metadata implementation.
+ */
+public class JdbcDatabaseMetadata implements DatabaseMetaData {
+ /** Connection. */
+ private final JdbcConnection conn;
+
+ /** Metadata. */
+ private Map<String, Map<String, Map<String, String>>> meta;
+
+ /** Index info. */
+ private Collection<List<Object>> indexes;
+
+ /**
+ * @param conn Connection.
+ */
+ JdbcDatabaseMetadata(JdbcConnection conn) {
+ this.conn = conn;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean allProceduresAreCallable() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean allTablesAreSelectable() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getURL() throws SQLException {
+ return conn.url();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getUserName() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isReadOnly() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean nullsAreSortedHigh() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean nullsAreSortedLow() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean nullsAreSortedAtStart() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean nullsAreSortedAtEnd() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getDatabaseProductName() throws SQLException {
+ return "Ignite Cache";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getDatabaseProductVersion() throws SQLException {
+ return "4.1.0";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getDriverName() throws SQLException {
+ return "Ignite JDBC Driver";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getDriverVersion() throws SQLException {
+ return "1.0";
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getDriverMajorVersion() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getDriverMinorVersion() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean usesLocalFiles() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean usesLocalFilePerTable() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMixedCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesUpperCaseIdentifiers() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesLowerCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesMixedCaseIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getIdentifierQuoteString() throws SQLException {
+ return " ";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSQLKeywords() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getNumericFunctions() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getStringFunctions() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSystemFunctions() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getTimeDateFunctions() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSearchStringEscape() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getExtraNameCharacters() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsColumnAliasing() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean nullPlusNonNullIsNull() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsConvert() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsConvert(int fromType, int toType) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsTableCorrelationNames() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsDifferentTableCorrelationNames() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsExpressionsInOrderBy() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOrderByUnrelated() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsGroupBy() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsGroupByUnrelated() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsGroupByBeyondSelect() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsLikeEscapeClause() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMultipleResultSets() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMultipleTransactions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsNonNullableColumns() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMinimumSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCoreSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsExtendedSQLGrammar() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsANSI92IntermediateSQL() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsANSI92FullSQL() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOuterJoins() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsFullOuterJoins() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsLimitedOuterJoins() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSchemaTerm() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getProcedureTerm() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getCatalogTerm() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isCatalogAtStart() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getCatalogSeparator() throws SQLException {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSchemasInDataManipulation() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSchemasInProcedureCalls() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSchemasInTableDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCatalogsInDataManipulation() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsPositionedDelete() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsPositionedUpdate() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSelectForUpdate() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsStoredProcedures() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSubqueriesInComparisons() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSubqueriesInExists() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSubqueriesInIns() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsCorrelatedSubqueries() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsUnion() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsUnionAll() throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxBinaryLiteralLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxCharLiteralLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnsInGroupBy() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnsInIndex() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnsInOrderBy() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnsInSelect() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxColumnsInTable() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxConnections() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxCursorNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxIndexLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxSchemaNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxProcedureNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxCatalogNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxRowSize() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxStatementLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxStatements() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxTableNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxTablesInSelect() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getMaxUserNameLength() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getDefaultTransactionIsolation() throws SQLException {
+ return TRANSACTION_NONE;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsTransactions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getProcedures(String catalog, String schemaPtrn,
+ String procedureNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME",
+ "REMARKS", "PROCEDURE_TYPE", "SPECIFIC_NAME"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Short.class.getName(), String.class.getName()),
+ Collections.<List<?>>emptyList(), true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getProcedureColumns(String catalog, String schemaPtrn, String procedureNamePtrn,
+ String colNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME",
+ "COLUMN_NAME", "COLUMN_TYPE", "DATA_TYPE", "TYPE_NAME", "PRECISION",
+ "LENGTH", "SCALE", "RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF",
+ "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
+ "ORDINAL_POSITION", "IS_NULLABLE", "SPECIFIC_NAME"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Short.class.getName(), Integer.class.getName(), String.class.getName(),
+ Integer.class.getName(), Integer.class.getName(), Short.class.getName(), Short.class.getName(),
+ Short.class.getName(), String.class.getName(), String.class.getName(), Integer.class.getName(),
+ Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), String.class.getName(),
+ String.class.getName()),
+ Collections.<List<?>>emptyList(), true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getTables(String catalog, String schemaPtrn, String tblNamePtrn,
+ String[] tblTypes) throws SQLException {
+ updateMetaData();
+
+ List<List<?>> rows = new LinkedList<>();
+
+ if (tblTypes == null || Arrays.asList(tblTypes).contains("TABLE"))
+ for (Map.Entry<String, Map<String, Map<String, String>>> schema : meta.entrySet())
+ if (matches(schema.getKey(), schemaPtrn))
+ for (String tbl : schema.getValue().keySet())
+ if (matches(tbl, tblNamePtrn))
+ rows.add(tableRow(schema.getKey(), tbl));
+
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TYPE_CAT",
+ "TYPE_SCHEM", "TYPE_NAME", "SELF_REFERENCING_COL_NAME", "REF_GENERATION"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), String.class.getName(), String.class.getName()),
+ rows, true
+ );
+ }
+
+ /**
+ * @param schema Schema name.
+ * @param tbl Table name.
+ * @return Table metadata row.
+ */
+ private List<Object> tableRow(String schema, String tbl) {
+ List<Object> row = new ArrayList<>(10);
+
+ row.add(null);
+ row.add(schema);
+ row.add(tbl.toUpperCase());
+ row.add("TABLE");
+ row.add(null);
+ row.add(null);
+ row.add(null);
+ row.add(null);
+ row.add(null);
+ row.add(null);
+
+ return row;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getSchemas() throws SQLException {
+ return getSchemas(null, "%");
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getCatalogs() throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.singletonList("TABLE_CAT"),
+ Collections.singletonList(String.class.getName()),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getTableTypes() throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.singletonList("TABLE_TYPE"),
+ Collections.singletonList(String.class.getName()),
+ Collections.<List<?>>singletonList(Collections.singletonList("TABLE")),
+ true);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getColumns(String catalog, String schemaPtrn, String tblNamePtrn,
+ String colNamePtrn) throws SQLException {
+ updateMetaData();
+
+ List<List<?>> rows = new LinkedList<>();
+
+ int cnt = 0;
+
+ for (Map.Entry<String, Map<String, Map<String, String>>> schema : meta.entrySet())
+ if (matches(schema.getKey(), schemaPtrn))
+ for (Map.Entry<String, Map<String, String>> tbl : schema.getValue().entrySet())
+ if (matches(tbl.getKey(), tblNamePtrn))
+ for (Map.Entry<String, String> col : tbl.getValue().entrySet())
+ rows.add(columnRow(schema.getKey(), tbl.getKey(), col.getKey(),
+ JdbcUtils.type(col.getValue()), JdbcUtils.typeName(col.getValue()),
+ JdbcUtils.nullable(col.getKey(), col.getValue()), ++cnt));
+
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE",
+ "TYPE_NAME", "COLUMN_SIZE", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE",
+ "REMARKS", "COLUMN_DEF", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE",
+ "SCOPE_CATLOG", "SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE", "IS_AUTOINCREMENT"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Integer.class.getName(), String.class.getName(), Integer.class.getName(),
+ Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), String.class.getName(),
+ String.class.getName(), Integer.class.getName(), Integer.class.getName(), String.class.getName(),
+ String.class.getName(), String.class.getName(), String.class.getName(), Short.class.getName(),
+ String.class.getName()),
+ rows, true
+ );
+ }
+
+ /**
+ * @param schema Schema name.
+ * @param tbl Table name.
+ * @param col Column name.
+ * @param type Type.
+ * @param typeName Type name.
+ * @param nullable Nullable flag.
+ * @param pos Ordinal position.
+ * @return Column metadata row.
+ */
+ private List<Object> columnRow(String schema, String tbl, String col, int type, String typeName,
+ boolean nullable, int pos) {
+ List<Object> row = new ArrayList<>(20);
+
+ row.add(null);
+ row.add(schema);
+ row.add(tbl);
+ row.add(col);
+ row.add(type);
+ row.add(typeName);
+ row.add(null);
+ row.add(null);
+ row.add(10);
+ row.add(nullable ? columnNullable : columnNoNulls);
+ row.add(null);
+ row.add(null);
+ row.add(Integer.MAX_VALUE);
+ row.add(pos);
+ row.add("YES");
+ row.add(null);
+ row.add(null);
+ row.add(null);
+ row.add(null);
+ row.add("NO");
+
+ return row;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getColumnPrivileges(String catalog, String schema, String tbl,
+ String colNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getTablePrivileges(String catalog, String schemaPtrn,
+ String tblNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getBestRowIdentifier(String catalog, String schema, String tbl, int scope,
+ boolean nullable) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getVersionColumns(String catalog, String schema, String tbl) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getPrimaryKeys(String catalog, String schema, String tbl) throws SQLException {
+ updateMetaData();
+
+ List<List<?>> rows = new LinkedList<>();
+
+ for (Map.Entry<String, Map<String, Map<String, String>>> s : meta.entrySet())
+ if (schema == null || schema.toUpperCase().equals(s.getKey()))
+ for (Map.Entry<String, Map<String, String>> t : s.getValue().entrySet())
+ if (tbl == null || tbl.toUpperCase().equals(t.getKey()))
+ rows.add(Arrays.<Object>asList(null, s.getKey().toUpperCase(),
+ t.getKey().toUpperCase(), "_KEY", 1, "_KEY"));
+
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", "PK_NAME"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Short.class.getName(), String.class.getName()),
+ rows, true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getImportedKeys(String catalog, String schema, String tbl) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getExportedKeys(String catalog, String schema, String tbl) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTbl,
+ String foreignCatalog, String foreignSchema, String foreignTbl) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getTypeInfo() throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getIndexInfo(String catalog, String schema, String tbl, boolean unique,
+ boolean approximate) throws SQLException {
+ Collection<List<?>> rows = new ArrayList<>(indexes.size());
+
+ for (List<Object> idx : indexes) {
+ String idxSchema = (String)idx.get(0);
+ String idxTbl = (String)idx.get(1);
+
+ if ((schema == null || schema.equals(idxSchema)) && (tbl == null || tbl.equals(idxTbl))) {
+ List<Object> row = new ArrayList<>(13);
+
+ row.add(null);
+ row.add(idxSchema);
+ row.add(idxTbl);
+ row.add(idx.get(2));
+ row.add(null);
+ row.add(idx.get(3));
+ row.add((int)tableIndexOther);
+ row.add(idx.get(4));
+ row.add(idx.get(5));
+ row.add((Boolean)idx.get(6) ? "D" : "A");
+ row.add(0);
+ row.add(0);
+ row.add(null);
+
+ rows.add(row);
+ }
+ }
+
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", "INDEX_QUALIFIER",
+ "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "CARDINALITY",
+ "PAGES", "FILTER_CONDITION"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ Boolean.class.getName(), String.class.getName(), String.class.getName(), Short.class.getName(),
+ Short.class.getName(), String.class.getName(), String.class.getName(), Integer.class.getName(),
+ Integer.class.getName(), String.class.getName()),
+ rows, true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsResultSetType(int type) throws SQLException {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
+ return concurrency == CONCUR_READ_ONLY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean ownUpdatesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean ownDeletesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean ownInsertsAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean othersUpdatesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean othersDeletesAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean othersInsertsAreVisible(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean updatesAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean deletesAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insertsAreDetected(int type) throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsBatchUpdates() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getUDTs(String catalog, String schemaPtrn, String typeNamePtrn,
+ int[] types) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public Connection getConnection() throws SQLException {
+ return conn;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsSavepoints() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsNamedParameters() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsMultipleOpenResults() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsGetGeneratedKeys() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getSuperTypes(String catalog, String schemaPtrn,
+ String typeNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getSuperTables(String catalog, String schemaPtrn,
+ String tblNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getAttributes(String catalog, String schemaPtrn, String typeNamePtrn,
+ String attributeNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsResultSetHoldability(int holdability) throws SQLException {
+ return holdability == HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getResultSetHoldability() throws SQLException {
+ return HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getDatabaseMajorVersion() throws SQLException {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getDatabaseMinorVersion() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getJDBCMajorVersion() throws SQLException {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getJDBCMinorVersion() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getSQLStateType() throws SQLException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean locatorsUpdateCopy() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsStatementPooling() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public RowIdLifetime getRowIdLifetime() throws SQLException {
+ return ROWID_UNSUPPORTED;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getSchemas(String catalog, String schemaPtrn) throws SQLException {
+ updateMetaData();
+
+ List<List<?>> rows = new ArrayList<>(meta.size());
+
+ for (String schema : meta.keySet())
+ if (matches(schema, schemaPtrn))
+ rows.add(Arrays.<Object>asList(schema, null));
+
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG"),
+ Arrays.asList(String.class.getName(), String.class.getName()),
+ rows, true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getClientInfoProperties() throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getFunctions(String catalog, String schemaPtrn,
+ String functionNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("FUNCTION_CAT", "FUNCTION_SCHEM", "FUNCTION_NAME",
+ "REMARKS", "FUNCTION_TYPE", "SPECIFIC_NAME"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Short.class.getName(), String.class.getName()),
+ Collections.<List<?>>emptyList(), true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getFunctionColumns(String catalog, String schemaPtrn, String functionNamePtrn,
+ String colNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Arrays.asList("FUNCTION_CAT", "FUNCTION_SCHEM", "FUNCTION_NAME",
+ "COLUMN_NAME", "COLUMN_TYPE", "DATA_TYPE", "TYPE_NAME", "PRECISION",
+ "LENGTH", "SCALE", "RADIX", "NULLABLE", "REMARKS", "CHAR_OCTET_LENGTH",
+ "ORDINAL_POSITION", "IS_NULLABLE", "SPECIFIC_NAME"),
+ Arrays.asList(String.class.getName(), String.class.getName(), String.class.getName(),
+ String.class.getName(), Short.class.getName(), Integer.class.getName(), String.class.getName(),
+ Integer.class.getName(), Integer.class.getName(), Short.class.getName(), Short.class.getName(),
+ Short.class.getName(), String.class.getName(), Integer.class.getName(), Integer.class.getName(),
+ String.class.getName(), String.class.getName()),
+ Collections.<List<?>>emptyList(), true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> iface) throws SQLException {
+ if (!isWrapperFor(iface))
+ throw new SQLException("Database meta data is not a wrapper for " + iface.getName());
+
+ return (T)this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface != null && iface == DatabaseMetaData.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet getPseudoColumns(String catalog, String schemaPtrn, String tblNamePtrn,
+ String colNamePtrn) throws SQLException {
+ return new JdbcResultSet(null,
+ conn.createStatement0(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<String>emptyList(),
+ Collections.<List<?>>emptyList(),
+ true
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean generatedKeyAlwaysReturned() throws SQLException {
+ return false;
+ }
+
+ /**
+ * Updates meta data.
+ *
+ * @throws SQLException In case of error.
+ */
+ @SuppressWarnings("unchecked")
+ private void updateMetaData() throws SQLException {
+ if (conn.isClosed())
+ throw new SQLException("Connection is closed.");
+
+ try {
+ Ignite ignite = conn.ignite();
+
+ UUID nodeId = conn.nodeId();
+
+ Collection<GridCacheSqlMetadata> metas;
+
+ UpdateMetadataTask task = new UpdateMetadataTask(conn.cacheName(), nodeId == null ? ignite : null);
+
+ metas = nodeId == null ? task.call() : ignite.compute(ignite.cluster().forNodeId(nodeId)).call(task);
+
+ meta = U.newHashMap(metas.size());
+
+ indexes = new ArrayList<>();
+
+ for (GridCacheSqlMetadata m : metas) {
+ String name = m.cacheName();
+
+ if (name == null)
+ name = "PUBLIC";
+
+ Collection<String> types = m.types();
+
+ Map<String, Map<String, String>> typesMap = U.newHashMap(types.size());
+
+ for (String type : types) {
+ typesMap.put(type.toUpperCase(), m.fields(type));
+
+ for (GridCacheSqlIndexMetadata idx : m.indexes(type)) {
+ int cnt = 0;
+
+ for (String field : idx.fields()) {
+ indexes.add(F.<Object>asList(name, type.toUpperCase(), !idx.unique(),
+ idx.name().toUpperCase(), ++cnt, field, idx.descending(field)));
+ }
+ }
+ }
+
+ meta.put(name, typesMap);
+ }
+ }
+ catch (Exception e) {
+ throw new SQLException("Failed to get meta data from Ignite.", e);
+ }
+ }
+
+ /**
+ * Checks whether string matches SQL pattern.
+ *
+ * @param str String.
+ * @param ptrn Pattern.
+ * @return Whether string matches pattern.
+ */
+ private boolean matches(String str, String ptrn) {
+ return str != null && (ptrn == null ||
+ str.toUpperCase().matches(ptrn.toUpperCase().replace("%", ".*").replace("_", ".")));
+ }
+
+ /**
+ *
+ */
+ private static class UpdateMetadataTask implements IgniteCallable<Collection<GridCacheSqlMetadata>> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0L;
+
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Cache name. */
+ private final String cacheName;
+
+ /**
+ * @param cacheName Cache name.
+ * @param ignite Ignite.
+ */
+ public UpdateMetadataTask(String cacheName, Ignite ignite) {
+ this.cacheName = cacheName;
+ this.ignite = ignite;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public Collection<GridCacheSqlMetadata> call() throws Exception {
+ IgniteCache cache = ignite.cache(cacheName);
+
+ return ((IgniteCacheProxy)cache).context().queries().sqlMetadata();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
new file mode 100644
index 0000000..a99f24c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
@@ -0,0 +1,411 @@
+/*
+ * 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.jdbc2;
+
+import java.io.*;
+import java.math.*;
+import java.net.*;
+import java.sql.*;
+import java.sql.Date;
+import java.util.*;
+
+/**
+ * JDBC prepared statement implementation.
+ */
+public class JdbcPreparedStatement extends JdbcStatement implements PreparedStatement {
+ /** SQL query. */
+ private final String sql;
+
+ /** Arguments count. */
+ private final int argsCnt;
+
+ /**
+ * Creates new prepared statement.
+ *
+ * @param conn Connection.
+ * @param sql SQL query.
+ */
+ JdbcPreparedStatement(JdbcConnection conn, String sql) {
+ super(conn);
+
+ this.sql = sql;
+
+ argsCnt = sql.replaceAll("[^?]", "").length();
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSet executeQuery() throws SQLException {
+ ResultSet rs = executeQuery(sql);
+
+ args = null;
+
+ return rs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int executeUpdate() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNull(int paramIdx, int sqlType) throws SQLException {
+ setArgument(paramIdx, null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBoolean(int paramIdx, boolean x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setByte(int paramIdx, byte x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setShort(int paramIdx, short x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setInt(int paramIdx, int x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setLong(int paramIdx, long x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setFloat(int paramIdx, float x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setDouble(int paramIdx, double x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBigDecimal(int paramIdx, BigDecimal x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setString(int paramIdx, String x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBytes(int paramIdx, byte[] x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setDate(int paramIdx, Date x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTime(int paramIdx, Time x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTimestamp(int paramIdx, Timestamp x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setAsciiStream(int paramIdx, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setUnicodeStream(int paramIdx, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBinaryStream(int paramIdx, InputStream x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearParameters() throws SQLException {
+ ensureNotClosed();
+
+ args = null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setObject(int paramIdx, Object x, int targetSqlType) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setObject(int paramIdx, Object x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean execute() throws SQLException {
+ return execute(sql);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void addBatch() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setCharacterStream(int paramIdx, Reader x, int len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setRef(int paramIdx, Ref x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBlob(int paramIdx, Blob x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setClob(int paramIdx, Clob x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setArray(int paramIdx, Array x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public ResultSetMetaData getMetaData() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Meta data for prepared statement is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setDate(int paramIdx, Date x, Calendar cal) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTime(int paramIdx, Time x, Calendar cal) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTimestamp(int paramIdx, Timestamp x, Calendar cal) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNull(int paramIdx, int sqlType, String typeName) throws SQLException {
+ setNull(paramIdx, sqlType);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setURL(int paramIdx, URL x) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ParameterMetaData getParameterMetaData() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Meta data for prepared statement is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setRowId(int paramIdx, RowId x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNString(int paramIdx, String val) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNCharacterStream(int paramIdx, Reader val, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNClob(int paramIdx, NClob val) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setClob(int paramIdx, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBlob(int paramIdx, InputStream inputStream, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNClob(int paramIdx, Reader reader, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setSQLXML(int paramIdx, SQLXML xmlObj) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setObject(int paramIdx, Object x, int targetSqlType,
+ int scaleOrLen) throws SQLException {
+ setArgument(paramIdx, x);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setAsciiStream(int paramIdx, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBinaryStream(int paramIdx, InputStream x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setCharacterStream(int paramIdx, Reader x, long len) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setAsciiStream(int paramIdx, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBinaryStream(int paramIdx, InputStream x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setCharacterStream(int paramIdx, Reader x) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Streams are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNCharacterStream(int paramIdx, Reader val) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setClob(int paramIdx, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setBlob(int paramIdx, InputStream inputStream) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNClob(int paramIdx, Reader reader) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /**
+ * Sets query argument value.
+ *
+ * @param paramIdx Index.
+ * @param val Value.
+ * @throws SQLException If index is invalid.
+ */
+ private void setArgument(int paramIdx, Object val) throws SQLException {
+ ensureNotClosed();
+
+ if (paramIdx < 1 || paramIdx > argsCnt)
+ throw new SQLException("Parameter index is invalid: " + paramIdx);
+
+ if (args == null)
+ args = new Object[argsCnt];
+
+ args[paramIdx - 1] = val;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
new file mode 100644
index 0000000..ac711b8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.jdbc2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteJdbcDriver;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
+import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
+import org.apache.ignite.internal.util.typedef.CAX;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task for SQL queries execution through {@link IgniteJdbcDriver}.
+ * <p>
+ * Not closed cursors will be removed after {@link #RMV_DELAY} milliseconds.
+ * This parameter can be configured via {@link IgniteSystemProperties#IGNITE_JDBC_DRIVER_CURSOR_REMOVE_DELAY}
+ * system property.
+ */
+class JdbcQueryTask implements IgniteCallable<JdbcQueryTask.QueryResult> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0L;
+
+ /** How long to store open cursor. */
+ private static final long RMV_DELAY = IgniteSystemProperties.getLong(
+ IgniteSystemProperties.IGNITE_JDBC_DRIVER_CURSOR_REMOVE_DELAY, 600000);
+
+ /** Scheduler. */
+ private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1);
+
+ /** Open cursors. */
+ private static final ConcurrentMap<UUID, Cursor> CURSORS = new ConcurrentHashMap<>();
+
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Uuid. */
+ private final UUID uuid;
+
+ /** Cache name. */
+ private final String cacheName;
+
+ /** Sql. */
+ private final String sql;
+
+ /** Args. */
+ private final Object[] args;
+
+ /** Fetch size. */
+ private final int fetchSize;
+
+ /** Local execution flag. */
+ private final boolean loc;
+
+ /** Local query flag. */
+ private final boolean locQry;
+
+ /** Collocated query flag. */
+ private final boolean collocatedQry;
+
+ /**
+ * @param ignite Ignite.
+ * @param cacheName Cache name.
+ * @param sql Sql query.
+ * @param loc Local execution flag.
+ * @param args Args.
+ * @param fetchSize Fetch size.
+ * @param uuid UUID.
+ * @param locQry Local query flag.
+ * @param collocatedQry Collocated query flag.
+ */
+ public JdbcQueryTask(Ignite ignite, String cacheName, String sql,
+ boolean loc, Object[] args, int fetchSize, UUID uuid, boolean locQry, boolean collocatedQry) {
+ this.ignite = ignite;
+ this.args = args;
+ this.uuid = uuid;
+ this.cacheName = cacheName;
+ this.sql = sql;
+ this.fetchSize = fetchSize;
+ this.loc = loc;
+ this.locQry = locQry;
+ this.collocatedQry = collocatedQry;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JdbcQueryTask.QueryResult call() throws Exception {
+ Cursor cursor = CURSORS.get(uuid);
+
+ List<String> tbls = null;
+ List<String> cols = null;
+ List<String> types = null;
+
+ boolean first;
+
+ if (first = (cursor == null)) {
+ IgniteCache<?, ?> cache = ignite.cache(cacheName);
+
+ SqlFieldsQuery qry = new SqlFieldsQuery(sql).setArgs(args);
+
+ qry.setPageSize(fetchSize);
+ qry.setLocal(locQry);
+ qry.setCollocated(collocatedQry);
+
+ QueryCursor<List<?>> qryCursor = cache.query(qry);
+
+ Collection<GridQueryFieldMetadata> meta = ((QueryCursorImpl<List<?>>)qryCursor).fieldsMeta();
+
+ tbls = new ArrayList<>(meta.size());
+ cols = new ArrayList<>(meta.size());
+ types = new ArrayList<>(meta.size());
+
+ for (GridQueryFieldMetadata desc : meta) {
+ tbls.add(desc.typeName());
+ cols.add(desc.fieldName().toUpperCase());
+ types.add(desc.fieldTypeName());
+ }
+
+ CURSORS.put(uuid, cursor = new Cursor(qryCursor, qryCursor.iterator()));
+ }
+
+ List<List<?>> rows = new ArrayList<>();
+
+ for (List<?> row : cursor) {
+ List<Object> row0 = new ArrayList<>(row.size());
+
+ for (Object val : row)
+ row0.add(JdbcUtils.sqlType(val) ? val : val.toString());
+
+ rows.add(row0);
+
+ if (rows.size() == fetchSize) // If fetchSize is 0 then unlimited
+ break;
+ }
+
+ boolean finished = !cursor.hasNext();
+
+ if (finished)
+ remove(uuid, cursor);
+ else if (first) {
+ if (!loc)
+ scheduleRemoval(uuid, RMV_DELAY);
+ }
+ else if (!loc && !CURSORS.replace(uuid, cursor, new Cursor(cursor.cursor, cursor.iter)))
+ assert !CURSORS.containsKey(uuid) : "Concurrent cursor modification.";
+
+ return new QueryResult(uuid, finished, rows, cols, tbls, types);
+ }
+
+ /**
+ * Schedules removal of stored cursor in case of remote query execution.
+ *
+ * @param uuid Cursor UUID.
+ * @param delay Delay in milliseconds.
+ */
+ private void scheduleRemoval(final UUID uuid, long delay) {
+ assert !loc;
+
+ SCHEDULER.schedule(new CAX() {
+ @Override public void applyx() {
+ while (true) {
+ Cursor c = CURSORS.get(uuid);
+
+ if (c == null)
+ break;
+
+ // If the cursor was accessed since last scheduling then reschedule.
+ long untouchedTime = U.currentTimeMillis() - c.lastAccessTime;
+
+ if (untouchedTime < RMV_DELAY) {
+ scheduleRemoval(uuid, RMV_DELAY - untouchedTime);
+
+ break;
+ }
+ else if (remove(uuid, c))
+ break;
+ }
+ }
+ }, delay, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * @param uuid Cursor UUID.
+ * @param c Cursor.
+ * @return {@code true} If succeeded.
+ */
+ private static boolean remove(UUID uuid, Cursor c) {
+ boolean rmv = CURSORS.remove(uuid, c);
+
+ if (rmv)
+ c.cursor.close();
+
+ return rmv;
+ }
+
+ /**
+ * Closes and removes cursor.
+ *
+ * @param uuid Cursor UUID.
+ */
+ static void remove(UUID uuid) {
+ Cursor c = CURSORS.remove(uuid);
+
+ if (c != null)
+ c.cursor.close();
+ }
+
+
+ /**
+ * Result of query execution.
+ */
+ static class QueryResult implements Serializable {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0L;
+
+ /** Uuid. */
+ private final UUID uuid;
+
+ /** Finished. */
+ private final boolean finished;
+
+ /** Rows. */
+ private final List<List<?>> rows;
+
+ /** Tables. */
+ private final List<String> tbls;
+
+ /** Columns. */
+ private final List<String> cols;
+
+ /** Types. */
+ private final List<String> types;
+
+ /**
+ * @param uuid UUID..
+ * @param finished Finished.
+ * @param rows Rows.
+ * @param cols Columns.
+ * @param tbls Tables.
+ * @param types Types.
+ */
+ public QueryResult(UUID uuid, boolean finished, List<List<?>> rows, List<String> cols,
+ List<String> tbls, List<String> types) {
+ this.cols = cols;
+ this.uuid = uuid;
+ this.finished = finished;
+ this.rows = rows;
+ this.tbls = tbls;
+ this.types = types;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public List<List<?>> getRows() {
+ return rows;
+ }
+
+ /**
+ * @return Tables metadata.
+ */
+ public List<String> getTbls() {
+ return tbls;
+ }
+
+ /**
+ * @return Columns metadata.
+ */
+ public List<String> getCols() {
+ return cols;
+ }
+
+ /**
+ * @return Types metadata.
+ */
+ public List<String> getTypes() {
+ return types;
+ }
+
+ /**
+ * @return Query UUID.
+ */
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ /**
+ * @return {@code True} if it is finished query.
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+ }
+
+ /**
+ * Cursor.
+ */
+ private static final class Cursor implements Iterable<List<?>> {
+ /** Cursor. */
+ final QueryCursor<List<?>> cursor;
+
+ /** Iterator. */
+ final Iterator<List<?>> iter;
+
+ /** Last access time. */
+ final long lastAccessTime;
+
+ /**
+ * @param cursor Cursor.
+ * @param iter Iterator.
+ */
+ private Cursor(QueryCursor<List<?>> cursor, Iterator<List<?>> iter) {
+ this.cursor = cursor;
+ this.iter = iter;
+ this.lastAccessTime = U.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterator<List<?>> iterator() {
+ return iter;
+ }
+
+ /**
+ * @return {@code True} if cursor has next element.
+ */
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+ }
+}
[13/28] ignite git commit: ignite-1399
Posted by sb...@apache.org.
ignite-1399
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f02fca6d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f02fca6d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f02fca6d
Branch: refs/heads/ignite-971
Commit: f02fca6d79be298599630004566305b110362449
Parents: 18752a6
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 11 12:37:57 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 11 12:37:57 2015 +0300
----------------------------------------------------------------------
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f02fca6d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fc609a0..f70bf3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -302,7 +302,7 @@
<chmod dir="${basedir}/target/release-package" perm="755" includes="**/*.sh" />
<!-- hotfix according to https://issues.apache.org/jira/browse/IGNITE-1399. Remove at 1.5 -->
- <move todir="${basedir}/target/temp/release-package/libs/optional/ignite-platform">
+ <move todir="${basedir}/target/temp/release-package/libs/optional/ignite-platform" failonerror="false">
<fileset dir="${basedir}/target/release-package/libs/optional/ignite-platform"/>
</move>
@@ -324,7 +324,7 @@
</zip>
<!-- hotfix according to https://issues.apache.org/jira/browse/IGNITE-1399. Remove at 1.5 -->
- <move todir="${basedir}/target/release-package/libs/optional/ignite-platform">
+ <move todir="${basedir}/target/release-package/libs/optional/ignite-platform" failonerror="false">
<fileset dir="${basedir}/target/temp/release-package/libs/optional/ignite-platform"/>
</move>
</target>
[10/28] ignite git commit: ignite-613: test is reworked. However,
the replicated iterator is broken. This functionality must be fixed
before unmuting the test.
Posted by sb...@apache.org.
ignite-613: test is reworked. However, the replicated iterator is broken. This functionality must be fixed before unmuting the test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b8be85d5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b8be85d5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b8be85d5
Branch: refs/heads/ignite-971
Commit: b8be85d5dcacfef1e1f04d9f132f8012239825ce
Parents: b5d8545
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 11 10:39:38 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 11 10:39:38 2015 +0300
----------------------------------------------------------------------
.../IgniteCacheReplicatedQuerySelfTest.java | 49 +++++++-------------
1 file changed, 16 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b8be85d5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
index d0cce4a..9c52f92 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
@@ -46,6 +46,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
+import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.typedef.F;
@@ -355,52 +356,36 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
}
/**
- * TODO: IGNITE-613.
- *
* @throws Exception If failed.
*/
public void testNodeLeft() throws Exception {
- // Test works long and fails after. Should be enabled after fix.
fail("https://issues.apache.org/jira/browse/IGNITE-613");
-
+
+ Ignite g = startGrid("client");
+
try {
- Ignite g = startGrid();
+ assertTrue(g.configuration().isClientMode());
IgniteCache<Integer, Integer> cache = g.cache(null);
for (int i = 0; i < 1000; i++)
cache.put(i, i);
- QueryCursor<Cache.Entry<Integer, Integer>> q =
- cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0 order by _key"));
-
- assertEquals(0, (int) q.iterator().next().getKey());
-
- final ConcurrentMap<UUID, Map<Long, GridFutureAdapter<GridCloseableIterator<
- IgniteBiTuple<Integer, Integer>>>>> map =
- U.field(((IgniteKernal)grid(0)).internalCache().context().queries(), "qryIters");
-
- // fut.nextX() does not guarantee the request has completed on remote node
- // (we could receive page from local one), so we need to wait.
- assertTrue(GridTestUtils.waitForCondition(new PA() {
- @Override public boolean apply() {
- return map.size() == 1;
- }
- }, getTestTimeout()));
-
- Map<Long, GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<Integer, Integer>>>> futs =
- map.get(g.cluster().localNode().id());
+ // Client cache should be empty.
+ assertEquals(0, cache.localSize());
- assertEquals(1, futs.size());
+ QueryCursor<Cache.Entry<Integer, Integer>> q =
+ cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0 order by _key").setPageSize(10));
- GridCloseableIterator<IgniteBiTuple<Integer, Integer>> iter =
- (GridCloseableIterator<IgniteBiTuple<Integer, Integer>>)((IgniteInternalFuture)F.first(futs.values()).get()).get();
+ assertEquals(0, (int)q.iterator().next().getKey());
- ResultSet rs = U.field(iter, "data");
+ ConcurrentMap<UUID, ConcurrentMap<Long, ?>> map = U.field(((IgniteH2Indexing)U.field(U.field(
+ grid(0).context(), "qryProc"), "idx")).mapQueryExecutor(), "qryRess");
- assertFalse(rs.isClosed());
+ assertEquals(1, map.size());
final UUID nodeId = g.cluster().localNode().id();
+
final CountDownLatch latch = new CountDownLatch(1);
grid(0).events().localListen(new IgnitePredicate<Event>() {
@@ -412,16 +397,14 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
}
}, EVT_NODE_LEFT);
- stopGrid();
+ stopGrid("client");
latch.await();
assertEquals(0, map.size());
- assertTrue(rs.isClosed());
}
finally {
- // Ensure that additional node is stopped.
- stopGrid();
+ stopGrid("client");
}
}
[28/28] ignite git commit: ignite-971 Fix offheap to swap eviction.
Posted by sb...@apache.org.
ignite-971 Fix offheap to swap eviction.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fcfc3790
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fcfc3790
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fcfc3790
Branch: refs/heads/ignite-971
Commit: fcfc37908d0b0187e2d38981f25951a5ca5415fa
Parents: 25bea53
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 14 12:10:58 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 14 12:10:58 2015 +0300
----------------------------------------------------------------------
.../testsuites/IgniteCacheRestartTestSuite.java | 12 -----
.../IgniteCacheRestartTestSuite2.java | 47 ++++++++++++++++++++
2 files changed, 47 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fcfc3790/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
index 7966bc7..34ef79b 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
@@ -18,15 +18,10 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
-import org.apache.ignite.internal.processors.cache.GridCachePutAllFailoverSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPutAllFailoverSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCachePutAllRestartTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicNodeRestartTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledOptimisticTxNodeRestartTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNodeRestartTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOptimisticTxNodeRestartTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedNodeRestartSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheAtomicReplicatedNodeRestartSelfTest;
/**
* Cache stability test suite on changing topology.
@@ -44,13 +39,6 @@ public class IgniteCacheRestartTestSuite extends TestSuite {
suite.addTestSuite(GridCacheReplicatedNodeRestartSelfTest.class);
suite.addTestSuite(GridCachePartitionedNearDisabledOptimisticTxNodeRestartTest.class);
- suite.addTestSuite(IgniteCacheAtomicNodeRestartTest.class);
- suite.addTestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class);
-
- suite.addTestSuite(IgniteCacheAtomicPutAllFailoverSelfTest.class);
- suite.addTestSuite(IgniteCachePutAllRestartTest.class);
- suite.addTestSuite(GridCachePutAllFailoverSelfTest.class);
-
return suite;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/fcfc3790/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
new file mode 100644
index 0000000..c9e9467
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
@@ -0,0 +1,47 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.GridCachePutAllFailoverSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPutAllFailoverSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCachePutAllRestartTest;
+import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicNodeRestartTest;
+import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheAtomicReplicatedNodeRestartSelfTest;
+
+/**
+ * Cache stability test suite on changing topology.
+ */
+public class IgniteCacheRestartTestSuite2 extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Cache Restart Test Suite2");
+
+ suite.addTestSuite(IgniteCacheAtomicNodeRestartTest.class);
+ suite.addTestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class);
+
+ suite.addTestSuite(IgniteCacheAtomicPutAllFailoverSelfTest.class);
+ suite.addTestSuite(IgniteCachePutAllRestartTest.class);
+ suite.addTestSuite(GridCachePutAllFailoverSelfTest.class);
+
+ return suite;
+ }
+}
[08/28] ignite git commit: IGNITE-264 - Check backup node for
one-phase transaction when primary node crashes.
Posted by sb...@apache.org.
IGNITE-264 - Check backup node for one-phase transaction when primary node crashes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e1707b68
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e1707b68
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e1707b68
Branch: refs/heads/ignite-971
Commit: e1707b6852f9d7c3e4999ea1d3967db68e7d8634
Parents: 071586e
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Sep 10 23:29:33 2015 -0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Sep 10 23:29:33 2015 -0700
----------------------------------------------------------------------
.../internal/portable/PortableContext.java | 18 +-
.../processors/cache/GridCacheAdapter.java | 6 +
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheIoManager.java | 4 +-
.../processors/cache/GridCacheMvcc.java | 5 +-
.../distributed/GridCacheTxRecoveryFuture.java | 11 +-
.../distributed/GridDistributedCacheEntry.java | 6 +-
.../GridDistributedTxFinishRequest.java | 13 +-
.../GridDistributedTxRemoteAdapter.java | 10 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 514 +++++++++----------
.../distributed/dht/GridDhtTxFinishFuture.java | 15 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 84 ++-
.../dht/GridDhtTxFinishResponse.java | 89 +++-
.../cache/distributed/dht/GridDhtTxLocal.java | 4 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 67 ++-
.../distributed/dht/GridDhtTxPrepareFuture.java | 32 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 40 +-
.../dht/GridPartitionedGetFuture.java | 4 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 4 +-
.../colocated/GridDhtColocatedLockFuture.java | 11 +-
.../distributed/near/GridNearLockFuture.java | 11 +-
.../distributed/near/GridNearLockRequest.java | 18 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 52 +-
.../GridNearPessimisticTxPrepareFuture.java | 11 +-
.../near/GridNearTxFinishFuture.java | 319 ++++++++++--
.../near/GridNearTxFinishRequest.java | 20 +-
.../cache/distributed/near/GridNearTxLocal.java | 64 +--
.../distributed/near/GridNearTxRemote.java | 38 +-
.../cache/transactions/IgniteTxAdapter.java | 5 +-
.../cache/transactions/IgniteTxHandler.java | 281 +++++-----
.../transactions/IgniteTxLocalAdapter.java | 37 +-
.../cache/transactions/IgniteTxManager.java | 48 +-
.../datastructures/DataStructuresProcessor.java | 102 ++--
.../GridTransactionalCacheQueueImpl.java | 15 +-
.../processors/igfs/IgfsFileAffinityRange.java | 4 +-
.../portable/GridPortableMetaDataSelfTest.java | 2 +
.../CacheStoreUsageMultinodeAbstractTest.java | 16 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 50 +-
.../processors/cache/GridCacheMvccSelfTest.java | 4 +-
.../cache/GridCachePutAllFailoverSelfTest.java | 28 +-
.../cache/IgniteCachePutAllRestartTest.java | 2 +
.../cache/IgniteInternalCacheTypesTest.java | 4 +-
.../cache/IgniteOnePhaseCommitNearSelfTest.java | 243 +++++++++
...ridCachePartitionNotLoadedEventSelfTest.java | 27 +-
.../GridCacheTransformEventSelfTest.java | 5 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 400 +++++++++++++++
.../dht/GridNearCacheTxNodeFailureSelfTest.java | 31 ++
...gniteAtomicLongChangingTopologySelfTest.java | 283 ++++++++++
.../near/IgniteCacheNearOnlyTxTest.java | 14 +-
.../IgniteCacheFailoverTestSuite.java | 9 +-
50 files changed, 2350 insertions(+), 734 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index c64adc8..165ad9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -440,7 +440,7 @@ public class PortableContext implements Externalizable {
PortableClassDescriptor desc = descByCls.get(cls);
if (desc == null || !desc.registered())
- desc = registerClassDescriptor(cls);
+ desc = registerClassDescriptor(cls, true);
return desc;
}
@@ -485,7 +485,7 @@ public class PortableContext implements Externalizable {
}
if (desc == null) {
- desc = registerClassDescriptor(cls);
+ desc = registerClassDescriptor(cls, false);
assert desc.typeId() == typeId;
}
@@ -499,7 +499,7 @@ public class PortableContext implements Externalizable {
* @param cls Class.
* @return Class descriptor.
*/
- private PortableClassDescriptor registerClassDescriptor(Class<?> cls) {
+ private PortableClassDescriptor registerClassDescriptor(Class<?> cls, boolean registerMetadata) {
PortableClassDescriptor desc;
String clsName = cls.getName();
@@ -525,7 +525,7 @@ public class PortableContext implements Externalizable {
desc = old;
}
else
- desc = registerUserClassDescriptor(cls);
+ desc = registerUserClassDescriptor(cls, registerMetadata);
return desc;
}
@@ -536,9 +536,7 @@ public class PortableContext implements Externalizable {
* @param cls Class.
* @return Class descriptor.
*/
- private PortableClassDescriptor registerUserClassDescriptor(Class<?> cls) {
- PortableClassDescriptor desc;
-
+ private PortableClassDescriptor registerUserClassDescriptor(Class<?> cls, boolean registerMetadata) {
boolean registered;
String typeName = typeName(cls.getName());
@@ -555,7 +553,7 @@ public class PortableContext implements Externalizable {
throw new PortableException("Failed to register class.", e);
}
- desc = new PortableClassDescriptor(this,
+ PortableClassDescriptor desc = new PortableClassDescriptor(this,
cls,
true,
typeId,
@@ -573,6 +571,10 @@ public class PortableContext implements Externalizable {
userTypes.put(typeId, desc);
descByCls.put(cls, desc);
+ // TODO uncomment for https://issues.apache.org/jira/browse/IGNITE-1377
+// if (registerMetadata && isMetaDataEnabled(typeId))
+// metaHnd.addMeta(typeId, new PortableMetaDataImpl(typeName, desc.fieldsMeta(), null));
+
return desc;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 79c5e4b..4460a2a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -4230,6 +4230,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
return tFut.get();
}
+ catch (IgniteTxRollbackCheckedException e) {
+ throw e;
+ }
catch (IgniteCheckedException e1) {
tx0.rollbackAsync();
@@ -4253,6 +4256,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
return tFut.get();
}
+ catch (IgniteTxRollbackCheckedException e) {
+ throw e;
+ }
catch (IgniteCheckedException e1) {
tx0.rollbackAsync();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 3d0f1ae..86ba3e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -480,7 +480,7 @@ public class GridCacheContext<K, V> implements Externalizable {
* @return {@code True} if should use system transactions which are isolated from user transactions.
*/
public boolean systemTx() {
- return cacheType == CacheType.UTILITY;
+ return cacheType == CacheType.UTILITY || (cacheType == CacheType.INTERNAL && transactional());
}
/**
@@ -1977,4 +1977,4 @@ public class GridCacheContext<K, V> implements Externalizable {
@Override public String toString() {
return "GridCacheContext: " + name();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index a935b26..b55c84d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -643,7 +643,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
if (!cctx.discovery().alive(node.id()) || !cctx.discovery().pingNode(node.id()))
throw new ClusterTopologyCheckedException("Node left grid while sending message to: " + node.id(), e);
- if (cnt == retryCnt)
+ if (cnt == retryCnt || cctx.kernalContext().isStopping())
throw e;
else if (log.isDebugEnabled())
log.debug("Failed to send message to node (will retry): " + node.id());
@@ -1107,4 +1107,4 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
return res;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index d1393ce..c2102bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -527,7 +527,8 @@ public final class GridCacheMvcc {
/*reenter*/false,
tx,
implicitSingle,
- /*near-local*/false, dhtLoc
+ /*near-local*/false,
+ dhtLoc
);
cctx.mvcc().addLocal(cand);
@@ -1271,4 +1272,4 @@ public final class GridCacheMvcc {
@Override public String toString() { // Synchronize to ensure one-thread at a time.
return S.toString(GridCacheMvcc.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
index eaaff67..d6f6a18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
@@ -167,7 +167,7 @@ public class GridCacheTxRecoveryFuture extends GridCompoundIdentityFuture<Boolea
try {
cctx.io().send(nearNodeId, req, tx.ioPolicy());
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException ignore) {
fut.onNodeLeft();
}
catch (IgniteCheckedException e) {
@@ -374,14 +374,11 @@ public class GridCacheTxRecoveryFuture extends GridCompoundIdentityFuture<Boolea
if (isMini(fut)) {
MiniFuture f = (MiniFuture)fut;
- if (f.nodeId().equals(nodeId)) {
+ if (f.nodeId().equals(nodeId))
f.onNodeLeft();
-
- return true;
- }
}
- return false;
+ return true;
}
/** {@inheritDoc} */
@@ -509,4 +506,4 @@ public class GridCacheTxRecoveryFuture extends GridCompoundIdentityFuture<Boolea
return S.toString(MiniFuture.class, this, "done", isDone(), "err", error());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
index 3fada86..6904e56 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
@@ -186,8 +186,8 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
long timeout,
boolean tx,
boolean implicitSingle,
- @Nullable GridCacheVersion owned) throws GridDistributedLockCancelledException,
- GridCacheEntryRemovedException {
+ @Nullable GridCacheVersion owned
+ ) throws GridDistributedLockCancelledException, GridCacheEntryRemovedException {
GridCacheMvccCandidate prev;
GridCacheMvccCandidate owner;
@@ -872,4 +872,4 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
@Override public synchronized String toString() {
return S.toString(GridDistributedCacheEntry.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
index fdd59be..ddf6799 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
@@ -210,17 +210,6 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
return commit ? syncCommit : syncRollback;
}
- /** {@inheritDoc}
- * @param ctx*/
- @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
- super.prepareMarshal(ctx);
- }
-
- /** {@inheritDoc} */
- @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- super.finishUnmarshal(ctx, ldr);
- }
-
/** {@inheritDoc} */
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
writer.setBuffer(buf);
@@ -426,4 +415,4 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
return GridToStringBuilder.toString(GridDistributedTxFinishRequest.class, this,
"super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index 41f9872..c930d88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -458,17 +458,17 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
assert txEntry != null : "Missing transaction entry for tx: " + this;
while (true) {
- GridCacheEntryEx Entry = txEntry.cached();
+ GridCacheEntryEx entry = txEntry.cached();
- assert Entry != null : "Missing cached entry for transaction entry: " + txEntry;
+ assert entry != null : "Missing cached entry for transaction entry: " + txEntry;
try {
GridCacheVersion ver = txEntry.explicitVersion() != null ? txEntry.explicitVersion() : xidVer;
// If locks haven't been acquired yet, keep waiting.
- if (!Entry.lockedBy(ver)) {
+ if (!entry.lockedBy(ver)) {
if (log.isDebugEnabled())
- log.debug("Transaction does not own lock for entry (will wait) [entry=" + Entry +
+ log.debug("Transaction does not own lock for entry (will wait) [entry=" + entry +
", tx=" + this + ']');
return;
@@ -802,4 +802,4 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
@Override public String toString() {
return GridToStringBuilder.toString(GridDistributedTxRemoteAdapter.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index d81b72c..b9514a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -709,337 +709,311 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
@Nullable final CacheEntryPredicate[] filter0) {
final List<KeyCacheObject> keys = req.keys();
- IgniteInternalFuture<Object> keyFut = null;
+ CacheEntryPredicate[] filter = filter0;
- if (req.onePhaseCommit()) {
- boolean forceKeys = req.hasTransforms() || req.filter() != null;
+ // Set message into thread context.
+ GridDhtTxLocal tx = null;
- if (!forceKeys) {
- for (int i = 0; i < req.keysCount() && !forceKeys; i++)
- forceKeys |= req.returnValue(i);
- }
-
- if (forceKeys)
- keyFut = ctx.dht().dhtPreloader().request(keys, req.topologyVersion());
- }
+ try {
+ int cnt = keys.size();
- if (keyFut == null)
- keyFut = new GridFinishedFuture<>();
+ if (req.inTx()) {
+ GridCacheVersion dhtVer = ctx.tm().mappedVersion(req.version());
- return new GridEmbeddedFuture<>(keyFut,
- new C2<Object, Exception, IgniteInternalFuture<GridNearLockResponse>>() {
- @Override public IgniteInternalFuture<GridNearLockResponse> apply(Object o, Exception exx) {
- if (exx != null)
- return new GridDhtFinishedFuture<>(exx);
+ if (dhtVer != null)
+ tx = ctx.tm().tx(dhtVer);
+ }
- CacheEntryPredicate[] filter = filter0;
+ final List<GridCacheEntryEx> entries = new ArrayList<>(cnt);
- // Set message into thread context.
- GridDhtTxLocal tx = null;
+ // Unmarshal filter first.
+ if (filter == null)
+ filter = req.filter();
- try {
- int cnt = keys.size();
+ GridDhtLockFuture fut = null;
- if (req.inTx()) {
- GridCacheVersion dhtVer = ctx.tm().mappedVersion(req.version());
+ if (!req.inTx()) {
+ GridDhtPartitionTopology top = null;
- if (dhtVer != null)
- tx = ctx.tm().tx(dhtVer);
- }
+ if (req.firstClientRequest()) {
+ assert CU.clientNode(nearNode);
- final List<GridCacheEntryEx> entries = new ArrayList<>(cnt);
+ top = topology();
- // Unmarshal filter first.
- if (filter == null)
- filter = req.filter();
+ topology().readLock();
+ }
- GridDhtLockFuture fut = null;
+ try {
+ if (top != null && needRemap(req.topologyVersion(), top.topologyVersion())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Client topology version mismatch, need remap lock request [" +
+ "reqTopVer=" + req.topologyVersion() +
+ ", locTopVer=" + top.topologyVersion() +
+ ", req=" + req + ']');
+ }
- if (!req.inTx()) {
- GridDhtPartitionTopology top = null;
+ GridNearLockResponse res = sendClientLockRemapResponse(nearNode,
+ req,
+ top.topologyVersion());
- if (req.firstClientRequest()) {
- assert CU.clientNode(nearNode);
+ return new GridFinishedFuture<>(res);
+ }
- top = topology();
+ fut = new GridDhtLockFuture(ctx,
+ nearNode.id(),
+ req.version(),
+ req.topologyVersion(),
+ cnt,
+ req.txRead(),
+ req.needReturnValue(),
+ req.timeout(),
+ tx,
+ req.threadId(),
+ req.accessTtl(),
+ filter,
+ req.skipStore());
+
+ // Add before mapping.
+ if (!ctx.mvcc().addFuture(fut))
+ throw new IllegalStateException("Duplicate future ID: " + fut);
+ }
+ finally {
+ if (top != null)
+ top.readUnlock();
+ }
+ }
- topology().readLock();
- }
+ boolean timedout = false;
- try {
- if (top != null && needRemap(req.topologyVersion(), top.topologyVersion())) {
- if (log.isDebugEnabled()) {
- log.debug("Client topology version mismatch, need remap lock request [" +
- "reqTopVer=" + req.topologyVersion() +
- ", locTopVer=" + top.topologyVersion() +
- ", req=" + req + ']');
- }
+ for (KeyCacheObject key : keys) {
+ if (timedout)
+ break;
- GridNearLockResponse res = sendClientLockRemapResponse(nearNode,
- req,
- top.topologyVersion());
+ while (true) {
+ // Specify topology version to make sure containment is checked
+ // based on the requested version, not the latest.
+ GridDhtCacheEntry entry = entryExx(key, req.topologyVersion());
- return new GridFinishedFuture<>(res);
- }
+ try {
+ if (fut != null) {
+ // This method will add local candidate.
+ // Entry cannot become obsolete after this method succeeded.
+ fut.addEntry(key == null ? null : entry);
- fut = new GridDhtLockFuture(ctx,
- nearNode.id(),
- req.version(),
- req.topologyVersion(),
- cnt,
- req.txRead(),
- req.needReturnValue(),
- req.timeout(),
- tx,
- req.threadId(),
- req.accessTtl(),
- filter,
- req.skipStore());
+ if (fut.isDone()) {
+ timedout = true;
- // Add before mapping.
- if (!ctx.mvcc().addFuture(fut))
- throw new IllegalStateException("Duplicate future ID: " + fut);
- }
- finally {
- if (top != null)
- top.readUnlock();
+ break;
}
}
- boolean timedout = false;
-
- for (KeyCacheObject key : keys) {
- if (timedout)
- break;
+ entries.add(entry);
- while (true) {
- // Specify topology version to make sure containment is checked
- // based on the requested version, not the latest.
- GridDhtCacheEntry entry = entryExx(key, req.topologyVersion());
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed entry when adding lock (will retry): " + entry);
+ }
+ catch (GridDistributedLockCancelledException e) {
+ if (log.isDebugEnabled())
+ log.debug("Got lock request for cancelled lock (will ignore): " +
+ entry);
- try {
- if (fut != null) {
- // This method will add local candidate.
- // Entry cannot become obsolete after this method succeeded.
- fut.addEntry(key == null ? null : entry);
+ fut.onError(e);
- if (fut.isDone()) {
- timedout = true;
+ return new GridDhtFinishedFuture<>(e);
+ }
+ }
+ }
- break;
- }
- }
+ // Handle implicit locks for pessimistic transactions.
+ if (req.inTx()) {
+ if (tx == null) {
+ GridDhtPartitionTopology top = null;
- entries.add(entry);
+ if (req.firstClientRequest()) {
+ assert CU.clientNode(nearNode);
- break;
- }
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry when adding lock (will retry): " + entry);
- }
- catch (GridDistributedLockCancelledException e) {
- if (log.isDebugEnabled())
- log.debug("Got lock request for cancelled lock (will ignore): " +
- entry);
+ top = topology();
- fut.onError(e);
+ topology().readLock();
+ }
- return new GridDhtFinishedFuture<>(e);
- }
+ try {
+ if (top != null && needRemap(req.topologyVersion(), top.topologyVersion())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Client topology version mismatch, need remap lock request [" +
+ "reqTopVer=" + req.topologyVersion() +
+ ", locTopVer=" + top.topologyVersion() +
+ ", req=" + req + ']');
}
- }
- // Handle implicit locks for pessimistic transactions.
- if (req.inTx()) {
- if (tx == null) {
- GridDhtPartitionTopology top = null;
+ GridNearLockResponse res = sendClientLockRemapResponse(nearNode,
+ req,
+ top.topologyVersion());
- if (req.firstClientRequest()) {
- assert CU.clientNode(nearNode);
+ return new GridFinishedFuture<>(res);
+ }
- top = topology();
+ tx = new GridDhtTxLocal(
+ ctx.shared(),
+ nearNode.id(),
+ req.version(),
+ req.futureId(),
+ req.miniId(),
+ req.threadId(),
+ req.implicitTx(),
+ req.implicitSingleTx(),
+ ctx.systemTx(),
+ false,
+ ctx.ioPolicy(),
+ PESSIMISTIC,
+ req.isolation(),
+ req.timeout(),
+ req.isInvalidate(),
+ !req.skipStore(),
+ false,
+ req.txSize(),
+ null,
+ req.subjectId(),
+ req.taskNameHash());
- topology().readLock();
- }
+ tx.syncCommit(req.syncCommit());
- try {
- if (top != null && needRemap(req.topologyVersion(), top.topologyVersion())) {
- if (log.isDebugEnabled()) {
- log.debug("Client topology version mismatch, need remap lock request [" +
- "reqTopVer=" + req.topologyVersion() +
- ", locTopVer=" + top.topologyVersion() +
- ", req=" + req + ']');
- }
+ tx = ctx.tm().onCreated(null, tx);
- GridNearLockResponse res = sendClientLockRemapResponse(nearNode,
- req,
- top.topologyVersion());
+ if (tx == null || !tx.init()) {
+ String msg = "Failed to acquire lock (transaction has been completed): " +
+ req.version();
- return new GridFinishedFuture<>(res);
- }
+ U.warn(log, msg);
- tx = new GridDhtTxLocal(
- ctx.shared(),
- nearNode.id(),
- req.version(),
- req.futureId(),
- req.miniId(),
- req.threadId(),
- req.implicitTx(),
- req.implicitSingleTx(),
- ctx.systemTx(),
- false,
- ctx.ioPolicy(),
- PESSIMISTIC,
- req.isolation(),
- req.timeout(),
- req.isInvalidate(),
- true,
- req.txSize(),
- null,
- req.subjectId(),
- req.taskNameHash());
-
- tx.syncCommit(req.syncCommit());
-
- tx = ctx.tm().onCreated(null, tx);
-
- if (tx == null || !tx.init()) {
- String msg = "Failed to acquire lock (transaction has been completed): " +
- req.version();
-
- U.warn(log, msg);
-
- if (tx != null)
- tx.rollback();
-
- return new GridDhtFinishedFuture<>(new IgniteCheckedException(msg));
- }
+ if (tx != null)
+ tx.rollback();
- tx.topologyVersion(req.topologyVersion());
- }
- finally {
- if (top != null)
- top.readUnlock();
- }
- }
+ return new GridDhtFinishedFuture<>(new IgniteCheckedException(msg));
+ }
- ctx.tm().txContext(tx);
+ tx.topologyVersion(req.topologyVersion());
+ }
+ finally {
+ if (top != null)
+ top.readUnlock();
+ }
+ }
- if (log.isDebugEnabled())
- log.debug("Performing DHT lock [tx=" + tx + ", entries=" + entries + ']');
+ ctx.tm().txContext(tx);
- IgniteInternalFuture<GridCacheReturn> txFut = tx.lockAllAsync(
- cacheCtx,
+ if (log.isDebugEnabled())
+ log.debug("Performing DHT lock [tx=" + tx + ", entries=" + entries + ']');
+
+ IgniteInternalFuture<GridCacheReturn> txFut = tx.lockAllAsync(
+ cacheCtx,
+ entries,
+ req.messageId(),
+ req.txRead(),
+ req.needReturnValue(),
+ req.accessTtl(),
+ req.skipStore());
+
+ final GridDhtTxLocal t = tx;
+
+ return new GridDhtEmbeddedFuture(
+ txFut,
+ new C2<GridCacheReturn, Exception, IgniteInternalFuture<GridNearLockResponse>>() {
+ @Override public IgniteInternalFuture<GridNearLockResponse> apply(
+ GridCacheReturn o, Exception e) {
+ if (e != null)
+ e = U.unwrap(e);
+
+ assert !t.empty();
+
+ // Create response while holding locks.
+ final GridNearLockResponse resp = createLockReply(nearNode,
entries,
- req.onePhaseCommit(),
- req.messageId(),
- req.txRead(),
- req.needReturnValue(),
- req.accessTtl(),
- req.skipStore());
+ req,
+ t,
+ t.xidVersion(),
+ e);
+
+ if (resp.error() == null && t.onePhaseCommit()) {
+ assert t.implicit();
+
+ return t.commitAsync().chain(
+ new C1<IgniteInternalFuture<IgniteInternalTx>, GridNearLockResponse>() {
+ @Override public GridNearLockResponse apply(IgniteInternalFuture<IgniteInternalTx> f) {
+ try {
+ // Check for error.
+ f.get();
+ }
+ catch (IgniteCheckedException e1) {
+ resp.error(e1);
+ }
- final GridDhtTxLocal t = tx;
-
- return new GridDhtEmbeddedFuture(
- txFut,
- new C2<GridCacheReturn, Exception, IgniteInternalFuture<GridNearLockResponse>>() {
- @Override public IgniteInternalFuture<GridNearLockResponse> apply(
- GridCacheReturn o, Exception e) {
- if (e != null)
- e = U.unwrap(e);
-
- assert !t.empty();
-
- // Create response while holding locks.
- final GridNearLockResponse resp = createLockReply(nearNode,
- entries,
- req,
- t,
- t.xidVersion(),
- e);
-
- if (resp.error() == null && t.onePhaseCommit()) {
- assert t.implicit();
-
- return t.commitAsync().chain(
- new C1<IgniteInternalFuture<IgniteInternalTx>, GridNearLockResponse>() {
- @Override public GridNearLockResponse apply(IgniteInternalFuture<IgniteInternalTx> f) {
- try {
- // Check for error.
- f.get();
- }
- catch (IgniteCheckedException e1) {
- resp.error(e1);
- }
-
- sendLockReply(nearNode, t, req, resp);
-
- return resp;
- }
- });
- }
- else {
sendLockReply(nearNode, t, req, resp);
- return new GridFinishedFuture<>(resp);
+ return resp;
}
- }
- }
- );
+ });
+ }
+ else {
+ sendLockReply(nearNode, t, req, resp);
+
+ return new GridFinishedFuture<>(resp);
+ }
}
- else {
- assert fut != null;
+ }
+ );
+ }
+ else {
+ assert fut != null;
- // This will send remote messages.
- fut.map();
+ // This will send remote messages.
+ fut.map();
- final GridCacheVersion mappedVer = fut.version();
+ final GridCacheVersion mappedVer = fut.version();
- return new GridDhtEmbeddedFuture<>(
- new C2<Boolean, Exception, GridNearLockResponse>() {
- @Override public GridNearLockResponse apply(Boolean b, Exception e) {
- if (e != null)
- e = U.unwrap(e);
- else if (!b)
- e = new GridCacheLockTimeoutException(req.version());
+ return new GridDhtEmbeddedFuture<>(
+ new C2<Boolean, Exception, GridNearLockResponse>() {
+ @Override public GridNearLockResponse apply(Boolean b, Exception e) {
+ if (e != null)
+ e = U.unwrap(e);
+ else if (!b)
+ e = new GridCacheLockTimeoutException(req.version());
- GridNearLockResponse res = createLockReply(nearNode,
- entries,
- req,
- null,
- mappedVer,
- e);
+ GridNearLockResponse res = createLockReply(nearNode,
+ entries,
+ req,
+ null,
+ mappedVer,
+ e);
- sendLockReply(nearNode, null, req, res);
+ sendLockReply(nearNode, null, req, res);
- return res;
- }
- },
- fut);
+ return res;
}
- }
- catch (IgniteCheckedException e) {
- String err = "Failed to unmarshal at least one of the keys for lock request message: " + req;
-
- U.error(log, err, e);
+ },
+ fut);
+ }
+ }
+ catch (IgniteCheckedException | RuntimeException e) {
+ String err = "Failed to unmarshal at least one of the keys for lock request message: " + req;
- if (tx != null) {
- try {
- tx.rollback();
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Failed to rollback the transaction: " + tx, ex);
- }
- }
+ U.error(log, err, e);
- return new GridDhtFinishedFuture<>(
- new IgniteCheckedException(err, e));
- }
+ if (tx != null) {
+ try {
+ tx.rollback();
+ }
+ catch (IgniteCheckedException ex) {
+ U.error(log, "Failed to rollback the transaction: " + tx, ex);
}
}
- );
+
+ return new GridDhtFinishedFuture<>(
+ new IgniteCheckedException(err, e));
+ }
}
/**
@@ -1626,4 +1600,4 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (nearEntry != null)
nearEntry.markObsolete(ctx.versions().next());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
index a7ec20f..79bccc2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
@@ -219,7 +219,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
@Override public boolean onDone(IgniteInternalTx tx, Throwable err) {
if (initialized() || err != null) {
if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING))
- this.tx.tmCommit();
+ this.tx.tmFinish(err == null);
Throwable e = this.err.get();
@@ -255,7 +255,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
/**
* Initializes future.
*/
- @SuppressWarnings("SimplifiableIfStatement")
+ @SuppressWarnings({"SimplifiableIfStatement", "IfMayBeConditional"})
public void finish() {
boolean sync;
@@ -277,7 +277,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
* @param nodes Nodes.
* @return {@code True} in case there is at least one synchronous {@code MiniFuture} to wait for.
*/
- private boolean rollbackLockTransactions(Set<ClusterNode> nodes) {
+ private boolean rollbackLockTransactions(Collection<ClusterNode> nodes) {
assert !commit;
assert !F.isEmpty(nodes);
@@ -399,6 +399,8 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
tx.subjectId(),
tx.taskNameHash());
+ req.writeVersion(tx.writeVersion() != null ? tx.writeVersion() : tx.xidVersion());
+
try {
cctx.io().send(n, req, tx.ioPolicy());
@@ -450,8 +452,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
tx.subjectId(),
tx.taskNameHash());
- if (tx.onePhaseCommit())
- req.writeVersion(tx.writeVersion());
+ req.writeVersion(tx.writeVersion());
try {
cctx.io().send(nearMapping.node(), req, tx.ioPolicy());
@@ -516,7 +517,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
/**
* @param node Node.
*/
- public MiniFuture(ClusterNode node) {
+ private MiniFuture(ClusterNode node) {
this.node = node;
}
@@ -582,4 +583,4 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index a9cb299..f859314 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@ -63,6 +63,9 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
@GridDirectCollection(GridCacheVersion.class)
private Collection<GridCacheVersion> pendingVers;
+ /** Check comitted flag. */
+ private boolean checkCommitted;
+
/** One phase commit write version. */
private GridCacheVersion writeVer;
@@ -126,8 +129,21 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
@Nullable UUID subjId,
int taskNameHash
) {
- super(xidVer, futId, commitVer, threadId, commit, invalidate, sys, plc, syncCommit, syncRollback, baseVer,
- committedVers, rolledbackVers, txSize);
+ super(
+ xidVer,
+ futId,
+ commitVer,
+ threadId,
+ commit,
+ invalidate,
+ sys,
+ plc,
+ syncCommit,
+ syncRollback,
+ baseVer,
+ committedVers,
+ rolledbackVers,
+ txSize);
assert miniId != null;
assert nearNodeId != null;
@@ -221,6 +237,20 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
return pendingVers == null ? Collections.<GridCacheVersion>emptyList() : pendingVers;
}
+ /**
+ * @return Check committed flag.
+ */
+ public boolean checkCommitted() {
+ return checkCommitted;
+ }
+
+ /**
+ * @param checkCommitted Check committed flag.
+ */
+ public void checkCommitted(boolean checkCommitted) {
+ this.checkCommitted = checkCommitted;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridDhtTxFinishRequest.class, this, super.toString());
@@ -242,54 +272,60 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
switch (writer.state()) {
case 18:
- if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
+ if (!writer.writeBoolean("checkCommitted", checkCommitted))
return false;
writer.incrementState();
case 19:
- if (!writer.writeIgniteUuid("miniId", miniId))
+ if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
return false;
writer.incrementState();
case 20:
- if (!writer.writeUuid("nearNodeId", nearNodeId))
+ if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
case 21:
- if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG))
+ if (!writer.writeUuid("nearNodeId", nearNodeId))
return false;
writer.incrementState();
case 22:
- if (!writer.writeUuid("subjId", subjId))
+ if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 23:
- if (!writer.writeBoolean("sysInvalidate", sysInvalidate))
+ if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
case 24:
- if (!writer.writeInt("taskNameHash", taskNameHash))
+ if (!writer.writeBoolean("sysInvalidate", sysInvalidate))
return false;
writer.incrementState();
case 25:
- if (!writer.writeMessage("topVer", topVer))
+ if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
case 26:
+ if (!writer.writeMessage("topVer", topVer))
+ return false;
+
+ writer.incrementState();
+
+ case 27:
if (!writer.writeMessage("writeVer", writeVer))
return false;
@@ -312,6 +348,14 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
switch (reader.state()) {
case 18:
+ checkCommitted = reader.readBoolean("checkCommitted");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 19:
byte isolationOrd;
isolationOrd = reader.readByte("isolation");
@@ -323,7 +367,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 19:
+ case 20:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -331,7 +375,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 20:
+ case 21:
nearNodeId = reader.readUuid("nearNodeId");
if (!reader.isLastRead())
@@ -339,7 +383,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 21:
+ case 22:
pendingVers = reader.readCollection("pendingVers", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -347,7 +391,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 22:
+ case 23:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -355,7 +399,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 23:
+ case 24:
sysInvalidate = reader.readBoolean("sysInvalidate");
if (!reader.isLastRead())
@@ -363,7 +407,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 24:
+ case 25:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -371,7 +415,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 25:
+ case 26:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -379,7 +423,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 26:
+ case 27:
writeVer = reader.readMessage("writeVer");
if (!reader.isLastRead())
@@ -399,6 +443,6 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 27;
+ return 28;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index d696c05..ec0f234 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -19,6 +19,10 @@ package org.apache.ignite.internal.processors.cache.distributed.dht;
import java.io.Externalizable;
import java.nio.ByteBuffer;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -36,6 +40,16 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
/** Mini future ID. */
private IgniteUuid miniId;
+ /** Error. */
+ @GridDirectTransient
+ private Throwable checkCommittedErr;
+
+ /** Serialized error. */
+ private byte[] checkCommittedErrBytes;
+
+ /** Flag indicating if this is a check-committed response. */
+ private boolean checkCommitted;
+
/**
* Empty constructor required by {@link Externalizable}.
*/
@@ -63,6 +77,51 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
return miniId;
}
+ /**
+ * @return Error for check committed backup requests.
+ */
+ public Throwable checkCommittedError() {
+ return checkCommittedErr;
+ }
+
+ /**
+ * @param checkCommittedErr Error for check committed backup requests.
+ */
+ public void checkCommittedError(Throwable checkCommittedErr) {
+ this.checkCommittedErr = checkCommittedErr;
+ }
+
+ /**
+ * @return Check committed flag.
+ */
+ public boolean checkCommitted() {
+ return checkCommitted;
+ }
+
+ /**
+ * @param checkCommitted Check committed flag.
+ */
+ public void checkCommitted(boolean checkCommitted) {
+ this.checkCommitted = checkCommitted;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
+ super.prepareMarshal(ctx);
+
+ if (checkCommittedErr != null)
+ checkCommittedErrBytes = ctx.marshaller().marshal(checkCommittedErr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr)
+ throws IgniteCheckedException {
+ super.finishUnmarshal(ctx, ldr);
+
+ if (checkCommittedErrBytes != null)
+ checkCommittedErr = ctx.marshaller().unmarshal(checkCommittedErrBytes, ldr);
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridDhtTxFinishResponse.class, this, super.toString());
@@ -84,6 +143,18 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
switch (writer.state()) {
case 5:
+ if (!writer.writeBoolean("checkCommitted", checkCommitted))
+ return false;
+
+ writer.incrementState();
+
+ case 6:
+ if (!writer.writeByteArray("checkCommittedErrBytes", checkCommittedErrBytes))
+ return false;
+
+ writer.incrementState();
+
+ case 7:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
@@ -106,6 +177,22 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
switch (reader.state()) {
case 5:
+ checkCommitted = reader.readBoolean("checkCommitted");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 6:
+ checkCommittedErrBytes = reader.readByteArray("checkCommittedErrBytes");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 7:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -125,6 +212,6 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 6;
+ return 8;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
index b23b3e1..4f8469f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
@@ -128,6 +128,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
long timeout,
boolean invalidate,
boolean storeEnabled,
+ boolean onePhaseCommit,
int txSize,
Map<UUID, Collection<UUID>> txNodes,
UUID subjId,
@@ -146,6 +147,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
timeout,
invalidate,
storeEnabled,
+ onePhaseCommit,
txSize,
subjId,
taskNameHash);
@@ -700,4 +702,4 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
@Override public String toString() {
return GridToStringBuilder.toString(GridDhtTxLocal.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 762d26f..8c7d985 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -98,6 +98,9 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/** Versions of pending locks for entries of this tx. */
private Collection<GridCacheVersion> pendingVers;
+ /** Flag indicating that originating node has near cache. */
+ private boolean nearOnOriginatingNode;
+
/** Nodes where transactions were started on lock step. */
private Set<ClusterNode> lockTxNodes;
@@ -132,12 +135,28 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
long timeout,
boolean invalidate,
boolean storeEnabled,
+ boolean onePhaseCommit,
int txSize,
@Nullable UUID subjId,
int taskNameHash
) {
- super(cctx, xidVer, implicit, implicitSingle, sys, plc, concurrency, isolation, timeout, invalidate,
- storeEnabled, txSize, subjId, taskNameHash);
+ super(
+ cctx,
+ xidVer,
+ implicit,
+ implicitSingle,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ timeout,
+ invalidate,
+ storeEnabled,
+ onePhaseCommit,
+ txSize,
+ subjId,
+ taskNameHash
+ );
assert cctx != null;
@@ -161,6 +180,29 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
}
/**
+ * Sets flag that indicates that originating node has a near cache that participates in this transaction.
+ *
+ * @param hasNear Has near cache flag.
+ */
+ public void nearOnOriginatingNode(boolean hasNear) {
+ nearOnOriginatingNode = hasNear;
+ }
+
+ /**
+ * @return {@code True} if explicit lock transaction.
+ */
+ public boolean explicitLock() {
+ return explicitLock;
+ }
+
+ /**
+ * @param explicitLock Explicit lock flag.
+ */
+ public void explicitLock(boolean explicitLock) {
+ this.explicitLock = explicitLock;
+ }
+
+ /**
* @return Nodes where transactions were started on lock step.
*/
@Nullable public Set<ClusterNode> lockTransactionNodes() {
@@ -229,20 +271,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
}
/**
- * @return Explicit lock flag.
- */
- public boolean explicitLock() {
- return explicitLock;
- }
-
- /**
- * @param explicitLock Explicit lock flag.
- */
- public void explicitLock(boolean explicitLock) {
- this.explicitLock = explicitLock;
- }
-
- /**
* @return DHT thread ID.
*/
long dhtThreadId() {
@@ -570,7 +598,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/**
* @param cacheCtx Cache context.
* @param entries Entries to lock.
- * @param onePhaseCommit One phase commit flag.
* @param msgId Message ID.
* @param read Read flag.
* @param accessTtl TTL for read operation.
@@ -582,7 +609,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
IgniteInternalFuture<GridCacheReturn> lockAllAsync(
GridCacheContext cacheCtx,
List<GridCacheEntryEx> entries,
- boolean onePhaseCommit,
long msgId,
final boolean read,
final boolean needRetVal,
@@ -864,13 +890,14 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
* @return {@code True} if transaction is finished on prepare step.
*/
protected final boolean commitOnPrepare() {
- return onePhaseCommit() && !near();
+ return onePhaseCommit() && !near() && !nearOnOriginatingNode;
}
/**
* @param prepFut Prepare future.
* @return If transaction if finished on prepare step returns future which is completed after transaction finish.
*/
+ @SuppressWarnings("TypeMayBeWeakened")
protected final IgniteInternalFuture<GridNearTxPrepareResponse> chainOnePhasePrepare(
final GridDhtTxPrepareFuture prepFut) {
if (commitOnPrepare()) {
@@ -901,4 +928,4 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
return GridToStringBuilder.toString(GridDhtTxLocalAdapter.class, this, "nearNodes", nearMap.keySet(),
"dhtNodes", dhtMap.keySet(), "explicitLock", explicitLock, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/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 6e8460f..89fc0ae 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
@@ -73,6 +73,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFutureCancelledException;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -338,15 +339,13 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
boolean hasFilters = !F.isEmptyOrNulls(txEntry.filters()) && !F.isAlwaysTrue(txEntry.filters());
if (hasFilters || retVal || txEntry.op() == DELETE || txEntry.op() == TRANSFORM) {
- CacheObject val;
-
cached.unswap(retVal);
boolean readThrough = (retVal || hasFilters) &&
cacheCtx.config().isLoadPreviousValue() &&
!txEntry.skipStore();
- val = cached.innerGet(
+ CacheObject val = cached.innerGet(
tx,
/*swap*/true,
readThrough,
@@ -561,7 +560,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (tx.optimistic())
tx.clearPrepareFuture(this);
- if (tx.onePhaseCommit()) {
+ // Do not commit one-phase commit transaction if originating node has near cache enabled.
+ if (tx.onePhaseCommit() && tx.commitOnPrepare()) {
assert last;
// Must create prepare response before transaction is committed to grab correct return value.
@@ -639,8 +639,14 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
* @throws IgniteCheckedException If failed to send response.
*/
private void sendPrepareResponse(GridNearTxPrepareResponse res) throws IgniteCheckedException {
- if (!tx.nearNodeId().equals(cctx.localNodeId()))
+ if (!tx.nearNodeId().equals(cctx.localNodeId())) {
+ Throwable err = this.err.get();
+
+ if (err != null && err instanceof IgniteFutureCancelledException)
+ return;
+
cctx.io().send(tx.nearNodeId(), res, tx.ioPolicy());
+ }
}
/**
@@ -902,6 +908,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
// We are holding transaction-level locks for entries here, so we can get next write version.
onEntriesLocked();
+ // We are holding transaction-level locks for entries here, so we can get next write version.
tx.writeVersion(cctx.versions().next(tx.topologyVersion()));
{
@@ -978,9 +985,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (entry.explicitVersion() == null) {
GridCacheMvccCandidate added = cached.candidate(version());
- assert added == null || added.dhtLocal() :
- "Got non-dht-local candidate for prepare future " +
- "[added=" + added + ", entry=" + entry + ']';
+ assert added != null : "Null candidate for non-group-lock entry " +
+ "[added=" + added + ", entry=" + entry + ']';
+ assert added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
+ "[added=" + added + ", entry=" + entry + ']';
if (added != null && added.ownerVersion() != null)
req.owned(entry.txKey(), added.ownerVersion());
@@ -1070,8 +1078,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (entry.explicitVersion() == null) {
GridCacheMvccCandidate added = entry.cached().candidate(version());
- assert added == null || added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
- "[added=" + added + ", entry=" + entry + ']';
+ assert added != null : "Null candidate for non-group-lock entry " +
+ "[added=" + added + ", entry=" + entry + ']';
+ assert added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
+ "[added=" + added + ", entry=" + entry + ']';
if (added != null && added.ownerVersion() != null)
req.owned(entry.txKey(), added.ownerVersion());
@@ -1473,4 +1483,4 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
index 2ff34a9..f8be2a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
@@ -111,8 +111,22 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
@Nullable UUID subjId,
int taskNameHash
) {
- super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ super(
+ ctx,
+ nodeId,
+ rmtThreadId,
+ xidVer,
+ commitVer,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ invalidate,
+ timeout,
+ txSize,
+ subjId,
+ taskNameHash
+ );
assert nearNodeId != null;
assert rmtFutId != null;
@@ -168,8 +182,22 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
@Nullable UUID subjId,
int taskNameHash
) {
- super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ super(
+ ctx,
+ nodeId,
+ rmtThreadId,
+ xidVer,
+ commitVer,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ invalidate,
+ timeout,
+ txSize,
+ subjId,
+ taskNameHash
+ );
assert nearNodeId != null;
assert rmtFutId != null;
@@ -224,7 +252,7 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
/**
* @return Near node ID.
*/
- UUID nearNodeId() {
+ public UUID nearNodeId() {
return nearNodeId;
}
@@ -334,4 +362,4 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
@Override public String toString() {
return GridToStringBuilder.toString(GridDhtTxRemote.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 3ddf6d3..0202c53 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -306,7 +306,7 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
) {
if (CU.affinityNodes(cctx, topVer).isEmpty()) {
onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
- "(all partition nodes left the grid)."));
+ "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + cctx.name() + ']'));
return;
}
@@ -816,4 +816,4 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
return S.toString(MiniFuture.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 65b1d38..d93f68f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -279,7 +279,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
public void map() {
AffinityTopologyVersion topVer = null;
- IgniteInternalTx tx = cctx.tm().anyActiveThreadTx();
+ IgniteInternalTx tx = cctx.tm().anyActiveThreadTx(null);
if (tx != null && tx.topologyVersionSnapshot() != null)
topVer = tx.topologyVersionSnapshot();
@@ -1188,4 +1188,4 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
public String toString() {
return S.toString(GridNearAtomicUpdateFuture.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index f7093b8..596ec77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLock
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+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.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -547,6 +548,14 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
// Obtain the topology version to use.
AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(threadId);
+ // If there is another system transaction in progress, use it's topology version to prevent deadlock.
+ if (topVer == null && tx != null && tx.system()) {
+ IgniteInternalTx tx0 = cctx.tm().anyActiveThreadTx(tx);
+
+ if (tx0 != null)
+ topVer = tx0.topologyVersionSnapshot();
+ }
+
if (topVer != null && tx != null)
tx.topologyVersion(topVer);
@@ -1425,4 +1434,4 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
return S.toString(MiniFuture.class, this, "node", node.id(), "super", super.toString());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 26276f0..f3e5ca3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.distributed.GridDistributedCa
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter;
+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.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -685,6 +686,14 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
// Obtain the topology version to use.
AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(Thread.currentThread().getId());
+ // If there is another system transaction in progress, use it's topology version to prevent deadlock.
+ if (topVer == null && tx != null && tx.system()) {
+ IgniteInternalTx tx0 = cctx.tm().anyActiveThreadTx(tx);
+
+ if (tx0 != null)
+ topVer = tx0.topologyVersionSnapshot();
+ }
+
if (topVer != null && tx != null)
tx.topologyVersion(topVer);
@@ -1566,4 +1575,4 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
return S.toString(MiniFuture.class, this, "node", node.id(), "super", super.toString());
}
}
-}
\ No newline at end of file
+}
[11/28] ignite git commit: IGNITE-1408: Fixed POJO code generation:
duplicate asc/desc fields. Fixed SQLXML JDBC type mapping to correct java
type: String.
Posted by sb...@apache.org.
IGNITE-1408: Fixed POJO code generation: duplicate asc/desc fields. Fixed SQLXML JDBC type mapping to correct java type: String.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d26f7466
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d26f7466
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d26f7466
Branch: refs/heads/ignite-971
Commit: d26f74662486516d72cfa704e70abc37e11c0123
Parents: b8be85d
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Sep 11 15:44:11 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Sep 11 15:44:11 2015 +0700
----------------------------------------------------------------------
.../org/apache/ignite/schema/generator/CodeGenerator.java | 4 ++--
.../java/org/apache/ignite/schema/model/PojoDescriptor.java | 6 ++++--
.../ignite/schema/parser/dialect/OracleMetadataDialect.java | 7 +++++--
3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d26f7466/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
index a278a56..f1119cf 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
@@ -571,7 +571,7 @@ public class CodeGenerator {
private static boolean addQueryFields(Collection<String> src, Collection<PojoField> fields, String varName,
String mtdName, String comment, boolean first) {
if (fields.isEmpty())
- return true;
+ return first;
add2(src, comment);
add2(src, (first ? "Map<String, Class<?>> " : "") + varName + " = new LinkedHashMap<>();");
@@ -739,4 +739,4 @@ public class CodeGenerator {
write(src, cacheCfg);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d26f7466/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
index c092c50..d84643b 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
@@ -56,6 +56,7 @@ import static java.sql.Types.NUMERIC;
import static java.sql.Types.NVARCHAR;
import static java.sql.Types.REAL;
import static java.sql.Types.SMALLINT;
+import static java.sql.Types.SQLXML;
import static java.sql.Types.TIME;
import static java.sql.Types.TIMESTAMP;
import static java.sql.Types.TINYINT;
@@ -529,6 +530,7 @@ public class PojoDescriptor {
case LONGNVARCHAR:
case CLOB:
case NCLOB:
+ case SQLXML:
return String.class;
case DATE:
@@ -541,9 +543,9 @@ public class PojoDescriptor {
return java.sql.Timestamp.class;
// BINARY, VARBINARY, LONGVARBINARY, ARRAY, BLOB, NULL, DATALINK
- // OTHER, JAVA_OBJECT, DISTINCT, STRUCT, REF, ROWID, SQLXML
+ // OTHER, JAVA_OBJECT, DISTINCT, STRUCT, REF, ROWID
default:
return Object.class;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d26f7466/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
index 2d4cf24..cf7e979 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
@@ -48,6 +48,7 @@ import static java.sql.Types.LONGVARCHAR;
import static java.sql.Types.NUMERIC;
import static java.sql.Types.OTHER;
import static java.sql.Types.SMALLINT;
+import static java.sql.Types.SQLXML;
import static java.sql.Types.TIMESTAMP;
import static java.sql.Types.TINYINT;
import static java.sql.Types.VARCHAR;
@@ -212,8 +213,10 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
case "CLOB":
case "NCLOB":
- case "XMLTYPE":
return CLOB;
+
+ case "XMLTYPE":
+ return SQLXML;
}
}
@@ -352,4 +355,4 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
return tbls;
}
-}
\ No newline at end of file
+}
[25/28] ignite git commit: Fixed test.
Posted by sb...@apache.org.
Fixed test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d0766224
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d0766224
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d0766224
Branch: refs/heads/ignite-971
Commit: d07662248ddc02c39f42a026323b7e77e66bc1f0
Parents: de632ac
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 14 09:43:40 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 14 09:43:40 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheVariableTopologySelfTest.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0766224/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
index 82e3f98..7078843 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
@@ -36,6 +36,7 @@ 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.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -142,8 +143,8 @@ public class GridCacheVariableTopologySelfTest extends GridCommonAbstractTest {
tx.commit();
}
- catch (ClusterTopologyException e) {
- info("Caught topology exception: " + e);
+ catch (TransactionRollbackException | ClusterTopologyException e) {
+ info("Caught exception: " + e);
}
catch (IgniteException e) {
if (X.hasCause(e, ClusterTopologyCheckedException.class))
[06/28] ignite git commit: IGNITE-264 - Check backup node for
one-phase transaction when primary node crashes.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
index 80fdbbe..ea7b124 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
@@ -131,7 +131,7 @@ public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest {
checkCache(ignite, CU.MARSH_CACHE_NAME, MARSH_CACHE_POOL, false, false);
- checkCache(ignite, CU.ATOMICS_CACHE_NAME, SYSTEM_POOL, false, false);
+ checkCache(ignite, CU.ATOMICS_CACHE_NAME, SYSTEM_POOL, false, true);
for (String cache : userCaches)
checkCache(ignite, cache, SYSTEM_POOL, true, false);
@@ -157,4 +157,4 @@ public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest {
assertEquals("Unexpected property for cache: " + cache.name(), user, cache.context().userCache());
assertEquals("Unexpected property for cache: " + cache.name(), sysTx, cache.context().systemTx());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
new file mode 100644
index 0000000..87c160f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.managers.communication.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.processors.cache.distributed.near.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.plugin.extensions.communication.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.spi.communication.tcp.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+import org.apache.ignite.transactions.*;
+
+import javax.cache.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.*;
+import static org.apache.ignite.transactions.TransactionIsolation.*;
+
+/**
+ * Checks one-phase commit scenarios.
+ */
+public class IgniteOnePhaseCommitNearSelfTest extends GridCommonAbstractTest {
+ /** Grid count. */
+ private static final int GRID_CNT = 4;
+
+ /** */
+ private int backups = 1;
+
+ /** */
+ private static Map<Class<?>, AtomicInteger> msgCntMap = new ConcurrentHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName));
+
+ cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
+
+ cfg.setCommunicationSpi(new MessageCountingCommunicationSpi());
+
+ return cfg;
+ }
+
+ /**
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ protected CacheConfiguration cacheConfiguration(String gridName) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setBackups(backups);
+ ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+ ccfg.setNearConfiguration(new NearCacheConfiguration());
+
+ return ccfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOnePhaseCommitFromNearNode() throws Exception {
+ backups = 1;
+
+ startGrids(GRID_CNT);
+
+ try {
+ awaitPartitionMapExchange();
+
+ int key = generateNearKey();
+
+ IgniteCache<Object, Object> cache = ignite(0).cache(null);
+
+ checkKey(ignite(0).transactions(), cache, key);
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * @param transactions Transactions instance.
+ * @param cache Cache instance.
+ * @param key Key.
+ */
+ private void checkKey(IgniteTransactions transactions, Cache<Object, Object> cache, int key) throws Exception {
+ cache.put(key, key);
+
+ finalCheck(key, true);
+
+ TransactionIsolation[] isolations = {READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE};
+ TransactionConcurrency[] concurrencies = {OPTIMISTIC, PESSIMISTIC};
+
+ for (TransactionIsolation isolation : isolations) {
+ for (TransactionConcurrency concurrency : concurrencies) {
+ info("Checking transaction [isolation=" + isolation + ", concurrency=" + concurrency + ']');
+
+ try (Transaction tx = transactions.txStart(concurrency, isolation)) {
+ cache.put(key, isolation + "-" + concurrency);
+
+ tx.commit();
+ }
+
+ finalCheck(key, true);
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void finalCheck(final int key, boolean onePhase) throws Exception {
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ try {
+ for (int i = 0; i < GRID_CNT; i++) {
+ GridCacheAdapter<Object, Object> cache = ((IgniteKernal)ignite(i)).internalCache();
+
+ GridCacheEntryEx entry = cache.peekEx(key);
+
+ if (entry != null) {
+ if (entry.lockedByAny()) {
+ info("Near entry is still locked [i=" + i + ", entry=" + entry + ']');
+
+ return false;
+ }
+ }
+
+ entry = cache.context().near().dht().peekEx(key);
+
+ if (entry != null) {
+ if (entry.lockedByAny()) {
+ info("DHT entry is still locked [i=" + i + ", entry=" + entry + ']');
+
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ info("Entry was removed, will retry");
+
+ return false;
+ }
+ }
+ }, 10_000);
+
+ if (onePhase) {
+ assertMessageCount(GridNearTxPrepareRequest.class, 1);
+ assertMessageCount(GridDhtTxPrepareRequest.class, 1);
+ assertMessageCount(GridNearTxFinishRequest.class, 1);
+ assertMessageCount(GridDhtTxFinishRequest.class, 0);
+
+ msgCntMap.clear();
+ }
+ }
+
+ /**
+ * @param cls Class to check.
+ * @param cnt Expected count.
+ */
+ private void assertMessageCount(Class<?> cls, int cnt) {
+ AtomicInteger val = msgCntMap.get(cls);
+
+ int iVal = val == null ? 0 : val.get();
+
+ assertEquals("Invalid message count for class: " + cls.getSimpleName(), cnt, iVal);
+ }
+
+ /**
+ * @return Key.
+ */
+ protected int generateNearKey() {
+ Affinity<Object> aff = ignite(0).affinity(null);
+
+ int key = 0;
+
+ while (true) {
+ boolean primary = aff.isPrimary(ignite(1).cluster().localNode(), key);
+ boolean primaryOrBackup = aff.isPrimaryOrBackup(ignite(0).cluster().localNode(), key);
+
+ if (primary && !primaryOrBackup)
+ return key;
+
+ key++;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MessageCountingCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ throws IgniteSpiException {
+ if (msg instanceof GridIoMessage) {
+ GridIoMessage ioMsg = (GridIoMessage)msg;
+
+ Class<?> cls = ioMsg.message().getClass();
+
+ AtomicInteger cntr = msgCntMap.get(cls);
+
+ if (cntr == null)
+ cntr = F.addIfAbsent(msgCntMap, cls, new AtomicInteger());
+
+ cntr.incrementAndGet();
+ }
+
+ super.sendMessage(node, msg, ackClosure);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java
index e712cc9..5bc779c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -98,7 +99,7 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
startGrid(1);
startGrid(2);
- PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
+ final PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
ignite(2).events().localListen(lsnr, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
@@ -127,7 +128,11 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
assert !cache.containsKey(key);
- assert !lsnr.lostParts.isEmpty();
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return !lsnr.lostParts.isEmpty();
+ }
+ }, getTestTimeout());
}
/**
@@ -139,7 +144,7 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
awaitPartitionMapExchange();
- PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
+ final PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
ignite(1).events().localListen(lsnr, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
@@ -157,7 +162,11 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
assert !jcache(1).containsKey(key);
- assert !lsnr.lostParts.isEmpty();
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return !lsnr.lostParts.isEmpty();
+ }
+ }, getTestTimeout());
}
/**
@@ -172,7 +181,7 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
startGrid(0);
- PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
+ final PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
grid(1).events().localListen(lsnr, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
@@ -206,7 +215,7 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
startGrid(1);
- PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
+ final PartitionNotFullyLoadedListener lsnr = new PartitionNotFullyLoadedListener();
grid(1).events().localListen(lsnr, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
@@ -235,7 +244,11 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract
awaitPartitionMapExchange();
- assert !lsnr.lostParts.isEmpty();
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return !lsnr.lostParts.isEmpty();
+ }
+ }, getTestTimeout());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
index 27b201f..806d8b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
@@ -182,7 +182,8 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
startGrids(GRID_CNT);
- awaitPartitionMapExchange();
+ if (cacheMode == REPLICATED)
+ awaitPartitionMapExchange();
ignites = new Ignite[GRID_CNT];
ids = new UUID[GRID_CNT];
@@ -624,4 +625,4 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
return null;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
new file mode 100644
index 0000000..1135c40
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -0,0 +1,400 @@
+/*
+ * 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.distributed.dht;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionRollbackException;
+
+import javax.cache.CacheException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+
+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;
+
+/**
+ * Tests one-phase commit transactions when some of the nodes fail in the middle of the transaction.
+ */
+@SuppressWarnings("unchecked")
+public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
+ /**
+ * @return Grid count.
+ */
+ public int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName));
+
+ cfg.setCommunicationSpi(new BanningCommunicationSpi());
+
+ return cfg;
+ }
+
+ /**
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ protected CacheConfiguration cacheConfiguration(String gridName) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+ ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ ccfg.setBackups(1);
+
+ return ccfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitPessimistic() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(PESSIMISTIC, false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitOptimistic() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitPessimisticOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(PESSIMISTIC, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitOptimisticOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackPessimistic() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(PESSIMISTIC, false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackOptimistic() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackPessimisticOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(PESSIMISTIC, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackOptimisticOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitImplicit() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(null, false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupCommitImplicitOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(null, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackImplicit() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(null, false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPrimaryNodeFailureBackupRollbackImplicitOnBackup() throws Exception {
+ checkPrimaryNodeFailureBackupCommit(null, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void checkPrimaryNodeFailureBackupCommit(
+ final TransactionConcurrency conc,
+ boolean backup,
+ final boolean commit
+ ) throws Exception {
+ startGrids(gridCount());
+ awaitPartitionMapExchange();
+
+ for (int i = 0; i < gridCount(); i++)
+ info("Grid " + i + ": " + ignite(i).cluster().localNode().id());
+
+ try {
+ final Ignite ignite = ignite(0);
+
+ final IgniteCache<Object, Object> cache = ignite.cache(null);
+
+ final int key = generateKey(ignite, backup);
+
+ IgniteEx backupNode = (IgniteEx)backupNode(key, null);
+
+ assertNotNull(backupNode);
+
+ final CountDownLatch commitLatch = new CountDownLatch(1);
+
+ if (!commit) {
+ communication(1).bannedClasses(Collections.<Class>singletonList(GridDhtTxPrepareRequest.class));
+ }
+ else {
+ if (!backup) {
+ communication(2).bannedClasses(Collections.<Class>singletonList(GridDhtTxPrepareResponse.class));
+ communication(3).bannedClasses(Collections.<Class>singletonList(GridDhtTxPrepareResponse.class));
+ }
+ else
+ communication(0).bannedClasses(Collections.<Class>singletonList(GridDhtTxPrepareResponse.class));
+ }
+
+ IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ if (conc != null) {
+ try (Transaction tx = ignite.transactions().txStart(conc, REPEATABLE_READ)) {
+ cache.put(key, key);
+
+ Transaction asyncTx = (Transaction)tx.withAsync();
+
+ asyncTx.commit();
+
+ commitLatch.countDown();
+
+ try {
+ IgniteFuture<Object> fut = asyncTx.future();
+
+ fut.get();
+
+ if (!commit) {
+ error("Transaction has been committed");
+
+ fail("Transaction has been committed: " + tx);
+ }
+ }
+ catch (TransactionRollbackException e) {
+ if (commit) {
+ error(e.getMessage(), e);
+
+ fail("Failed to commit: " + e);
+ }
+ else
+ assertTrue(X.hasCause(e, TransactionRollbackException.class));
+ }
+ }
+ }
+ else {
+ IgniteCache<Object, Object> cache0 = cache.withAsync();
+
+ cache0.put(key, key);
+
+ Thread.sleep(1000);
+
+ commitLatch.countDown();
+
+ try {
+ cache0.future().get();
+
+ if (!commit) {
+ error("Transaction has been committed");
+
+ fail("Transaction has been committed.");
+ }
+ }
+ catch (CacheException e) {
+ if (commit) {
+ error(e.getMessage(), e);
+
+ fail("Failed to commit: " + e);
+ }
+ else
+ assertTrue(X.hasCause(e, TransactionRollbackException.class));
+ }
+ }
+
+ return null;
+ }
+ });
+
+ commitLatch.await();
+
+ stopGrid(1);
+
+ // Check that thread successfully finished.
+ fut.get();
+
+ // Check there are no hanging transactions.
+ assertEquals(0, ((IgniteEx)ignite(0)).context().cache().context().tm().idMapSize());
+ assertEquals(0, ((IgniteEx)ignite(2)).context().cache().context().tm().idMapSize());
+ assertEquals(0, ((IgniteEx)ignite(3)).context().cache().context().tm().idMapSize());
+
+ dataCheck((IgniteKernal)ignite(0), (IgniteKernal)backupNode, key, commit);
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * @param orig Originating cache.
+ * @param backup Backup cache.
+ * @param key Key being committed and checked.
+ * @param commit Commit or rollback flag.
+ * @throws Exception If check failed.
+ */
+ private void dataCheck(IgniteKernal orig, IgniteKernal backup, int key, boolean commit) throws Exception {
+ GridNearCacheEntry nearEntry = null;
+
+ GridCacheAdapter origCache = orig.internalCache(null);
+
+ if (origCache.isNear())
+ nearEntry = (GridNearCacheEntry)origCache.peekEx(key);
+
+ GridCacheAdapter backupCache = backup.internalCache(null);
+
+ if (backupCache.isNear())
+ backupCache = backupCache.context().near().dht();
+
+ GridDhtCacheEntry dhtEntry = (GridDhtCacheEntry)backupCache.peekEx(key);
+
+ if (commit) {
+ assertNotNull(dhtEntry);
+ assertTrue("dhtEntry=" + dhtEntry, dhtEntry.remoteMvccSnapshot().isEmpty());
+ assertTrue("dhtEntry=" + dhtEntry, dhtEntry.localCandidates().isEmpty());
+ assertEquals(key, backupCache.localPeek(key, null, null));
+
+ if (nearEntry != null) {
+ assertTrue("near=" + nearEntry, nearEntry.remoteMvccSnapshot().isEmpty());
+ assertTrue("near=" + nearEntry, nearEntry.localCandidates().isEmpty());
+
+ // Near peek wil be null since primary node has changed.
+ assertNull("near=" + nearEntry, origCache.localPeek(key, null, null));
+ }
+ }
+ else {
+ assertTrue("near=" + nearEntry + ", hc=" + System.identityHashCode(nearEntry), nearEntry == null);
+ assertTrue("Invalid backup cache entry: " + dhtEntry,
+ dhtEntry == null || dhtEntry.rawGetOrUnmarshal(false) == null);
+ }
+ }
+
+ /**
+ * @param idx Index.
+ * @return Communication SPI.
+ */
+ private BanningCommunicationSpi communication(int idx) {
+ return (BanningCommunicationSpi)ignite(idx).configuration().getCommunicationSpi();
+ }
+
+ /**
+ * @param ignite Ignite instance to generate key.
+ * @return Generated key that is not primary nor backup for {@code ignite(0)} and primary for
+ * {@code ignite(1)}.
+ */
+ private int generateKey(Ignite ignite, boolean backup) {
+ Affinity<Object> aff = ignite.affinity(null);
+
+ for (int key = 0;;key++) {
+ if (backup) {
+ if (!aff.isBackup(ignite(0).cluster().localNode(), key))
+ continue;
+ }
+ else {
+ if (aff.isPrimaryOrBackup(ignite(0).cluster().localNode(), key))
+ continue;
+ }
+
+ if (aff.isPrimary(ignite(1).cluster().localNode(), key))
+ return key;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class BanningCommunicationSpi extends TcpCommunicationSpi {
+ /** */
+ private volatile Collection<Class> bannedClasses = Collections.emptyList();
+
+ /**
+ * @param bannedClasses Banned classes.
+ */
+ public void bannedClasses(Collection<Class> bannedClasses) {
+ this.bannedClasses = bannedClasses;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException {
+ GridIoMessage ioMsg = (GridIoMessage)msg;
+
+ if (!bannedClasses.contains(ioMsg.message().getClass())) {
+ super.sendMessage(node, msg, ackClosure);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNearCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNearCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNearCacheTxNodeFailureSelfTest.java
new file mode 100644
index 0000000..5735182
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNearCacheTxNodeFailureSelfTest.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.cache.distributed.dht;
+
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+
+/**
+ *
+ */
+public class GridNearCacheTxNodeFailureSelfTest extends GridCacheTxNodeFailureSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration cacheConfiguration(String gridName) {
+ return super.cacheConfiguration(gridName).setNearConfiguration(new NearCacheConfiguration());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
new file mode 100644
index 0000000..cee54b8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
@@ -0,0 +1,283 @@
+/*
+ * 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.distributed.dht;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ *
+ */
+public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstractTest {
+ /**
+ * Grid count.
+ */
+ private static final int GRID_CNT = 5;
+
+ /**
+ * Restart count.
+ */
+ private static final int RESTART_CNT = 15;
+
+ /**
+ * Atomic long name.
+ */
+ private static final String ATOMIC_LONG_NAME = "test-atomic-long";
+
+ /**
+ * Queue.
+ */
+ private final Queue<Long> queue = new ConcurrentLinkedQueue<>();
+
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ AtomicConfiguration atomicCfg = new AtomicConfiguration();
+ atomicCfg.setCacheMode(CacheMode.PARTITIONED);
+ atomicCfg.setBackups(1);
+
+ cfg.setAtomicConfiguration(atomicCfg);
+
+ return cfg;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ queue.clear();
+ }
+
+ /**
+ *
+ */
+ public void testQueueCreateNodesJoin() throws Exception {
+ CountDownLatch startLatch = new CountDownLatch(GRID_CNT);
+ final AtomicBoolean run = new AtomicBoolean(true);
+
+ Collection<IgniteInternalFuture<?>> futs = new ArrayList<>();
+
+ for (int i = 0; i < GRID_CNT; i++)
+ futs.add(startNodeAndCreaterThread(i, startLatch, run));
+
+ startLatch.await();
+
+ info("All nodes started.");
+
+ Thread.sleep(10_000);
+
+ run.set(false);
+
+ for (IgniteInternalFuture<?> fut : futs)
+ fut.get();
+
+ info("Increments: " + queue.size());
+
+ assert !queue.isEmpty();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncrementConsistency() throws Exception {
+ startGrids(GRID_CNT);
+
+ final AtomicBoolean run = new AtomicBoolean(true);
+
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ /** {@inheritDoc} */
+ @Override
+ public Void call() throws Exception {
+ IgniteAtomicLong cntr = ignite(0).atomicLong(ATOMIC_LONG_NAME, 0, true);
+
+ while (run.get())
+ queue.add(cntr.getAndIncrement());
+
+ return null;
+ }
+ }, 4, "increment-runner");
+
+ for (int i = 0; i < RESTART_CNT; i++) {
+ int restartIdx = ThreadLocalRandom.current().nextInt(GRID_CNT - 1) + 1;
+
+ stopGrid(restartIdx);
+
+ U.sleep(500);
+
+ startGrid(restartIdx);
+ }
+
+ run.set(false);
+
+ fut.get();
+
+ info("Increments: " + queue.size());
+
+ checkQueue();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueueClose() throws Exception {
+ startGrids(GRID_CNT);
+
+ int threads = 4;
+
+ final AtomicBoolean run = new AtomicBoolean(true);
+ final AtomicInteger idx = new AtomicInteger();
+ final AtomicReferenceArray<Exception> arr = new AtomicReferenceArray<>(threads);
+
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ /** {@inheritDoc} */
+ @Override
+ public Void call() throws Exception {
+ int base = idx.getAndIncrement();
+
+ try {
+ int delta = 0;
+
+ while (run.get()) {
+ IgniteAtomicLong cntr = ignite(0).atomicLong(ATOMIC_LONG_NAME + "-" + base + "-" + delta, 0, true);
+
+ for (int i = 0; i < 5; i++)
+ queue.add(cntr.getAndIncrement());
+
+ cntr.close();
+
+ delta++;
+ }
+ }
+ catch (Exception e) {
+ arr.set(base, e);
+
+ throw e;
+ }
+ finally {
+ info("RUNNER THREAD IS STOPPING");
+ }
+
+ return null;
+ }
+ }, threads, "increment-runner");
+
+ for (int i = 0; i < RESTART_CNT; i++) {
+ int restartIdx = ThreadLocalRandom.current().nextInt(GRID_CNT - 1) + 1;
+
+ stopGrid(restartIdx);
+
+ U.sleep(500);
+
+ startGrid(restartIdx);
+ }
+
+ run.set(false);
+
+ fut.get();
+
+ for (int i = 0; i < threads; i++) {
+ Exception err = arr.get(i);
+
+ if (err != null)
+ throw err;
+ }
+ }
+
+ /**
+ *
+ */
+ private void checkQueue() {
+ List<Long> list = new ArrayList<>(queue);
+
+ Collections.sort(list);
+
+ boolean failed = false;
+
+ int delta = 0;
+
+ for (int i = 0; i < list.size(); i++) {
+ Long exp = (long)(i + delta);
+
+ Long actual = list.get(i);
+
+ if (!exp.equals(actual)) {
+ failed = true;
+
+ delta++;
+
+ info(">>> Expected " + exp + ", actual " + actual);
+ }
+ }
+
+ assertFalse(failed);
+ }
+
+ /**
+ * @param i Node index.
+ */
+ private IgniteInternalFuture<?> startNodeAndCreaterThread(final int i, final CountDownLatch startLatch, final AtomicBoolean run)
+ throws Exception {
+ return multithreadedAsync(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Ignite ignite = startGrid(i);
+
+ startLatch.countDown();
+
+ while (run.get()) {
+ IgniteAtomicLong cntr = ignite.atomicLong(ATOMIC_LONG_NAME, 0, true);
+
+ queue.add(cntr.getAndIncrement());
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 1, "grunner-" + i);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
index db55731..1d80ac1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
@@ -90,11 +92,14 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
IgniteCache<Integer, Integer> cache0 = ignite(0).cache(null);
IgniteCache<Integer, Integer> cache1 = ignite1.cache(null);
+ Collection<IgniteInternalFuture<?>> futs = new ArrayList<>();
+
for (int i = 0; i < 5; i++) {
log.info("Iteration: " + i);
- GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
+ futs.add(GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
int val = idx.getAndIncrement();
IgniteCache<Integer, Integer> cache = ignite1.cache(null);
@@ -104,10 +109,13 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
return null;
}
- }, 5, "put-thread");
+ }, 5, "put-thread"));
assertEquals(cache0.localPeek(key), cache1.localPeek(key));
}
+
+ for (IgniteInternalFuture<?> fut : futs)
+ fut.get();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index 28f9a65..eaeb7b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -30,6 +30,9 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxNode
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtAtomicRemoveFailureTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtClientRemoveFailureTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtRemoveFailureTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheTxNodeFailureSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridNearCacheTxNodeFailureSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteAtomicLongChangingTopologySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicClientInvalidPartitionHandlingSelfTest;
@@ -97,7 +100,11 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheSizeFailoverTest.class);
suite.addTestSuite(IgniteCacheTopologySafeGetSelfTest.class);
+ suite.addTestSuite(IgniteAtomicLongChangingTopologySelfTest.class);
+
+ suite.addTestSuite(GridCacheTxNodeFailureSelfTest.class);
+ suite.addTestSuite(GridNearCacheTxNodeFailureSelfTest.class);
return suite;
}
-}
\ No newline at end of file
+}
[07/28] ignite git commit: IGNITE-264 - Check backup node for
one-phase transaction when primary node crashes.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index 23a8b1f..25ab297 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -63,7 +63,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** Implicit transaction with one key flag. */
private boolean implicitSingleTx;
- /** One phase commit flag. */
+ /** Flag is kept for backward compatibility. */
private boolean onePhaseCommit;
/** Array of mapped DHT versions for this entry. */
@@ -220,20 +220,6 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
/**
- * @return One phase commit flag.
- */
- public boolean onePhaseCommit() {
- return onePhaseCommit;
- }
-
- /**
- * @param onePhaseCommit One phase commit flag.
- */
- public void onePhaseCommit(boolean onePhaseCommit) {
- this.onePhaseCommit = onePhaseCommit;
- }
-
- /**
* @return Sync commit flag.
*/
public boolean syncCommit() {
@@ -603,4 +589,4 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
return S.toString(GridNearLockRequest.class, this, "filter", Arrays.toString(filter),
"super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index 529f29c..3f9decf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -24,6 +24,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterTopologyException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
@@ -50,6 +51,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -142,6 +144,16 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
* @param e Error.
*/
void onError(@Nullable UUID nodeId, @Nullable Iterable<GridDistributedTxMapping> mappings, Throwable e) {
+ if (X.hasCause(e, ClusterTopologyCheckedException.class) || X.hasCause(e, ClusterTopologyException.class)) {
+ if (tx.onePhaseCommit()) {
+ tx.markForBackupCheck();
+
+ onComplete();
+
+ return;
+ }
+ }
+
if (err.compareAndSet(null, e)) {
boolean marked = tx.setRollbackOnly();
@@ -209,17 +221,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
this.err.compareAndSet(null, err);
- if (err == null)
- tx.state(PREPARED);
-
- if (super.onDone(tx, err)) {
- // Don't forget to clean up.
- cctx.mvcc().removeFuture(this);
-
- return true;
- }
-
- return false;
+ return onComplete();
}
/**
@@ -233,10 +235,20 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
/**
* Completeness callback.
*/
- private void onComplete() {
- if (super.onDone(tx, err.get()))
+ private boolean onComplete() {
+ Throwable err0 = err.get();
+
+ if (err0 == null || tx.needCheckBackup())
+ tx.state(PREPARED);
+
+ if (super.onDone(tx, err0)) {
// Don't forget to clean up.
cctx.mvcc().removeFuture(this);
+
+ return true;
+ }
+
+ return false;
}
/** {@inheritDoc} */
@@ -244,6 +256,14 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
// Obtain the topology version to use.
AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(Thread.currentThread().getId());
+ // If there is another system transaction in progress, use it's topology version to prevent deadlock.
+ if (topVer == null && tx != null && tx.system()) {
+ IgniteInternalTx tx0 = cctx.tm().anyActiveThreadTx(tx);
+
+ if (tx0 != null)
+ topVer = tx0.topologyVersionSnapshot();
+ }
+
if (topVer != null) {
tx.topologyVersion(topVer);
@@ -437,7 +457,6 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
/**
* @param reads Read entries.
* @param writes Write entries.
- * @throws IgniteCheckedException If transaction is group-lock and some key was mapped to to the local node.
*/
private void prepare(
Iterable<IgniteTxEntry> reads,
@@ -618,7 +637,6 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
* @param topVer Topology version.
* @param cur Current mapping.
* @param waitLock Wait lock flag.
- * @throws IgniteCheckedException If transaction is group-lock and local node is not primary for key.
* @return Mapping.
*/
private GridDistributedTxMapping map(
@@ -626,7 +644,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
AffinityTopologyVersion topVer,
@Nullable GridDistributedTxMapping cur,
boolean waitLock
- ) throws IgniteCheckedException {
+ ) {
GridCacheContext cacheCtx = entry.context();
List<ClusterNode> nodes = cacheCtx.affinity().nodes(entry.key(), topVer);
@@ -857,4 +875,4 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index 63f1f79..b8d2250 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -261,7 +261,7 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
err = this.err.get();
- if (err == null)
+ if (err == null || tx.needCheckBackup())
tx.state(PREPARED);
if (super.onDone(tx, err)) {
@@ -339,6 +339,13 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
* @param e Error.
*/
void onNodeLeft(ClusterTopologyCheckedException e) {
+ if (tx.onePhaseCommit()) {
+ tx.markForBackupCheck();
+
+ // Do not fail future for one-phase transaction right away.
+ onDone(tx);
+ }
+
onError(e);
}
@@ -366,4 +373,4 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index f29bd28..ddc8be5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -18,6 +18,8 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReference;
@@ -32,6 +34,8 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse;
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;
@@ -42,14 +46,17 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.transactions.TransactionRollbackException;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.NOOP;
-import static org.apache.ignite.transactions.TransactionState.COMMITTING;
+import static org.apache.ignite.transactions.TransactionState.UNKNOWN;
/**
*
@@ -57,6 +64,9 @@ import static org.apache.ignite.transactions.TransactionState.COMMITTING;
public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFuture<IgniteInternalTx>
implements GridCacheFuture<IgniteInternalTx> {
/** */
+ public static final IgniteProductVersion FINISH_NEAR_ONE_PHASE_SINCE = IgniteProductVersion.fromString("1.4.0");
+
+ /** */
private static final long serialVersionUID = 0L;
/** Logger reference. */
@@ -216,27 +226,66 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
}
}
+ /**
+ * @param nodeId Sender.
+ * @param res Result.
+ */
+ public void onResult(UUID nodeId, GridDhtTxFinishResponse res) {
+ if (!isDone())
+ for (IgniteInternalFuture<IgniteInternalTx> fut : futures()) {
+ if (isMini(fut)) {
+ MiniFuture f = (MiniFuture)fut;
+
+ if (f.futureId().equals(res.miniId())) {
+ assert f.node().id().equals(nodeId);
+
+ f.onResult(res);
+ }
+ }
+ }
+ }
+
/** {@inheritDoc} */
- @Override public boolean onDone(IgniteInternalTx tx, Throwable err) {
+ @Override public boolean onDone(IgniteInternalTx tx0, Throwable err) {
if ((initialized() || err != null)) {
- if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING))
- this.tx.tmCommit();
+ if (tx.needCheckBackup()) {
+ assert tx.onePhaseCommit();
+
+ if (err != null)
+ err = new TransactionRollbackException("Failed to commit transaction.", err);
+
+ try {
+ tx.finish(err == null);
+ }
+ catch (IgniteCheckedException e) {
+ if (err != null)
+ err.addSuppressed(e);
+ else
+ err = e;
+ }
+ }
+
+ if (tx.onePhaseCommit()) {
+ finishOnePhase();
+
+ tx.tmFinish(err == null);
+ }
Throwable th = this.err.get();
- if (super.onDone(tx, th != null ? th : err)) {
+ if (super.onDone(tx0, th != null ? th : err)) {
if (error() instanceof IgniteTxHeuristicCheckedException) {
- AffinityTopologyVersion topVer = this.tx.topologyVersion();
+ AffinityTopologyVersion topVer = tx.topologyVersion();
- for (IgniteTxEntry e : this.tx.writeMap().values()) {
+ for (IgniteTxEntry e : tx.writeMap().values()) {
GridCacheContext cacheCtx = e.context();
try {
if (e.op() != NOOP && !cacheCtx.affinity().localNode(e.key(), topVer)) {
- GridCacheEntryEx Entry = cacheCtx.cache().peekEx(e.key());
+ GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key());
- if (Entry != null)
- Entry.invalidate(null, this.tx.xidVersion());
+ if (entry != null)
+ entry.invalidate(null, tx.xidVersion());
}
}
catch (Throwable t) {
@@ -284,52 +333,194 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
* Initializes future.
*/
void finish() {
- if (tx.onePhaseCommit()) {
- // No need to send messages as transaction was already committed on remote node.
- // Finish local mapping only as we need send commit message to backups.
- for (GridDistributedTxMapping m : mappings.values()) {
- if (m.node().isLocal()) {
- IgniteInternalFuture<IgniteInternalTx> fut = cctx.tm().txHandler().finishColocatedLocal(commit, tx);
-
- // Add new future.
- if (fut != null)
- add(fut);
- }
- }
+ if (tx.needCheckBackup()) {
+ assert tx.onePhaseCommit();
+
+ checkBackup();
+ // If checkBackup is set, it means that primary node has crashed and we will not need to send
+ // finish request to it, so we can mark future as initialized.
markInitialized();
return;
}
- if (mappings != null) {
- finish(mappings.values());
+ try {
+ if (tx.finish(commit) || (!commit && tx.state() == UNKNOWN)) {
+ if ((tx.onePhaseCommit() && needFinishOnePhase()) || (!tx.onePhaseCommit() && mappings != null))
+ finish(mappings.values());
- markInitialized();
+ markInitialized();
- if (!isSync()) {
- boolean complete = true;
+ if (!isSync()) {
+ boolean complete = true;
- for (IgniteInternalFuture<?> f : pending())
- // Mini-future in non-sync mode gets done when message gets sent.
- if (isMini(f) && !f.isDone())
- complete = false;
+ for (IgniteInternalFuture<?> f : pending())
+ // Mini-future in non-sync mode gets done when message gets sent.
+ if (isMini(f) && !f.isDone())
+ complete = false;
- if (complete)
- onComplete();
+ if (complete)
+ onComplete();
+ }
}
+ else
+ onError(new IgniteCheckedException("Failed to commit transaction: " + CU.txString(tx)));
}
- else {
- assert !commit;
+ catch (Error | RuntimeException e) {
+ onError(e);
- try {
- tx.rollback();
+ throw e;
+ }
+ catch (IgniteCheckedException e) {
+ onError(e);
+ }
+ }
+
+ /**
+ *
+ */
+ private void checkBackup() {
+ assert mappings.size() <= 1;
+
+ for (Map.Entry<UUID, GridDistributedTxMapping> entry : mappings.entrySet()) {
+ UUID nodeId = entry.getKey();
+ GridDistributedTxMapping mapping = entry.getValue();
+
+ Collection<UUID> backups = tx.transactionNodes().get(nodeId);
+
+ if (!F.isEmpty(backups)) {
+ assert backups.size() == 1;
+
+ UUID backupId = F.first(backups);
+
+ ClusterNode backup = cctx.discovery().node(backupId);
+
+ // Nothing to do if backup has left the grid.
+ if (backup == null)
+ return;
+
+ MiniFuture mini = new MiniFuture(backup, mapping);
+
+ add(mini);
+
+ if (backup.isLocal()) {
+ if (cctx.tm().txHandler().checkDhtRemoteTxCommitted(tx.xidVersion())) {
+ readyNearMappingFromBackup(mapping);
+
+ mini.onDone(tx);
+ }
+ else
+ mini.onDone(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
+ "(transaction has been rolled back on backup node): " + tx.xidVersion()));
+ }
+ else {
+ GridDhtTxFinishRequest finishReq = new GridDhtTxFinishRequest(
+ cctx.localNodeId(),
+ futureId(),
+ mini.futureId(),
+ tx.topologyVersion(),
+ tx.xidVersion(),
+ tx.commitVersion(),
+ tx.threadId(),
+ tx.isolation(),
+ true,
+ false,
+ tx.system(),
+ tx.ioPolicy(),
+ false,
+ true,
+ true,
+ null,
+ null,
+ null,
+ null,
+ 0,
+ null,
+ 0);
+
+ finishReq.checkCommitted(true);
+
+ try {
+ if (FINISH_NEAR_ONE_PHASE_SINCE.compareTo(backup.version()) <= 0)
+ cctx.io().send(backup, finishReq, tx.ioPolicy());
+ else
+ mini.onDone(new IgniteTxHeuristicCheckedException("Failed to check for tx commit on " +
+ "the backup node (node has an old Ignite version) [rmtNodeId=" + backup.id() +
+ ", ver=" + backup.version() + ']'));
+ }
+ catch (ClusterTopologyCheckedException e) {
+ mini.onResult(e);
+ }
+ catch (IgniteCheckedException e) {
+ mini.onResult(e);
+ }
+ }
}
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to rollback empty transaction: " + tx, e);
+ else
+ readyNearMappingFromBackup(mapping);
+ }
+ }
+
+ /**
+ *
+ */
+ private boolean needFinishOnePhase() {
+ if (F.isEmpty(tx.mappings()))
+ return false;
+
+ assert tx.mappings().size() == 1;
+
+ boolean finish = false;
+
+ for (Integer cacheId : tx.activeCacheIds()) {
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
+
+ if (cacheCtx.isNear()) {
+ finish = true;
+
+ break;
}
+ }
- markInitialized();
+ if (finish) {
+ GridDistributedTxMapping mapping = F.first(tx.mappings().values());
+
+ if (FINISH_NEAR_ONE_PHASE_SINCE.compareTo(mapping.node().version()) > 0)
+ finish = false;
+ }
+
+ return finish;
+ }
+
+ /**
+ *
+ */
+ private void finishOnePhase() {
+ // No need to send messages as transaction was already committed on remote node.
+ // Finish local mapping only as we need send commit message to backups.
+ for (GridDistributedTxMapping m : mappings.values()) {
+ if (m.node().isLocal()) {
+ IgniteInternalFuture<IgniteInternalTx> fut = cctx.tm().txHandler().finishColocatedLocal(commit, tx);
+
+ // Add new future.
+ if (fut != null)
+ add(fut);
+ }
+ }
+ }
+
+ /**
+ * @param mapping Mapping to finish.
+ */
+ private void readyNearMappingFromBackup(GridDistributedTxMapping mapping) {
+ if (mapping.near()) {
+ GridCacheVersion xidVer = tx.xidVersion();
+
+ mapping.dhtVersion(xidVer, xidVer);
+
+ tx.readyNearLocks(mapping, Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList(),
+ Collections.<GridCacheVersion>emptyList());
}
}
@@ -417,9 +608,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
@SuppressWarnings("unchecked")
@Override public String apply(IgniteInternalFuture<?> f) {
if (isMini(f)) {
- return "[node=" + ((MiniFuture) f).node().id() +
- ", loc=" + ((MiniFuture) f).node().isLocal() +
- ", done=" + f.isDone() + "]";
+ MiniFuture m = (MiniFuture)f;
+
+ return "[node=" + m.node().id() + ", loc=" + m.node().isLocal() + ", done=" + f.isDone() + "]";
}
else
return "[loc=true, done=" + f.isDone() + "]";
@@ -446,6 +637,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
@GridToStringInclude
private GridDistributedTxMapping m;
+ /** Backup check flag. */
+ private ClusterNode backup;
+
/**
* @param m Mapping.
*/
@@ -454,6 +648,15 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
}
/**
+ * @param backup Backup to check.
+ * @param m Mapping associated with the backup.
+ */
+ MiniFuture(ClusterNode backup, GridDistributedTxMapping m) {
+ this.backup = backup;
+ this.m = m;
+ }
+
+ /**
* @return Future ID.
*/
IgniteUuid futureId() {
@@ -464,7 +667,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
* @return Node ID.
*/
public ClusterNode node() {
- return m.node();
+ assert m != null || backup != null;
+
+ return backup != null ? backup : m.node();
}
/**
@@ -492,20 +697,42 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
if (log.isDebugEnabled())
log.debug("Remote node left grid while sending or waiting for reply (will fail): " + this);
- // Complete future with tx.
- onDone(tx);
+ if (backup != null) {
+ readyNearMappingFromBackup(m);
+
+ onDone(e);
+ }
+ else
+ // Complete future with tx.
+ onDone(tx);
}
/**
* @param res Result callback.
*/
void onResult(GridNearTxFinishResponse res) {
+ assert backup == null;
+
if (res.error() != null)
onDone(res.error());
else
onDone(tx);
}
+ /**
+ * @param res Response.
+ */
+ void onResult(GridDhtTxFinishResponse res) {
+ assert backup != null;
+
+ readyNearMappingFromBackup(m);
+
+ if (res.checkCommittedError() != null)
+ onDone(res.checkCommittedError());
+ else
+ onDone(tx);
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
index 5e5a222..c52a127 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
@@ -97,8 +97,22 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
int txSize,
@Nullable UUID subjId,
int taskNameHash) {
- super(xidVer, futId, null, threadId, commit, invalidate, sys, plc, syncCommit, syncRollback, baseVer,
- committedVers, rolledbackVers, txSize);
+ super(
+ xidVer,
+ futId,
+ null,
+ threadId,
+ commit,
+ invalidate,
+ sys,
+ plc,
+ syncCommit,
+ syncRollback,
+ baseVer,
+ committedVers,
+ rolledbackVers,
+ txSize
+ );
this.explicitLock = explicitLock;
this.storeEnabled = storeEnabled;
@@ -290,4 +304,4 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
@Override public String toString() {
return GridToStringBuilder.toString(GridNearTxFinishRequest.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/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 fd64fdf..a4e06c3 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
@@ -114,6 +114,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
private Map<IgniteTxKey, IgniteCacheExpiryPolicy> accessMap;
/** */
+ private boolean needCheckBackup;
+
+ /** */
private boolean hasRemoteLocks;
/**
@@ -164,6 +167,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
timeout,
false,
storeEnabled,
+ false,
txSize,
subjId,
taskNameHash);
@@ -242,6 +246,20 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
/**
+ * Marks transaction to check if commit on backup.
+ */
+ public void markForBackupCheck() {
+ needCheckBackup = true;
+ }
+
+ /**
+ * @return If need to check tx commit on backup.
+ */
+ public boolean needCheckBackup() {
+ return needCheckBackup;
+ }
+
+ /**
* Checks if transaction is fully synchronous.
*
* @return {@code True} if transaction is fully synchronous.
@@ -501,9 +519,15 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
GridDistributedTxMapping m = mappings.get(n.id());
- if (m == null)
+ if (m == null) {
m = F.addIfAbsent(mappings, n.id(), new GridDistributedTxMapping(n));
+ m.near(map.near());
+
+ if (map.explicitLock())
+ m.markExplicitLock();
+ }
+
assert m != null;
for (IgniteTxEntry entry : map.entries())
@@ -736,7 +760,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
cctx.mvcc().addFuture(fut);
- IgniteInternalFuture<?> prepareFut = prepFut.get();
+ final IgniteInternalFuture<?> prepareFut = prepFut.get();
prepareFut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override public void apply(IgniteInternalFuture<?> f) {
@@ -744,17 +768,15 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
try {
// Make sure that here are no exceptions.
- f.get();
+ prepareFut.get();
- if (finish(true))
- fut0.finish();
- else
- fut0.onError(new IgniteCheckedException("Failed to commit transaction: " +
- CU.txString(GridNearTxLocal.this)));
+ fut0.finish();
}
catch (Error | RuntimeException e) {
commitErr.compareAndSet(null, e);
+ fut0.onError(e);
+
throw e;
}
catch (IgniteCheckedException e) {
@@ -796,15 +818,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
log.debug("Got optimistic tx failure [tx=" + this + ", err=" + e + ']');
}
- try {
- if (finish(false) || state() == UNKNOWN)
- fut.finish();
- else
- fut.onError(new IgniteCheckedException("Failed to gracefully rollback transaction: " + CU.txString(this)));
- }
- catch (IgniteCheckedException e) {
- fut.onError(e);
- }
+ fut.finish();
}
else {
prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
@@ -820,19 +834,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
GridNearTxFinishFuture fut0 = rollbackFut.get();
- try {
- if (finish(false) || state() == UNKNOWN)
- fut0.finish();
- else
- fut0.onError(new IgniteCheckedException("Failed to gracefully rollback transaction: " +
- CU.txString(GridNearTxLocal.this)));
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to gracefully rollback transaction: " +
- CU.txString(GridNearTxLocal.this), e);
-
- fut0.onError(e);
- }
+ fut0.finish();
}
});
}
@@ -1253,4 +1255,4 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
@Override public String toString() {
return S.toString(GridNearTxLocal.class, this, "mappings", mappings.keySet(), "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 4395198..87c68b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@ -106,8 +106,22 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
@Nullable UUID subjId,
int taskNameHash
) throws IgniteCheckedException {
- super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ super(
+ ctx,
+ nodeId,
+ rmtThreadId,
+ xidVer,
+ commitVer,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ invalidate,
+ timeout,
+ txSize,
+ subjId,
+ taskNameHash
+ );
assert nearNodeId != null;
@@ -162,8 +176,22 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
@Nullable UUID subjId,
int taskNameHash
) {
- super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ super(
+ ctx,
+ nodeId,
+ rmtThreadId,
+ xidVer,
+ commitVer,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ invalidate,
+ timeout,
+ txSize,
+ subjId,
+ taskNameHash
+ );
assert nearNodeId != null;
@@ -383,4 +411,4 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
@Override public String toString() {
return GridToStringBuilder.toString(GridNearTxRemote.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 1ad1064..88752a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -211,6 +211,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
private AtomicBoolean preparing = new AtomicBoolean();
/** */
+ @GridToStringInclude
private Map<Integer, Set<Integer>> invalidParts = new HashMap<>(3);
/**
@@ -293,6 +294,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
long timeout,
boolean invalidate,
boolean storeEnabled,
+ boolean onePhaseCommit,
int txSize,
@Nullable UUID subjId,
int taskNameHash
@@ -312,6 +314,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
this.timeout = timeout;
this.invalidate = invalidate;
this.storeEnabled = storeEnabled;
+ this.onePhaseCommit = onePhaseCommit;
this.txSize = txSize;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
@@ -2210,4 +2213,4 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
return S.toString(TxShadow.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index d64b26e..9efa43a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -59,24 +59,24 @@ import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
-import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.lang.GridClosureException;
-import org.apache.ignite.internal.util.typedef.C2;
+import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFutureCancelledException;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.UTILITY_CACHE_POOL;
import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled;
+import static org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture.FINISH_NEAR_ONE_PHASE_SINCE;
import static org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx.FinalizationStatus.USER_FINISH;
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionState.PREPARED;
import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK;
import static org.apache.ignite.transactions.TransactionState.ROLLING_BACK;
@@ -211,41 +211,40 @@ public class IgniteTxHandler {
final GridNearTxLocal locTx,
final GridNearTxPrepareRequest req
) {
- IgniteInternalFuture<Object> fut = new GridFinishedFuture<>(); // TODO force preload keys.
-
- return new GridEmbeddedFuture<>(
- fut,
- new C2<Object, Exception, IgniteInternalFuture<GridNearTxPrepareResponse>>() {
- @Override public IgniteInternalFuture<GridNearTxPrepareResponse> apply(Object o, Exception ex) {
- if (ex != null)
- throw new GridClosureException(ex);
-
- IgniteInternalFuture<GridNearTxPrepareResponse> fut = locTx.prepareAsyncLocal(
- req.reads(),
- req.writes(),
- req.transactionNodes(),
- req.last(),
- req.lastBackups());
-
- if (locTx.isRollbackOnly())
- locTx.rollbackAsync();
-
- return fut;
+ IgniteInternalFuture<GridNearTxPrepareResponse> fut = locTx.prepareAsyncLocal(
+ req.reads(),
+ req.writes(),
+ req.transactionNodes(),
+ req.last(),
+ req.lastBackups());
+
+ if (locTx.isRollbackOnly())
+ locTx.rollbackAsync();
+
+ return fut.chain(new C1<IgniteInternalFuture<GridNearTxPrepareResponse>, GridNearTxPrepareResponse>() {
+ @Override public GridNearTxPrepareResponse apply(IgniteInternalFuture<GridNearTxPrepareResponse> f) {
+ try {
+ return f.get();
}
- },
- new C2<GridNearTxPrepareResponse, Exception, GridNearTxPrepareResponse>() {
- @Nullable @Override public GridNearTxPrepareResponse apply(GridNearTxPrepareResponse res, Exception e) {
- if (e != null) {
- locTx.setRollbackOnly(); // Just in case.
-
- if (!(e instanceof IgniteTxOptimisticCheckedException))
- U.error(log, "Failed to prepare transaction: " + locTx, e);
- }
+ catch (Exception e) {
+ locTx.setRollbackOnly(); // Just in case.
+
+ if (!X.hasCause(e, IgniteTxOptimisticCheckedException.class) &&
+ !X.hasCause(e, IgniteFutureCancelledException.class))
+ U.error(log, "Failed to prepare DHT transaction: " + locTx, e);
- return res;
+ return new GridNearTxPrepareResponse(
+ req.version(),
+ req.futureId(),
+ req.miniId(),
+ req.version(),
+ req.version(),
+ null,
+ e,
+ null);
}
}
- );
+ });
}
/**
@@ -303,7 +302,7 @@ public class IgniteTxHandler {
GridDhtPartitionTopology top = null;
if (req.firstClientRequest()) {
- assert req.concurrency().equals(OPTIMISTIC) : req;
+ assert req.concurrency() == OPTIMISTIC : req;
assert CU.clientNode(nearNode) : nearNode;
top = firstEntry.context().topology();
@@ -333,7 +332,7 @@ public class IgniteTxHandler {
try {
ctx.io().send(nearNode, res, req.policy());
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException ignored) {
if (log.isDebugEnabled())
log.debug("Failed to send client tx remap response, client node failed " +
"[node=" + nearNode + ", req=" + req + ']');
@@ -363,6 +362,7 @@ public class IgniteTxHandler {
req.timeout(),
req.isInvalidate(),
true,
+ req.onePhaseCommit(),
req.txSize(),
req.transactionNodes(),
req.subjectId(),
@@ -389,6 +389,10 @@ public class IgniteTxHandler {
tx.transactionNodes(req.transactionNodes());
+ // Set near on originating node flag only if the sender node has new version.
+ if (req.near() && FINISH_NEAR_ONE_PHASE_SINCE.compareTo(nearNode.version()) <= 0)
+ tx.nearOnOriginatingNode(true);
+
if (req.onePhaseCommit()) {
assert req.last();
assert F.isEmpty(req.lastBackups()) || req.lastBackups().size() <= 1;
@@ -428,7 +432,8 @@ public class IgniteTxHandler {
catch (IgniteCheckedException e) {
tx0.setRollbackOnly(); // Just in case.
- if (!(e instanceof IgniteTxOptimisticCheckedException))
+ if (!X.hasCause(e, IgniteTxOptimisticCheckedException.class) &&
+ !X.hasCause(e, IgniteFutureCancelledException.class))
U.error(log, "Failed to prepare DHT transaction: " + tx0, e);
}
}
@@ -527,17 +532,32 @@ public class IgniteTxHandler {
assert nodeId != null;
assert res != null;
- GridDhtTxFinishFuture fut = (GridDhtTxFinishFuture)ctx.mvcc().<IgniteInternalTx>future(res.xid(),
- res.futureId());
+ if (res.checkCommitted()) {
+ GridNearTxFinishFuture fut = (GridNearTxFinishFuture)ctx.mvcc().<IgniteInternalTx>future(
+ res.xid(), res.futureId());
- if (fut == null) {
- if (log.isDebugEnabled())
- log.debug("Received response for unknown future (will ignore): " + res);
+ if (fut == null) {
+ if (log.isDebugEnabled())
+ log.debug("Received response for unknown future (will ignore): " + res);
- return;
+ return;
+ }
+
+ fut.onResult(nodeId, res);
}
+ else {
+ GridDhtTxFinishFuture fut = (GridDhtTxFinishFuture)ctx.mvcc().<IgniteInternalTx>future(
+ res.xid(), res.futureId());
- fut.onResult(nodeId, res);
+ if (fut == null) {
+ if (log.isDebugEnabled())
+ log.debug("Received response for unknown future (will ignore): " + res);
+
+ return;
+ }
+
+ fut.onResult(nodeId, res);
+ }
}
/**
@@ -653,42 +673,10 @@ public class IgniteTxHandler {
}
try {
- if (req.commit()) {
- if (tx == null) {
- // Create transaction and add entries.
- tx = ctx.tm().onCreated(null,
- new GridDhtTxLocal(
- ctx,
- nodeId,
- req.version(),
- req.futureId(),
- req.miniId(),
- req.threadId(),
- true,
- false, /* we don't know, so assume false. */
- req.system(),
- req.explicitLock(),
- req.policy(),
- PESSIMISTIC,
- READ_COMMITTED,
- /*timeout */0,
- req.isInvalidate(),
- req.storeEnabled(),
- req.txSize(),
- null,
- req.subjectId(),
- req.taskNameHash()));
-
- if (tx == null || !ctx.tm().onStarted(tx))
- throw new IgniteTxRollbackCheckedException("Attempt to start a completed transaction: " + req);
-
- tx.topologyVersion(req.topologyVersion());
- }
- else {
- if (req.explicitLock())
- tx.explicitLock(req.explicitLock());
- }
+ assert tx != null : "Transaction is null for near finish request [nodeId=" +
+ nodeId + ", req=" + req + "]";
+ if (req.commit()) {
tx.storeEnabled(req.storeEnabled());
if (!tx.markFinalizing(USER_FINISH)) {
@@ -712,47 +700,17 @@ public class IgniteTxHandler {
return commitFut;
}
else {
- assert tx != null || req.explicitLock() : "Transaction is null for near rollback request [nodeId=" +
- nodeId + ", req=" + req + "]";
-
- if (tx != null) {
- tx.syncRollback(req.syncRollback());
-
- tx.nearFinishFutureId(req.futureId());
- tx.nearFinishMiniId(req.miniId());
+ tx.syncRollback(req.syncRollback());
- IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
-
- // Only for error logging.
- rollbackFut.listen(CU.errorLogger(log));
-
- return rollbackFut;
- }
- else {
- // Always send finish response.
- GridCacheMessage res = new GridNearTxFinishResponse(req.version(), req.threadId(),
- req.futureId(), req.miniId(), null);
+ tx.nearFinishFutureId(req.futureId());
+ tx.nearFinishMiniId(req.miniId());
- try {
- ctx.io().send(nodeId, res, req.policy());
- }
- catch (Throwable e) {
- // Double-check.
- if (ctx.discovery().node(nodeId) == null) {
- if (log.isDebugEnabled())
- log.debug("Node left while sending finish response [nodeId=" + nodeId + ", res=" + res +
- ']');
- }
- else
- U.error(log, "Failed to send finish response to node [nodeId=" + nodeId + ", " +
- "res=" + res + ']', e);
+ IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
- if (e instanceof Error)
- throw (Error)e;
- }
+ // Only for error logging.
+ rollbackFut.listen(CU.errorLogger(log));
- return null;
- }
+ return rollbackFut;
}
}
catch (Throwable e) {
@@ -912,6 +870,12 @@ public class IgniteTxHandler {
if (log.isDebugEnabled())
log.debug("Processing dht tx finish request [nodeId=" + nodeId + ", req=" + req + ']');
+ if (req.checkCommitted()) {
+ sendReply(nodeId, req, checkDhtRemoteTxCommitted(req.version()));
+
+ return;
+ }
+
GridDhtTxRemote dhtTx = ctx.tm().tx(req.version());
GridNearTxRemote nearTx = ctx.tm().nearTx(req.version());
@@ -947,13 +911,33 @@ public class IgniteTxHandler {
completeFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override
public void apply(IgniteInternalFuture<IgniteInternalTx> igniteTxIgniteFuture) {
- sendReply(nodeId, req);
+ sendReply(nodeId, req, true);
}
});
}
else
- sendReply(nodeId, req);
+ sendReply(nodeId, req, true);
}
+ else
+ sendReply(nodeId, req, true);
+ }
+
+ /**
+ * Checks whether DHT remote transaction with given version has been committed. If not, will add version
+ * to rollback version set so that late response will not falsely commit this transaction.
+ *
+ * @param writeVer Write version to check.
+ * @return {@code True} if transaction has been committed, {@code false} otherwise.
+ */
+ public boolean checkDhtRemoteTxCommitted(GridCacheVersion writeVer) {
+ assert writeVer != null;
+
+ boolean committed = true;
+
+ if (ctx.tm().addRolledbackTx(writeVer))
+ committed = false;
+
+ return committed;
}
/**
@@ -988,15 +972,14 @@ public class IgniteTxHandler {
try {
if (req.commit() || req.isSystemInvalidate()) {
- if (tx.commitVersion(req.commitVersion())) {
- tx.invalidate(req.isInvalidate());
- tx.systemInvalidate(req.isSystemInvalidate());
+ tx.commitVersion(req.commitVersion());
+ tx.invalidate(req.isInvalidate());
+ tx.systemInvalidate(req.isSystemInvalidate());
- // Complete remote candidates.
- tx.doneRemote(req.baseVersion(), null, null, null);
+ // Complete remote candidates.
+ tx.doneRemote(req.baseVersion(), null, null, null);
- tx.commit();
- }
+ tx.commit();
}
else {
tx.doneRemote(req.baseVersion(), null, null, null);
@@ -1067,23 +1050,33 @@ public class IgniteTxHandler {
* @param nodeId Node id that originated finish request.
* @param req Request.
*/
- protected void sendReply(UUID nodeId, GridDhtTxFinishRequest req) {
- GridCacheMessage res = new GridDhtTxFinishResponse(req.version(), req.futureId(), req.miniId());
+ protected void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committed) {
+ if (req.replyRequired()) {
+ GridDhtTxFinishResponse res = new GridDhtTxFinishResponse(req.version(), req.futureId(), req.miniId());
- try {
- ctx.io().send(nodeId, res, req.system() ? UTILITY_CACHE_POOL : SYSTEM_POOL);
- }
- catch (Throwable e) {
- // Double-check.
- if (ctx.discovery().node(nodeId) == null) {
- if (log.isDebugEnabled())
- log.debug("Node left while sending finish response [nodeId=" + nodeId + ", res=" + res + ']');
+ if (req.checkCommitted()) {
+ res.checkCommitted(true);
+
+ if (!committed)
+ res.checkCommittedError(new IgniteTxRollbackCheckedException("Failed to commit transaction " +
+ "(transaction has been rolled back on backup node): " + req.version()));
}
- else
- U.error(log, "Failed to send finish response to node [nodeId=" + nodeId + ", res=" + res + ']', e);
- if (e instanceof Error)
- throw (Error)e;
+ try {
+ ctx.io().send(nodeId, res, req.system() ? UTILITY_CACHE_POOL : SYSTEM_POOL);
+ }
+ catch (Throwable e) {
+ // Double-check.
+ if (ctx.discovery().node(nodeId) == null) {
+ if (log.isDebugEnabled())
+ log.debug("Node left while sending finish response [nodeId=" + nodeId + ", res=" + res + ']');
+ }
+ else
+ U.error(log, "Failed to send finish response to node [nodeId=" + nodeId + ", res=" + res + ']', e);
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
}
}
@@ -1188,8 +1181,14 @@ public class IgniteTxHandler {
// in prepare phase will get properly ordered as well.
tx.prepare();
- if (req.last())
+ if (req.last()) {
+ assert !F.isEmpty(req.transactionNodes()) :
+ "Received last prepare request with empty transaction nodes: " + req;
+
+ tx.transactionNodes(req.transactionNodes());
+
tx.state(PREPARED);
+ }
res.invalidPartitionsByCacheId(tx.invalidPartitions());
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 7d32401..00b91dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -196,12 +196,29 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
long timeout,
boolean invalidate,
boolean storeEnabled,
+ boolean onePhaseCommit,
int txSize,
@Nullable UUID subjId,
int taskNameHash
) {
- super(cctx, xidVer, implicit, implicitSingle, /*local*/true, sys, plc, concurrency, isolation, timeout,
- invalidate, storeEnabled, txSize, subjId, taskNameHash);
+ super(
+ cctx,
+ xidVer,
+ implicit,
+ implicitSingle,
+ /*local*/true,
+ sys,
+ plc,
+ concurrency,
+ isolation,
+ timeout,
+ invalidate,
+ storeEnabled,
+ onePhaseCommit,
+ txSize,
+ subjId,
+ taskNameHash
+ );
minVer = xidVer;
}
@@ -986,6 +1003,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
log.debug("Ignoring READ entry when committing: " + txEntry);
}
else {
+ assert ownsLock(txEntry.cached()):
+ "Transaction does not own lock for group lock entry during commit [tx=" +
+ this + ", txEntry=" + txEntry + ']';
+
if (conflictCtx == null || !conflictCtx.isUseOld()) {
if (txEntry.ttl() != CU.TTL_NOT_CHANGED)
cached.updateTtl(null, txEntry.ttl());
@@ -1085,14 +1106,17 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
/**
* Commits transaction to transaction manager. Used for one-phase commit transactions only.
*/
- public void tmCommit() {
+ public void tmFinish(boolean commit) {
assert onePhaseCommit();
if (doneFlag.compareAndSet(false, true)) {
// Unlock all locks.
- cctx.tm().commitTx(this);
+ if (commit)
+ cctx.tm().commitTx(this);
+ else
+ cctx.tm().rollbackTx(this);
- state(COMMITTED);
+ state(commit ? COMMITTED : ROLLED_BACK);
boolean needsCompletedVersions = needsCompletedVersions();
@@ -1386,7 +1410,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
null,
skipStore);
-
// As optimization, mark as checked immediately
// for non-pessimistic if value is not null.
if (val != null && !pessimistic())
@@ -3785,4 +3808,4 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
*/
abstract T finish(T t) throws IgniteCheckedException;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index b28225d..4074eee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -415,7 +415,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
TransactionIsolation isolation,
long timeout,
boolean storeEnabled,
- int txSize) {
+ int txSize
+ ) {
assert sysCacheCtx == null || sysCacheCtx.systemTx();
UUID subjId = null; // TODO GG-9141 how to get subj ID?
@@ -692,7 +693,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
/**
* @return Any transaction associated with the current thread.
*/
- public IgniteInternalTx anyActiveThreadTx() {
+ public IgniteInternalTx anyActiveThreadTx(IgniteInternalTx ignore) {
long threadId = Thread.currentThread().getId();
IgniteInternalTx tx = threadMap.get(threadId);
@@ -706,7 +707,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
tx = sysThreadMap.get(new TxThreadKey(threadId, cacheCtx.cacheId()));
- if (tx != null && tx.topologyVersionSnapshot() != null)
+ if (tx != null && tx != ignore && tx.topologyVersionSnapshot() != null)
return tx;
}
@@ -1067,7 +1068,12 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @return If transaction was not already present in committed set.
*/
public boolean addCommittedTx(IgniteInternalTx tx) {
- return addCommittedTx(tx.xidVersion(), tx.nearXidVersion());
+ boolean res = addCommittedTx(tx.xidVersion(), tx.nearXidVersion());
+
+ if (!tx.local() && !tx.near() && tx.onePhaseCommit())
+ addCommittedTx(tx.nearXidVersion(), null);
+
+ return res;
}
/**
@@ -1261,9 +1267,12 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (!((committed != null && committed) || tx.writeSet().isEmpty() || tx.isSystemInvalidate())) {
uncommitTx(tx);
+ GridCacheVersion first = completedVers.isEmpty() ? null : completedVers.firstKey();
+ GridCacheVersion last = completedVers.isEmpty() ? null : completedVers.lastKey();
+
throw new IgniteException("Missing commit version (consider increasing " +
IGNITE_MAX_COMPLETED_TX_COUNT + " system property) [ver=" + tx.xidVersion() + ", firstVer=" +
- completedVers.firstKey() + ", lastVer=" + completedVers.lastKey() + ", tx=" + tx.xid() + ']');
+ first + ", lastVer=" + last + ", tx=" + tx.xid() + ']');
}
ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx);
@@ -1786,13 +1795,13 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
- * @param ver Version.
+ * @param xidVer Version.
* @return Future for flag indicating if transactions was committed.
*/
- public IgniteInternalFuture<Boolean> txCommitted(GridCacheVersion ver) {
+ public IgniteInternalFuture<Boolean> txCommitted(GridCacheVersion xidVer) {
final GridFutureAdapter<Boolean> resFut = new GridFutureAdapter<>();
- final IgniteInternalTx tx = cctx.tm().tx(ver);
+ final IgniteInternalTx tx = cctx.tm().tx(xidVer);
if (tx != null) {
assert tx.near() && tx.local() : tx;
@@ -1814,7 +1823,22 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
return resFut;
}
- Boolean committed = completedVers.get(ver);
+ Boolean committed = null;
+
+ for (Map.Entry<GridCacheVersion, Boolean> entry : completedVers.entrySet()) {
+ if (entry.getValue() == null)
+ continue;
+
+ if (entry.getKey() instanceof CommittedVersion) {
+ CommittedVersion comm = (CommittedVersion)entry.getKey();
+
+ if (comm.nearVer.equals(xidVer)) {
+ committed = entry.getValue();
+
+ break;
+ }
+ }
+ }
if (log.isDebugEnabled())
log.debug("Near transaction committed: " + committed);
@@ -2030,9 +2054,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
try {
cctx.kernalContext().gateway().readLock();
}
- catch (IllegalStateException | IgniteClientDisconnectedException ignore) {
+ catch (IllegalStateException | IgniteClientDisconnectedException e) {
if (log.isDebugEnabled())
- log.debug("Failed to acquire kernal gateway [err=" + ignore + ']');
+ log.debug("Failed to acquire kernal gateway [err=" + e + ']');
return;
}
@@ -2213,4 +2237,4 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 0025f6bf..a5561e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -492,18 +492,28 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
if (!create)
return c.applyx();
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
- err = utilityCache.invoke(DATA_STRUCTURES_KEY, new AddAtomicProcessor(dsInfo)).get();
+ while (true) {
+ try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ err = utilityCache.invoke(DATA_STRUCTURES_KEY, new AddAtomicProcessor(dsInfo)).get();
- if (err != null)
- throw err;
+ if (err != null)
+ throw err;
- dataStructure = c.applyx();
+ dataStructure = c.applyx();
- tx.commit();
- }
+ tx.commit();
+
+ return dataStructure;
+ }
+ catch (ClusterTopologyCheckedException e) {
+ IgniteInternalFuture<?> fut = e.retryReadyFuture();
- return dataStructure;
+ fut.get();
+ }
+ catch (IgniteTxRollbackCheckedException ignore) {
+ // Safe to retry right away.
+ }
+ }
}
/**
@@ -559,31 +569,39 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
if (err != null)
throw err;
- T rmvInfo;
+ while (true) {
+ try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ T2<Boolean, IgniteCheckedException> res =
+ utilityCache.invoke(DATA_STRUCTURES_KEY, new RemoveDataStructureProcessor(dsInfo)).get();
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
- T2<Boolean, IgniteCheckedException> res =
- utilityCache.invoke(DATA_STRUCTURES_KEY, new RemoveDataStructureProcessor(dsInfo)).get();
+ err = res.get2();
- err = res.get2();
+ if (err != null)
+ throw err;
- if (err != null)
- throw err;
+ assert res.get1() != null;
- assert res.get1() != null;
+ boolean exists = res.get1();
- boolean exists = res.get1();
+ if (!exists)
+ return;
- if (!exists)
- return;
+ T rmvInfo = c.applyx();
- rmvInfo = c.applyx();
+ tx.commit();
- tx.commit();
- }
+ if (afterRmv != null && rmvInfo != null)
+ afterRmv.applyx(rmvInfo);
+ }
+ catch (ClusterTopologyCheckedException e) {
+ IgniteInternalFuture<?> fut = e.retryReadyFuture();
- if (afterRmv != null && rmvInfo != null)
- afterRmv.applyx(rmvInfo);
+ fut.get();
+ }
+ catch (IgniteTxRollbackCheckedException ignore) {
+ // Safe to retry right away.
+ }
+ }
}
/**
@@ -953,27 +971,35 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return c.applyx(cacheCtx);
}
- T col;
+ while (true) {
+ try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ T2<String, IgniteCheckedException> res =
+ utilityCache.invoke(DATA_STRUCTURES_KEY, new AddCollectionProcessor(dsInfo)).get();
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
- T2<String, IgniteCheckedException> res =
- utilityCache.invoke(DATA_STRUCTURES_KEY, new AddCollectionProcessor(dsInfo)).get();
+ err = res.get2();
- err = res.get2();
+ if (err != null)
+ throw err;
- if (err != null)
- throw err;
+ String cacheName = res.get1();
- String cacheName = res.get1();
+ final GridCacheContext cacheCtx = ctx.cache().internalCache(cacheName).context();
- final GridCacheContext cacheCtx = ctx.cache().internalCache(cacheName).context();
+ T col = c.applyx(cacheCtx);
- col = c.applyx(cacheCtx);
+ tx.commit();
- tx.commit();
- }
+ return col;
+ }
+ catch (ClusterTopologyCheckedException e) {
+ IgniteInternalFuture<?> fut = e.retryReadyFuture();
- return col;
+ fut.get();
+ }
+ catch (IgniteTxRollbackCheckedException ignore) {
+ // Safe to retry right away.
+ }
+ }
}
/**
@@ -2060,4 +2086,4 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return S.toString(RemoveDataStructureProcessor.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
index 94cbfbd..c7750a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
@@ -22,19 +22,22 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteQueue;
import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.TransactionRollbackException;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
- * {@link org.apache.ignite.IgniteQueue} implementation using transactional cache.
+ * {@link IgniteQueue} implementation using transactional cache.
*/
public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T> {
/**
@@ -76,7 +79,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
break;
}
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException | TransactionRollbackException | IgniteTxRollbackCheckedException e) {
if (e instanceof ClusterGroupEmptyCheckedException)
throw e;
@@ -123,14 +126,14 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
break;
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException | TransactionRollbackException | IgniteTxRollbackCheckedException e) {
if (e instanceof ClusterGroupEmptyCheckedException)
throw e;
if (cnt++ == MAX_UPDATE_RETRIES)
throw e;
else {
- U.warn(log, "Failed to add item, will retry [err=" + e + ']');
+ U.warn(log, "Failed to poll item, will retry [err=" + e + ']');
U.sleep(RETRY_DELAY);
}
@@ -180,7 +183,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
break;
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException | TransactionRollbackException | IgniteTxRollbackCheckedException e) {
if (e instanceof ClusterGroupEmptyCheckedException)
throw e;
@@ -223,7 +226,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
break;
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException | TransactionRollbackException | IgniteTxRollbackCheckedException e) {
if (e instanceof ClusterGroupEmptyCheckedException)
throw e;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
index 5f083b6..9cf1da4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
@@ -274,7 +274,6 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
writer.incrementState();
case 1:
- // The field 'done' was removed, but its writing preserved for compatibility reasons.
if (!writer.writeBoolean("done", done))
return false;
@@ -320,7 +319,6 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
reader.incrementState();
case 1:
- // field 'done' was removed, but reading preserved for compatibility reasons.
done = reader.readBoolean("done");
if (!reader.isLastRead())
@@ -371,4 +369,4 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
@Override public String toString() {
return S.toString(IgfsFileAffinityRange.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index 9054297..fa3c9a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -148,6 +148,8 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testNoConfiguration() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1377");
+
portables().toPortable(new TestObject3());
assertNotNull(portables().metadata(TestObject3.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java
index 0f16862..9c4b7b2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java
@@ -26,6 +26,7 @@ import javax.cache.configuration.Factory;
import javax.cache.integration.CacheLoaderException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.store.CacheStore;
@@ -104,6 +105,7 @@ public abstract class CacheStoreUsageMultinodeAbstractTest extends GridCommonAbs
ccfg.setCacheMode(PARTITIONED);
ccfg.setAtomicityMode(atomicityMode());
+ ccfg.setAtomicWriteOrderMode(CacheAtomicWriteOrderMode.PRIMARY);
ccfg.setBackups(1);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
@@ -220,10 +222,16 @@ public abstract class CacheStoreUsageMultinodeAbstractTest extends GridCommonAbs
Transaction tx = tc != null ? ignite.transactions().txStart(tc, REPEATABLE_READ) : null;
- cache.put(key, key);
+ try {
+ cache.put(key, key);
- if (tx != null)
- tx.commit();
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
@@ -310,4 +318,4 @@ public abstract class CacheStoreUsageMultinodeAbstractTest extends GridCommonAbs
// No-op.
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index faebcfe..3e646d3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -64,6 +64,7 @@ import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
@@ -2866,6 +2867,53 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @param keys0 Keys to check.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected void checkUnlocked(final Collection<String> keys0) throws IgniteCheckedException {
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ try {
+ for (int i = 0; i < gridCount(); i++) {
+ GridCacheAdapter<Object, Object> cache = ((IgniteKernal)ignite(i)).internalCache();
+
+ for (String key : keys0) {
+ GridCacheEntryEx entry = cache.peekEx(key);
+
+ if (entry != null) {
+ if (entry.lockedByAny()) {
+ info("Entry is still locked [i=" + i + ", entry=" + entry + ']');
+
+ return false;
+ }
+ }
+
+ if (cache.isNear()) {
+ entry = cache.context().near().dht().peekEx(key);
+
+ if (entry != null) {
+ if (entry.lockedByAny()) {
+ info("Entry is still locked [i=" + i + ", entry=" + entry + ']');
+
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ info("Entry was removed, will retry");
+
+ return false;
+ }
+ }
+ }, 10_000);
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testGlobalClearAll() throws Exception {
@@ -5173,4 +5221,4 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** */
ONE_BY_ONE
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
index f2bb8fa..cdf8eca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
@@ -1650,7 +1650,7 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
* @param vers Ordered versions.
*/
private void checkOrder(Collection<GridCacheMvccCandidate> cands, GridCacheVersion... vers) {
- assert cands.size() == vers.length;
+ assertEquals(vers.length, cands.size());
int i = 0;
@@ -1841,4 +1841,4 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
for (GridCacheMvccCandidate c : cands)
info(">>> " + c);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
index 26911a3..b401907 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
@@ -358,6 +358,32 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
info(">>> Absent keys: " + absentKeys);
+ if (!F.isEmpty(absentKeys)) {
+ for (Ignite g : runningWorkers) {
+ IgniteKernal k = (IgniteKernal)g;
+
+ info(">>>> Entries on node: " + k.getLocalNodeId());
+
+ GridCacheAdapter<Object, Object> cache = k.internalCache("partitioned");
+
+ for (Integer key : absentKeys) {
+ GridCacheEntryEx entry = cache.peekEx(key);
+
+ if (entry != null)
+ info(" >>> " + entry);
+
+ if (cache.context().isNear()) {
+ GridCacheEntryEx entry0 = cache.context().near().dht().peekEx(key);
+
+ if (entry0 != null)
+ info(" >>> " + entry);
+ }
+ }
+
+ info("");
+ }
+ }
+
assertTrue(absentKeys.isEmpty());
// Actual primary cache size.
@@ -746,4 +772,4 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
return failedOverJobs;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1707b68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
index c5ad4ec..fc14085 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
@@ -161,6 +161,8 @@ public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest {
final Ignite ignite = ignite(node);
+ info("Running iteration on the node [idx=" + node + ", nodeId=" + ignite.cluster().localNode().id() + ']');
+
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
Thread.currentThread().setName("put-thread");
[26/28] ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-1.4' into ignite-971
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.4' into ignite-971
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/716972fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/716972fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/716972fe
Branch: refs/heads/ignite-971
Commit: 716972fed892b73970666ced118dd3183004421f
Parents: ee0041f d076622
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 14 10:09:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 14 10:09:20 2015 +0300
----------------------------------------------------------------------
examples/config/platform/cpp/example-cache.xml | 87 -
modules/clients/pom.xml | 7 +
modules/clients/src/test/config/jdbc-config.xml | 55 +
.../jdbc2/JdbcComplexQuerySelfTest.java | 316 ++++
.../internal/jdbc2/JdbcConnectionSelfTest.java | 268 +++
.../internal/jdbc2/JdbcEmptyCacheSelfTest.java | 140 ++
.../internal/jdbc2/JdbcLocalCachesSelfTest.java | 156 ++
.../internal/jdbc2/JdbcMetadataSelfTest.java | 334 ++++
.../jdbc2/JdbcPreparedStatementSelfTest.java | 730 +++++++++
.../internal/jdbc2/JdbcResultSetSelfTest.java | 751 +++++++++
.../internal/jdbc2/JdbcStatementSelfTest.java | 292 ++++
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 11 +
.../org/apache/ignite/IgniteJdbcDriver.java | 281 +++-
.../apache/ignite/IgniteSystemProperties.java | 5 +-
.../configuration/CacheConfiguration.java | 41 +-
.../ignite/configuration/TopologyValidator.java | 24 +-
.../ignite/internal/jdbc/JdbcConnection.java | 4 +
.../internal/jdbc/JdbcConnectionInfo.java | 91 --
.../internal/jdbc/JdbcDatabaseMetadata.java | 4 +
.../internal/jdbc/JdbcPreparedStatement.java | 4 +
.../ignite/internal/jdbc/JdbcResultSet.java | 4 +
.../internal/jdbc/JdbcResultSetMetadata.java | 4 +
.../ignite/internal/jdbc/JdbcStatement.java | 4 +
.../apache/ignite/internal/jdbc/JdbcUtils.java | 4 +
.../ignite/internal/jdbc2/JdbcConnection.java | 777 +++++++++
.../internal/jdbc2/JdbcDatabaseMetadata.java | 1401 ++++++++++++++++
.../internal/jdbc2/JdbcPreparedStatement.java | 411 +++++
.../ignite/internal/jdbc2/JdbcQueryTask.java | 361 +++++
.../ignite/internal/jdbc2/JdbcResultSet.java | 1520 ++++++++++++++++++
.../internal/jdbc2/JdbcResultSetMetadata.java | 171 ++
.../ignite/internal/jdbc2/JdbcStatement.java | 456 ++++++
.../apache/ignite/internal/jdbc2/JdbcUtils.java | 155 ++
.../internal/portable/PortableContext.java | 24 +-
.../internal/portable/PortableReaderExImpl.java | 3 -
.../processors/cache/GridCacheAdapter.java | 6 +
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheIoManager.java | 4 +-
.../processors/cache/GridCacheMvcc.java | 5 +-
.../distributed/GridCacheTxRecoveryFuture.java | 11 +-
.../distributed/GridDistributedCacheEntry.java | 6 +-
.../GridDistributedTxFinishRequest.java | 13 +-
.../GridDistributedTxRemoteAdapter.java | 10 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 514 +++---
.../distributed/dht/GridDhtTxFinishFuture.java | 15 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 84 +-
.../dht/GridDhtTxFinishResponse.java | 89 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 4 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 67 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 32 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 40 +-
.../dht/GridPartitionedGetFuture.java | 4 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 4 +-
.../colocated/GridDhtColocatedLockFuture.java | 11 +-
.../distributed/near/GridNearLockFuture.java | 11 +-
.../distributed/near/GridNearLockRequest.java | 18 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 52 +-
.../GridNearPessimisticTxPrepareFuture.java | 11 +-
.../near/GridNearTxFinishFuture.java | 319 +++-
.../near/GridNearTxFinishRequest.java | 20 +-
.../cache/distributed/near/GridNearTxLocal.java | 64 +-
.../distributed/near/GridNearTxRemote.java | 38 +-
.../cache/transactions/IgniteTxAdapter.java | 5 +-
.../cache/transactions/IgniteTxHandler.java | 281 ++--
.../transactions/IgniteTxLocalAdapter.java | 37 +-
.../cache/transactions/IgniteTxManager.java | 48 +-
.../datastructures/DataStructuresProcessor.java | 102 +-
.../GridTransactionalCacheQueueImpl.java | 15 +-
.../processors/igfs/IgfsFileAffinityRange.java | 4 +-
.../dotnet/PlatformDotNetConfiguration.java | 119 ++
.../PlatformDotNetPortableConfiguration.java | 228 +++
...PlatformDotNetPortableTypeConfiguration.java | 248 +++
.../util/GridSpiCloseableIteratorWrapper.java | 5 +
.../dotnet/PlatformDotNetConfiguration.java | 119 --
.../PlatformDotNetPortableConfiguration.java | 228 ---
...PlatformDotNetPortableTypeConfiguration.java | 248 ---
.../resources/META-INF/classnames.properties | 12 +-
...idPortableMarshallerCtxDisabledSelfTest.java | 168 +-
.../GridPortableMarshallerSelfTest.java | 1 -
.../portable/GridPortableMetaDataSelfTest.java | 2 +
.../CacheStoreUsageMultinodeAbstractTest.java | 16 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 50 +-
.../processors/cache/GridCacheMvccSelfTest.java | 4 +-
.../cache/GridCacheP2PUndeploySelfTest.java | 30 +-
.../cache/GridCachePutAllFailoverSelfTest.java | 28 +-
.../GridCacheVariableTopologySelfTest.java | 5 +-
.../cache/IgniteCachePutAllRestartTest.java | 2 +
.../cache/IgniteInternalCacheTypesTest.java | 4 +-
.../cache/IgniteOnePhaseCommitNearSelfTest.java | 243 +++
.../IgniteTxExceptionAbstractSelfTest.java | 29 +-
...dCachePartitionedQueueEntryMoveSelfTest.java | 191 +--
...ridCachePartitionNotLoadedEventSelfTest.java | 27 +-
.../GridCacheTransformEventSelfTest.java | 5 +-
.../GridCacheColocatedTxExceptionSelfTest.java | 2 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 400 +++++
.../dht/GridNearCacheTxNodeFailureSelfTest.java | 31 +
...gniteAtomicLongChangingTopologySelfTest.java | 283 ++++
.../near/GridCacheNearTxExceptionSelfTest.java | 2 +-
.../near/IgniteCacheNearOnlyTxTest.java | 14 +-
.../GridCacheReplicatedTxExceptionSelfTest.java | 2 +-
.../GridCacheLocalTxExceptionSelfTest.java | 2 +-
.../processors/igfs/IgfsStartCacheTest.java | 2 +-
.../IgniteCacheFailoverTestSuite.java | 9 +-
.../IgniteCacheReplicatedQuerySelfTest.java | 49 +-
.../PlatformDotNetConfigurationClosure.java | 1 -
.../dotnet/PlatformDotNetConfigurationEx.java | 1 -
.../platform/events/PlatformEvents.java | 2 +-
.../Cache/CacheAbstractTest.cs | 71 +-
.../Config/Compute/compute-standalone.xml | 8 +-
.../Config/cache-portables.xml | 4 +-
.../Config/cache-query.xml | 4 +-
.../native-client-test-cache-affinity.xml | 6 +-
.../ignite/schema/generator/CodeGenerator.java | 4 +-
.../ignite/schema/model/PojoDescriptor.java | 6 +-
.../parser/dialect/OracleMetadataDialect.java | 7 +-
.../yardstick/config/benchmark-query.properties | 5 +-
modules/yardstick/config/ignite-base-config.xml | 2 +-
modules/yardstick/config/ignite-jdbc-config.xml | 55 +
pom.xml | 10 +
118 files changed, 11898 insertions(+), 1940 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/716972fe/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
----------------------------------------------------------------------
[09/28] ignite git commit: ignite-257: fixed most of the test. Only
collocated and near tests are keep failing.
Posted by sb...@apache.org.
ignite-257: fixed most of the test. Only collocated and near tests are keep failing.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b5d85453
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b5d85453
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b5d85453
Branch: refs/heads/ignite-971
Commit: b5d8545341aeb2b58904a4d9b4405b608d53baee
Parents: e1707b6
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 11 10:16:50 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 11 10:16:50 2015 +0300
----------------------------------------------------------------------
.../IgniteTxExceptionAbstractSelfTest.java | 29 ++++++++++++++------
.../GridCacheColocatedTxExceptionSelfTest.java | 20 ++++++++++----
.../near/GridCacheNearTxExceptionSelfTest.java | 2 +-
.../GridCacheReplicatedTxExceptionSelfTest.java | 5 ----
.../GridCacheLocalTxExceptionSelfTest.java | 5 ----
5 files changed, 37 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5d85453/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
index bdbc004..10b47fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
@@ -26,7 +26,9 @@ import javax.cache.Cache;
import javax.cache.CacheException;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -64,7 +66,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
private static final int NOT_PRIMARY_AND_BACKUP = 2;
/** */
- private static Integer lastKey;
+ private static volatile Integer lastKey;
/** {@inheritDoc} */
@Override protected int gridCount() {
@@ -91,6 +93,8 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
ccfg.setWriteThrough(false);
ccfg.setLoadPreviousValue(true);
+ ccfg.setIndexedTypes(Integer.class, Integer.class);
+
return ccfg;
}
@@ -105,8 +109,18 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
@Override protected void afterTest() throws Exception {
idxSpi.forceFail(false);
- for (int key = 0; key < lastKey; key++)
+ Transaction tx = jcache().unwrap(Ignite.class).transactions().tx();
+
+ if (tx != null) {
+ tx.close();
+
+ fail("Cache transaction remained after test completion: " + tx);
+ }
+
+ for (int key = 0; key <= lastKey; key++)
grid(0).cache(null).remove(key);
+
+ assertEquals(0, jcache(0).size(CachePeekMode.ALL));
}
/** {@inheritDoc} */
@@ -367,7 +381,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
info("Check key: " + key);
for (int i = 0; i < gridCount(); i++) {
- IgniteKernal grid = (IgniteKernal) grid(i);
+ IgniteKernal grid = (IgniteKernal)grid(i);
GridCacheAdapter cache = grid.internalCache(null);
@@ -383,9 +397,8 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
log.info("Dht entry: " + entry);
- if (entry != null) {
+ if (entry != null)
assertFalse("Unexpected entry for grid [i=" + i + ", entry=" + entry + ']', entry.lockedByAny());
- }
}
}
}
@@ -459,7 +472,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
}
}, CacheException.class, null);
- assertTrue("Unexpected cause: " +e, e.getCause() instanceof TransactionHeuristicException);
+ assertTrue("Unexpected cause: " + e, e.getCause() instanceof TransactionHeuristicException);
checkUnlocked(key);
}
@@ -469,7 +482,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
* @param keys Keys.
* @throws Exception If failed.
*/
- private void checkPutAll(boolean putBefore, Integer ... keys) throws Exception {
+ private void checkPutAll(boolean putBefore, Integer... keys) throws Exception {
assert keys.length > 1;
if (putBefore) {
@@ -616,7 +629,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
}
/** {@inheritDoc} */
- @Override public Iterator<Cache.Entry<?,?>> query(@Nullable String spaceName, Collection<Object> params,
+ @Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String spaceName, Collection<Object> params,
@Nullable IndexingQueryFilter filters) throws IgniteSpiException {
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5d85453/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
index 5c1435f..86f32f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
@@ -28,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-257");
- }
-
- /** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return PARTITIONED;
}
@@ -41,4 +36,19 @@ public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbst
@Override protected NearCacheConfiguration nearConfiguration() {
return null;
}
+
+ /** {@inheritDoc} */
+ @Override public void testRemovePrimary() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testPutPrimary() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testTransformPrimary() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5d85453/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
index 4cb47f4..67bccac 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
@@ -27,7 +27,7 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
+ @Override protected void beforeTestsStarted() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5d85453/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
index fa74043..1c96a4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
@@ -28,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
*/
public class GridCacheReplicatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-257");
- }
-
- /** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5d85453/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
index a112462..63a900d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
@@ -27,11 +27,6 @@ import static org.apache.ignite.cache.CacheMode.LOCAL;
*/
public class GridCacheLocalTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-257");
- }
-
- /** {@inheritDoc} */
@Override protected int gridCount() {
return 1;
}
[16/28] ignite git commit: Fixed IGFS test which failed because of
incorrect GridCacheContext.systemTx() assertion.
Posted by sb...@apache.org.
Fixed IGFS test which failed because of incorrect GridCacheContext.systemTx() assertion.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cbc8877a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cbc8877a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cbc8877a
Branch: refs/heads/ignite-971
Commit: cbc8877acc3f5c86aa4320dc60c3d4de64c9d9dd
Parents: 82ca431
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 11 14:44:53 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 11 14:44:53 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc8877a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
index f6a7a72..56559cb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
@@ -157,7 +157,7 @@ public class IgfsStartCacheTest extends IgfsCommonAbstractTest {
private void checkCache(GridCacheAdapter cache) {
assertNotNull(cache);
assertFalse(cache.context().userCache());
- assertFalse(cache.context().systemTx());
+ assertTrue(cache.context().systemTx());
assertEquals(SYSTEM_POOL, cache.context().ioPolicy());
}
}
\ No newline at end of file
[22/28] ignite git commit: ignite-1250 JDBC driver: migration to
embedded Ignite client node
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java
new file mode 100644
index 0000000..7898bc8
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java
@@ -0,0 +1,292 @@
+/*
+ * 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.jdbc2;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Statement test.
+ */
+public class JdbcStatementSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** JDBC URL. */
+ private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
+
+ /** SQL query. */
+ private static final String SQL = "select * from Person where age > 30";
+
+ /** Connection. */
+ private Connection conn;
+
+ /** Statement. */
+ private Statement stmt;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<?,?> cache = defaultCacheConfiguration();
+
+ cache.setCacheMode(PARTITIONED);
+ cache.setBackups(1);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setIndexedTypes(
+ String.class, Person.class
+ );
+
+ cfg.setCacheConfiguration(cache);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ IgniteCache<String, Person> cache = grid(0).cache(null);
+
+ assert cache != null;
+
+ cache.put("p1", new Person(1, "John", "White", 25));
+ cache.put("p2", new Person(2, "Joe", "Black", 35));
+ cache.put("p3", new Person(3, "Mike", "Green", 40));
+
+ Class.forName("org.apache.ignite.IgniteJdbcDriver");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ conn = DriverManager.getConnection(BASE_URL);
+ stmt = conn.createStatement();
+
+ assertNotNull(stmt);
+ assertFalse(stmt.isClosed());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ if (stmt != null && !stmt.isClosed())
+ stmt.close();
+
+ conn.close();
+
+ assertTrue(stmt.isClosed());
+ assertTrue(conn.isClosed());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExecuteQuery() throws Exception {
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt("id");
+
+ if (id == 2) {
+ assert "Joe".equals(rs.getString("firstName"));
+ assert "Black".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 35;
+ }
+ else if (id == 3) {
+ assert "Mike".equals(rs.getString("firstName"));
+ assert "Green".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 40;
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 2;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExecute() throws Exception {
+ assert stmt.execute(SQL);
+
+ ResultSet rs = stmt.getResultSet();
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt("id");
+
+ if (id == 2) {
+ assert "Joe".equals(rs.getString("firstName"));
+ assert "Black".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 35;
+ }
+ else if (id == 3) {
+ assert "Mike".equals(rs.getString("firstName"));
+ assert "Green".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 40;
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 2;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMaxRows() throws Exception {
+ stmt.setMaxRows(1);
+
+ ResultSet rs = stmt.executeQuery(SQL);
+
+ assert rs != null;
+
+ int cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt("id");
+
+ if (id == 2) {
+ assert "Joe".equals(rs.getString("firstName"));
+ assert "Black".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 35;
+ }
+ else if (id == 3) {
+ assert "Mike".equals(rs.getString("firstName"));
+ assert "Green".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 40;
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 1;
+
+ stmt.setMaxRows(0);
+
+ rs = stmt.executeQuery(SQL);
+
+ assert rs != null;
+
+ cnt = 0;
+
+ while (rs.next()) {
+ int id = rs.getInt("id");
+
+ if (id == 2) {
+ assert "Joe".equals(rs.getString("firstName"));
+ assert "Black".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 35;
+ }
+ else if (id == 3) {
+ assert "Mike".equals(rs.getString("firstName"));
+ assert "Green".equals(rs.getString("lastName"));
+ assert rs.getInt("age") == 40;
+ }
+ else
+ assert false : "Wrong ID: " + id;
+
+ cnt++;
+ }
+
+ assert cnt == 2;
+ }
+
+ /**
+ * Person.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Person implements Serializable {
+ /** ID. */
+ @QuerySqlField
+ private final int id;
+
+ /** First name. */
+ @QuerySqlField(index = false)
+ private final String firstName;
+
+ /** Last name. */
+ @QuerySqlField(index = false)
+ private final String lastName;
+
+ /** Age. */
+ @QuerySqlField
+ private final int age;
+
+ /**
+ * @param id ID.
+ * @param firstName First name.
+ * @param lastName Last name.
+ * @param age Age.
+ */
+ private Person(int id, String firstName, String lastName, int age) {
+ assert !F.isEmpty(firstName);
+ assert !F.isEmpty(lastName);
+ assert age > 0;
+
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/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 b0c0c58..bac2f60 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
@@ -38,6 +38,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite("Ignite JDBC Driver Test Suite");
+ // Thin client based driver tests
suite.addTest(new TestSuite(JdbcConnectionSelfTest.class));
suite.addTest(new TestSuite(JdbcStatementSelfTest.class));
suite.addTest(new TestSuite(JdbcPreparedStatementSelfTest.class));
@@ -47,6 +48,16 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
suite.addTest(new TestSuite(JdbcEmptyCacheSelfTest.class));
suite.addTest(new TestSuite(JdbcLocalCachesSelfTest.class));
+ // Ignite client node based driver tests
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcConnectionSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStatementSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcPreparedStatementSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcResultSetSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcComplexQuerySelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcMetadataSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcEmptyCacheSelfTest.class));
+ suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcLocalCachesSelfTest.class));
+
return suite;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
index 6ba362e..7f8b523 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
@@ -17,17 +17,19 @@
package org.apache.ignite;
-
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
+import java.util.Arrays;
+import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
import org.apache.ignite.cache.affinity.AffinityKey;
import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.apache.ignite.logger.java.JavaLogger;
/**
* JDBC driver implementation for In-Memory Data Grid.
@@ -66,8 +68,47 @@ import org.apache.ignite.internal.jdbc.JdbcConnection;
* {@code IGNITE_HOME/libs} folder. So if you are using JDBC driver in any external tool,
* you have to add main Ignite JAR will all dependencies to its classpath.
* <h1 class="header">Configuration</h1>
- * Internally JDBC driver <b>is based on Ignite Java client</b>. Therefore, all client
- * configuration properties can be applied to JDBC connection.
+ *
+ * JDBC driver can return two different types of connection: Ignite Java client based connection and
+ * Ignite client node based connection. Java client best connection is deprecated and left only for
+ * compatibility with previous version, so you should always use Ignite client node based mode.
+ * It is also preferable because it has much better performance.
+ *
+ * The type of returned connection depends on provided JDBC connection URL.
+ *
+ * <h2 class="header">Configuration of Ignite client node based connection</h2>
+ *
+ * JDBC connection URL has the following pattern: {@code jdbc:ignite:cfg://[<params>@]<config_url>}.<br>
+ *
+ * {@code <config_url>} represents any valid URL which points to Ignite configuration file. It is required.<br>
+ *
+ * {@code <params>} are optional and have the following format: {@code param1=value1:param2=value2:...:paramN=valueN}.<br>
+ *
+ * The following parameters are supported:
+ * <ul>
+ * <li>{@code cache} - cache name. If it is not defined than default cache will be used.</li>
+ * <li>
+ * {@code nodeId} - ID of node where query will be executed.
+ * It can be useful for querying through local caches.
+ * If node with provided ID doesn't exist, exception is thrown.
+ * </li>
+ * <li>
+ * {@code local} - query will be executed only on local node. Use this parameter with {@code nodeId} parameter.
+ * Default value is {@code false}.
+ * </li>
+ * <li>
+ * {@code collocated} - flag that used for optimization purposes. Whenever Ignite executes
+ * a distributed query, it sends sub-queries to individual cluster members.
+ * If you know in advance that the elements of your query selection are collocated
+ * together on the same node, usually based on some <b>affinity-key</b>, Ignite
+ * can make significant performance and network optimizations.
+ * Default value is {@code false}.
+ * </li>
+ * </ul>
+ *
+ * <h2 class="header">Configuration of Ignite Java client based connection</h2>
+ *
+ * All Ignite Java client configuration properties can be applied to JDBC connection of this type.
* <p>
* JDBC connection URL has the following pattern:
* {@code jdbc:ignite://<hostname>:<port>/<cache_name>?nodeId=<UUID>}<br>
@@ -197,10 +238,10 @@ import org.apache.ignite.internal.jdbc.JdbcConnection;
* <h1 class="header">Example</h1>
* <pre name="code" class="java">
* // Register JDBC driver.
- * Class.forName("org.apache.ignite.jdbc.IgniteJdbcDriver");
+ * Class.forName("org.apache.ignite.IgniteJdbcDriver");
*
* // Open JDBC connection.
- * Connection conn = DriverManager.getConnection("jdbc:ignite://localhost/cache");
+ * Connection conn = DriverManager.getConnection("jdbc:ignite:cfg//cache=persons@file:///etc/configs/ignite-jdbc.xml");
*
* // Query persons' names
* ResultSet rs = conn.createStatement().executeQuery("select name from Person");
@@ -231,6 +272,18 @@ public class IgniteJdbcDriver implements Driver {
/** Prefix for property names. */
private static final String PROP_PREFIX = "ignite.jdbc.";
+ /** Node ID parameter name. */
+ private static final String PARAM_NODE_ID = "nodeId";
+
+ /** Cache parameter name. */
+ private static final String PARAM_CACHE = "cache";
+
+ /** Local parameter name. */
+ private static final String PARAM_LOCAL = "local";
+
+ /** Collocated parameter name. */
+ private static final String PARAM_COLLOCATED = "collocated";
+
/** Hostname property name. */
public static final String PROP_HOST = PROP_PREFIX + "host";
@@ -238,14 +291,26 @@ public class IgniteJdbcDriver implements Driver {
public static final String PROP_PORT = PROP_PREFIX + "port";
/** Cache name property name. */
- public static final String PROP_CACHE = PROP_PREFIX + "cache";
+ public static final String PROP_CACHE = PROP_PREFIX + PARAM_CACHE;
/** Node ID property name. */
- public static final String PROP_NODE_ID = PROP_PREFIX + "nodeId";
+ public static final String PROP_NODE_ID = PROP_PREFIX + PARAM_NODE_ID;
+
+ /** Local property name. */
+ public static final String PROP_LOCAL = PROP_PREFIX + PARAM_LOCAL;
+
+ /** Collocated property name. */
+ public static final String PROP_COLLOCATED = PROP_PREFIX + PARAM_COLLOCATED;
+
+ /** Cache name property name. */
+ public static final String PROP_CFG = PROP_PREFIX + "cfg";
/** URL prefix. */
public static final String URL_PREFIX = "jdbc:ignite://";
+ /** Config URL prefix. */
+ public static final String CFG_URL_PREFIX = "jdbc:ignite:cfg://";
+
/** Default port. */
public static final int DFLT_PORT = 11211;
@@ -255,6 +320,9 @@ public class IgniteJdbcDriver implements Driver {
/** Minor version. */
private static final int MINOR_VER = 0;
+ /** Logger. */
+ private static final IgniteLogger LOG = new JavaLogger();
+
/**
* Register driver.
*/
@@ -272,12 +340,19 @@ public class IgniteJdbcDriver implements Driver {
if (!parseUrl(url, props))
throw new SQLException("URL is invalid: " + url);
- return new JdbcConnection(url, props);
+ if (url.startsWith(URL_PREFIX)) {
+ if (props.getProperty(PROP_CFG) != null)
+ LOG.warning(PROP_CFG + " property is not applicable for this URL.");
+
+ return new JdbcConnection(url, props);
+ }
+ else
+ return new org.apache.ignite.internal.jdbc2.JdbcConnection(url, props);
}
/** {@inheritDoc} */
@Override public boolean acceptsURL(String url) throws SQLException {
- return url.startsWith(URL_PREFIX);
+ return url.startsWith(URL_PREFIX) || url.startsWith(CFG_URL_PREFIX);
}
/** {@inheritDoc} */
@@ -285,49 +360,72 @@ public class IgniteJdbcDriver implements Driver {
if (!parseUrl(url, info))
throw new SQLException("URL is invalid: " + url);
- DriverPropertyInfo[] props = new DriverPropertyInfo[20];
-
- props[0] = new PropertyInfo("Hostname", info.getProperty(PROP_HOST), true);
- props[1] = new PropertyInfo("Port number", info.getProperty(PROP_PORT), "");
- props[2] = new PropertyInfo("Cache name", info.getProperty(PROP_CACHE), "");
- props[3] = new PropertyInfo("Node ID", info.getProperty(PROP_NODE_ID, ""));
- props[4] = new PropertyInfo("ignite.client.protocol", info.getProperty("ignite.client.protocol", "TCP"),
- "Communication protocol (TCP or HTTP).");
- props[5] = new PropertyInfo("ignite.client.connectTimeout", info.getProperty("ignite.client.connectTimeout", "0"),
- "Socket connection timeout.");
- props[6] = new PropertyInfo("ignite.client.tcp.noDelay", info.getProperty("ignite.client.tcp.noDelay", "true"),
- "Flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections.");
- props[7] = new PropertyInfo("ignite.client.ssl.enabled", info.getProperty("ignite.client.ssl.enabled", "false"),
- "Flag indicating that SSL is needed for connection.");
- props[8] = new PropertyInfo("ignite.client.ssl.protocol", info.getProperty("ignite.client.ssl.protocol", "TLS"),
- "SSL protocol.");
- props[9] = new PropertyInfo("ignite.client.ssl.key.algorithm", info.getProperty("ignite.client.ssl.key.algorithm",
- "SunX509"), "Key manager algorithm.");
- props[10] = new PropertyInfo("ignite.client.ssl.keystore.location",
- info.getProperty("ignite.client.ssl.keystore.location", ""),
- "Key store to be used by client to connect with Ignite topology.");
- props[11] = new PropertyInfo("ignite.client.ssl.keystore.password",
- info.getProperty("ignite.client.ssl.keystore.password", ""), "Key store password.");
- props[12] = new PropertyInfo("ignite.client.ssl.keystore.type", info.getProperty("ignite.client.ssl.keystore.type",
- "jks"), "Key store type.");
- props[13] = new PropertyInfo("ignite.client.ssl.truststore.location",
- info.getProperty("ignite.client.ssl.truststore.location", ""),
- "Trust store to be used by client to connect with Ignite topology.");
- props[14] = new PropertyInfo("ignite.client.ssl.keystore.password",
- info.getProperty("ignite.client.ssl.truststore.password", ""), "Trust store password.");
- props[15] = new PropertyInfo("ignite.client.ssl.truststore.type", info.getProperty("ignite.client.ssl.truststore.type",
- "jks"), "Trust store type.");
- props[16] = new PropertyInfo("ignite.client.credentials", info.getProperty("ignite.client.credentials", ""),
- "Client credentials used in authentication process.");
- props[17] = new PropertyInfo("ignite.client.cache.top", info.getProperty("ignite.client.cache.top", "false"),
- "Flag indicating that topology is cached internally. Cache will be refreshed in the background with " +
- "interval defined by topologyRefreshFrequency property (see below).");
- props[18] = new PropertyInfo("ignite.client.topology.refresh", info.getProperty("ignite.client.topology.refresh",
- "2000"), "Topology cache refresh frequency (ms).");
- props[19] = new PropertyInfo("ignite.client.idleTimeout", info.getProperty("ignite.client.idleTimeout", "30000"),
- "Maximum amount of time that connection can be idle before it is closed (ms).");
-
- return props;
+ List<DriverPropertyInfo> props = Arrays.<DriverPropertyInfo>asList(
+ new PropertyInfo("Hostname", info.getProperty(PROP_HOST), ""),
+ new PropertyInfo("Port number", info.getProperty(PROP_PORT), ""),
+ new PropertyInfo("Cache name", info.getProperty(PROP_CACHE), ""),
+ new PropertyInfo("Node ID", info.getProperty(PROP_NODE_ID), ""),
+ new PropertyInfo("Local", info.getProperty(PROP_LOCAL), ""),
+ new PropertyInfo("Collocated", info.getProperty(PROP_COLLOCATED), "")
+ );
+
+ if (info.getProperty(PROP_CFG) != null)
+ props.add(new PropertyInfo("Configuration path", info.getProperty(PROP_CFG), ""));
+ else
+ props.addAll(Arrays.<DriverPropertyInfo>asList(
+ new PropertyInfo("ignite.client.protocol",
+ info.getProperty("ignite.client.protocol", "TCP"),
+ "Communication protocol (TCP or HTTP)."),
+ new PropertyInfo("ignite.client.connectTimeout",
+ info.getProperty("ignite.client.connectTimeout", "0"),
+ "Socket connection timeout."),
+ new PropertyInfo("ignite.client.tcp.noDelay",
+ info.getProperty("ignite.client.tcp.noDelay", "true"),
+ "Flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections."),
+ new PropertyInfo("ignite.client.ssl.enabled",
+ info.getProperty("ignite.client.ssl.enabled", "false"),
+ "Flag indicating that SSL is needed for connection."),
+ new PropertyInfo("ignite.client.ssl.protocol",
+ info.getProperty("ignite.client.ssl.protocol", "TLS"),
+ "SSL protocol."),
+ new PropertyInfo("ignite.client.ssl.key.algorithm",
+ info.getProperty("ignite.client.ssl.key.algorithm", "SunX509"),
+ "Key manager algorithm."),
+ new PropertyInfo("ignite.client.ssl.keystore.location",
+ info.getProperty("ignite.client.ssl.keystore.location", ""),
+ "Key store to be used by client to connect with Ignite topology."),
+ new PropertyInfo("ignite.client.ssl.keystore.password",
+ info.getProperty("ignite.client.ssl.keystore.password", ""),
+ "Key store password."),
+ new PropertyInfo("ignite.client.ssl.keystore.type",
+ info.getProperty("ignite.client.ssl.keystore.type", "jks"),
+ "Key store type."),
+ new PropertyInfo("ignite.client.ssl.truststore.location",
+ info.getProperty("ignite.client.ssl.truststore.location", ""),
+ "Trust store to be used by client to connect with Ignite topology."),
+ new PropertyInfo("ignite.client.ssl.keystore.password",
+ info.getProperty("ignite.client.ssl.truststore.password", ""),
+ "Trust store password."),
+ new PropertyInfo("ignite.client.ssl.truststore.type",
+ info.getProperty("ignite.client.ssl.truststore.type", "jks"),
+ "Trust store type."),
+ new PropertyInfo("ignite.client.credentials",
+ info.getProperty("ignite.client.credentials", ""),
+ "Client credentials used in authentication process."),
+ new PropertyInfo("ignite.client.cache.top",
+ info.getProperty("ignite.client.cache.top", "false"),
+ "Flag indicating that topology is cached internally. Cache will be refreshed in the " +
+ "background with interval defined by topologyRefreshFrequency property (see below)."),
+ new PropertyInfo("ignite.client.topology.refresh",
+ info.getProperty("ignite.client.topology.refresh", "2000"),
+ "Topology cache refresh frequency (ms)."),
+ new PropertyInfo("ignite.client.idleTimeout",
+ info.getProperty("ignite.client.idleTimeout", "30000"),
+ "Maximum amount of time that connection can be idle before it is closed (ms).")
+ )
+ );
+
+ return props.toArray(new DriverPropertyInfo[0]);
}
/** {@inheritDoc} */
@@ -358,9 +456,44 @@ public class IgniteJdbcDriver implements Driver {
* @return Whether URL is valid.
*/
private boolean parseUrl(String url, Properties props) {
- if (url == null || !url.startsWith(URL_PREFIX) || url.length() == URL_PREFIX.length())
+ if (url == null)
+ return false;
+
+ if (url.startsWith(URL_PREFIX) && url.length() > URL_PREFIX.length())
+ return parseJdbcUrl(url, props);
+ else if (url.startsWith(CFG_URL_PREFIX) && url.length() > CFG_URL_PREFIX.length())
+ return parseJdbcConfigUrl(url, props);
+
+ return false;
+ }
+
+ /**
+ * @param url Url.
+ * @param props Properties.
+ */
+ private boolean parseJdbcConfigUrl(String url, Properties props) {
+ url = url.substring(CFG_URL_PREFIX.length());
+
+ String[] parts = url.split("@");
+
+ if (parts.length > 2)
return false;
+ if (parts.length == 2) {
+ if (!parseParameters(parts[0], ":", props))
+ return false;
+ }
+
+ props.setProperty(PROP_CFG, parts[parts.length - 1]);
+
+ return true;
+ }
+
+ /**
+ * @param url Url.
+ * @param props Properties.
+ */
+ private boolean parseJdbcUrl(String url, Properties props) {
url = url.substring(URL_PREFIX.length());
String[] parts = url.split("\\?");
@@ -369,7 +502,7 @@ public class IgniteJdbcDriver implements Driver {
return false;
if (parts.length == 2)
- if (!parseUrlParameters(parts[1], props))
+ if (!parseParameters(parts[1], "&", props))
return false;
parts = parts[0].split("/");
@@ -406,12 +539,13 @@ public class IgniteJdbcDriver implements Driver {
/**
* Validates and parses URL parameters.
*
- * @param urlParams URL parameters string.
+ * @param val Parameters string.
+ * @param delim Delimiter.
* @param props Properties.
* @return Whether URL parameters string is valid.
*/
- private boolean parseUrlParameters(String urlParams, Properties props) {
- String[] params = urlParams.split("&");
+ private boolean parseParameters(String val, String delim, Properties props) {
+ String[] params = val.split(delim);
for (String param : params) {
String[] pair = param.split("=");
@@ -430,13 +564,6 @@ public class IgniteJdbcDriver implements Driver {
* convenient constructors.
*/
private static class PropertyInfo extends DriverPropertyInfo {
- /**
- * @param name Name.
- * @param val Value.
- */
- private PropertyInfo(String name, String val) {
- super(name, val);
- }
/**
* @param name Name.
@@ -448,29 +575,5 @@ public class IgniteJdbcDriver implements Driver {
description = desc;
}
-
- /**
- * @param name Name.
- * @param val Value.
- * @param required Required flag.
- */
- private PropertyInfo(String name, String val, boolean required) {
- super(name, val);
-
- this.required = required;
- }
-
- /**
- * @param name Name.
- * @param val Value.
- * @param desc Description.
- * @param required Required flag.
- */
- private PropertyInfo(String name, String val, String desc, boolean required) {
- super(name, val);
-
- description = desc;
- this.required = required;
- }
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 546a33d..1e4c8b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -356,6 +356,9 @@ public final class IgniteSystemProperties {
/** Number of times pending cache objects will be dumped to the log in case of partition exchange timeout. */
public static final String IGNITE_DUMP_PENDING_OBJECTS_THRESHOLD = "IGNITE_DUMP_PENDING_OBJECTS_THRESHOLD";
+ /** JDBC driver cursor remove delay. */
+ public static final String IGNITE_JDBC_DRIVER_CURSOR_REMOVE_DELAY = "IGNITE_JDBC_DRIVER_CURSOR_RMV_DELAY";
+
/**
* Enforces singleton.
*/
@@ -517,4 +520,4 @@ public final class IgniteSystemProperties {
public static Properties snapshot() {
return (Properties)System.getProperties().clone();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
index 0116ace..a4be6f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
@@ -56,7 +56,11 @@ import static org.apache.ignite.IgniteJdbcDriver.PROP_PORT;
/**
* JDBC connection implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
public class JdbcConnection implements Connection {
/** Validation task name. */
private static final String VALID_TASK_NAME =
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnectionInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnectionInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnectionInfo.java
deleted file mode 100644
index 36fa0aa..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnectionInfo.java
+++ /dev/null
@@ -1,91 +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.jdbc;
-
-/**
- * Connection properties.
- */
-public class JdbcConnectionInfo {
- /** URL. */
- private final String url;
-
- /** Hostname. */
- private String hostname;
-
- /** Port number. */
- private int port;
-
- /** Cache name. */
- private String cacheName;
-
- /**
- * @param url URL.
- */
- JdbcConnectionInfo(String url) {
- this.url = url;
- }
-
- /**
- * @return URL.
- */
- public String url() {
- return url;
- }
-
- /**
- * @return Hostname.
- */
- public String hostname() {
- return hostname;
- }
-
- /**
- * @param hostname Hostname.
- */
- public void hostname(String hostname) {
- this.hostname = hostname;
- }
-
- /**
- * @return Port number.
- */
- public int port() {
- return port;
- }
-
- /**
- * @param port Port number.
- */
- public void port(int port) {
- this.port = port;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcDatabaseMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcDatabaseMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcDatabaseMetadata.java
index df26412..e2fbe05 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcDatabaseMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcDatabaseMetadata.java
@@ -39,8 +39,12 @@ import static java.sql.RowIdLifetime.ROWID_UNSUPPORTED;
/**
* JDBC database metadata implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
@SuppressWarnings("RedundantCast")
+@Deprecated
public class JdbcDatabaseMetadata implements DatabaseMetaData {
/** Task name. */
private static final String TASK_NAME =
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
index 6dfaa18..7e5358b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
@@ -41,7 +41,11 @@ import java.util.Calendar;
/**
* JDBC prepared statement implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
public class JdbcPreparedStatement extends JdbcStatement implements PreparedStatement {
/** SQL query. */
private final String sql;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java
index 1566006..5961279 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java
@@ -49,7 +49,11 @@ import org.apache.ignite.internal.util.typedef.internal.U;
/**
* JDBC result set implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
public class JdbcResultSet implements ResultSet {
/** Task name. */
private static final String TASK_NAME =
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSetMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSetMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSetMetadata.java
index afe1d28..75fe522 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSetMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSetMetadata.java
@@ -23,7 +23,11 @@ import java.util.List;
/**
* JDBC result set metadata implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
public class JdbcResultSetMetadata implements ResultSetMetaData {
/** Column width. */
private static final int COL_WIDTH = 30;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java
index caa8495..0f4e08c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java
@@ -36,7 +36,11 @@ import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
/**
* JDBC statement implementation.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
public class JdbcStatement implements Statement {
/** Task name. */
private static final String TASK_NAME =
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
index 46e3cfa..ecea21f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
@@ -47,7 +47,11 @@ import static java.sql.Types.VARCHAR;
/**
* Utility methods for JDBC driver.
+ *
+ * @deprecated Using Ignite client node based JDBC driver is preferable.
+ * See documentation of {@link org.apache.ignite.IgniteJdbcDriver} for details.
*/
+@Deprecated
class JdbcUtils {
/** Marshaller. */
private static final Marshaller MARSHALLER = new JdkMarshaller();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb9e2e9/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
new file mode 100644
index 0000000..00eb6b5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
@@ -0,0 +1,777 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteJdbcDriver;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.compute.ComputeTaskTimeoutException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.ignite.IgniteJdbcDriver.PROP_CACHE;
+import static org.apache.ignite.IgniteJdbcDriver.PROP_CFG;
+import static org.apache.ignite.IgniteJdbcDriver.PROP_COLLOCATED;
+import static org.apache.ignite.IgniteJdbcDriver.PROP_LOCAL;
+import static org.apache.ignite.IgniteJdbcDriver.PROP_NODE_ID;
+
+/**
+ * JDBC connection implementation.
+ */
+public class JdbcConnection implements Connection {
+ /**
+ * Ignite nodes cache.
+ *
+ * The key is result of concatenation of the following properties:
+ * <ol>
+ * <li>{@link IgniteJdbcDriver#PROP_CFG}</li>
+ * </ol>
+ */
+ private static final ConcurrentMap<String, IgniteNodeFuture> NODES = new ConcurrentHashMap<>();
+
+ /** Ignite ignite. */
+ private final Ignite ignite;
+
+ /** Node key. */
+ private final String cfg;
+
+ /** Cache name. */
+ private String cacheName;
+
+ /** Closed flag. */
+ private boolean closed;
+
+ /** URL. */
+ private String url;
+
+ /** Node ID. */
+ private UUID nodeId;
+
+ /** Local query flag. */
+ private boolean locQry;
+
+ /** Collocated query flag. */
+ private boolean collocatedQry;
+
+ /** Statements. */
+ final Set<JdbcStatement> statements = new HashSet<>();
+
+ /**
+ * Creates new connection.
+ *
+ * @param url Connection URL.
+ * @param props Additional properties.
+ * @throws SQLException In case Ignite node failed to start.
+ */
+ public JdbcConnection(String url, Properties props) throws SQLException {
+ assert url != null;
+ assert props != null;
+
+ this.url = url;
+
+ this.cacheName = props.getProperty(PROP_CACHE);
+ this.locQry = Boolean.parseBoolean(props.getProperty(PROP_LOCAL));
+ this.collocatedQry = Boolean.parseBoolean(props.getProperty(PROP_COLLOCATED));
+
+ String nodeIdProp = props.getProperty(PROP_NODE_ID);
+
+ if (nodeIdProp != null)
+ this.nodeId = UUID.fromString(nodeIdProp);
+
+ try {
+ cfg = props.getProperty(PROP_CFG);
+
+ ignite = getIgnite(cfg);
+
+ if (!isValid(2))
+ throw new SQLException("Client is invalid. Probably cache name is wrong.");
+ }
+ catch (Exception e) {
+ close();
+
+ if (e instanceof SQLException)
+ throw (SQLException)e;
+ else
+ throw new SQLException("Failed to start Ignite node.", e);
+ }
+ }
+
+ /**
+ * @param cfgUrl Config url.
+ */
+ private Ignite getIgnite(String cfgUrl) throws IgniteCheckedException {
+ while (true) {
+ IgniteNodeFuture fut = NODES.get(cfg);
+
+ if (fut == null) {
+ fut = new IgniteNodeFuture();
+
+ IgniteNodeFuture old = NODES.putIfAbsent(cfg, fut);
+
+ if (old != null)
+ fut = old;
+ else {
+ try {
+ Ignite ignite = Ignition.start(loadConfiguration(cfgUrl));
+
+ fut.onDone(ignite);
+ }
+ catch (IgniteException e) {
+ fut.onDone(e);
+ }
+
+ return fut.get();
+ }
+ }
+
+ if (fut.acquire())
+ return fut.get();
+ else
+ NODES.remove(cfg, fut);
+ }
+ }
+
+ /**
+ * @param cfgUrl Config URL.
+ */
+ private IgniteConfiguration loadConfiguration(String cfgUrl) {
+ try {
+ IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap =
+ IgnitionEx.loadConfigurations(cfgUrl);
+
+ IgniteConfiguration cfg = F.first(cfgMap.get1());
+
+ if (cfg.getGridName() == null)
+ cfg.setGridName("ignite-jdbc-driver-" + UUID.randomUUID().toString());
+
+ return cfg;
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statement createStatement() throws SQLException {
+ return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql) throws SQLException {
+ ensureNotClosed();
+
+ return prepareStatement(sql, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CallableStatement prepareCall(String sql) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Callable functions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String nativeSQL(String sql) throws SQLException {
+ ensureNotClosed();
+
+ return sql;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setAutoCommit(boolean autoCommit) throws SQLException {
+ ensureNotClosed();
+
+ if (!autoCommit)
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getAutoCommit() throws SQLException {
+ ensureNotClosed();
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void commit() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rollback() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws SQLException {
+ if (closed)
+ return;
+
+ closed = true;
+
+ IgniteNodeFuture fut = NODES.get(cfg);
+
+ if (fut != null && fut.release()) {
+ NODES.remove(cfg);
+
+ if (ignite != null)
+ ignite.close();
+ }
+
+ for (Iterator<JdbcStatement> it = statements.iterator(); it.hasNext();) {
+ JdbcStatement stmt = it.next();
+
+ stmt.closeInternal();
+
+ it.remove();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() throws SQLException {
+ return closed;
+ }
+
+ /** {@inheritDoc} */
+ @Override public DatabaseMetaData getMetaData() throws SQLException {
+ ensureNotClosed();
+
+ return new JdbcDatabaseMetadata(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setReadOnly(boolean readOnly) throws SQLException {
+ ensureNotClosed();
+
+ if (!readOnly)
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isReadOnly() throws SQLException {
+ ensureNotClosed();
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setCatalog(String catalog) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Catalogs are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getCatalog() throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTransactionIsolation(int level) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getTransactionIsolation() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLWarning getWarnings() throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearWarnings() throws SQLException {
+ ensureNotClosed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statement createStatement(int resSetType, int resSetConcurrency) throws SQLException {
+ return createStatement(resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql, int resSetType,
+ int resSetConcurrency) throws SQLException {
+ ensureNotClosed();
+
+ return prepareStatement(sql, resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CallableStatement prepareCall(String sql, int resSetType,
+ int resSetConcurrency) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Callable functions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, Class<?>> getTypeMap() throws SQLException {
+ throw new SQLFeatureNotSupportedException("Types mapping is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Types mapping is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setHoldability(int holdability) throws SQLException {
+ ensureNotClosed();
+
+ if (holdability != HOLD_CURSORS_OVER_COMMIT)
+ throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getHoldability() throws SQLException {
+ ensureNotClosed();
+
+ return HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Savepoint setSavepoint() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Savepoint setSavepoint(String name) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rollback(Savepoint savepoint) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Transactions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statement createStatement(int resSetType, int resSetConcurrency,
+ int resSetHoldability) throws SQLException {
+ ensureNotClosed();
+
+ if (resSetType != TYPE_FORWARD_ONLY)
+ throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)");
+
+ if (resSetConcurrency != CONCUR_READ_ONLY)
+ throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported).");
+
+ if (resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
+ throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
+
+ JdbcStatement stmt = new JdbcStatement(this);
+
+ statements.add(stmt);
+
+ return stmt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql, int resSetType, int resSetConcurrency,
+ int resSetHoldability) throws SQLException {
+ ensureNotClosed();
+
+ if (resSetType != TYPE_FORWARD_ONLY)
+ throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)");
+
+ if (resSetConcurrency != CONCUR_READ_ONLY)
+ throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported).");
+
+ if (resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
+ throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
+
+ JdbcPreparedStatement stmt = new JdbcPreparedStatement(this, sql);
+
+ statements.add(stmt);
+
+ return stmt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CallableStatement prepareCall(String sql, int resSetType, int resSetConcurrency,
+ int resSetHoldability) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Callable functions are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql, int[] colIndexes) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public PreparedStatement prepareStatement(String sql, String[] colNames) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("Updates are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Clob createClob() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Blob createBlob() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public NClob createNClob() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public SQLXML createSQLXML() throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isValid(int timeout) throws SQLException {
+ ensureNotClosed();
+
+ if (timeout < 0)
+ throw new SQLException("Invalid timeout: " + timeout);
+
+ try {
+ JdbcConnectionValidationTask task = new JdbcConnectionValidationTask(cacheName,
+ nodeId == null ? ignite : null);
+
+ if (nodeId != null) {
+ ClusterGroup grp = ignite.cluster().forServers().forNodeId(nodeId);
+
+ if (grp.nodes().isEmpty())
+ throw new SQLException("Failed to establish connection with node (is it a server node?): " +
+ nodeId);
+
+ assert grp.nodes().size() == 1;
+
+ if (grp.node().isDaemon())
+ throw new SQLException("Failed to establish connection with node (is it a server node?): " +
+ nodeId);
+
+ IgniteCompute compute = ignite.compute(grp).withAsync();
+
+ compute.call(task);
+
+ return compute.<Boolean>future().get(timeout, SECONDS);
+ }
+ else
+ return task.call();
+ }
+ catch (IgniteClientDisconnectedException | ComputeTaskTimeoutException e) {
+ throw new SQLException("Failed to establish connection.", e);
+ }
+ catch (IgniteException ignored) {
+ return false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setClientInfo(String name, String val) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Client info is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setClientInfo(Properties props) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Client info is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getClientInfo(String name) throws SQLException {
+ ensureNotClosed();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Properties getClientInfo() throws SQLException {
+ ensureNotClosed();
+
+ return new Properties();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public Struct createStruct(String typeName, Object[] attrs) throws SQLException {
+ ensureNotClosed();
+
+ throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> iface) throws SQLException {
+ if (!isWrapperFor(iface))
+ throw new SQLException("Connection is not a wrapper for " + iface.getName());
+
+ return (T)this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface != null && iface == Connection.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setSchema(String schema) throws SQLException {
+ cacheName = schema;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getSchema() throws SQLException {
+ return cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void abort(Executor executor) throws SQLException {
+ close();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setNetworkTimeout(Executor executor, int ms) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Network timeout is not supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getNetworkTimeout() throws SQLException {
+ throw new SQLFeatureNotSupportedException("Network timeout is not supported.");
+ }
+
+ /**
+ * @return Ignite node.
+ */
+ Ignite ignite() {
+ return ignite;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ String cacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @return URL.
+ */
+ String url() {
+ return url;
+ }
+
+ /**
+ * @return Node ID.
+ */
+ UUID nodeId() {
+ return nodeId;
+ }
+
+ /**
+ * @return Local query flag.
+ */
+ boolean isLocalQuery() {
+ return locQry;
+ }
+
+ /**
+ * @return Collocated query flag.
+ */
+ boolean isCollocatedQuery() {
+ return collocatedQry;
+ }
+
+ /**
+ * Ensures that connection is not closed.
+ *
+ * @throws SQLException If connection is closed.
+ */
+ private void ensureNotClosed() throws SQLException {
+ if (closed)
+ throw new SQLException("Connection is closed.");
+ }
+
+ /**
+ * @return Internal statement.
+ * @throws SQLException In case of error.
+ */
+ JdbcStatement createStatement0() throws SQLException {
+ return (JdbcStatement)createStatement();
+ }
+
+ /**
+ * JDBC connection validation task.
+ */
+ private static class JdbcConnectionValidationTask implements IgniteCallable<Boolean> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0L;
+
+ /** Cache name. */
+ private final String cacheName;
+
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /**
+ * @param cacheName Cache name.
+ * @param ignite Ignite instance.
+ */
+ public JdbcConnectionValidationTask(String cacheName, Ignite ignite) {
+ this.cacheName = cacheName;
+ this.ignite = ignite;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() {
+ return ignite.cache(cacheName) != null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IgniteNodeFuture extends GridFutureAdapter<Ignite> {
+ /** Reference count. */
+ private final AtomicInteger refCnt = new AtomicInteger(1);
+
+ /**
+ *
+ */
+ public boolean acquire() {
+ while (true) {
+ int cur = refCnt.get();
+
+ if (cur == 0)
+ return false;
+
+ if (refCnt.compareAndSet(cur, cur + 1))
+ return true;
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean release() {
+ while (true) {
+ int cur = refCnt.get();
+
+ assert cur > 0;
+
+ if (refCnt.compareAndSet(cur, cur - 1))
+ // CASed to 0.
+ return cur == 1;
+ }
+ }
+ }
+}
[19/28] ignite git commit: ignite-257: fully muted
GridCacheColocatedTxExceptionSelfTest
Posted by sb...@apache.org.
ignite-257: fully muted GridCacheColocatedTxExceptionSelfTest
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1ff4a52a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1ff4a52a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1ff4a52a
Branch: refs/heads/ignite-971
Commit: 1ff4a52af5e31465b474d8dcc9700d37b7656df6
Parents: a66400a
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 11 17:10:19 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 11 17:10:19 2015 +0300
----------------------------------------------------------------------
.../GridCacheColocatedTxExceptionSelfTest.java | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1ff4a52a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
index 86f32f3..5514ff6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
@@ -28,27 +28,17 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return PARTITIONED;
- }
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void testRemovePrimary() throws Exception {
+ @Override protected void beforeTestsStarted() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}
/** {@inheritDoc} */
- @Override public void testPutPrimary() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
}
/** {@inheritDoc} */
- @Override public void testTransformPrimary() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
}
}
\ No newline at end of file
[24/28] ignite git commit: ignite-257: muted back unmuted tests
Posted by sb...@apache.org.
ignite-257: muted back unmuted tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/de632ace
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/de632ace
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/de632ace
Branch: refs/heads/ignite-971
Commit: de632ace6d0495ed5298644191960f383db57a72
Parents: ebb9e2e
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Sep 14 09:29:54 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Sep 14 09:29:54 2015 +0300
----------------------------------------------------------------------
.../replicated/GridCacheReplicatedTxExceptionSelfTest.java | 5 +++++
.../cache/local/GridCacheLocalTxExceptionSelfTest.java | 5 +++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/de632ace/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
index 1c96a4d..c2799db 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
@@ -28,6 +28,11 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
*/
public class GridCacheReplicatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ }
+
+ /** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/de632ace/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
index 63a900d..2fae99b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
@@ -27,6 +27,11 @@ import static org.apache.ignite.cache.CacheMode.LOCAL;
*/
public class GridCacheLocalTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-257");
+ }
+
+ /** {@inheritDoc} */
@Override protected int gridCount() {
return 1;
}
[15/28] ignite git commit: ignite-1028 (cherry picked from commit
e4d7ae0)
Posted by sb...@apache.org.
ignite-1028
(cherry picked from commit e4d7ae0)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/82ca4317
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/82ca4317
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/82ca4317
Branch: refs/heads/ignite-971
Commit: 82ca43176610ff543102b049c26a9f79add098ef
Parents: 70ad5ba
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 11 13:51:22 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 11 14:02:31 2015 +0300
----------------------------------------------------------------------
.../cache/GridCacheP2PUndeploySelfTest.java | 26 ++++++++++++--------
1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/82ca4317/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
index 2c8c748..92c5340 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -36,6 +37,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -201,7 +203,7 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest {
* @param cacheName Cache name.
* @throws Exception If failed.
*/
- private void checkP2PUndeploy(String cacheName) throws Exception {
+ private void checkP2PUndeploy(final String cacheName) throws Exception {
assert !F.isEmpty(cacheName);
ClassLoader ldr = getExternalClassLoader();
@@ -210,7 +212,7 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest {
try {
Ignite ignite1 = startGrid(1);
- IgniteKernal grid2 = (IgniteKernal)startGrid(2);
+ final IgniteKernal grid2 = (IgniteKernal)startGrid(2);
IgniteCache<Integer, Object> cache1 = ignite1.cache(cacheName);
IgniteCache<Integer, Object> cache2 = grid2.cache(cacheName);
@@ -237,20 +239,24 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest {
cache2.localEvict(ImmutableSet.of(2, 3, 4));
- U.sleep(100); //Time to store entries to disk.
-
- long swapSize = size(cacheName, grid2);
-
- info("Swap size: " + swapSize);
-
- assert swapSize > 0;
+ //Wait until entries stored to disk.
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ try {
+ return size(cacheName, grid2) > 0;
+ }
+ catch (IgniteCheckedException e) {
+ throw new AssertionError(e);
+ }
+ }
+ }, 5000);
stopGrid(1);
assert waitCacheEmpty(cache2, 10000);
for (int i = 0; i < 3; i++) {
- swapSize = size(cacheName, grid2);
+ long swapSize = size(cacheName, grid2);
if (swapSize > 0) {
if (i < 2) {
[02/28] ignite git commit: IGNITE-802: reworked
GridCachePartitionedQueueEntryMoveSelfTest.testQueue
Posted by sb...@apache.org.
IGNITE-802: reworked GridCachePartitionedQueueEntryMoveSelfTest.testQueue
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ec5c795a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ec5c795a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ec5c795a
Branch: refs/heads/ignite-971
Commit: ec5c795aa523cc48c292cfb09e422edcd8a1a42b
Parents: d96e0d2
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 10 12:18:44 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 10 12:18:44 2015 +0300
----------------------------------------------------------------------
...dCachePartitionedQueueEntryMoveSelfTest.java | 191 +++++++------------
1 file changed, 66 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec5c795a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
index 4d92b88..1d225a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.datastructures.partitioned;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.Ignite;
@@ -30,18 +29,15 @@ import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.AffinityFunction;
-import org.apache.ignite.cache.affinity.AffinityKeyMapper;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.CollectionConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
import org.apache.ignite.internal.processors.cache.datastructures.IgniteCollectionAbstractTest;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestNode;
import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -52,11 +48,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
* Cache queue test with changing topology.
*/
public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollectionAbstractTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-802");
- }
-
/** Queue capacity. */
private static final int QUEUE_CAP = 5;
@@ -66,9 +57,6 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection
/** Backups count. */
private static final int BACKUP_CNT = 1;
- /** Node ID to set manually on node startup. */
- private UUID nodeId;
-
/** {@inheritDoc} */
@Override protected int gridCount() {
return GRID_CNT;
@@ -98,116 +86,93 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection
return colCfg;
}
- /** {@inheritDoc} */
- @SuppressWarnings("deprecation")
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- if (nodeId != null) {
- cfg.setNodeId(nodeId);
-
- nodeId = null;
- }
-
- return cfg;
- }
-
/**
* @throws Exception If failed.
*/
public void testQueue() throws Exception {
- try {
- startGrids(GRID_CNT);
-
- final String queueName = "queue-name-" + UUID.randomUUID();
+ final String queueName = "queue-test-name";
- System.out.println(U.filler(20, '\n'));
+ System.out.println(U.filler(20, '\n'));
- final CountDownLatch latch1 = new CountDownLatch(1);
- //final CountDownLatch latch2 = new CountDownLatch(1);
+ final CountDownLatch latch1 = new CountDownLatch(1);
+ final CountDownLatch latch2 = new CountDownLatch(1);
- IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
- @Override public Void call() {
- Ignite ignite = grid(0);
+ IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws IgniteInterruptedCheckedException {
+ Ignite ignite = grid(0);
- IgniteQueue<Integer> queue = ignite.queue(queueName,
- QUEUE_CAP,
- config(true));
+ IgniteQueue<Integer> queue = ignite.queue(queueName, QUEUE_CAP, config(true));
- for (int i = 0; i < QUEUE_CAP * 2; i++) {
- if (i == QUEUE_CAP) {
- latch1.countDown();
+ for (int i = 0; i < QUEUE_CAP * 2; i++) {
+ if (i == QUEUE_CAP) {
+ latch1.countDown();
- //U.await(latch2);
- }
-
- try {
- info(">>> Putting value: " + i);
+ U.await(latch2);
+ }
- queue.put(i);
+ try {
+ info(">>> Putting value: " + i);
- info(">>> Value is in queue: " + i);
- }
- catch (Error | RuntimeException e) {
- error("Failed to put value: " + i, e);
+ queue.put(i);
- throw e;
- }
+ info(">>> Value is in queue: " + i);
}
+ catch (Error | RuntimeException e) {
+ error("Failed to put value: " + i, e);
- return null;
+ throw e;
+ }
}
- });
- latch1.await();
+ return null;
+ }
+ });
- startAdditionalNodes(BACKUP_CNT + 2, queueName);
+ latch1.await();
- System.out.println(U.filler(20, '\n'));
+ startAdditionalNodes(BACKUP_CNT + 2, queueName);
- //latch2.countDown();
+ System.out.println(U.filler(20, '\n'));
- IgniteInternalFuture<?> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
- @Override public Void call() throws IgniteCheckedException {
- Ignite ignite = grid(GRID_CNT);
+ latch2.countDown();
- IgniteQueue<Integer> queue = ignite.queue(queueName, Integer.MAX_VALUE, config(true));
+ IgniteInternalFuture<?> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws IgniteCheckedException {
+ Ignite ignite = grid(GRID_CNT);
- int cnt = 0;
+ IgniteQueue<Integer> queue = ignite.queue(queueName, QUEUE_CAP, config(true));
- do {
- try {
- Integer i = queue.poll();
+ int cnt = 0;
- if (i != null) {
- info(">>> Polled value: " + cnt);
+ do {
+ try {
+ Integer i = queue.poll();
- cnt++;
- }
- else {
- info(">>> Waiting for value...");
+ if (i != null) {
+ info(">>> Polled value: " + cnt);
- U.sleep(2000);
- }
+ cnt++;
}
- catch (Error | RuntimeException e) {
- error("Failed to poll value.", e);
+ else {
+ info(">>> Waiting for value...");
- throw e;
+ U.sleep(2000);
}
}
- while (cnt < QUEUE_CAP * 2);
+ catch (Error | RuntimeException e) {
+ error("Failed to poll value.", e);
- return null;
+ throw e;
+ }
}
- });
+ while (cnt < QUEUE_CAP * 2);
- fut1.get();
- fut2.get();
- }
- finally {
- stopAllGrids();
- }
+ return null;
+ }
+ });
+
+ fut1.get();
+ fut2.get();
}
/**
@@ -218,51 +183,27 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection
* @throws Exception If failed.
*/
private void startAdditionalNodes(int cnt, String queueName) throws Exception {
- AffinityFunction aff = jcache(0).getConfiguration(CacheConfiguration.class).getAffinity();
- AffinityKeyMapper mapper = jcache(0).getConfiguration(CacheConfiguration.class).getAffinityMapper();
-
- assertNotNull(aff);
- assertNotNull(mapper);
-
- int part = aff.partition(mapper.affinityKey(queueName));
+ IgniteQueue queue = ignite(0).queue(queueName, 0, null);
- Collection<ClusterNode> nodes = grid(0).cluster().nodes();
+ CacheConfiguration cCfg = getQueueCache(queue);
- Collection<ClusterNode> aff0 = ignite(0).affinity(null).mapKeyToPrimaryAndBackups(queueName);
- Collection<ClusterNode> aff1 = nodes(aff, part, nodes);
+ Collection<ClusterNode> aff1 = ignite(0).affinity(cCfg.getName()).mapKeyToPrimaryAndBackups(queueName);
- assertEquals(new ArrayList<>(aff0), new ArrayList<>(aff1));
+ for (int i = 0, id = GRID_CNT; i < cnt; i++) {
+ startGrid(id++);
- Collection<ClusterNode> aff2;
- Collection<ClusterNode> tmpNodes;
+ awaitPartitionMapExchange();
- int retries = 10000;
+ Collection<ClusterNode> aff2 = ignite(0).affinity(cCfg.getName()).mapKeyToPrimaryAndBackups(queueName);
- do {
- tmpNodes = new ArrayList<>(cnt);
+ if (!aff1.iterator().next().equals(aff2.iterator().next())) {
+ info("Moved queue to new primary node [oldAff=" + aff1 + ", newAff=" + aff2 + ']');
- for (int i = 0; i < cnt; i++)
- tmpNodes.add(new GridTestNode(UUID.randomUUID()));
-
- aff2 = nodes(aff, part, F.concat(true, tmpNodes, nodes));
-
- if (retries-- < 0)
- throw new IgniteCheckedException("Failed to find node IDs to change current affinity mapping.");
+ return;
+ }
}
- while (F.containsAny(aff1, aff2));
-
- int i = GRID_CNT;
-
- // Start several additional grids.
- for (UUID id : F.nodeIds(tmpNodes)) {
- nodeId = id;
-
- startGrid(i++);
- }
-
- aff2 = ignite(0).affinity(null).mapKeyToPrimaryAndBackups(queueName);
- assertFalse("Unexpected affinity [aff1=" + aff1 + ", aff2=" + aff2 + ']', F.containsAny(aff1, aff2));
+ throw new IgniteCheckedException("Unable to move the queue to a new primary node");
}
/**