tledkov-gridgain commented on a change in pull request #284:
URL: https://github.com/apache/ignite-3/pull/284#discussion_r705449620



##########
File path: 
modules/client/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java
##########
@@ -0,0 +1,769 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.jdbc;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLPermission;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.ShardingKey;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.client.proto.query.JdbcQueryEventHandler;
+import org.apache.ignite.client.proto.query.SqlStateCode;
+import org.apache.ignite.internal.client.HostAndPortRange;
+import org.apache.ignite.internal.client.TcpIgniteClient;
+import org.apache.ignite.internal.client.query.JdbcClientQueryEventHandler;
+import org.apache.ignite.schema.SchemaTable;
+import org.jetbrains.annotations.Nullable;
+
+import static java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT;
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+import static 
org.apache.ignite.client.proto.query.SqlStateCode.CONNECTION_CLOSED;
+
+/**
+ * JDBC connection implementation.
+ */
+public class JdbcConnection implements Connection {
+    /** Network timeout permission. */
+    private static final String SET_NETWORK_TIMEOUT_PERM = "setNetworkTimeout";
+
+    /** Statements modification mutex. */
+    private final Object stmtsMux = new Object();
+
+    /** Handler. */
+    private final JdbcQueryEventHandler handler;
+
+    /** Schema name. */
+    private String schema;
+
+    /** Closed flag. */
+    private volatile boolean closed;
+
+    /** Current transaction isolation. */
+    private int txIsolation;
+
+    /** Auto-commit flag. */
+    private boolean autoCommit;
+
+    /** Read-only flag. */
+    private boolean readOnly;
+
+    /** Current transaction holdability. */
+    private int holdability;
+
+    /** Connection properties. */
+    private final ConnectionProperties connProps;
+
+    /** Tracked statements to close on disconnect. */
+    private final Set<JdbcStatement> stmts = Collections.newSetFromMap(new 
IdentityHashMap<>());
+
+    /** Network timeout. */
+    private int netTimeout;
+
+    /** Retry limit. */
+    private final int retryLimit;
+
+    /** Reconnect throttling period. */
+    private final long reconnectThrottlingPeriod;
+
+    /** Reconnect throttling retries. */
+    private final int reconnectThrottlingRetries;
+
+    /** Query timeout. */
+    private final @Nullable Integer qryTimeout;
+
+    /** Ignite remote client. */
+    private final TcpIgniteClient client;
+
+    /**
+     * Constructor.
+     *
+     * @param handler Handler.
+     * @param props Properties.
+     */
+    public JdbcConnection(JdbcQueryEventHandler handler, ConnectionProperties 
props) {
+        this.connProps = props;
+        this.handler = handler;
+
+        autoCommit = true;
+
+        netTimeout = connProps.getConnectionTimeout();
+        qryTimeout = connProps.getQueryTimeout();
+        retryLimit = connProps.getRetryLimit();
+        reconnectThrottlingPeriod = connProps.getReconnectThrottlingPeriod();
+        reconnectThrottlingRetries = connProps.getReconnectThrottlingRetries();
+
+        holdability = HOLD_CURSORS_OVER_COMMIT;
+
+        schema = SchemaTable.DEFAULT_SCHEMA_NAME;
+
+        client = null;
+    }
+
+    /**
+     * Creates new connection.
+     *
+     * @param props Connection properties.
+     */
+    public JdbcConnection(ConnectionProperties props) {
+        this.connProps = props;
+        autoCommit = true;
+
+        String[] addrs = 
Arrays.stream(props.getAddresses()).map(HostAndPortRange::toString)
+            .toArray(String[]::new);
+
+        netTimeout = connProps.getConnectionTimeout();
+        qryTimeout = connProps.getQueryTimeout();
+        retryLimit = connProps.getRetryLimit();
+        reconnectThrottlingPeriod = connProps.getReconnectThrottlingPeriod();
+        reconnectThrottlingRetries = connProps.getReconnectThrottlingRetries();
+
+        client = ((TcpIgniteClient)IgniteClient
+            .builder()
+            .addresses(addrs)
+            .connectTimeout(netTimeout)
+            .retryLimit(retryLimit)

Review comment:
       retryLimit member field is used only here.
   T same about reconnectThrottlingPeriod, reconnectThrottlingRetries




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to