You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/02/27 09:11:51 UTC
[1/3] ignite git commit: Revert "IGNITE-7253: JDBC thin streaming:
fixed default local buffer size,
improved error messages in case of unsupported SQL statements."
Repository: ignite
Updated Branches:
refs/heads/master cb4277e6c -> e9f1a7e0b
Revert "IGNITE-7253: JDBC thin streaming: fixed default local buffer size, improved error messages in case of unsupported SQL statements."
This reverts commit 501bbed0d223304b7591437659d5aa0eb2acd5b4.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ed0ef9d2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ed0ef9d2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ed0ef9d2
Branch: refs/heads/master
Commit: ed0ef9d202f137524174322fa1bdabf50a43a388
Parents: cb4277e
Author: devozerov <vo...@gridgain.com>
Authored: Tue Feb 27 12:07:51 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Feb 27 12:07:51 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java | 2 +-
.../ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java | 9 +++------
.../apache/ignite/internal/jdbc/thin/JdbcThinStatement.java | 2 +-
.../internal/processors/query/h2/IgniteH2Indexing.java | 2 +-
4 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed0ef9d2/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
index 4c7e079..ebb6bc9 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
@@ -287,7 +287,7 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
return null;
}
- }, SQLException.class,"Streaming mode supports only INSERT commands without subqueries.");
+ }, SQLException.class,"Only tuple based INSERT statements are supported in streaming mode");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed0ef9d2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
index 1c8e153..3f1819d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
@@ -24,8 +24,6 @@ import java.util.Arrays;
import java.util.Properties;
import javax.naming.RefAddr;
import javax.naming.Reference;
-
-import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.configuration.ClientConnectorConfiguration;
import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.util.typedef.F;
@@ -166,16 +164,15 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
"streamingPerNodeBufferSize", "Buffer size per cluster node during streaming",
0, false, 0, Integer.MAX_VALUE);
- /** Server-size flush frequency during streaming. */
+ /** Buffer size per cluster node during streaming. */
private LongProperty streamFlushFreq = new LongProperty(
- "streamingFlushFrequency", "Server-size flush frequency during streaming",
+ "streamingFlushFrequency", "Buffer size per cluster node during streaming",
0, false, 0, Long.MAX_VALUE);
/** Buffer size per cluster node during streaming. */
private IntegerProperty streamBatchSize = new IntegerProperty(
"streamingBatchSize", "Batch size for streaming (number of commands to accumulate internally " +
- "before actually sending over the wire)", IgniteDataStreamer.DFLT_PER_NODE_BUFFER_SIZE * 4, false, 1,
- Integer.MAX_VALUE);
+ "before actually sending over the wire)", 10, false, 1, Integer.MAX_VALUE);
/** Properties array. */
private final ConnectionProperty [] props = {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed0ef9d2/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
index 51be8d5..a71812f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
@@ -138,7 +138,7 @@ public class JdbcThinStatement implements Statement {
if (conn.isStream()) {
if (stmtType == JdbcStatementType.SELECT_STATEMENT_TYPE)
- throw new SQLException("executeQuery() method is not allowed in streaming mode.",
+ throw new SQLException("Only tuple based INSERT statements are supported in streaming mode.",
SqlStateCode.INTERNAL_ERROR,
IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed0ef9d2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 1691522..a0b2c34 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -2337,7 +2337,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
/** {@inheritDoc} */
@Override public void checkStatementStreamable(PreparedStatement nativeStmt) {
if (!GridSqlQueryParser.isStreamableInsertStatement(nativeStmt))
- throw new IgniteSQLException("Streaming mode supports only INSERT commands without subqueries.",
+ throw new IgniteSQLException("Only tuple based INSERT statements are supported in streaming mode.",
IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
}
[3/3] ignite git commit: Revert "IGNITE-7253: Streaming mode for JDBC
thin driver. This closes #3499."
Posted by vo...@apache.org.
Revert "IGNITE-7253: Streaming mode for JDBC thin driver. This closes #3499."
This reverts commit 692e48880dfaae23c415047656de632fbb5e23d1.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e9f1a7e0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e9f1a7e0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e9f1a7e0
Branch: refs/heads/master
Commit: e9f1a7e0b3149bf3521c8f633ae26bc62e626e24
Parents: ed0ef9d
Author: devozerov <vo...@gridgain.com>
Authored: Tue Feb 27 12:08:03 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Feb 27 12:08:03 2018 +0300
----------------------------------------------------------------------
.../jdbc2/JdbcNoCacheStreamingSelfTest.java | 182 ------------
.../internal/jdbc2/JdbcStreamingSelfTest.java | 218 +++-----------
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 3 -
.../jdbc/thin/JdbcThinStreamingSelfTest.java | 285 -------------------
.../jdbc/thin/ConnectionProperties.java | 66 -----
.../jdbc/thin/ConnectionPropertiesImpl.java | 136 +--------
.../internal/jdbc/thin/JdbcThinConnection.java | 69 -----
.../jdbc/thin/JdbcThinPreparedStatement.java | 18 +-
.../internal/jdbc/thin/JdbcThinStatement.java | 53 +---
.../internal/jdbc/thin/JdbcThinTcpIo.java | 13 +-
.../ignite/internal/jdbc2/JdbcConnection.java | 10 +-
.../jdbc2/JdbcStreamedPreparedStatement.java | 2 +-
.../processors/cache/IgniteCacheProxyImpl.java | 4 +-
.../odbc/jdbc/JdbcConnectionContext.java | 29 +-
.../odbc/jdbc/JdbcRequestHandler.java | 82 ++----
.../processors/query/GridQueryIndexing.java | 32 +--
.../processors/query/GridQueryProcessor.java | 85 +-----
.../processors/query/SqlClientContext.java | 195 -------------
.../apache/ignite/internal/sql/SqlParser.java | 2 +-
...IgniteClientCacheInitializationFailTest.java | 15 +-
.../ignite/testframework/GridTestUtils.java | 2 +-
.../query/h2/DmlStatementsProcessor.java | 100 ++++---
.../processors/query/h2/IgniteH2Indexing.java | 119 ++------
.../query/h2/ddl/DdlStatementsProcessor.java | 22 +-
.../processors/query/h2/dml/UpdatePlan.java | 2 +-
.../query/h2/dml/UpdatePlanBuilder.java | 13 +-
.../query/h2/sql/GridSqlQueryParser.java | 12 -
.../cache/GridCacheCrossCacheQuerySelfTest.java | 18 +-
28 files changed, 235 insertions(+), 1552 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java
deleted file mode 100644
index 74c2820..0000000
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java
+++ /dev/null
@@ -1,182 +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.jdbc2;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.util.Collections;
-import java.util.Properties;
-import org.apache.ignite.IgniteJdbcDriver;
-import org.apache.ignite.IgniteLogger;
-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.U;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-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;
-
-/**
- * Data streaming test for thick driver and no explicit caches.
- */
-public class JdbcNoCacheStreamingSelfTest extends GridCommonAbstractTest {
- /** JDBC URL. */
- private static final String BASE_URL = CFG_URL_PREFIX +
- "cache=default@modules/clients/src/test/config/jdbc-config.xml";
-
- /** Connection. */
- protected Connection conn;
-
- /** */
- protected transient IgniteLogger log;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- return getConfiguration0(gridName);
- }
-
- /**
- * @param gridName Grid name.
- * @return Grid configuration used for starting the grid.
- * @throws Exception If failed.
- */
- private IgniteConfiguration getConfiguration0(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, Integer.class
- );
-
- cfg.setCacheConfiguration(cache);
- cfg.setLocalHost("127.0.0.1");
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
- ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));
-
- disco.setIpFinder(ipFinder);
-
- cfg.setDiscoverySpi(disco);
-
- cfg.setConnectorConfiguration(new ConnectorConfiguration());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(2);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /**
- * @param allowOverwrite Allow overwriting of existing keys.
- * @return Connection to use for the test.
- * @throws Exception if failed.
- */
- protected Connection createConnection(boolean allowOverwrite) throws Exception {
- Properties props = new Properties();
-
- props.setProperty(IgniteJdbcDriver.PROP_STREAMING, "true");
- props.setProperty(IgniteJdbcDriver.PROP_STREAMING_FLUSH_FREQ, "500");
-
- if (allowOverwrite)
- props.setProperty(IgniteJdbcDriver.PROP_STREAMING_ALLOW_OVERWRITE, "true");
-
- return DriverManager.getConnection(BASE_URL, props);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- U.closeQuiet(conn);
-
- ignite(0).cache(DEFAULT_CACHE_NAME).clear();
-
- super.afterTest();
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testStreamedInsert() throws Exception {
- for (int i = 10; i <= 100; i += 10)
- ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100);
-
- try (Connection conn = createConnection(false)) {
- try (PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values (?, ?)")) {
- for (int i = 1; i <= 100; i++) {
- stmt.setInt(1, i);
- stmt.setInt(2, i);
-
- stmt.executeUpdate();
- }
- }
- }
-
- U.sleep(500);
-
- // Now let's check it's all there.
- for (int i = 1; i <= 100; i++) {
- if (i % 10 != 0)
- assertEquals(i, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
- else // All that divides by 10 evenly should point to numbers 100 times greater - see above
- assertEquals(i * 100, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testStreamedInsertWithOverwritesAllowed() throws Exception {
- for (int i = 10; i <= 100; i += 10)
- ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100);
-
- try (Connection conn = createConnection(true)) {
- try (PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values (?, ?)")) {
- for (int i = 1; i <= 100; i++) {
- stmt.setInt(1, i);
- stmt.setInt(2, i);
-
- stmt.executeUpdate();
- }
- }
- }
-
- U.sleep(500);
-
- // Now let's check it's all there.
- // i should point to i at all times as we've turned overwrites on above.
- for (int i = 1; i <= 100; i++)
- assertEquals(i, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
index ebb6bc9..5418ca0 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
@@ -20,24 +20,16 @@ package org.apache.ignite.internal.jdbc2;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
import java.util.Collections;
import java.util.Properties;
-import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteJdbcDriver;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
@@ -49,12 +41,10 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
*/
public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
/** JDBC URL. */
- private static final String BASE_URL = CFG_URL_PREFIX +
- "cache=default@modules/clients/src/test/config/jdbc-config.xml";
+ private static final String BASE_URL = CFG_URL_PREFIX + "cache=default@modules/clients/src/test/config/jdbc-config.xml";
- /** Streaming URL. */
- private static final String STREAMING_URL = CFG_URL_PREFIX +
- "cache=person@modules/clients/src/test/config/jdbc-config.xml";
+ /** Connection. */
+ protected Connection conn;
/** */
protected transient IgniteLogger log;
@@ -100,18 +90,7 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
startGrids(2);
-
- try (Connection c = createOrdinaryConnection()) {
- try (Statement s = c.createStatement()) {
- s.execute("CREATE TABLE PUBLIC.Person(\"id\" int primary key, \"name\" varchar) WITH " +
- "\"cache_name=person,value_type=Person\"");
- }
- }
-
- U.sleep(1000);
}
/** {@inheritDoc} */
@@ -120,51 +99,27 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
}
/**
- * @return Connection without streaming initially turned on.
- * @throws SQLException if failed.
- */
- protected Connection createOrdinaryConnection() throws SQLException {
- Connection res = DriverManager.getConnection(BASE_URL, new Properties());
-
- res.setSchema(QueryUtils.DFLT_SCHEMA);
-
- return res;
- }
-
- /**
- * @param allowOverwrite Allow overwriting of existing keys.
- * @return Connection to use for the test.
- * @throws Exception if failed.
- */
- protected Connection createStreamedConnection(boolean allowOverwrite) throws Exception {
- return createStreamedConnection(allowOverwrite, 500);
- }
-
- /**
* @param allowOverwrite Allow overwriting of existing keys.
- * @param flushTimeout Stream flush timeout.
* @return Connection to use for the test.
* @throws Exception if failed.
*/
- protected Connection createStreamedConnection(boolean allowOverwrite, long flushTimeout) throws Exception {
+ private Connection createConnection(boolean allowOverwrite) throws Exception {
Properties props = new Properties();
props.setProperty(IgniteJdbcDriver.PROP_STREAMING, "true");
- props.setProperty(IgniteJdbcDriver.PROP_STREAMING_FLUSH_FREQ, String.valueOf(flushTimeout));
+ props.setProperty(IgniteJdbcDriver.PROP_STREAMING_FLUSH_FREQ, "500");
if (allowOverwrite)
props.setProperty(IgniteJdbcDriver.PROP_STREAMING_ALLOW_OVERWRITE, "true");
- Connection res = DriverManager.getConnection(STREAMING_URL, props);
-
- res.setSchema(QueryUtils.DFLT_SCHEMA);
-
- return res;
+ return DriverManager.getConnection(BASE_URL, props);
}
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
- cache().clear();
+ U.closeQuiet(conn);
+
+ ignite(0).cache(DEFAULT_CACHE_NAME).clear();
super.afterTest();
}
@@ -173,59 +128,30 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
* @throws Exception if failed.
*/
public void testStreamedInsert() throws Exception {
+ conn = createConnection(false);
+
for (int i = 10; i <= 100; i += 10)
- put(i, nameForId(i * 100));
-
- try (Connection conn = createStreamedConnection(false)) {
- try (PreparedStatement stmt = conn.prepareStatement("insert into PUBLIC.Person(\"id\", \"name\") " +
- "values (?, ?)")) {
- for (int i = 1; i <= 100; i++) {
- stmt.setInt(1, i);
- stmt.setString(2, nameForId(i));
-
- stmt.executeUpdate();
- }
- }
- }
+ ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100);
- U.sleep(500);
+ PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values (?, ?)");
- // Now let's check it's all there.
for (int i = 1; i <= 100; i++) {
- if (i % 10 != 0)
- assertEquals(nameForId(i), nameForIdInCache(i));
- else // All that divides by 10 evenly should point to numbers 100 times greater - see above
- assertEquals(nameForId(i * 100), nameForIdInCache(i));
- }
- }
+ stmt.setInt(1, i);
+ stmt.setInt(2, i);
- /**
- * @throws Exception if failed.
- */
- public void testStreamedInsertWithoutColumnsList() throws Exception {
- for (int i = 10; i <= 100; i += 10)
- put(i, nameForId(i * 100));
-
- try (Connection conn = createStreamedConnection(false)) {
- try (PreparedStatement stmt = conn.prepareStatement("insert into PUBLIC.Person(\"id\", \"name\") " +
- "values (?, ?)")) {
- for (int i = 1; i <= 100; i++) {
- stmt.setInt(1, i);
- stmt.setString(2, nameForId(i));
-
- stmt.executeUpdate();
- }
- }
+ stmt.executeUpdate();
}
- U.sleep(500);
+ // Closing connection makes it wait for streamer close
+ // and thus for data load completion as well
+ conn.close();
// Now let's check it's all there.
for (int i = 1; i <= 100; i++) {
if (i % 10 != 0)
- assertEquals(nameForId(i), nameForIdInCache(i));
+ assertEquals(i, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
else // All that divides by 10 evenly should point to numbers 100 times greater - see above
- assertEquals(nameForId(i * 100), nameForIdInCache(i));
+ assertEquals(i * 100, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
}
}
@@ -233,99 +159,27 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
* @throws Exception if failed.
*/
public void testStreamedInsertWithOverwritesAllowed() throws Exception {
+ conn = createConnection(true);
+
for (int i = 10; i <= 100; i += 10)
- put(i, nameForId(i * 100));
-
- try (Connection conn = createStreamedConnection(true)) {
- try (PreparedStatement stmt = conn.prepareStatement("insert into PUBLIC.Person(\"id\", \"name\") " +
- "values (?, ?)")) {
- for (int i = 1; i <= 100; i++) {
- stmt.setInt(1, i);
- stmt.setString(2, nameForId(i));
-
- stmt.executeUpdate();
- }
- }
+ ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100);
+
+ PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values (?, ?)");
+
+ for (int i = 1; i <= 100; i++) {
+ stmt.setInt(1, i);
+ stmt.setInt(2, i);
+
+ stmt.executeUpdate();
}
- U.sleep(500);
+ // Closing connection makes it wait for streamer close
+ // and thus for data load completion as well
+ conn.close();
// Now let's check it's all there.
// i should point to i at all times as we've turned overwrites on above.
for (int i = 1; i <= 100; i++)
- assertEquals(nameForId(i), nameForIdInCache(i));
- }
-
- /** */
- public void testOnlyInsertsAllowed() {
- assertStatementForbidden("CREATE TABLE PUBLIC.X (x int primary key, y int)");
-
- assertStatementForbidden("SELECT * from Person");
-
- assertStatementForbidden("insert into PUBLIC.Person(\"id\", \"name\") " +
- "(select \"id\" + 1, CONCAT(\"name\", '1') from Person)");
-
- assertStatementForbidden("DELETE from Person");
-
- assertStatementForbidden("UPDATE Person SET \"name\" = 'name0'");
-
- assertStatementForbidden("alter table Person add column y int");
- }
-
- /**
- * @param sql Statement to check.
- */
- @SuppressWarnings("ThrowableNotThrown")
- protected void assertStatementForbidden(String sql) {
- GridTestUtils.assertThrows(null, new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- try (Connection c = createStreamedConnection(false)) {
- try (PreparedStatement s = c.prepareStatement(sql)) {
- s.execute();
- }
- }
-
- return null;
- }
- }, SQLException.class,"Only tuple based INSERT statements are supported in streaming mode");
- }
-
- /**
- * @return Person cache.
- */
- protected IgniteCache<Integer, Object> cache() {
- return grid(0).cache("person");
- }
-
- /**
- * @param id id of person to put.
- * @param name name of person to put.
- */
- protected void put(int id, String name) {
- BinaryObjectBuilder bldr = grid(0).binary().builder("Person");
-
- bldr.setField("name", name);
-
- cache().put(id, bldr.build());
- }
-
- /**
- * @param id Person id.
- * @return Default name for person w/given id.
- */
- protected String nameForId(int id) {
- return "Person" + id;
- }
-
- /**
- * @param id person id.
- * @return Name for person with given id currently stored in cache.
- */
- protected String nameForIdInCache(int id) {
- Object o = cache().withKeepBinary().get(id);
-
- assertTrue(String.valueOf(o), o instanceof BinaryObject);
-
- return ((BinaryObject)o).field("name");
+ assertEquals(i, grid(0).cache(DEFAULT_CACHE_NAME).get(i));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/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 3e31d78..4530ae7 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
@@ -65,7 +65,6 @@ import org.apache.ignite.jdbc.thin.JdbcThinResultSetSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinSchemaCaseTest;
import org.apache.ignite.jdbc.thin.JdbcThinSelectAfterAlterTable;
import org.apache.ignite.jdbc.thin.JdbcThinStatementSelfTest;
-import org.apache.ignite.jdbc.thin.JdbcThinStreamingSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinUpdateStatementSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinComplexDmlDdlSkipReducerOnUpdateSelfTest;
import org.apache.ignite.jdbc.thin.JdbcThinInsertStatementSkipReducerOnUpdateSelfTest;
@@ -122,11 +121,9 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStatementBatchingSelfTest.class));
suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcErrorsSelfTest.class));
suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStreamingToPublicCacheTest.class));
- suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcNoCacheStreamingSelfTest.class));
suite.addTest(new TestSuite(JdbcBlobTest.class));
suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStreamingSelfTest.class));
- suite.addTest(new TestSuite(JdbcThinStreamingSelfTest.class));
// DDL tests.
suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicPartitionedNearSelfTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingSelfTest.java
deleted file mode 100644
index 9eba4da..0000000
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingSelfTest.java
+++ /dev/null
@@ -1,285 +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.jdbc.thin;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.internal.jdbc2.JdbcStreamingSelfTest;
-import org.apache.ignite.internal.processors.query.SqlClientContext;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- * Tests for streaming via thin driver.
- */
-public class JdbcThinStreamingSelfTest extends JdbcStreamingSelfTest {
- /** */
- private int batchSize = 17;
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- batchSize = 17;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- try (Connection c = createOrdinaryConnection()) {
- execute(c, "DROP TABLE PUBLIC.T IF EXISTS");
- }
-
- super.afterTest();
- }
-
- /** {@inheritDoc} */
- @Override protected Connection createStreamedConnection(boolean allowOverwrite, long flushFreq) throws Exception {
- return JdbcThinAbstractSelfTest.connect(grid(0), "streaming=true&streamingFlushFrequency="
- + flushFreq + "&" + "streamingAllowOverwrite=" + allowOverwrite + "&streamingPerNodeBufferSize=1000&"
- + "streamingBatchSize=" + batchSize);
- }
-
- /** {@inheritDoc} */
- @Override protected Connection createOrdinaryConnection() throws SQLException {
- return JdbcThinAbstractSelfTest.connect(grid(0), null);
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testStreamedBatchedInsert() throws Exception {
- for (int i = 10; i <= 100; i += 10)
- put(i, nameForId(i * 100));
-
- try (Connection conn = createStreamedConnection(false)) {
- assertStreamingOn();
-
- try (PreparedStatement stmt = conn.prepareStatement("insert into Person(\"id\", \"name\") values (?, ?), " +
- "(?, ?)")) {
- for (int i = 1; i <= 100; i+=2) {
- stmt.setInt(1, i);
- stmt.setString(2, nameForId(i));
- stmt.setInt(3, i + 1);
- stmt.setString(4, nameForId(i + 1));
-
- stmt.addBatch();
- }
-
- stmt.executeBatch();
- }
- }
-
- U.sleep(500);
-
- // Now let's check it's all there.
- for (int i = 1; i <= 100; i++) {
- if (i % 10 != 0)
- assertEquals(nameForId(i), nameForIdInCache(i));
- else // All that divides by 10 evenly should point to numbers 100 times greater - see above
- assertEquals(nameForId(i * 100), nameForIdInCache(i));
- }
- }
-
- /**
- * @throws SQLException if failed.
- */
- public void testSimultaneousStreaming() throws Exception {
- try (Connection anotherConn = createOrdinaryConnection()) {
- execute(anotherConn, "CREATE TABLE PUBLIC.T(x int primary key, y int) WITH " +
- "\"cache_name=T,wrap_value=false\"");
- }
-
- // Timeout to let connection close be handled on server side.
- U.sleep(500);
-
- try (Connection conn = createStreamedConnection(false, 10000)) {
- assertStreamingOn();
-
- PreparedStatement firstStmt = conn.prepareStatement("insert into Person(\"id\", \"name\") values (?, ?)");
-
- PreparedStatement secondStmt = conn.prepareStatement("insert into PUBLIC.T(x, y) values (?, ?)");
-
- try {
- for (int i = 1; i <= 10; i++) {
- firstStmt.setInt(1, i);
- firstStmt.setString(2, nameForId(i));
-
- firstStmt.executeUpdate();
- }
-
- for (int i = 51; i <= 67; i++) {
- secondStmt.setInt(1, i);
- secondStmt.setInt(2, i);
-
- secondStmt.executeUpdate();
- }
-
- for (int i = 11; i <= 50; i++) {
- firstStmt.setInt(1, i);
- firstStmt.setString(2, nameForId(i));
-
- firstStmt.executeUpdate();
- }
-
- for (int i = 68; i <= 100; i++) {
- secondStmt.setInt(1, i);
- secondStmt.setInt(2, i);
-
- secondStmt.executeUpdate();
- }
-
- assertCacheEmpty();
-
- SqlClientContext cliCtx = sqlClientContext();
-
- HashMap<String, IgniteDataStreamer<?, ?>> streamers = U.field(cliCtx, "streamers");
-
- assertEquals(2, streamers.size());
-
- assertEqualsCollections(new HashSet<>(Arrays.asList("person", "T")), streamers.keySet());
- }
- finally {
- U.closeQuiet(firstStmt);
-
- U.closeQuiet(secondStmt);
- }
- }
-
- // Let's wait a little so that all data arrives to destination - we can't intercept streamers' flush
- // on connection close in any way.
- U.sleep(1000);
-
- // Now let's check it's all there.
- for (int i = 1; i <= 50; i++)
- assertEquals(nameForId(i), nameForIdInCache(i));
-
- for (int i = 51; i <= 100; i++)
- assertEquals(i, grid(0).cache("T").get(i));
- }
-
- /**
- *
- */
- public void testStreamingWithMixedStatementTypes() throws Exception {
- String prepStmtStr = "insert into Person(\"id\", \"name\") values (?, ?)";
-
- String stmtStr = "insert into Person(\"id\", \"name\") values (%d, '%s')";
-
- try (Connection conn = createStreamedConnection(false, 10000)) {
- assertStreamingOn();
-
- PreparedStatement firstStmt = conn.prepareStatement(prepStmtStr);
-
- Statement secondStmt = conn.createStatement();
-
- try {
- for (int i = 1; i <= 100; i++) {
- boolean usePrep = Math.random() > 0.5;
-
- boolean useBatch = Math.random() > 0.5;
-
- if (usePrep) {
- firstStmt.setInt(1, i);
- firstStmt.setString(2, nameForId(i));
-
- if (useBatch)
- firstStmt.addBatch();
- else
- firstStmt.execute();
- }
- else {
- String sql = String.format(stmtStr, i, nameForId(i));
-
- if (useBatch)
- secondStmt.addBatch(sql);
- else
- secondStmt.execute(sql);
- }
- }
- }
- finally {
- U.closeQuiet(firstStmt);
-
- U.closeQuiet(secondStmt);
- }
- }
-
- // Let's wait a little so that all data arrives to destination - we can't intercept streamers' flush
- // on connection close in any way.
- U.sleep(1000);
-
- // Now let's check it's all there.
- for (int i = 1; i <= 100; i++)
- assertEquals(nameForId(i), nameForIdInCache(i));
- }
-
- /**
- * Check that there's nothing in cache.
- */
- private void assertCacheEmpty() {
- assertEquals(0, grid(0).cache(DEFAULT_CACHE_NAME).size(CachePeekMode.ALL));
- }
-
- /**
- * @param conn Connection.
- * @param sql Statement.
- * @throws SQLException if failed.
- */
- private static void execute(Connection conn, String sql) throws SQLException {
- try (Statement s = conn.createStatement()) {
- s.execute(sql);
- }
- }
-
- /**
- * @return Active SQL client context.
- */
- private SqlClientContext sqlClientContext() {
- Set<SqlClientContext> ctxs = U.field(grid(0).context().query(), "cliCtxs");
-
- assertFalse(F.isEmpty(ctxs));
-
- assertEquals(1, ctxs.size());
-
- return ctxs.iterator().next();
- }
-
- /**
- * Check that streaming state on target node is as expected.
- */
- private void assertStreamingOn() {
- SqlClientContext cliCtx = sqlClientContext();
-
- assertTrue(cliCtx.isStream());
- }
-
- /** {@inheritDoc} */
- @Override protected void assertStatementForbidden(String sql) {
- batchSize = 1;
-
- super.assertStatementForbidden(sql);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java
index e7a25a5..169f85b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java
@@ -351,70 +351,4 @@ public interface ConnectionProperties {
* @param sslFactory Custom class name that implements Factory<SSLSocketFactory>.
*/
public void setSslFactory(String sslFactory);
-
- /**
- * @return Streamed connection flag.
- */
- public boolean isStream();
-
- /**
- * @param stream Streamed connection flag.
- */
- public void setStream(boolean stream);
-
- /**
- * @return Allow overwrites during streaming connection flag.
- */
- public boolean isStreamAllowOverwrite();
-
- /**
- * @param streamAllowOverwrite Allow overwrites during streaming connection flag.
- */
- public void setStreamAllowOverwrite(boolean streamAllowOverwrite);
-
- /**
- * @return Number of parallel operations per node during streaming connection param.
- */
- public int getStreamParallelOperations();
-
- /**
- * @param streamParallelOperations Number of parallel operations per node during streaming connection param.
- * @throws SQLException if value check failed.
- */
- public void setStreamParallelOperations(int streamParallelOperations) throws SQLException;
-
- /**
- * @return Buffer size during streaming connection param.
- */
- public int getStreamBufferSize();
-
- /**
- * @param streamBufSize Buffer size during streaming connection param.
- * @throws SQLException if value check failed.
- */
- public void setStreamBufferSize(int streamBufSize) throws SQLException;
-
- /**
- * @return Flush timeout during streaming connection param.
- */
- public long getStreamFlushFrequency();
-
- /**
- * @param streamFlushFreq Flush timeout during streaming connection param.
- * @throws SQLException if value check failed.
- */
- public void setStreamFlushFrequency(long streamFlushFreq) throws SQLException;
-
- /**
- * @return Batch size for streaming (number of commands to accumulate internally before actually
- * sending over the wire).
- */
- public int getStreamBatchSize();
-
- /**
- * @param streamBatchSize Batch size for streaming (number of commands to accumulate internally before actually
- * sending over the wire).
- * @throws SQLException if value check failed.
- */
- public void setStreamBatchSize(int streamBatchSize) throws SQLException;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
index 3f1819d..471381b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java
@@ -146,44 +146,15 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
private StringProperty sslFactory = new StringProperty("sslFactory",
"Custom class name that implements Factory<SSLSocketFactory>", null, null, false, null);
- /** Turn on streaming mode on this connection. */
- private BooleanProperty stream = new BooleanProperty(
- "streaming", "Turn on streaming mode on this connection", false, false);
-
- /** Turn on overwrite during streaming on this connection. */
- private BooleanProperty streamAllowOverwrite = new BooleanProperty(
- "streamingAllowOverwrite", "Turn on overwrite during streaming on this connection", false, false);
-
- /** Number of parallel operations per cluster node during streaming. */
- private IntegerProperty streamParOps = new IntegerProperty(
- "streamingPerNodeParallelOperations", "Number of parallel operations per cluster node during streaming",
- 0, false, 0, Integer.MAX_VALUE);
-
- /** Buffer size per cluster node during streaming. */
- private IntegerProperty streamBufSize = new IntegerProperty(
- "streamingPerNodeBufferSize", "Buffer size per cluster node during streaming",
- 0, false, 0, Integer.MAX_VALUE);
-
- /** Buffer size per cluster node during streaming. */
- private LongProperty streamFlushFreq = new LongProperty(
- "streamingFlushFrequency", "Buffer size per cluster node during streaming",
- 0, false, 0, Long.MAX_VALUE);
-
- /** Buffer size per cluster node during streaming. */
- private IntegerProperty streamBatchSize = new IntegerProperty(
- "streamingBatchSize", "Batch size for streaming (number of commands to accumulate internally " +
- "before actually sending over the wire)", 10, false, 1, Integer.MAX_VALUE);
-
/** Properties array. */
- private final ConnectionProperty [] props = {
+ private final ConnectionProperty [] propsArray = {
host, port,
distributedJoins, enforceJoinOrder, collocated, replicatedOnly, autoCloseServerCursor,
tcpNoDelay, lazy, socketSendBuffer, socketReceiveBuffer, skipReducerOnUpdate,
sslMode, sslProtocol, sslKeyAlgorithm,
sslClientCertificateKeyStoreUrl, sslClientCertificateKeyStorePassword, sslClientCertificateKeyStoreType,
sslTrustCertificateKeyStoreUrl, sslTrustCertificateKeyStorePassword, sslTrustCertificateKeyStoreType,
- sslTrustAll, sslFactory,
- stream, streamAllowOverwrite, streamParOps, streamBufSize, streamFlushFreq, streamBatchSize
+ sslTrustAll, sslFactory
};
/** {@inheritDoc} */
@@ -416,66 +387,6 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
this.sslFactory.setValue(sslFactory);
}
- /** {@inheritDoc} */
- @Override public boolean isStream() {
- return stream.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStream(boolean val) {
- stream.setValue(val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean isStreamAllowOverwrite() {
- return streamAllowOverwrite.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStreamAllowOverwrite(boolean val) {
- streamAllowOverwrite.setValue(val);
- }
-
- /** {@inheritDoc} */
- @Override public int getStreamParallelOperations() {
- return streamParOps.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStreamParallelOperations(int val) throws SQLException {
- streamParOps.setValue(val);
- }
-
- /** {@inheritDoc} */
- @Override public int getStreamBufferSize() {
- return streamBufSize.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStreamBufferSize(int val) throws SQLException {
- streamBufSize.setValue(val);
- }
-
- /** {@inheritDoc} */
- @Override public long getStreamFlushFrequency() {
- return streamFlushFreq.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStreamFlushFrequency(long val) throws SQLException {
- streamFlushFreq.setValue(val);
- }
-
- /** {@inheritDoc} */
- @Override public int getStreamBatchSize() {
- return streamBatchSize.value();
- }
-
- /** {@inheritDoc} */
- @Override public void setStreamBatchSize(int val) throws SQLException {
- streamBatchSize.setValue(val);
- }
-
/**
* @param props Environment properties.
* @throws SQLException On error.
@@ -483,7 +394,7 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
void init(Properties props) throws SQLException {
Properties props0 = (Properties)props.clone();
- for (ConnectionProperty aPropsArray : this.props)
+ for (ConnectionProperty aPropsArray : propsArray)
aPropsArray.init(props0);
}
@@ -491,10 +402,10 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
* @return Driver's properties info array.
*/
private DriverPropertyInfo[] getDriverPropertyInfo() {
- DriverPropertyInfo[] dpis = new DriverPropertyInfo[props.length];
+ DriverPropertyInfo[] dpis = new DriverPropertyInfo[propsArray.length];
- for (int i = 0; i < props.length; ++i)
- dpis[i] = props[i].getDriverPropertyInfo();
+ for (int i = 0; i < propsArray.length; ++i)
+ dpis[i] = propsArray[i].getDriverPropertyInfo();
return dpis;
}
@@ -811,8 +722,7 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
else {
try {
setValue(parse(str));
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
throw new SQLException("Failed to parse int property [name=" + name +
", value=" + str + ']', SqlStateCode.CLIENT_CONNECTION_FAILED);
}
@@ -887,38 +797,6 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa
/**
*
*/
- private static class LongProperty extends NumberProperty {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * @param name Name.
- * @param desc Description.
- * @param dfltVal Default value.
- * @param required {@code true} if the property is required.
- * @param min Lower bound of allowed range.
- * @param max Upper bound of allowed range.
- */
- LongProperty(String name, String desc, Number dfltVal, boolean required, long min, long max) {
- super(name, desc, dfltVal, required, min, max);
- }
-
- /** {@inheritDoc} */
- @Override protected Number parse(String str) throws NumberFormatException {
- return Long.parseLong(str);
- }
-
- /**
- * @return Property value.
- */
- long value() {
- return val.longValue();
- }
- }
-
- /**
- *
- */
private static class StringProperty extends ConnectionProperty {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
index b223f54..ac9925d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.jdbc.thin;
import java.sql.Array;
-import java.sql.BatchUpdateException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
@@ -34,19 +33,13 @@ import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
-import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
import org.apache.ignite.internal.processors.odbc.SqlStateCode;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult;
-import org.apache.ignite.internal.processors.odbc.jdbc.JdbcQuery;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequest;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResponse;
import org.apache.ignite.internal.processors.odbc.jdbc.JdbcResult;
@@ -101,12 +94,6 @@ public class JdbcThinConnection implements Connection {
/** Connection properties. */
private ConnectionProperties connProps;
- /** Batch for streaming. */
- private List<JdbcQuery> streamBatch;
-
- /** Last added query to recognize batches. */
- private String lastStreamQry;
-
/**
* Creates new connection.
*
@@ -148,53 +135,6 @@ public class JdbcThinConnection implements Connection {
}
}
- /**
- * @return Whether this connection is streamed or not.
- */
- public boolean isStream() {
- return connProps.isStream();
- }
-
- /**
- * Add another query for batched execution.
- * @param sql Query.
- * @param args Arguments.
- */
- synchronized void addBatch(String sql, List<Object> args) throws SQLException {
- boolean newQry = (args == null || !F.eq(lastStreamQry, sql));
-
- // Providing null as SQL here allows for recognizing subbatches on server and handling them more efficiently.
- JdbcQuery q = new JdbcQuery(newQry ? sql : null, args != null ? args.toArray() : null);
-
- if (streamBatch == null)
- streamBatch = new ArrayList<>(connProps.getStreamBatchSize());
-
- streamBatch.add(q);
-
- // Null args means "addBatch(String)" was called on non-prepared Statement,
- // we don't want to remember its query string.
- lastStreamQry = (args != null ? sql : null);
-
- if (streamBatch.size() == connProps.getStreamBatchSize())
- executeBatch();
- }
-
- /**
- * @throws SQLException if failed.
- */
- private void executeBatch() throws SQLException {
- JdbcBatchExecuteResult res = sendRequest(new JdbcBatchExecuteRequest(schema, streamBatch));
-
- streamBatch = null;
-
- lastStreamQry = null;
-
- if (res.errorCode() != ClientListenerResponse.STATUS_SUCCESS) {
- throw new BatchUpdateException(res.errorMessage(), IgniteQueryErrorCode.codeToSqlState(res.errorCode()),
- res.errorCode(), res.updateCounts());
- }
- }
-
/** {@inheritDoc} */
@Override public Statement createStatement() throws SQLException {
return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
@@ -337,15 +277,6 @@ public class JdbcThinConnection implements Connection {
if (isClosed())
return;
- if (!F.isEmpty(streamBatch)) {
- try {
- executeBatch();
- }
- catch (SQLException e) {
- LOG.log(Level.WARNING, "Exception during batch send on streamed connection close", e);
- }
- }
-
closed = true;
cliIo.close();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
index dfd1e77..23d3bbe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
@@ -262,19 +262,13 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements Prep
@Override public void addBatch() throws SQLException {
ensureNotClosed();
- batchSize++;
-
- if (conn.isStream())
- conn.addBatch(sql, args);
- else {
- if (batch == null) {
- batch = new ArrayList<>();
-
- batch.add(new JdbcQuery(sql, args.toArray(new Object[args.size()])));
- }
- else
- batch.add(new JdbcQuery(null, args.toArray(new Object[args.size()])));
+ if (batch == null) {
+ batch = new ArrayList<>();
+
+ batch.add(new JdbcQuery(sql, args.toArray(new Object[args.size()])));
}
+ else
+ batch.add(new JdbcQuery(null, args.toArray(new Object[args.size()])));
args = null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
index a71812f..9c41804 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinStatement.java
@@ -79,9 +79,6 @@ public class JdbcThinStatement implements Statement {
/** Result set holdability*/
private final int resHoldability;
- /** Batch size to keep track of number of items to return as fake update counters for executeBatch. */
- protected int batchSize;
-
/** Batch. */
protected List<JdbcQuery> batch;
@@ -136,19 +133,6 @@ public class JdbcThinStatement implements Statement {
if (sql == null || sql.isEmpty())
throw new SQLException("SQL query is empty.");
- if (conn.isStream()) {
- if (stmtType == JdbcStatementType.SELECT_STATEMENT_TYPE)
- throw new SQLException("Only tuple based INSERT statements are supported in streaming mode.",
- SqlStateCode.INTERNAL_ERROR,
- IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
-
- conn.addBatch(sql, args);
-
- resultSets = Collections.singletonList(resultSetForUpdate(0));
-
- return;
- }
-
JdbcResult res0 = conn.sendRequest(new JdbcQueryExecuteRequest(stmtType, schema, pageSize,
maxRows, sql, args == null ? null : args.toArray(new Object[args.size()])));
@@ -174,8 +158,11 @@ public class JdbcThinStatement implements Statement {
boolean firstRes = true;
for(JdbcResultInfo rsInfo : resInfos) {
- if (!rsInfo.isQuery())
- resultSets.add(resultSetForUpdate(rsInfo.updateCount()));
+ if (!rsInfo.isQuery()) {
+ resultSets.add(new JdbcThinResultSet(this, -1, pageSize,
+ true, Collections.<List<Object>>emptyList(), false,
+ conn.autoCloseServerCursor(), rsInfo.updateCount(), closeOnCompletion));
+ }
else {
if (firstRes) {
firstRes = false;
@@ -199,16 +186,6 @@ public class JdbcThinStatement implements Statement {
}
/**
- * @param cnt Update counter.
- * @return Result set for given update counter.
- */
- private JdbcThinResultSet resultSetForUpdate(long cnt) {
- return new JdbcThinResultSet(this, -1, pageSize,
- true, Collections.<List<Object>>emptyList(), false,
- conn.autoCloseServerCursor(), cnt, closeOnCompletion);
- }
-
- /**
* Sends a file to server in batches via multiple {@link JdbcBulkLoadBatchRequest}s.
*
* @param cmdRes Result of invoking COPY command: contains server-parsed
@@ -492,14 +469,6 @@ public class JdbcThinStatement implements Statement {
@Override public void addBatch(String sql) throws SQLException {
ensureNotClosed();
- batchSize++;
-
- if (conn.isStream()) {
- conn.addBatch(sql, null);
-
- return;
- }
-
if (batch == null)
batch = new ArrayList<>();
@@ -510,8 +479,6 @@ public class JdbcThinStatement implements Statement {
@Override public void clearBatch() throws SQLException {
ensureNotClosed();
- batchSize = 0;
-
batch = null;
}
@@ -521,14 +488,6 @@ public class JdbcThinStatement implements Statement {
closeResults();
- if (conn.isStream()) {
- int[] res = new int[batchSize];
-
- batchSize = 0;
-
- return res;
- }
-
if (batch == null || batch.isEmpty())
throw new SQLException("Batch is empty.");
@@ -543,8 +502,6 @@ public class JdbcThinStatement implements Statement {
return res.updateCounts();
}
finally {
- batchSize = 0;
-
batch = null;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
index efd7df0..7aa6c33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -62,11 +62,8 @@ public class JdbcThinTcpIo {
/** Version 2.4.0. */
private static final ClientListenerProtocolVersion VER_2_4_0 = ClientListenerProtocolVersion.create(2, 4, 0);
- /** Version 2.5.0. */
- private static final ClientListenerProtocolVersion VER_2_5_0 = ClientListenerProtocolVersion.create(2, 5, 0);
-
/** Current version. */
- private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_5_0;
+ private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_4_0;
/** Initial output stream capacity for handshake. */
private static final int HANDSHAKE_MSG_SIZE = 13;
@@ -268,11 +265,6 @@ public class JdbcThinTcpIo {
writer.writeBoolean(connProps.isAutoCloseServerCursor());
writer.writeBoolean(connProps.isLazy());
writer.writeBoolean(connProps.isSkipReducerOnUpdate());
- writer.writeBoolean(connProps.isStream());
- writer.writeBoolean(connProps.isStreamAllowOverwrite());
- writer.writeInt(connProps.getStreamParallelOperations());
- writer.writeInt(connProps.getStreamBufferSize());
- writer.writeLong(connProps.getStreamFlushFrequency());
send(writer.array());
@@ -306,8 +298,7 @@ public class JdbcThinTcpIo {
ClientListenerProtocolVersion srvProtocolVer = ClientListenerProtocolVersion.create(maj, min, maintenance);
- if (VER_2_4_0.equals(srvProtocolVer) || VER_2_3_0.equals(srvProtocolVer) ||
- VER_2_1_5.equals(srvProtocolVer))
+ if (VER_2_3_0.equals(srvProtocolVer) || VER_2_1_5.equals(srvProtocolVer))
handshake(srvProtocolVer);
else if (VER_2_1_0.equals(srvProtocolVer))
handshake_2_1_0();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/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
index f61ccf9..b51e0b9 100644
--- 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
@@ -60,7 +60,6 @@ import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.odbc.SqlStateCode;
import org.apache.ignite.internal.processors.query.GridQueryIndexing;
-import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -613,11 +612,10 @@ public class JdbcConnection implements Connection {
PreparedStatement nativeStmt = prepareNativeStatement(sql);
- try {
- idx.checkStatementStreamable(nativeStmt);
- }
- catch (IgniteSQLException e) {
- throw e.toJdbcException();
+ if (!idx.isInsertStatement(nativeStmt)) {
+ throw new SQLException("Only INSERT operations are supported in streaming mode",
+ SqlStateCode.INTERNAL_ERROR,
+ IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
}
IgniteDataStreamer streamer = ignite().dataStreamer(cacheName);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStreamedPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStreamedPreparedStatement.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStreamedPreparedStatement.java
index 25f55f2..408f089 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStreamedPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcStreamedPreparedStatement.java
@@ -55,7 +55,7 @@ class JdbcStreamedPreparedStatement extends JdbcPreparedStatement {
/** {@inheritDoc} */
@Override protected void execute0(String sql, Boolean isQuery) throws SQLException {
- assert isQuery == null || !isQuery;
+ assert isQuery != null && !isQuery;
long updCnt = conn.ignite().context().query().streamUpdateQuery(conn.cacheName(), conn.schemaName(),
streamer, sql, getArgs());
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index c5d68b5..a834022 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -629,7 +629,7 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
- return ctx.kernalContext().query().querySqlFields(ctx, qry, null, keepBinary, false);
+ return ctx.kernalContext().query().querySqlFields(ctx, qry, keepBinary, false);
}
catch (Exception e) {
if (e instanceof CacheException)
@@ -662,7 +662,7 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
if (qry instanceof SqlFieldsQuery)
return (FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, (SqlFieldsQuery)qry,
- null, keepBinary, true).get(0);
+ keepBinary, true).get(0);
if (qry instanceof ScanQuery)
return query((ScanQuery)qry, null, projection(qry.isLocal()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
index 214d006..5841a4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java
@@ -28,7 +28,7 @@ import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler;
import org.apache.ignite.internal.util.GridSpinBusyLock;
/**
- * JDBC Connection Context.
+ * ODBC Connection Context.
*/
public class JdbcConnectionContext implements ClientListenerConnectionContext {
/** Version 2.1.0. */
@@ -38,16 +38,13 @@ public class JdbcConnectionContext implements ClientListenerConnectionContext {
private static final ClientListenerProtocolVersion VER_2_1_5 = ClientListenerProtocolVersion.create(2, 1, 5);
/** Version 2.3.1: added "multiple statements query" feature. */
- static final ClientListenerProtocolVersion VER_2_3_0 = ClientListenerProtocolVersion.create(2, 3, 0);
+ public static final ClientListenerProtocolVersion VER_2_3_0 = ClientListenerProtocolVersion.create(2, 3, 0);
/** Version 2.4.0: adds default values for columns feature. */
- static final ClientListenerProtocolVersion VER_2_4_0 = ClientListenerProtocolVersion.create(2, 4, 0);
-
- /** Version 2.5.0: adds streaming via thin connection. */
- static final ClientListenerProtocolVersion VER_2_5_0 = ClientListenerProtocolVersion.create(2, 5, 0);
+ public static final ClientListenerProtocolVersion VER_2_4_0 = ClientListenerProtocolVersion.create(2, 4, 0);
/** Current version. */
- private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_5_0;
+ private static final ClientListenerProtocolVersion CURRENT_VER = VER_2_4_0;
/** Supported versions. */
private static final Set<ClientListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
@@ -69,7 +66,6 @@ public class JdbcConnectionContext implements ClientListenerConnectionContext {
static {
SUPPORTED_VERS.add(CURRENT_VER);
- SUPPORTED_VERS.add(VER_2_4_0);
SUPPORTED_VERS.add(VER_2_3_0);
SUPPORTED_VERS.add(VER_2_1_5);
SUPPORTED_VERS.add(VER_2_1_0);
@@ -117,23 +113,8 @@ public class JdbcConnectionContext implements ClientListenerConnectionContext {
if (ver.compareTo(VER_2_3_0) >= 0)
skipReducerOnUpdate = reader.readBoolean();
- boolean stream = false;
- boolean streamAllowOverwrites = false;
- int streamParOps = 0;
- int streamBufSize = 0;
- long streamFlushFreq = 0;
-
- if (ver.compareTo(VER_2_5_0) >= 0) {
- stream = reader.readBoolean();
- streamAllowOverwrites = reader.readBoolean();
- streamParOps = reader.readInt();
- streamBufSize = reader.readInt();
- streamFlushFreq = reader.readLong();
- }
-
handler = new JdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, enforceJoinOrder,
- collocated, replicatedOnly, autoCloseCursors, lazyExec, skipReducerOnUpdate, stream, streamAllowOverwrites,
- streamParOps, streamBufSize, streamFlushFreq, ver);
+ collocated, replicatedOnly, autoCloseCursors, lazyExec, skipReducerOnUpdate, ver);
parser = new JdbcMessageParser(ctx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
index 8786f26..59fc06b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
@@ -53,7 +53,6 @@ import org.apache.ignite.internal.processors.query.GridQueryProperty;
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.processors.query.SqlClientContext;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
@@ -89,9 +88,6 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
/** Kernel context. */
private final GridKernalContext ctx;
- /** Client context. */
- private final SqlClientContext cliCtx;
-
/** Logger. */
private final IgniteLogger log;
@@ -107,9 +103,24 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
/** Current bulk load processors. */
private final ConcurrentHashMap<Long, JdbcBulkLoadProcessor> bulkLoadRequests = new ConcurrentHashMap<>();
+ /** Distributed joins flag. */
+ private final boolean distributedJoins;
+
+ /** Enforce join order flag. */
+ private final boolean enforceJoinOrder;
+
+ /** Collocated flag. */
+ private final boolean collocated;
+
/** Replicated only flag. */
private final boolean replicatedOnly;
+ /** Lazy query execution flag. */
+ private final boolean lazy;
+
+ /** Skip reducer on update flag. */
+ private final boolean skipReducerOnUpdate;
+
/** Automatic close of cursors. */
private final boolean autoCloseCursors;
@@ -129,38 +140,22 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
* @param autoCloseCursors Flag to automatically close server cursors.
* @param lazy Lazy query execution flag.
* @param skipReducerOnUpdate Skip reducer on update flag.
- * @param stream Streaming flag.
- * @param streamAllowOverwrites Streaming overwrites flag.
- * @param streamParOps Number of parallel ops per cluster node during streaming.
- * @param streamBufSize Buffer size per cluster node during streaming.
- * @param streamFlushFreq Data streamers' flush timeout.
* @param protocolVer Protocol version.
*/
public JdbcRequestHandler(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors,
boolean distributedJoins, boolean enforceJoinOrder, boolean collocated, boolean replicatedOnly,
boolean autoCloseCursors, boolean lazy, boolean skipReducerOnUpdate,
- boolean stream, boolean streamAllowOverwrites, int streamParOps, int streamBufSize, long streamFlushFreq,
ClientListenerProtocolVersion protocolVer) {
this.ctx = ctx;
-
- this.cliCtx = new SqlClientContext(
- ctx,
- distributedJoins,
- enforceJoinOrder,
- collocated,
- lazy,
- skipReducerOnUpdate,
- stream,
- streamAllowOverwrites,
- streamParOps,
- streamBufSize,
- streamFlushFreq
- );
-
this.busyLock = busyLock;
this.maxCursors = maxCursors;
+ this.distributedJoins = distributedJoins;
+ this.enforceJoinOrder = enforceJoinOrder;
+ this.collocated = collocated;
this.replicatedOnly = replicatedOnly;
this.autoCloseCursors = autoCloseCursors;
+ this.lazy = lazy;
+ this.skipReducerOnUpdate = skipReducerOnUpdate;
this.protocolVer = protocolVer;
log = ctx.log(getClass());
@@ -306,8 +301,6 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
}
bulkLoadRequests.clear();
-
- U.close(cliCtx, log);
}
finally {
busyLock.leaveBusy();
@@ -333,8 +326,6 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
long qryId = QRY_ID_GEN.getAndIncrement();
- assert !cliCtx.isStream();
-
try {
String sql = req.sqlQuery();
@@ -356,17 +347,17 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
qry = new SqlFieldsQueryEx(sql, false);
- if (cliCtx.isSkipReducerOnUpdate())
+ if (skipReducerOnUpdate)
((SqlFieldsQueryEx)qry).setSkipReducerOnUpdate(true);
}
qry.setArgs(req.arguments());
- qry.setDistributedJoins(cliCtx.isDistributedJoins());
- qry.setEnforceJoinOrder(cliCtx.isEnforceJoinOrder());
- qry.setCollocated(cliCtx.isCollocated());
+ qry.setDistributedJoins(distributedJoins);
+ qry.setEnforceJoinOrder(enforceJoinOrder);
+ qry.setCollocated(collocated);
qry.setReplicatedOnly(replicatedOnly);
- qry.setLazy(cliCtx.isLazy());
+ qry.setLazy(lazy);
if (req.pageSize() <= 0)
return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, "Invalid fetch size: " + req.pageSize());
@@ -380,7 +371,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
qry.setSchema(schemaName);
- List<FieldsQueryCursor<List<?>>> results = ctx.query().querySqlFields(null, qry, cliCtx, true,
+ List<FieldsQueryCursor<List<?>>> results = ctx.query().querySqlFields(qry, true,
protocolVer.compareTo(VER_2_3_0) < 0);
FieldsQueryCursor<List<?>> fieldsCur = results.get(0);
@@ -578,11 +569,11 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
qry = new SqlFieldsQueryEx(q.sql(), false);
- qry.setDistributedJoins(cliCtx.isDistributedJoins());
- qry.setEnforceJoinOrder(cliCtx.isEnforceJoinOrder());
- qry.setCollocated(cliCtx.isCollocated());
+ qry.setDistributedJoins(distributedJoins);
+ qry.setEnforceJoinOrder(enforceJoinOrder);
+ qry.setCollocated(collocated);
qry.setReplicatedOnly(replicatedOnly);
- qry.setLazy(cliCtx.isLazy());
+ qry.setLazy(lazy);
qry.setSchema(schemaName);
}
@@ -610,21 +601,10 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler {
* @param updCntsAcc Per query rows updates counter.
* @param firstErr First error data - code and message.
*/
- @SuppressWarnings("ForLoopReplaceableByForEach")
private void executeBatchedQuery(SqlFieldsQueryEx qry, List<Integer> updCntsAcc,
IgniteBiTuple<Integer, String> firstErr) {
try {
- if (cliCtx.isStream()) {
- List<Long> cnt = ctx.query().streamBatchedUpdateQuery(qry.getSchema(), cliCtx, qry.getSql(),
- qry.batchedArguments());
-
- for (int i = 0; i < cnt.size(); i++)
- updCntsAcc.add(cnt.get(i).intValue());
-
- return;
- }
-
- List<FieldsQueryCursor<List<?>>> qryRes = ctx.query().querySqlFields(null, qry, cliCtx, true, true);
+ List<FieldsQueryCursor<List<?>>> qryRes = ctx.query().querySqlFields(qry, true, true);
for (FieldsQueryCursor<List<?>> cur : qryRes) {
if (cur instanceof BulkLoadContextCursor)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index dedd075..6b425a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -76,46 +76,33 @@ public interface GridQueryIndexing {
* Detect whether SQL query should be executed in distributed or local manner and execute it.
* @param schemaName Schema name.
* @param qry Query.
- * @param cliCtx Client context.
* @param keepBinary Keep binary flag.
* @param failOnMultipleStmts Whether an exception should be thrown for multiple statements query.
- * @param cancel Query cancel state handler. @return Cursor.
+ * @param cancel Query cancel state handler.
+ * @return Cursor.
*/
- public List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry,
- SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel);
+ public List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry, boolean keepBinary,
+ boolean failOnMultipleStmts, GridQueryCancel cancel);
/**
- * Execute an INSERT statement using data streamer as receiver.
+ * Perform a MERGE statement using data streamer as receiver.
*
* @param schemaName Schema name.
* @param qry Query.
* @param params Query parameters.
* @param streamer Data streamer to feed data to.
- * @return Update counter.
+ * @return Query result.
* @throws IgniteCheckedException If failed.
*/
public long streamUpdateQuery(String schemaName, String qry, @Nullable Object[] params,
IgniteDataStreamer<?, ?> streamer) throws IgniteCheckedException;
/**
- * Execute a batched INSERT statement using data streamer as receiver.
- *
- * @param schemaName Schema name.
- * @param qry Query.
- * @param params Query parameters.
- * @param cliCtx Client connection context.
- * @return Update counters.
- * @throws IgniteCheckedException If failed.
- */
- public List<Long> streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params,
- SqlClientContext cliCtx) throws IgniteCheckedException;
-
- /**
* Executes regular query.
*
* @param schemaName Schema name.
* @param cacheName Cache name.
- * @param qry Query.
+ *@param qry Query.
* @param filter Cache name and key filter.
* @param keepBinary Keep binary flag. @return Cursor.
*/
@@ -326,11 +313,12 @@ public interface GridQueryIndexing {
public String schema(String cacheName);
/**
- * Check if passed statement is insert statement eligible for streaming, throw an {@link IgniteSQLException} if not.
+ * Check if passed statement is insert statemtn.
*
* @param nativeStmt Native statement.
+ * @return {@code True} if insert.
*/
- public void checkStatementStreamable(PreparedStatement nativeStmt);
+ public boolean isInsertStatement(PreparedStatement nativeStmt);
/**
* Return row cache cleaner.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index fcea905..f666cdd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -100,7 +100,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.T3;
-import org.apache.ignite.internal.util.typedef.internal.A;
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;
@@ -190,9 +189,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** Pending status messages. */
private final LinkedList<SchemaOperationStatusMessage> pendingMsgs = new LinkedList<>();
- /** All currently open client contexts. */
- private final Set<SqlClientContext> cliCtxs = Collections.newSetFromMap(new ConcurrentHashMap<>());
-
/** Current cache that has a query running on it. */
private final ThreadLocal<GridCacheContext> curCache = new ThreadLocal<>();
@@ -263,15 +259,11 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (cancel && idx != null) {
try {
- while (!busyLock.tryBlock(500)) {
+ while (!busyLock.tryBlock(500))
idx.cancelAllQueries();
- closeAllSqlStreams();
- }
-
return;
- }
- catch (InterruptedException ignored) {
+ } catch (InterruptedException ignored) {
U.warn(log, "Interrupted while waiting for active queries cancellation.");
Thread.currentThread().interrupt();
@@ -355,32 +347,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * @param cliCtx Client context to register.
- */
- void registerClientContext(SqlClientContext cliCtx) {
- A.notNull(cliCtx, "cliCtx");
-
- cliCtxs.add(cliCtx);
- }
-
- /**
- * @param cliCtx Client context to register.
- */
- void unregisterClientContext(SqlClientContext cliCtx) {
- A.notNull(cliCtx, "cliCtx");
-
- cliCtxs.remove(cliCtx);
- }
-
- /**
- * Flush streamers on all currently open client contexts.
- */
- private void closeAllSqlStreams() {
- for (SqlClientContext cliCtx : cliCtxs)
- U.close(cliCtx, log);
- }
-
- /**
* Process schema propose message from discovery thread.
*
* @param msg Message.
@@ -2008,7 +1974,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*/
public List<FieldsQueryCursor<List<?>>> querySqlFields(final SqlFieldsQuery qry, final boolean keepBinary,
final boolean failOnMultipleStmts) {
- return querySqlFields(null, qry, null, keepBinary, failOnMultipleStmts);
+ return querySqlFields(null, qry, keepBinary, failOnMultipleStmts);
+ }
+
+ @SuppressWarnings("unchecked")
+ public FieldsQueryCursor<List<?>> querySqlFields(final GridCacheContext<?,?> cctx, final SqlFieldsQuery qry,
+ final boolean keepBinary) {
+ return querySqlFields(cctx, qry, keepBinary, true).get(0);
}
/**
@@ -2019,7 +1991,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @return Cursor.
*/
public FieldsQueryCursor<List<?>> querySqlFields(final SqlFieldsQuery qry, final boolean keepBinary) {
- return querySqlFields(null, qry, null, keepBinary, true).get(0);
+ return querySqlFields(null, qry, keepBinary, true).get(0);
}
/**
@@ -2027,16 +1999,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*
* @param cctx Cache context.
* @param qry Query.
- * @param cliCtx Client context.
* @param keepBinary Keep binary flag.
* @param failOnMultipleStmts If {@code true} the method must throws exception when query contains
* more then one SQL statement.
* @return Cursor.
*/
@SuppressWarnings("unchecked")
- public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable final GridCacheContext<?, ?> cctx,
- final SqlFieldsQuery qry, final SqlClientContext cliCtx, final boolean keepBinary,
- final boolean failOnMultipleStmts) {
+ public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable final GridCacheContext<?,?> cctx,
+ final SqlFieldsQuery qry, final boolean keepBinary, final boolean failOnMultipleStmts) {
checkxEnabled();
validateSqlFieldsQuery(qry);
@@ -2064,7 +2034,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
GridQueryCancel cancel = new GridQueryCancel();
List<FieldsQueryCursor<List<?>>> res =
- idx.querySqlFields(schemaName, qry, cliCtx, keepBinary, failOnMultipleStmts, cancel);
+ idx.querySqlFields(schemaName, qry, keepBinary, failOnMultipleStmts, cancel);
if (cctx != null)
sendQueryExecutedEvent(qry.getSql(), qry.getArgs(), cctx);
@@ -2103,7 +2073,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param schemaName Schema name.
* @param streamer Data streamer.
* @param qry Query.
- * @return Update counter.
+ * @return Iterator.
*/
public long streamUpdateQuery(@Nullable final String cacheName, final String schemaName,
final IgniteDataStreamer<?, ?> streamer, final String qry, final Object[] args) {
@@ -2130,33 +2100,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * @param schemaName Schema name.
- * @param cliCtx Client context.
- * @param qry Query.
- * @param args Query arguments.
- * @return Update counters.
- */
- public List<Long> streamBatchedUpdateQuery(final String schemaName, final SqlClientContext cliCtx,
- final String qry, final List<Object[]> args) {
- if (!busyLock.enterBusy())
- throw new IllegalStateException("Failed to execute query (grid is stopping).");
-
- try {
- return executeQuery(GridCacheQueryType.SQL_FIELDS, qry, null, new IgniteOutClosureX<List<Long>>() {
- @Override public List<Long> applyx() throws IgniteCheckedException {
- return idx.streamBatchedUpdateQuery(schemaName, qry, args, cliCtx);
- }
- }, true);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- busyLock.leaveBusy();
- }
- }
-
- /**
* Execute distributed SQL query.
*
* @param cctx Cache context.
[2/3] ignite git commit: Revert "IGNITE-7253: Streaming mode for JDBC
thin driver. This closes #3499."
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java
deleted file mode 100644
index b185535..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.query;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- * Container for connection properties passed by various drivers (JDBC drivers, possibly ODBC) having notion of an
- * <b>SQL connection</b> - Ignite basically does not have one.<p>
- * Also contains anything that a driver may need to share between threads processing queries of logically same client -
- * see JDBC thin driver
- */
-public class SqlClientContext implements AutoCloseable {
- /** Kernal context. */
- private final GridKernalContext ctx;
-
- /** Distributed joins flag. */
- private final boolean distributedJoins;
-
- /** Enforce join order flag. */
- private final boolean enforceJoinOrder;
-
- /** Collocated flag. */
- private final boolean collocated;
-
- /** Lazy query execution flag. */
- private final boolean lazy;
-
- /** Skip reducer on update flag. */
- private final boolean skipReducerOnUpdate;
-
- /** Allow overwrites for duplicate keys on streamed {@code INSERT}s. */
- private final boolean streamAllowOverwrite;
-
- /** Parallel ops count per node for data streamer. */
- private final int streamNodeParOps;
-
- /** Node buffer size for data streamer. */
- private final int streamNodeBufSize;
-
- /** Auto flush frequency for streaming. */
- private final long streamFlushTimeout;
-
- /** Streamers for various caches. */
- private final Map<String, IgniteDataStreamer<?, ?>> streamers;
-
- /** Logger. */
- private final IgniteLogger log;
-
- /**
- * @param ctx Kernal context.
- * @param distributedJoins Distributed joins flag.
- * @param enforceJoinOrder Enforce join order flag.
- * @param collocated Collocated flag.
- * @param lazy Lazy query execution flag.
- * @param skipReducerOnUpdate Skip reducer on update flag.
- * @param stream Streaming state flag
- * @param streamAllowOverwrite Allow overwrites for duplicate keys on streamed {@code INSERT}s.
- * @param streamNodeParOps Parallel ops count per node for data streamer.
- * @param streamNodeBufSize Node buffer size for data streamer.
- * @param streamFlushTimeout Auto flush frequency for streaming.
- */
- public SqlClientContext(GridKernalContext ctx, boolean distributedJoins, boolean enforceJoinOrder,
- boolean collocated, boolean lazy, boolean skipReducerOnUpdate, boolean stream, boolean streamAllowOverwrite,
- int streamNodeParOps, int streamNodeBufSize, long streamFlushTimeout) {
- this.ctx = ctx;
- this.distributedJoins = distributedJoins;
- this.enforceJoinOrder = enforceJoinOrder;
- this.collocated = collocated;
- this.lazy = lazy;
- this.skipReducerOnUpdate = skipReducerOnUpdate;
- this.streamAllowOverwrite = streamAllowOverwrite;
- this.streamNodeParOps = streamNodeParOps;
- this.streamNodeBufSize = streamNodeBufSize;
- this.streamFlushTimeout = streamFlushTimeout;
-
- streamers = stream ? new HashMap<>() : null;
-
- log = ctx.log(SqlClientContext.class.getName());
-
- ctx.query().registerClientContext(this);
- }
-
- /**
- * @return Collocated flag.
- */
- public boolean isCollocated() {
- return collocated;
- }
-
- /**
- * @return Distributed joins flag.
- */
- public boolean isDistributedJoins() {
- return distributedJoins;
- }
-
- /**
- * @return Enforce join order flag.
- */
- public boolean isEnforceJoinOrder() {
- return enforceJoinOrder;
- }
-
- /**
- * @return Lazy query execution flag.
- */
- public boolean isLazy() {
- return lazy;
- }
-
- /**
- * @return Skip reducer on update flag,
- */
- public boolean isSkipReducerOnUpdate() {
- return skipReducerOnUpdate;
- }
-
- /**
- * @return Streaming state flag (on or off).
- */
- public boolean isStream() {
- return streamers != null;
- }
-
- /**
- * @param cacheName Cache name.
- * @return Streamer for given cache.
- */
- public IgniteDataStreamer<?, ?> streamerForCache(String cacheName) {
- Map<String, IgniteDataStreamer<?, ?>> curStreamers = streamers;
-
- if (curStreamers == null)
- return null;
-
- IgniteDataStreamer<?, ?> res = curStreamers.get(cacheName);
-
- if (res != null)
- return res;
-
- res = ctx.grid().dataStreamer(cacheName);
-
- IgniteDataStreamer<?, ?> exStreamer = curStreamers.putIfAbsent(cacheName, res);
-
- if (exStreamer == null) {
- res.autoFlushFrequency(streamFlushTimeout);
-
- res.allowOverwrite(streamAllowOverwrite);
-
- if (streamNodeBufSize > 0)
- res.perNodeBufferSize(streamNodeBufSize);
-
- if (streamNodeParOps > 0)
- res.perNodeParallelOperations(streamNodeParOps);
-
- return res;
- }
- else { // Someone got ahead of us.
- res.close();
-
- return exStreamer;
- }
- }
-
- /** {@inheritDoc} */
- @Override public void close() throws Exception {
- ctx.query().unregisterClientContext(this);
-
- if (streamers == null)
- return;
-
- for (IgniteDataStreamer<?, ?> s : streamers.values())
- U.close(s, log);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java
index 70f72a7..0627def 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java
@@ -122,7 +122,7 @@ public class SqlParser {
return cmd;
}
else
- throw errorUnexpectedToken(lex, CREATE, DROP, ALTER, COPY);
+ throw errorUnexpectedToken(lex, CREATE, DROP, COPY, ALTER);
case QUOTED:
case MINUS:
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
index 6d7e9ae..df27c5f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
@@ -52,7 +52,6 @@ import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
import org.apache.ignite.internal.processors.query.GridRunningQueryInfo;
import org.apache.ignite.internal.processors.query.QueryField;
import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
-import org.apache.ignite.internal.processors.query.SqlClientContext;
import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
@@ -245,18 +244,12 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT
/** {@inheritDoc} */
@Override public List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry,
- SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel) {
+ boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel) {
return null;
}
/** {@inheritDoc} */
- @Override public List<Long> streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params,
- SqlClientContext cliCtx) throws IgniteCheckedException {
- return Collections.emptyList();
- }
-
- /** {@inheritDoc} */
- @Override public long streamUpdateQuery(String schemaName, String qry, @Nullable Object[] params,
+ @Override public long streamUpdateQuery(String spaceName, String qry, @Nullable Object[] params,
IgniteDataStreamer<?, ?> streamer) throws IgniteCheckedException {
return 0;
}
@@ -379,8 +372,8 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT
}
/** {@inheritDoc} */
- @Override public void checkStatementStreamable(PreparedStatement nativeStmt) {
- // No-op.
+ @Override public boolean isInsertStatement(PreparedStatement nativeStmt) {
+ return false;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 8d2a820..b114828 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -299,7 +299,7 @@ public final class GridTestUtils {
call.call();
}
catch (Throwable e) {
- if (cls != e.getClass() && !cls.isAssignableFrom(e.getClass())) {
+ if (cls != e.getClass()) {
if (e.getClass() == CacheException.class && e.getCause() != null && e.getCause().getClass() == cls)
e = e.getCause();
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 284d50a..ea6c7c1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -385,7 +385,6 @@ public class DmlStatementsProcessor {
/**
* Perform given statement against given data streamer. Only rows based INSERT is supported.
*
- * @param schemaName Schema name.
* @param streamer Streamer to feed data to.
* @param stmt Statement.
* @param args Statement arguments.
@@ -393,74 +392,81 @@ public class DmlStatementsProcessor {
* @throws IgniteCheckedException if failed.
*/
@SuppressWarnings({"unchecked", "ConstantConditions"})
- long streamUpdateQuery(String schemaName, IgniteDataStreamer streamer, PreparedStatement stmt, final Object[] args)
+ long streamUpdateQuery(IgniteDataStreamer streamer, PreparedStatement stmt, final Object[] args)
throws IgniteCheckedException {
- idx.checkStatementStreamable(stmt);
-
Prepared p = GridSqlQueryParser.prepared(stmt);
assert p != null;
- final UpdatePlan plan = getPlanForStatement(schemaName, null, p, null, true, null);
+ final UpdatePlan plan = UpdatePlanBuilder.planForStatement(p, true, idx, null, null, null);
- assert plan.isLocalSubquery();
+ if (!F.eq(streamer.cacheName(), plan.cacheContext().name()))
+ throw new IgniteSQLException("Cross cache streaming is not supported, please specify cache explicitly" +
+ " in connection options", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
- final GridCacheContext cctx = plan.cacheContext();
+ if (plan.mode() == UpdateMode.INSERT && plan.rowCount() > 0) {
+ assert plan.isLocalSubquery();
- QueryCursorImpl<List<?>> cur;
+ final GridCacheContext cctx = plan.cacheContext();
- final ArrayList<List<?>> data = new ArrayList<>(plan.rowCount());
+ QueryCursorImpl<List<?>> cur;
- QueryCursorImpl<List<?>> stepCur = new QueryCursorImpl<>(new Iterable<List<?>>() {
- @Override public Iterator<List<?>> iterator() {
- try {
- Iterator<List<?>> it;
+ final ArrayList<List<?>> data = new ArrayList<>(plan.rowCount());
- if (!F.isEmpty(plan.selectQuery())) {
- GridQueryFieldsResult res = idx.queryLocalSqlFields(idx.schema(cctx.name()),
- plan.selectQuery(), F.asList(U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)),
- null, false, 0, null);
+ QueryCursorImpl<List<?>> stepCur = new QueryCursorImpl<>(new Iterable<List<?>>() {
+ @Override public Iterator<List<?>> iterator() {
+ try {
+ Iterator<List<?>> it;
- it = res.iterator();
- }
- else
- it = plan.createRows(U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)).iterator();
+ if (!F.isEmpty(plan.selectQuery())) {
+ GridQueryFieldsResult res = idx.queryLocalSqlFields(idx.schema(cctx.name()),
+ plan.selectQuery(), F.asList(U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)),
+ null, false, 0, null);
- return new GridQueryCacheObjectsIterator(it, idx.objectContext(), cctx.keepBinary());
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
+ it = res.iterator();
+ }
+ else
+ it = plan.createRows(U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)).iterator();
+
+ return new GridQueryCacheObjectsIterator(it, idx.objectContext(), cctx.keepBinary());
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException(e);
+ }
}
- }
- }, null);
+ }, null);
- data.addAll(stepCur.getAll());
+ data.addAll(stepCur.getAll());
- cur = new QueryCursorImpl<>(new Iterable<List<?>>() {
- @Override public Iterator<List<?>> iterator() {
- return data.iterator();
- }
- }, null);
+ cur = new QueryCursorImpl<>(new Iterable<List<?>>() {
+ @Override public Iterator<List<?>> iterator() {
+ return data.iterator();
+ }
+ }, null);
- if (plan.rowCount() == 1) {
- IgniteBiTuple t = plan.processRow(cur.iterator().next());
+ if (plan.rowCount() == 1) {
+ IgniteBiTuple t = plan.processRow(cur.iterator().next());
- streamer.addData(t.getKey(), t.getValue());
+ streamer.addData(t.getKey(), t.getValue());
- return 1;
- }
+ return 1;
+ }
- Map<Object, Object> rows = new LinkedHashMap<>(plan.rowCount());
+ Map<Object, Object> rows = new LinkedHashMap<>(plan.rowCount());
- for (List<?> row : cur) {
- final IgniteBiTuple t = plan.processRow(row);
+ for (List<?> row : cur) {
+ final IgniteBiTuple t = plan.processRow(row);
- rows.put(t.getKey(), t.getValue());
- }
+ rows.put(t.getKey(), t.getValue());
+ }
- streamer.addData(rows);
+ streamer.addData(rows);
- return rows.size();
+ return rows.size();
+ }
+ else
+ throw new IgniteSQLException("Only tuple based INSERT statements are supported in streaming mode",
+ IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
}
/**
@@ -513,7 +519,7 @@ public class DmlStatementsProcessor {
.setPageSize(fieldsQry.getPageSize())
.setTimeout(fieldsQry.getTimeout(), TimeUnit.MILLISECONDS);
- cur = (QueryCursorImpl<List<?>>)idx.querySqlFields(schemaName, newFieldsQry, null, true, true,
+ cur = (QueryCursorImpl<List<?>>)idx.querySqlFields(schemaName, newFieldsQry, true, true,
cancel).get(0);
}
else if (plan.hasRows())
@@ -604,7 +610,7 @@ public class DmlStatementsProcessor {
* @return Update plan.
*/
@SuppressWarnings({"unchecked", "ConstantConditions"})
- UpdatePlan getPlanForStatement(String schema, Connection conn, Prepared p, SqlFieldsQuery fieldsQry,
+ private UpdatePlan getPlanForStatement(String schema, Connection conn, Prepared p, SqlFieldsQuery fieldsQry,
boolean loc, @Nullable Integer errKeysPos) throws IgniteCheckedException {
H2CachedStatementKey planKey = H2CachedStatementKey.forDmlStatement(schema, p.getSQL(), fieldsQry, loc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index a0b2c34..361623c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -92,7 +92,6 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.QueryField;
import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.processors.query.SqlClientContext;
import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex;
import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasInnerIO;
@@ -101,7 +100,6 @@ import org.apache.ignite.internal.processors.query.h2.database.io.H2InnerIO;
import org.apache.ignite.internal.processors.query.h2.database.io.H2LeafIO;
import org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor;
import org.apache.ignite.internal.processors.query.h2.dml.DmlUtils;
-import org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2DefaultTableEngine;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2PlainRowFactory;
@@ -151,6 +149,7 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilterImpl;
import org.h2.api.ErrorCode;
import org.h2.api.JavaObjectSerializer;
import org.h2.command.Prepared;
+import org.h2.command.dml.Insert;
import org.h2.command.dml.NoOperation;
import org.h2.engine.Session;
import org.h2.engine.SysProperties;
@@ -192,7 +191,7 @@ import static org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType
@SuppressWarnings({"UnnecessaryFullyQualifiedName", "NonFinalStaticVariableUsedInClassInitialization"})
public class IgniteH2Indexing implements GridQueryIndexing {
public static final Pattern INTERNAL_CMD_RE = Pattern.compile(
- "^(create|drop)\\s+index|^alter\\s+table|^copy|^set|^flush", Pattern.CASE_INSENSITIVE);
+ "^(create|drop)\\s+index|^alter\\s+table|^copy", Pattern.CASE_INSENSITIVE);
/*
* Register IO for indexes.
@@ -501,10 +500,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/** {@inheritDoc} */
- @Override public PreparedStatement prepareNativeStatement(String schemaName, String sql) {
+ @Override public PreparedStatement prepareNativeStatement(String schemaName, String sql) throws SQLException {
Connection conn = connectionForSchema(schemaName);
- return prepareStatementAndCaches(conn, sql);
+ return prepareStatement(conn, sql, true);
}
/**
@@ -1014,60 +1013,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
throw new IgniteSQLException(e);
}
- return dmlProc.streamUpdateQuery(schemaName, streamer, stmt, params);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("ForLoopReplaceableByForEach")
- @Override public List<Long> streamBatchedUpdateQuery(String schemaName, String qry, List<Object[]> params,
- SqlClientContext cliCtx) throws IgniteCheckedException {
- if (cliCtx == null || !cliCtx.isStream()) {
- U.warn(log, "Connection is not in streaming mode.");
-
- return zeroBatchedStreamedUpdateResult(params.size());
- }
-
- final Connection conn = connectionForSchema(schemaName);
-
- final PreparedStatement stmt = prepareStatementAndCaches(conn, qry);
-
- if (GridSqlQueryParser.checkMultipleStatements(stmt))
- throw new IgniteSQLException("Multiple statements queries are not supported for streaming mode.",
- IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
-
- checkStatementStreamable(stmt);
-
- Prepared p = GridSqlQueryParser.prepared(stmt);
-
- UpdatePlan plan = dmlProc.getPlanForStatement(schemaName, conn, p, null, true, null);
-
- IgniteDataStreamer<?, ?> streamer = cliCtx.streamerForCache(plan.cacheContext().name());
-
- if (streamer != null) {
- List<Long> res = new ArrayList<>(params.size());
-
- for (int i = 0; i < params.size(); i++)
- res.add(dmlProc.streamUpdateQuery(schemaName, streamer, stmt, params.get(i)));
-
- return res;
- }
- else {
- U.warn(log, "Streaming has been turned off by concurrent command.");
-
- return zeroBatchedStreamedUpdateResult(params.size());
- }
- }
-
- /**
- * @param size Result size.
- * @return List of given size filled with 0Ls.
- */
- private static List<Long> zeroBatchedStreamedUpdateResult(int size) {
- Long[] res = new Long[size];
-
- Arrays.fill(res, 0);
-
- return Arrays.asList(res);
+ return dmlProc.streamUpdateQuery(streamer, stmt, params);
}
/**
@@ -1453,7 +1399,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
fqry.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);
final QueryCursor<List<?>> res =
- querySqlFields(schemaName, fqry, null, keepBinary, true, null).get(0);
+ querySqlFields(schemaName, fqry, keepBinary, true, null).get(0);
final Iterable<Cache.Entry<K, V>> converted = new Iterable<Cache.Entry<K, V>>() {
@Override public Iterator<Cache.Entry<K, V>> iterator() {
@@ -1489,19 +1435,19 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* Try executing query using native facilities.
*
* @param schemaName Schema name.
- * @param sql Query.
+ * @param qry Query.
* @return Result or {@code null} if cannot parse/process this query.
*/
- private List<FieldsQueryCursor<List<?>>> tryQueryDistributedSqlFieldsNative(String schemaName, String sql) {
+ private List<FieldsQueryCursor<List<?>>> tryQueryDistributedSqlFieldsNative(String schemaName, SqlFieldsQuery qry) {
// Heuristic check for fast return.
- if (!INTERNAL_CMD_RE.matcher(sql.trim()).find())
+ if (!INTERNAL_CMD_RE.matcher(qry.getSql().trim()).find())
return null;
// Parse.
SqlCommand cmd;
try {
- SqlParser parser = new SqlParser(schemaName, sql);
+ SqlParser parser = new SqlParser(schemaName, qry.getSql());
cmd = parser.nextCommand();
@@ -1509,20 +1455,15 @@ public class IgniteH2Indexing implements GridQueryIndexing {
if (parser.nextCommand() != null)
return null;
- // Currently supported commands are:
- // CREATE/DROP INDEX
- // COPY
- // ALTER TABLE
- // SET STREAMING
- // FLUSH STREAMER
+ // Currently supported commands are: CREATE/DROP INDEX/COPY/ALTER TABLE
if (!(cmd instanceof SqlCreateIndexCommand || cmd instanceof SqlDropIndexCommand ||
- cmd instanceof SqlAlterTableCommand || cmd instanceof SqlBulkLoadCommand))
+ cmd instanceof SqlBulkLoadCommand || cmd instanceof SqlAlterTableCommand))
return null;
}
catch (Exception e) {
// Cannot parse, return.
if (log.isDebugEnabled())
- log.debug("Failed to parse SQL with native parser [qry=" + sql + ", err=" + e + ']');
+ log.debug("Failed to parse SQL with native parser [qry=" + qry.getSql() + ", err=" + e + ']');
if (!IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK))
return null;
@@ -1532,24 +1473,24 @@ public class IgniteH2Indexing implements GridQueryIndexing {
if (e instanceof SqlParseException)
code = ((SqlParseException)e).code();
- throw new IgniteSQLException("Failed to parse DDL statement: " + sql + ": " + e.getMessage(),
+ throw new IgniteSQLException("Failed to parse DDL statement: " + qry.getSql() + ": " + e.getMessage(),
code, e);
}
// Execute.
if (cmd instanceof SqlBulkLoadCommand) {
- FieldsQueryCursor<List<?>> cursor = dmlProc.runNativeDmlStatement(sql, cmd);
+ FieldsQueryCursor<List<?>> cursor = dmlProc.runNativeDmlStatement(qry.getSql(), cmd);
return Collections.singletonList(cursor);
}
else {
try {
- FieldsQueryCursor<List<?>> cursor = ddlProc.runDdlStatement(sql, cmd);
+ FieldsQueryCursor<List<?>> cursor = ddlProc.runDdlStatement(qry.getSql(), cmd);
return Collections.singletonList(cursor);
}
catch (IgniteCheckedException e) {
- throw new IgniteSQLException("Failed to execute DDL statement [stmt=" + sql + "]: "
+ throw new IgniteSQLException("Failed to execute DDL statement [stmt=" + qry.getSql() + "]: "
+ e.getMessage(), e);
}
}
@@ -1573,8 +1514,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
/** {@inheritDoc} */
@SuppressWarnings("StringEquality")
@Override public List<FieldsQueryCursor<List<?>>> querySqlFields(String schemaName, SqlFieldsQuery qry,
- SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel) {
- List<FieldsQueryCursor<List<?>>> res = tryQueryDistributedSqlFieldsNative(schemaName, qry.getSql());
+ boolean keepBinary, boolean failOnMultipleStmts, GridQueryCancel cancel) {
+ List<FieldsQueryCursor<List<?>>> res = tryQueryDistributedSqlFieldsNative(schemaName, qry);
if (res != null)
return res;
@@ -1612,8 +1553,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
// We may use this cached statement only for local queries and non queries.
if (qry.isLocal() || !prepared.isQuery())
- return (List<FieldsQueryCursor<List<?>>>)doRunPrepared(schemaName, prepared, qry, null, cliCtx,
- null, keepBinary, cancel);
+ return (List<FieldsQueryCursor<List<?>>>)doRunPrepared(schemaName, prepared, qry, null, null,
+ keepBinary, cancel);
}
}
@@ -1643,7 +1584,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
firstArg += prepared.getParameters().size();
- res.addAll(doRunPrepared(schemaName, prepared, newQry, twoStepQry, cliCtx, meta, keepBinary, cancel));
+ res.addAll(doRunPrepared(schemaName, prepared, newQry, twoStepQry, meta, keepBinary, cancel));
if (parseRes.twoStepQuery() != null && parseRes.twoStepQueryKey() != null &&
!parseRes.twoStepQuery().explain())
@@ -1659,14 +1600,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* @param prepared H2 command.
* @param qry Fields query with flags.
* @param twoStepQry Two-step query if this query must be executed in a distributed way.
- * @param cliCtx Client context, or {@code null} if not applicable.
* @param meta Metadata for {@code twoStepQry}.
* @param keepBinary Whether binary objects must not be deserialized automatically.
- * @param cancel Query cancel state holder. @return Query result.
+ * @param cancel Query cancel state holder.
+ * @return Query result.
*/
private List<? extends FieldsQueryCursor<List<?>>> doRunPrepared(String schemaName, Prepared prepared,
- SqlFieldsQuery qry, GridCacheTwoStepQuery twoStepQry, @Nullable SqlClientContext cliCtx,
- List<GridQueryFieldMetadata> meta, boolean keepBinary, GridQueryCancel cancel) {
+ SqlFieldsQuery qry, GridCacheTwoStepQuery twoStepQry, List<GridQueryFieldMetadata> meta, boolean keepBinary,
+ GridQueryCancel cancel) {
String sqlQry = qry.getSql();
boolean loc = qry.isLocal();
@@ -2335,10 +2276,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/** {@inheritDoc} */
- @Override public void checkStatementStreamable(PreparedStatement nativeStmt) {
- if (!GridSqlQueryParser.isStreamableInsertStatement(nativeStmt))
- throw new IgniteSQLException("Only tuple based INSERT statements are supported in streaming mode.",
- IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+ @Override public boolean isInsertStatement(PreparedStatement nativeStmt) {
+ Prepared prep = GridSqlQueryParser.prepared(nativeStmt);
+
+ return prep instanceof Insert;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index 5441e36..6f5b51f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -106,7 +106,7 @@ public class DdlStatementsProcessor {
* @throws IgniteCheckedException On error.
*/
@SuppressWarnings("unchecked")
- public FieldsQueryCursor<List<?>> runDdlStatement(String sql, SqlCommand cmd) throws IgniteCheckedException {
+ public FieldsQueryCursor<List<?>> runDdlStatement(String sql, SqlCommand cmd) throws IgniteCheckedException{
IgniteInternalFuture fut;
try {
@@ -211,7 +211,12 @@ public class DdlStatementsProcessor {
if (fut != null)
fut.get();
- return zeroCursor();
+ QueryCursorImpl<List<?>> resCur = (QueryCursorImpl<List<?>>)new QueryCursorImpl(Collections.singletonList
+ (Collections.singletonList(0L)), null, false);
+
+ resCur.fieldsMeta(UPDATE_RESULT_META);
+
+ return resCur;
}
catch (SchemaOperationException e) {
throw convert(e);
@@ -225,19 +230,6 @@ public class DdlStatementsProcessor {
}
/**
- * @return Single-column, single-row cursor with 0 as number of updated records.
- */
- @SuppressWarnings("unchecked")
- public static QueryCursorImpl<List<?>> zeroCursor() {
- QueryCursorImpl<List<?>> resCur = (QueryCursorImpl<List<?>>)new QueryCursorImpl(Collections.singletonList
- (Collections.singletonList(0L)), null, false);
-
- resCur.fieldsMeta(UPDATE_RESULT_META);
-
- return resCur;
- }
-
- /**
* Execute DDL statement.
*
* @param sql SQL.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
index 98fbb97..10d485a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
@@ -505,7 +505,7 @@ public final class UpdatePlan {
/**
* @return Local subquery flag.
*/
- public boolean isLocalSubquery() {
+ @Nullable public boolean isLocalSubquery() {
return isLocSubqry;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
index d897ac7..bced836 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
@@ -85,21 +85,20 @@ public final class UpdatePlanBuilder {
* @param loc Local query flag.
* @param idx Indexing.
* @param conn Connection.
- * @param fieldsQry Original query.
+ * @param fieldsQuery Original query.
* @return Update plan.
*/
public static UpdatePlan planForStatement(Prepared prepared, boolean loc, IgniteH2Indexing idx,
- @Nullable Connection conn, @Nullable SqlFieldsQuery fieldsQry, @Nullable Integer errKeysPos)
+ @Nullable Connection conn, @Nullable SqlFieldsQuery fieldsQuery, @Nullable Integer errKeysPos)
throws IgniteCheckedException {
+ assert !prepared.isQuery();
+
GridSqlStatement stmt = new GridSqlQueryParser(false).parse(prepared);
if (stmt instanceof GridSqlMerge || stmt instanceof GridSqlInsert)
- return planForInsert(stmt, loc, idx, conn, fieldsQry);
- else if (stmt instanceof GridSqlUpdate || stmt instanceof GridSqlDelete)
- return planForUpdate(stmt, loc, idx, conn, fieldsQry, errKeysPos);
+ return planForInsert(stmt, loc, idx, conn, fieldsQuery);
else
- throw new IgniteSQLException("Unsupported operation: " + prepared.getSQL(),
- IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+ return planForUpdate(stmt, loc, idx, conn, fieldsQuery, errKeysPos);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index 2d2c25c..04bc212 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -1993,18 +1993,6 @@ public class GridSqlQueryParser {
}
/**
- * Check if passed statement is insert statement eligible for streaming.
- *
- * @param nativeStmt Native statement.
- * @return {@code True} if streamable insert.
- */
- public static boolean isStreamableInsertStatement(PreparedStatement nativeStmt) {
- Prepared prep = prepared(nativeStmt);
-
- return prep instanceof Insert && INSERT_QUERY.get((Insert)prep) == null;
- }
-
- /**
* @param cond Condition.
* @param o Object.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9f1a7e0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
index cf8bb2e..069bdd7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
@@ -140,7 +140,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
SqlFieldsQuery qry = new SqlFieldsQuery("select f.productId, p.name, f.price " +
"from FactPurchase f, \"replicated-prod\".DimProduct p where p.id = f.productId ");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
set1.add((Integer)o.get(0));
@@ -154,7 +154,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
qry = new SqlFieldsQuery("select productId from FactPurchase group by productId");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
assertTrue(set0.add((Integer) o.get(0)));
@@ -173,7 +173,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
"where p.id = f.productId " +
"group by f.productId, p.name");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
assertTrue(names.add((String)o.get(0)));
@@ -190,7 +190,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
"group by f.productId, p.name " +
"having s >= 15");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
assertTrue(i(o, 1) >= 15);
@@ -203,7 +203,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
qry = new SqlFieldsQuery("select top 3 distinct productId " +
"from FactPurchase f order by productId desc ");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
assertEquals(top--, o.get(0));
@@ -216,7 +216,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
qry = new SqlFieldsQuery("select distinct productId " +
"from FactPurchase f order by productId desc limit 2 offset 1");
- for (List<?> o : qryProc.querySqlFields(cache.context(), qry, null, false, true).get(0).getAll()) {
+ for (List<?> o : qryProc.querySqlFields(cache.context(), qry, false, true).get(0).getAll()) {
X.println("___ -> " + o);
assertEquals(top--, o.get(0));
@@ -256,13 +256,13 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
- qryProc.querySqlFields(cache.context(), qry, null, false, true);
+ qryProc.querySqlFields(cache.context(), qry, false, true);
return null;
}
}, IgniteSQLException.class, "Multiple statements queries are not supported");
- List<FieldsQueryCursor<List<?>>> cursors = qryProc.querySqlFields(cache.context(), qry, null, false, false);
+ List<FieldsQueryCursor<List<?>>> cursors = qryProc.querySqlFields(cache.context(), qry, false, false);
assertEquals(2, cursors.size());
@@ -274,7 +274,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
- qryProc.querySqlFields(cache.context(), qry, null, false, false);
+ qryProc.querySqlFields(cache.context(), qry, false, false);
return null;
}