AMashenkov commented on a change in pull request #284: URL: https://github.com/apache/ignite-3/pull/284#discussion_r700009087
########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessagePacker.java ########## @@ -550,6 +573,75 @@ public ClientMessagePacker packObject(Object val) { throw new UnsupportedOperationException("Unsupported type, can't serialize: " + val.getClass()); } + /** + * Packs an array of different objects. + * + * @param args Object array. + * @return This instance. + * @throws UnsupportedOperationException in case of unknown type. + */ + public ClientMessagePacker packObjectArray(Object[] args) { + assert !closed : "Packer is closed"; + + if (args == null) { + packNil(); + + return this; + } + + packArrayHeader(args.length); + + for (Object arg : args) { + if (arg == null) { + packNil(); + + continue; + } + + Class<?> cls = arg.getClass(); + + if (cls == Boolean.class) + packBoolean((Boolean)arg); + else if (cls == Byte.class) { + packInt(ClientDataType.INT8); + packByte((Byte)arg); + } + else if (cls == Short.class) { + packInt(ClientDataType.INT16); + packShort((Short)arg); + } + else if (cls == Integer.class) { + packInt(ClientDataType.INT32); + packInt((Integer)arg); + } + else if (cls == Long.class) { + packInt(ClientDataType.INT64); + packLong((Long)arg); + } + else if (cls == Float.class) + packFloat((Float)arg); + else if (cls == Double.class) + packDouble((Double)arg); + else if (cls == String.class) + packString((String)arg); + else if (cls == UUID.class) { + packInt(ClientDataType.UUID); + packUuid((UUID)arg); + } + else if (cls == byte[].class) + writeByteArray((byte[])arg); + else + throw new UnsupportedOperationException("Custom objects are not supported"); Review comment: Can this be replaced with packObject() ? ########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessagePacker.java ########## @@ -550,6 +573,75 @@ public ClientMessagePacker packObject(Object val) { throw new UnsupportedOperationException("Unsupported type, can't serialize: " + val.getClass()); } + /** + * Packs an array of different objects. + * + * @param args Object array. + * @return This instance. + * @throws UnsupportedOperationException in case of unknown type. + */ + public ClientMessagePacker packObjectArray(Object[] args) { + assert !closed : "Packer is closed"; + + if (args == null) { + packNil(); + + return this; + } + + packArrayHeader(args.length); + + for (Object arg : args) { + if (arg == null) { + packNil(); + + continue; + } + + Class<?> cls = arg.getClass(); + + if (cls == Boolean.class) + packBoolean((Boolean)arg); + else if (cls == Byte.class) { + packInt(ClientDataType.INT8); + packByte((Byte)arg); + } + else if (cls == Short.class) { + packInt(ClientDataType.INT16); + packShort((Short)arg); + } + else if (cls == Integer.class) { + packInt(ClientDataType.INT32); + packInt((Integer)arg); + } + else if (cls == Long.class) { + packInt(ClientDataType.INT64); + packLong((Long)arg); + } + else if (cls == Float.class) + packFloat((Float)arg); + else if (cls == Double.class) + packDouble((Double)arg); + else if (cls == String.class) + packString((String)arg); + else if (cls == UUID.class) { + packInt(ClientDataType.UUID); + packUuid((UUID)arg); + } + else if (cls == byte[].class) + writeByteArray((byte[])arg); + else + throw new UnsupportedOperationException("Custom objects are not supported"); Review comment: I think it make sense to support all primitive arrays, maybe in a separate ticket. ########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessageUnpacker.java ########## @@ -584,6 +606,92 @@ public Object unpackObject(int dataType) { throw new IgniteException("Unknown client data type: " + dataType); } + /** + * Packs an object. + * + * @return Object array. + * @throws IllegalStateException in case of unexpected value type. + */ + public Object[] unpackObjectArray() { + assert refCnt > 0 : "Unpacker is closed"; + + if (tryUnpackNil()) + return null; + + int size = unpackArrayHeader(); + + if (size == 0) + return ArrayUtils.OBJECT_EMPTY_ARRAY; + + Object[] args = new Object[size]; + + for (int i = 0; i < size; i++) { + MessageFormat format = getNextFormat(); + + switch (format) { + case NIL: + unpackNil(); + + break; + case BOOLEAN: + args[i] = unpackBoolean(); + + break; + case FLOAT32: + args[i] = unpackFloat(); + + break; + case FLOAT64: + args[i] = unpackDouble(); + + break; + case POSFIXINT: + args[i] = extractExtendedValue(unpackInt()); Review comment: I'm not sure we can correctly restore numeric type here. As I understand @ptupitsyn concerns in one of my PR: when we serializes small Long value (i.e. which is fit to short) and it can be wrote as short value, so it will be deserialized to Short. This may lead to cast error in case `Long x = (Long)arr[i]`, if `arr[i]` is a Short. ########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessageUnpacker.java ########## @@ -584,6 +606,92 @@ public Object unpackObject(int dataType) { throw new IgniteException("Unknown client data type: " + dataType); } + /** + * Packs an object. + * + * @return Object array. + * @throws IllegalStateException in case of unexpected value type. + */ + public Object[] unpackObjectArray() { + assert refCnt > 0 : "Unpacker is closed"; + + if (tryUnpackNil()) + return null; + + int size = unpackArrayHeader(); + + if (size == 0) + return ArrayUtils.OBJECT_EMPTY_ARRAY; + + Object[] args = new Object[size]; + + for (int i = 0; i < size; i++) { + MessageFormat format = getNextFormat(); + + switch (format) { + case NIL: + unpackNil(); + + break; + case BOOLEAN: + args[i] = unpackBoolean(); + + break; + case FLOAT32: + args[i] = unpackFloat(); + + break; + case FLOAT64: + args[i] = unpackDouble(); + + break; + case POSFIXINT: + args[i] = extractExtendedValue(unpackInt()); Review comment: @ptupitsyn, could you, please, chim in? ########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/query/event/JdbcQueryExecuteRequest.java ########## @@ -0,0 +1,180 @@ +/* + * 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.client.proto.query.event; + +import java.sql.Statement; +import org.apache.ignite.client.proto.ClientMessagePacker; +import org.apache.ignite.client.proto.ClientMessageUnpacker; +import org.apache.ignite.client.proto.query.JdbcStatementType; +import org.apache.ignite.internal.tostring.S; + +/** + * JDBC query execute request. + */ +public class JdbcQueryExecuteRequest implements JdbcClientMessage { Review comment: Not all fields are serialized. Is it ok? ########## File path: modules/client-common/src/main/java/org/apache/ignite/client/proto/query/event/JdbcQueryExecuteResult.java ########## @@ -0,0 +1,117 @@ +/* + * 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.client.proto.query.event; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.ignite.client.proto.ClientMessagePacker; +import org.apache.ignite.client.proto.ClientMessageUnpacker; +import org.apache.ignite.internal.tostring.S; + +/** + * JDBC query execute result. + */ +public class JdbcQueryExecuteResult extends JdbcResponse { + /** Query result rows. */ + private List<JdbcQuerySingleResult> results; + + /** + * Constructor. For deserialization purposes only. + */ + public JdbcQueryExecuteResult() { + } + + /** + * Constructor. + * + * @param status Status code. + * @param err Error message. + */ + public JdbcQueryExecuteResult(int status, String err) { + super(status, err); + } + + /** + * Constructor. + * + * @param results Results. + */ + public JdbcQueryExecuteResult(List<JdbcQuerySingleResult> results) { + super(); + + this.results = results; + } + + /** {@inheritDoc} */ + @Override public void writeBinary(ClientMessagePacker packer) { + super.writeBinary(packer); + + if (status() != STATUS_SUCCESS) + return; Review comment: Let's avoid any logic from serialization. If you want to have different messages to safe few bytes, then it would be better to create different Java classes representing these messages. So, we won't care about binary message layout here. ########## File path: modules/client-common/src/test/java/org/apache/ignite/client/proto/ClientMessagePackerUnpackerTest.java ########## @@ -257,4 +257,45 @@ private void testDecimal(BigDecimal val) { } } } + + @Test + public void testIntegerArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + int[] arr = new int[] {4, 8, 15, 16, 23, 42}; + + packer.packIntArray(arr); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + int[] res = unpacker.unpackIntArray(); + assertArrayEquals(arr, res); + } + } + } + + @Test + public void testObjectArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + Object[] args = new Object[] {(byte)4, (short)8, 15, 16L, 23.0f, 42.0d, "TEST_STRING", null, UUID.randomUUID(), false}; + packer.packObjectArray(args); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + Object[] res = unpacker.unpackObjectArray(); + assertArrayEquals(args, res); + } + } Review comment: Will this tests pass? ` try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { Object[] args = new Object[] {16L}; packer.packObjectArray(args); var buf = packer.getBuffer(); byte[] data = new byte[buf.readableBytes()]; buf.readBytes(data); try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { unpacker.skipValue(4); assertEquals(16L, res[0]); } }` ########## File path: modules/client-common/src/test/java/org/apache/ignite/client/proto/ClientMessagePackerUnpackerTest.java ########## @@ -257,4 +257,45 @@ private void testDecimal(BigDecimal val) { } } } + + @Test + public void testIntegerArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + int[] arr = new int[] {4, 8, 15, 16, 23, 42}; + + packer.packIntArray(arr); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + int[] res = unpacker.unpackIntArray(); + assertArrayEquals(arr, res); + } + } + } + + @Test + public void testObjectArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + Object[] args = new Object[] {(byte)4, (short)8, 15, 16L, 23.0f, 42.0d, "TEST_STRING", null, UUID.randomUUID(), false}; + packer.packObjectArray(args); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + Object[] res = unpacker.unpackObjectArray(); + assertArrayEquals(args, res); + } + } Review comment: Will this tests pass? ` try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { Object[] args = new Object[] {16L}; packer.packObjectArray(args); var buf = packer.getBuffer(); byte[] data = new byte[buf.readableBytes()]; buf.readBytes(data); try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { unpacker.skipValue(4); assertEquals(16L, res[0]); } }` ########## File path: modules/client-common/src/test/java/org/apache/ignite/client/proto/ClientMessagePackerUnpackerTest.java ########## @@ -257,4 +257,45 @@ private void testDecimal(BigDecimal val) { } } } + + @Test + public void testIntegerArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + int[] arr = new int[] {4, 8, 15, 16, 23, 42}; + + packer.packIntArray(arr); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + int[] res = unpacker.unpackIntArray(); + assertArrayEquals(arr, res); + } + } + } + + @Test + public void testObjectArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + Object[] args = new Object[] {(byte)4, (short)8, 15, 16L, 23.0f, 42.0d, "TEST_STRING", null, UUID.randomUUID(), false}; + packer.packObjectArray(args); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + Object[] res = unpacker.unpackObjectArray(); + assertArrayEquals(args, res); + } + } Review comment: Will this tests pass? ``` try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { Object[] args = new Object[] {16L}; packer.packObjectArray(args); var buf = packer.getBuffer(); byte[] data = new byte[buf.readableBytes()]; buf.readBytes(data); try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { unpacker.skipValue(4); assertEquals(16L, res[0]); } } ``` ########## File path: modules/client-common/src/test/java/org/apache/ignite/client/proto/ClientMessagePackerUnpackerTest.java ########## @@ -257,4 +257,45 @@ private void testDecimal(BigDecimal val) { } } } + + @Test + public void testIntegerArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + int[] arr = new int[] {4, 8, 15, 16, 23, 42}; + + packer.packIntArray(arr); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + int[] res = unpacker.unpackIntArray(); + assertArrayEquals(arr, res); + } + } + } + + @Test + public void testObjectArray() { + try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { + Object[] args = new Object[] {(byte)4, (short)8, 15, 16L, 23.0f, 42.0d, "TEST_STRING", null, UUID.randomUUID(), false}; + packer.packObjectArray(args); + + var buf = packer.getBuffer(); + + byte[] data = new byte[buf.readableBytes()]; + + buf.readBytes(data); + + try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { + unpacker.skipValue(4); + Object[] res = unpacker.unpackObjectArray(); + assertArrayEquals(args, res); + } + } Review comment: Will this tests pass? ``` try (var packer = new ClientMessagePacker(PooledByteBufAllocator.DEFAULT.directBuffer())) { Object[] args = new Object[] {16L}; packer.packObjectArray(args); var buf = packer.getBuffer(); byte[] data = new byte[buf.readableBytes()]; buf.readBytes(data); try (var unpacker = new ClientMessageUnpacker(Unpooled.wrappedBuffer(data))) { unpacker.skipValue(4); assertEquals(16L,(Long) res[0]); } } ``` ########## File path: modules/client/src/main/java/org/apache/ignite/jdbc/ConnectionProperties.java ########## @@ -0,0 +1,444 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.jdbc; + +import java.sql.SQLException; +import org.apache.ignite.internal.client.HostAndPortRange; +import org.apache.ignite.internal.client.ProtocolBitmaskFeature; + +/** + * Provide access and manipulations with connect0000ion JDBC properties. + */ +interface ConnectionProperties { + /** SSL mode: DISABLE. */ + String SSL_MODE_DISABLE = "disable"; + + /** SSL mode: REQUIRE. */ + String SSL_MODE_REQUIRE = "require"; + + /** + * Get the schema name. + * + * @return Schema name of the connection. + */ + String getSchema(); + + /** + * Set the schema name. + * + * @param schema Schema name of the connection. + */ + void setSchema(String schema); + + /** + * Get the URL. + * + * @return The URL of the connection. + */ + String getUrl(); + + /** + * Set the URL. + * + * @param url The URL of the connection. + * @throws SQLException On invalid URL. + */ + void setUrl(String url) throws SQLException; + + /** + * Get the addresses. + * + * @return Ignite nodes addresses. + */ + HostAndPortRange[] getAddresses(); + + /** + * Set the ignite node addresses. + * + * @param addrs Ignite nodes addresses. + */ + void setAddresses(HostAndPortRange[] addrs); + + + /** + * Get the auto close server cursors flag. + * + * @return Auto close server cursors flag. + */ + boolean isAutoCloseServerCursor(); + + /** + * Set the auto close server cursors flag. + * + * @param autoCloseServerCursor Auto close server cursors flag. + */ + void setAutoCloseServerCursor(boolean autoCloseServerCursor); + + /** + * Get the socket send buffer size. + * + * @return Socket send buffer size. + */ + int getSocketSendBuffer(); + + /** + * Set the socket send buffer size. + * + * @param size Socket send buffer size. + * @throws SQLException On error. + */ + void setSocketSendBuffer(int size) throws SQLException; + + /** + * Get the socket receive buffer size. + * + * @return Socket receive buffer size. + */ + int getSocketReceiveBuffer(); + + /** + * Set the socket receive buffer size. + * + * @param size Socket receive buffer size. + * @throws SQLException On error. + */ + void setSocketReceiveBuffer(int size) throws SQLException; + + /** + * Get the TCP no delay flag. + * + * @return TCP no delay flag. + */ + boolean isTcpNoDelay(); + + /** + * Set the TCP no delay flag. + * + * @param tcpNoDelay TCP no delay flag. + */ + void setTcpNoDelay(boolean tcpNoDelay); + + /** + * Gets SSL connection mode. + * + * @return Use SSL flag. + * @see #setSslMode(String) + */ + String getSslMode(); + + /** + * Use SSL connection to Ignite node. In case set to {@code "require"} SSL context must be configured. + * {@link #setSslClientCertificateKeyStoreUrl} property and related properties must be set up + * or JSSE properties must be set up (see {@code javax.net.ssl.keyStore} and other {@code javax.net.ssl.*} + * properties) + * + * In case set to {@code "disable"} plain connection is used. + * Available modes: {@code "disable", "require"}. Default value is {@code "disable"} + * + * @param mode SSL mode. + */ + void setSslMode(String mode); + + /** + * Gets protocol for secure transport. + * + * @return SSL protocol name. + */ + String getSslProtocol(); + + /** + * Sets protocol for secure transport. If not specified, TLS protocol will be used. + * Protocols implementations supplied by JSEE: SSLv3 (SSL), TLSv1 (TLS), TLSv1.1, TLSv1.2 Review comment: I think this should depends on SSL Provider, as some users may have 3-rd party one. ########## File path: modules/client/src/main/java/org/apache/ignite/jdbc/ConnectionProperties.java ########## @@ -0,0 +1,444 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.jdbc; + +import java.sql.SQLException; +import org.apache.ignite.internal.client.HostAndPortRange; +import org.apache.ignite.internal.client.ProtocolBitmaskFeature; + +/** + * Provide access and manipulations with connect0000ion JDBC properties. + */ +interface ConnectionProperties { + /** SSL mode: DISABLE. */ + String SSL_MODE_DISABLE = "disable"; + + /** SSL mode: REQUIRE. */ + String SSL_MODE_REQUIRE = "require"; + + /** + * Get the schema name. + * + * @return Schema name of the connection. + */ + String getSchema(); + + /** + * Set the schema name. + * + * @param schema Schema name of the connection. + */ + void setSchema(String schema); + + /** + * Get the URL. + * + * @return The URL of the connection. + */ + String getUrl(); + + /** + * Set the URL. + * + * @param url The URL of the connection. + * @throws SQLException On invalid URL. + */ + void setUrl(String url) throws SQLException; + + /** + * Get the addresses. + * + * @return Ignite nodes addresses. + */ + HostAndPortRange[] getAddresses(); + + /** + * Set the ignite node addresses. + * + * @param addrs Ignite nodes addresses. + */ + void setAddresses(HostAndPortRange[] addrs); + + + /** + * Get the auto close server cursors flag. + * + * @return Auto close server cursors flag. + */ + boolean isAutoCloseServerCursor(); + + /** + * Set the auto close server cursors flag. + * + * @param autoCloseServerCursor Auto close server cursors flag. + */ + void setAutoCloseServerCursor(boolean autoCloseServerCursor); + + /** + * Get the socket send buffer size. + * + * @return Socket send buffer size. + */ + int getSocketSendBuffer(); + + /** + * Set the socket send buffer size. + * + * @param size Socket send buffer size. + * @throws SQLException On error. + */ + void setSocketSendBuffer(int size) throws SQLException; + + /** + * Get the socket receive buffer size. + * + * @return Socket receive buffer size. + */ + int getSocketReceiveBuffer(); + + /** + * Set the socket receive buffer size. + * + * @param size Socket receive buffer size. + * @throws SQLException On error. + */ + void setSocketReceiveBuffer(int size) throws SQLException; + + /** + * Get the TCP no delay flag. + * + * @return TCP no delay flag. + */ + boolean isTcpNoDelay(); + + /** + * Set the TCP no delay flag. + * + * @param tcpNoDelay TCP no delay flag. + */ + void setTcpNoDelay(boolean tcpNoDelay); + + /** + * Gets SSL connection mode. + * + * @return Use SSL flag. + * @see #setSslMode(String) + */ + String getSslMode(); + + /** + * Use SSL connection to Ignite node. In case set to {@code "require"} SSL context must be configured. + * {@link #setSslClientCertificateKeyStoreUrl} property and related properties must be set up + * or JSSE properties must be set up (see {@code javax.net.ssl.keyStore} and other {@code javax.net.ssl.*} + * properties) + * + * In case set to {@code "disable"} plain connection is used. + * Available modes: {@code "disable", "require"}. Default value is {@code "disable"} + * + * @param mode SSL mode. + */ + void setSslMode(String mode); + + /** + * Gets protocol for secure transport. + * + * @return SSL protocol name. + */ + String getSslProtocol(); + + /** + * Sets protocol for secure transport. If not specified, TLS protocol will be used. + * Protocols implementations supplied by JSEE: SSLv3 (SSL), TLSv1 (TLS), TLSv1.1, TLSv1.2 Review comment: I think this should depends on SSL Provider, as some users may have 3-rd party one. Does it make sense to move SSL setting to a separate class and reuse it everywhere in Ignite, but not only in JDBC connection settings? I'm ok to do it in a separate ticket. ########## File path: modules/client/src/main/java/org/apache/ignite/jdbc/ConnectionProperties.java ########## @@ -0,0 +1,444 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.jdbc; + +import java.sql.SQLException; +import org.apache.ignite.internal.client.HostAndPortRange; +import org.apache.ignite.internal.client.ProtocolBitmaskFeature; + +/** + * Provide access and manipulations with connect0000ion JDBC properties. + */ +interface ConnectionProperties { + /** SSL mode: DISABLE. */ + String SSL_MODE_DISABLE = "disable"; + + /** SSL mode: REQUIRE. */ + String SSL_MODE_REQUIRE = "require"; + + /** + * Get the schema name. + * + * @return Schema name of the connection. + */ + String getSchema(); + + /** + * Set the schema name. + * + * @param schema Schema name of the connection. + */ + void setSchema(String schema); + + /** + * Get the URL. + * + * @return The URL of the connection. + */ + String getUrl(); + + /** + * Set the URL. + * + * @param url The URL of the connection. + * @throws SQLException On invalid URL. + */ + void setUrl(String url) throws SQLException; + + /** + * Get the addresses. + * + * @return Ignite nodes addresses. + */ + HostAndPortRange[] getAddresses(); + + /** + * Set the ignite node addresses. + * + * @param addrs Ignite nodes addresses. + */ + void setAddresses(HostAndPortRange[] addrs); + + + /** + * Get the auto close server cursors flag. + * + * @return Auto close server cursors flag. + */ + boolean isAutoCloseServerCursor(); + + /** + * Set the auto close server cursors flag. + * + * @param autoCloseServerCursor Auto close server cursors flag. + */ + void setAutoCloseServerCursor(boolean autoCloseServerCursor); + + /** + * Get the socket send buffer size. + * + * @return Socket send buffer size. + */ + int getSocketSendBuffer(); + + /** + * Set the socket send buffer size. + * + * @param size Socket send buffer size. + * @throws SQLException On error. + */ + void setSocketSendBuffer(int size) throws SQLException; + + /** + * Get the socket receive buffer size. + * + * @return Socket receive buffer size. + */ + int getSocketReceiveBuffer(); + + /** + * Set the socket receive buffer size. + * + * @param size Socket receive buffer size. + * @throws SQLException On error. + */ + void setSocketReceiveBuffer(int size) throws SQLException; + + /** + * Get the TCP no delay flag. + * + * @return TCP no delay flag. + */ + boolean isTcpNoDelay(); + + /** + * Set the TCP no delay flag. + * + * @param tcpNoDelay TCP no delay flag. + */ + void setTcpNoDelay(boolean tcpNoDelay); + + /** + * Gets SSL connection mode. + * + * @return Use SSL flag. + * @see #setSslMode(String) + */ + String getSslMode(); + + /** + * Use SSL connection to Ignite node. In case set to {@code "require"} SSL context must be configured. + * {@link #setSslClientCertificateKeyStoreUrl} property and related properties must be set up + * or JSSE properties must be set up (see {@code javax.net.ssl.keyStore} and other {@code javax.net.ssl.*} + * properties) + * + * In case set to {@code "disable"} plain connection is used. + * Available modes: {@code "disable", "require"}. Default value is {@code "disable"} + * + * @param mode SSL mode. + */ + void setSslMode(String mode); + + /** + * Gets protocol for secure transport. + * + * @return SSL protocol name. + */ + String getSslProtocol(); + + /** + * Sets protocol for secure transport. If not specified, TLS protocol will be used. + * Protocols implementations supplied by JSEE: SSLv3 (SSL), TLSv1 (TLS), TLSv1.1, TLSv1.2 Review comment: I think this should depends on SSL Provider, as some users may have 3-rd party one. Does it make sense to move SSL setting to a separate class and reuse it everywhere in Ignite, but not only in JDBC connection settings? For example, we can move SSL related properties to a separate interface SslProperties and make СonnectionProperties just to extend it. I'm ok to discuss this at first and do in a separate ticket. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org