IGNITE-8495: Thin C++ client. This closes #4270 and #4071
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ed658597 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ed658597 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ed658597 Branch: refs/heads/ignite-8446 Commit: ed658597eb0d2e38c02f75ea48d4c6e38bb315bb Parents: 219c983 Author: Igor Sapego <[email protected]> Authored: Mon Jul 9 19:28:59 2018 +0300 Committer: Igor Sapego <[email protected]> Committed: Mon Jul 9 19:36:08 2018 +0300 ---------------------------------------------------------------------- .gitignore | 3 +- .../odbc/ClientConnectableNodePartitions.java | 83 ++ .../odbc/ClientListenerProcessor.java | 5 + .../platform/client/ClientMessageParser.java | 16 + .../cache/ClientCacheLocalPeekRequest.java | 50 ++ .../cache/ClientCacheNodePartitionsRequest.java | 75 ++ .../ClientCacheNodePartitionsResponse.java | 54 ++ .../plugin/security/SecurityPermission.java | 2 +- modules/platforms/cpp/DEVNOTES.txt | 7 +- modules/platforms/cpp/Makefile.am | 16 +- modules/platforms/cpp/Makefile.amrel | 6 + modules/platforms/cpp/README.txt | 16 +- .../include/ignite/binary/binary_raw_writer.h | 2 +- .../ignite/impl/binary/binary_reader_impl.h | 7 + .../ignite/impl/binary/binary_type_manager.h | 5 +- .../ignite/impl/binary/binary_writer_impl.h | 26 +- .../ignite/impl/interop/interop_output_stream.h | 8 + .../src/impl/binary/binary_object_impl.cpp | 2 + .../src/impl/binary/binary_reader_impl.cpp | 32 +- .../src/impl/binary/binary_type_manager.cpp | 53 +- .../src/impl/interop/interop_output_stream.cpp | 7 + .../include/ignite/common/platform_utils.h | 6 + .../cpp/common/include/ignite/common/utils.h | 62 ++ .../os/linux/src/common/platform_utils.cpp | 16 +- .../common/os/win/src/common/platform_utils.cpp | 23 + modules/platforms/cpp/configure.ac | 16 + modules/platforms/cpp/configure.acrel | 14 + .../cpp/core-test/project/vs/core-test.vcxproj | 2 +- .../project/vs/core-test.vcxproj.filters | 23 +- .../cpp/core-test/src/cache_query_test.cpp | 7 + .../include/ignite/cache/mutable_cache_entry.h | 8 +- .../cpp/core/include/ignite/ignite_binding.h | 5 + .../impl/interop/interop_external_memory.h | 2 +- modules/platforms/cpp/core/namespaces.dox | 72 +- modules/platforms/cpp/cpp.dxg | 6 +- modules/platforms/cpp/odbc-test/Makefile.am | 1 + .../cpp/odbc-test/include/test_utils.h | 5 + .../cpp/odbc-test/src/authentication_test.cpp | 12 +- .../cpp/odbc-test/src/queries_test.cpp | 4 + .../platforms/cpp/odbc-test/src/test_utils.cpp | 17 + .../cpp/odbc-test/src/utility_test.cpp | 3 +- .../include/ignite/odbc/config/config_tools.h | 1 - .../cpp/odbc/include/ignite/odbc/utility.h | 65 -- .../platforms/cpp/odbc/project/vs/odbc.vcxproj | 6 +- .../cpp/odbc/src/config/config_tools.cpp | 13 +- .../src/config/connection_string_parser.cpp | 4 +- modules/platforms/cpp/project/vs/ignite.sln | 23 + modules/platforms/cpp/project/vs/ignite.slnrel | 13 + .../platforms/cpp/project/vs/ignite_x86.slnrel | 13 + .../platforms/cpp/thin-client-test/Makefile.am | 74 ++ .../cpp/thin-client-test/config/auth-32.xml | 48 ++ .../thin-client-test/config/auth-default.xml | 77 ++ .../cpp/thin-client-test/config/auth.xml | 31 + .../cpp/thin-client-test/config/cache-32.xml | 52 ++ .../thin-client-test/config/cache-default.xml | 141 ++++ .../cpp/thin-client-test/config/cache.xml | 35 + .../cpp/thin-client-test/config/ssl-32.xml | 48 ++ .../cpp/thin-client-test/config/ssl-default.xml | 84 ++ .../cpp/thin-client-test/config/ssl.xml | 31 + .../cpp/thin-client-test/config/ssl/ca.pem | 24 + .../thin-client-test/config/ssl/client_full.pem | 84 ++ .../config/ssl/client_unknown.pem | 50 ++ .../cpp/thin-client-test/config/ssl/server.jks | Bin 0 -> 4256 bytes .../cpp/thin-client-test/config/ssl/trust.jks | Bin 0 -> 1089 bytes .../platforms/cpp/thin-client-test/configure.ac | 62 ++ .../cpp/thin-client-test/include/Makefile.am | 24 + .../include/ignite/complex_type.h | 123 +++ .../include/teamcity/teamcity_messages.h | 55 ++ .../cpp/thin-client-test/include/test_utils.h | 72 ++ .../project/vs/thin-client-test.vcxproj | 186 +++++ .../project/vs/thin-client-test.vcxproj.filters | 82 ++ .../cpp/thin-client-test/src/auth_test.cpp | 76 ++ .../thin-client-test/src/cache_client_test.cpp | 743 +++++++++++++++++ .../thin-client-test/src/ignite_client_test.cpp | 72 ++ .../cpp/thin-client-test/src/ssl_test.cpp | 103 +++ .../src/teamcity/teamcity_boost.cpp | 159 ++++ .../src/teamcity/teamcity_messages.cpp | 150 ++++ .../cpp/thin-client-test/src/test_utils.cpp | 106 +++ modules/platforms/cpp/thin-client/Makefile.am | 72 ++ modules/platforms/cpp/thin-client/README.md | 4 + .../cpp/thin-client/include/Makefile.am | 31 + .../ignite/impl/thin/cache/cache_client_proxy.h | 165 ++++ .../include/ignite/impl/thin/readable.h | 98 +++ .../include/ignite/impl/thin/writable.h | 98 +++ .../include/ignite/impl/thin/writable_key.h | 681 +++++++++++++++ .../include/ignite/thin/cache/cache_client.h | 225 +++++ .../include/ignite/thin/cache/cache_peek_mode.h | 77 ++ .../include/ignite/thin/ignite_client.h | 157 ++++ .../ignite/thin/ignite_client_configuration.h | 228 ++++++ .../thin-client/include/ignite/thin/ssl_mode.h | 45 + .../thin-client/os/linux/src/net/net_utils.cpp | 109 +++ .../os/linux/src/net/tcp_socket_client.cpp | 361 ++++++++ .../thin-client/os/win/src/net/net_utils.cpp | 106 +++ .../os/win/src/net/tcp_socket_client.cpp | 417 ++++++++++ .../thin-client/project/vs/thin-client.vcxproj | 213 +++++ .../project/vs/thin-client.vcxproj.filters | 157 ++++ .../cpp/thin-client/src/ignite_client.cpp | 101 +++ .../src/impl/cache/cache_affinity_info.cpp | 110 +++ .../src/impl/cache/cache_affinity_info.h | 106 +++ .../src/impl/cache/cache_client_impl.cpp | 179 ++++ .../src/impl/cache/cache_client_impl.h | 185 +++++ .../src/impl/cache/cache_client_proxy.cpp | 101 +++ .../src/impl/connectable_node_partitions.h | 118 +++ .../cpp/thin-client/src/impl/data_channel.cpp | 387 +++++++++ .../cpp/thin-client/src/impl/data_channel.h | 333 ++++++++ .../cpp/thin-client/src/impl/data_router.cpp | 265 ++++++ .../cpp/thin-client/src/impl/data_router.h | 291 +++++++ .../thin-client/src/impl/ignite_client_impl.cpp | 138 ++++ .../thin-client/src/impl/ignite_client_impl.h | 132 +++ .../cpp/thin-client/src/impl/message.cpp | 276 +++++++ .../cpp/thin-client/src/impl/message.h | 820 +++++++++++++++++++ .../cpp/thin-client/src/impl/net/end_point.h | 161 ++++ .../cpp/thin-client/src/impl/net/net_utils.h | 46 ++ .../src/impl/net/remote_type_updater.cpp | 84 ++ .../src/impl/net/remote_type_updater.h | 81 ++ .../cpp/thin-client/src/impl/net/tcp_range.h | 177 ++++ .../src/impl/net/tcp_socket_client.h | 157 ++++ .../thin-client/src/impl/protocol_version.cpp | 151 ++++ .../cpp/thin-client/src/impl/protocol_version.h | 163 ++++ .../cpp/thin-client/src/impl/response_status.h | 63 ++ .../cpp/thin-client/src/impl/socket_client.h | 105 +++ .../src/impl/ssl/secure_socket_client.cpp | 445 ++++++++++ .../src/impl/ssl/secure_socket_client.h | 187 +++++ .../cpp/thin-client/src/impl/ssl/ssl_bindings.h | 360 ++++++++ .../thin-client/src/impl/ssl/ssl_gateway.cpp | 237 ++++++ .../cpp/thin-client/src/impl/ssl/ssl_gateway.h | 161 ++++ .../cpp/thin-client/src/impl/utility.cpp | 181 ++++ .../cpp/thin-client/src/impl/utility.h | 82 ++ 128 files changed, 13154 insertions(+), 182 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 47220b2..cd52dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -94,6 +94,7 @@ packages /modules/platforms/cpp/missing /modules/platforms/cpp/odbc-test/ignite-odbc-tests /modules/platforms/cpp/stamp-h1 +/modules/platforms/cpp/thin-client-test/ignite-thin-client-tests #Files related to ML manual-runnable tests -/modules/ml/src/test/resources/manualrun/trees/columntrees.manualrun.properties \ No newline at end of file +/modules/ml/src/test/resources/manualrun/trees/columntrees.manualrun.properties http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientConnectableNodePartitions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientConnectableNodePartitions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientConnectableNodePartitions.java new file mode 100644 index 0000000..0fbba4e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientConnectableNodePartitions.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.odbc; + +import java.util.Collection; +import org.apache.ignite.binary.BinaryRawWriter; + +/** + * Address of the node, connectible for the thin client, associated with cache partitions info. + */ +public class ClientConnectableNodePartitions { + /** Client listener port */ + private final int port; + + /** Addresses. */ + private final Collection<String> addrs; + + /** Cache partitions. */ + private final int[] parts; + + /** + * @param port Client listener port. + * @param addrs Node addresses. + * @param parts Partitions. + */ + public ClientConnectableNodePartitions(int port, Collection<String> addrs, int[] parts) { + this.port = port; + this.addrs = addrs; + this.parts = parts; + } + + /** + * @return Client listener port of the node. + */ + public int getPort() { + return port; + } + + /** + * @return Node's addresses. + */ + public Collection<String> getAddress() { + return addrs; + } + + /** + * @return Cache partitions mapped to the node. + */ + public int[] getPartitions() { + return parts; + } + + /** + * Write using writer. + * @param writer Writer. + */ + public void write(BinaryRawWriter writer) { + writer.writeInt(port); + + writer.writeInt(addrs.size()); + for (String addr : addrs) + writer.writeString(addr); + + writer.writeInt(parts.length); + for (int part : parts) + writer.writeInt(part); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java index 666af92..c8c0260 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerProcessor.java @@ -64,6 +64,9 @@ public class ClientListenerProcessor extends GridProcessorAdapter { /** Default client connector configuration. */ public static final ClientConnectorConfiguration DFLT_CLI_CFG = new ClientConnectorConfigurationEx(); + /** Client listener port. */ + public static final String CLIENT_LISTENER_PORT = "clientListenerPort"; + /** Default number of selectors. */ private static final int DFLT_SELECTOR_CNT = Math.min(4, Runtime.getRuntime().availableProcessors()); @@ -168,6 +171,8 @@ public class ClientListenerProcessor extends GridProcessorAdapter { lastErr = null; + ctx.addNodeAttribute(CLIENT_LISTENER_PORT, port); + break; } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java index 057995d..c887b3c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java @@ -52,6 +52,8 @@ import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGe import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetOrCreateWithNameRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetSizeRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheLocalPeekRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheNodePartitionsRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutAllRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutIfAbsentRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutRequest; @@ -138,6 +140,9 @@ public class ClientMessageParser implements ClientListenerMessageParser { /** */ private static final short OP_CACHE_GET_SIZE = 1020; + /** */ + private static final short OP_CACHE_LOCAL_PEEK = 1021; + /* Cache create / destroy, configuration. */ /** */ private static final short OP_CACHE_GET_NAMES = 1050; @@ -160,6 +165,11 @@ public class ClientMessageParser implements ClientListenerMessageParser { /** */ private static final short OP_CACHE_DESTROY = 1056; + /* Cache service info. */ + + /** */ + private static final short OP_CACHE_NODE_PARTITIONS = 1100; + /* Query operations. */ /** */ private static final short OP_QUERY_SCAN = 2000; @@ -311,6 +321,9 @@ public class ClientMessageParser implements ClientListenerMessageParser { case OP_CACHE_REMOVE_KEYS: return new ClientCacheRemoveKeysRequest(reader); + case OP_CACHE_LOCAL_PEEK: + return new ClientCacheLocalPeekRequest(reader); + case OP_CACHE_REMOVE_ALL: return new ClientCacheRemoveAllRequest(reader); @@ -323,6 +336,9 @@ public class ClientMessageParser implements ClientListenerMessageParser { case OP_CACHE_DESTROY: return new ClientCacheDestroyRequest(reader); + case OP_CACHE_NODE_PARTITIONS: + return new ClientCacheNodePartitionsRequest(reader); + case OP_CACHE_GET_NAMES: return new ClientCacheGetNamesRequest(reader); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java new file mode 100644 index 0000000..068bbc9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; +import org.apache.ignite.plugin.security.SecurityPermission; + +/** + * Cache local peek request. + * Only should be used in testing purposes. + */ +public class ClientCacheLocalPeekRequest extends ClientCacheKeyRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheLocalPeekRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + authorize(ctx, SecurityPermission.CACHE_READ); + + Object val = cache(ctx).localPeek(key(), CachePeekMode.ALL); + + return new ClientObjectResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java new file mode 100644 index 0000000..b9bf80e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import java.util.ArrayList; +import java.util.Collection; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.cache.affinity.Affinity; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.odbc.ClientConnectableNodePartitions; +import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; +import org.apache.ignite.plugin.security.SecurityPermission; + +/** + * Cluster node list request. + * Currently used to request list of nodes, to calculate affinity on the client side. + */ +public class ClientCacheNodePartitionsRequest extends ClientCacheRequest { + /** + * Initializes a new instance of ClientRawRequest class. + * @param reader Reader. + */ + public ClientCacheNodePartitionsRequest(BinaryRawReader reader) { + super(reader); + } + + /** {@inheritDoc} */ + @Override public ClientResponse process(ClientConnectionContext ctx) { + authorize(ctx, SecurityPermission.CACHE_READ); + IgniteCache cache = cache(ctx); + + GridDiscoveryManager discovery = ctx.kernalContext().discovery(); + Collection<ClusterNode> nodes = discovery.cacheNodes(cache.getName(), + new AffinityTopologyVersion(discovery.topologyVersion())); + + Affinity aff = ctx.kernalContext().affinity().affinityProxy(cache.getName()); + + ArrayList<ClientConnectableNodePartitions> res = new ArrayList<>(); + + for (ClusterNode node : nodes) { + Integer port = node.attribute(ClientListenerProcessor.CLIENT_LISTENER_PORT); + + if (port == null) + continue; + + Collection<String> addrs = node.addresses(); + + int[] parts = aff.primaryPartitions(node); + + res.add(new ClientConnectableNodePartitions(port, addrs, parts)); + } + + return new ClientCacheNodePartitionsResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsResponse.java new file mode 100644 index 0000000..3b6067b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsResponse.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import java.util.Collection; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; +import org.apache.ignite.internal.processors.odbc.ClientConnectableNodePartitions; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Client cache nodes partitions response. + */ +class ClientCacheNodePartitionsResponse extends ClientResponse { + /** Node partitions. */ + private final Collection<ClientConnectableNodePartitions> nodeParts; + + /** + * @param requestId Request id. + * @param nodeParts Node partitions info. + */ + ClientCacheNodePartitionsResponse(long requestId, Collection<ClientConnectableNodePartitions> nodeParts) { + super(requestId); + + assert nodeParts != null; + + this.nodeParts = nodeParts; + } + + /** {@inheritDoc} */ + @Override public void encode(BinaryRawWriterEx writer) { + super.encode(writer); + + writer.writeInt(nodeParts.size()); + + for (ClientConnectableNodePartitions nodePart : nodeParts) { + nodePart.write(writer); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java index bca667d..a202351 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java @@ -87,4 +87,4 @@ public enum SecurityPermission { @Nullable public static SecurityPermission fromOrdinal(int ord) { return ord >= 0 && ord < VALS.length ? VALS[ord] : null; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/DEVNOTES.txt ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/DEVNOTES.txt b/modules/platforms/cpp/DEVNOTES.txt index 473af23..132d163 100644 --- a/modules/platforms/cpp/DEVNOTES.txt +++ b/modules/platforms/cpp/DEVNOTES.txt @@ -33,14 +33,19 @@ Among standard included by autotools options configure script also include follo Ignite-specific options: * --enable-odbc - build included ODBC driver. Disabled by default. * --enable-core - build Ignite core library. Enabled by default. + * --enable-thin-client - build thin client library. Enabled by default. * --enable-node - build stand-alone node executable. Enabled by default. If you only need to build ODBC driver and do not want to build anything else you may just use configure script with the following arguments: - ./configure --enable-odbc --disable-core --disable-node + ./configure --enable-odbc --disable-core --disable-thin-client --disable-node With the config like that you should not have any ignite dependencies as jvm.dll installed to build ODBC driver. + +Similarly if you only want to build only thin client you may use configure script with +the following arguments: + ./configure --disable-core --disable-node NOTE: You may want to use "make install" command to install Ignite libraries and headers for your operation system. Note however that this action may require superuser privileges. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/Makefile.am b/modules/platforms/cpp/Makefile.am index 6b643bc..8471259 100644 --- a/modules/platforms/cpp/Makefile.am +++ b/modules/platforms/cpp/Makefile.am @@ -17,6 +17,14 @@ ACLOCAL_AMFLAGS =-I m4 +if COND_THIN_CLIENT + MAYBE_THIN_CLIENT = thin-client + +if COND_TESTS + MAYBE_THIN_CLIENT_TESTS = thin-client-test +endif +endif + if COND_ODBC MAYBE_ODBC = odbc @@ -46,9 +54,11 @@ SUBDIRS = \ $(MAYBE_JNI) \ $(MAYBE_ODBC) \ $(MAYBE_CORE) \ + $(MAYBE_THIN_CLIENT) \ $(MAYBE_NODE) \ $(MAYBE_ODBC_TESTS) \ - $(MAYBE_CORE_TESTS) + $(MAYBE_CORE_TESTS) \ + $(MAYBE_THIN_CLIENT_TESTS) DIST_SUBDIRS = \ common \ @@ -56,6 +66,8 @@ DIST_SUBDIRS = \ jni \ odbc \ core \ + thin-client \ ignite \ core-test \ - odbc-test + odbc-test \ + thin-client-test http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/Makefile.amrel ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/Makefile.amrel b/modules/platforms/cpp/Makefile.amrel index ae34b03..522e2fc 100644 --- a/modules/platforms/cpp/Makefile.amrel +++ b/modules/platforms/cpp/Makefile.amrel @@ -17,6 +17,10 @@ ACLOCAL_AMFLAGS =-I m4 +if COND_THIN_CLIENT + MAYBE_THIN_CLIENT = thin-client +endif + if COND_ODBC MAYBE_ODBC = odbc endif @@ -38,6 +42,7 @@ SUBDIRS = \ $(MAYBE_JNI) \ $(MAYBE_ODBC) \ $(MAYBE_CORE) \ + $(MAYBE_THIN_CLIENT) \ $(MAYBE_NODE) DIST_SUBDIRS = \ @@ -46,4 +51,5 @@ DIST_SUBDIRS = \ jni \ odbc \ core \ + thin-client \ ignite http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/README.txt ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/README.txt b/modules/platforms/cpp/README.txt index b1d7eef..dc740eb 100644 --- a/modules/platforms/cpp/README.txt +++ b/modules/platforms/cpp/README.txt @@ -31,6 +31,7 @@ Files list: * ignite - executable to start standalone Ignite C++ node. * libignite.so - Ignite C++ API library. * libignite-odbc.so - Ignite ODBC driver. + * libignite-thin-client.so - Ignite C++ thin client library. Development: @@ -54,6 +55,7 @@ Files list: * ignite.exe - executable to start standalone Ignite C++ node. * ignite.core.dll - Ignite C++ API library. * ignite.odbc.dll - Ignite ODBC driver. + * ignite.thin-client.dll - Ignite ODBC driver. Development: @@ -64,7 +66,8 @@ Development: * $(IGNITE_HOME)\platforms\cpp\jni\include * $(IGNITE_HOME)\platforms\cpp\jni\os\win\include * $(IGNITE_HOME)\platforms\cpp\binary\include - * $(IGNITE_HOME)\platforms\cpp\core\include + * $(IGNITE_HOME)\platforms\cpp\core\include to use thick client + * $(IGNITE_HOME)\platforms\cpp\thin-client\include to use thin client * $(JAVA_HOME)\include * $(JAVA_HOME)\include\win32 * Update Library Directories with path to the built binaries @@ -72,9 +75,10 @@ Development: * ignite.common.lib * ignite.jni.lib * ignite.binary.lib - * ignite.core.lib - * Make sure that your application is aware about ignite.jni.dll and ignite.core.dll - libraries. The easiest way to achieve this is to either make sure these files are in - %PATH%, or to put them into the output directory of your project with help of - PostBuild events. + * ignite.core.lib to use thick client + * ignite.thin-client.lib to use thin client + * Make sure that your application is aware about ignite.jni.dll and ignite.core.dll or + ignite.thin-client.dll libraries. The easiest way to achieve this is to either make + sure these files are in %PATH%, or to put them into the output directory of your + project with help of PostBuild events. * To start Apache Ignite as a standalone node or Windows service use ignite.exe http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h index 81e34b0..9dc73df 100644 --- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h +++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h @@ -266,7 +266,7 @@ namespace ignite */ void WriteString(const std::string& val) { - WriteString(val.c_str()); + WriteString(val.c_str(), static_cast<int32_t>(val.size())); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h index 4a0e2d4..998c7c3 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h @@ -568,6 +568,13 @@ namespace ignite /** * Read string. * + * @param res String to store result. + */ + void ReadString(std::string& res); + + /** + * Read string. + * * @param fieldName Field name. * @param res Array to store data to (should be able to acocmodate null-terminator). * @param len Expected length of string. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h index dc147fa..4a848cc 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h @@ -89,10 +89,7 @@ namespace ignite * * @param updater Updater. */ - void SetUpdater(BinaryTypeUpdater* updater) - { - this->updater = updater; - } + void SetUpdater(BinaryTypeUpdater* updater); /** * Get metadata snapshop for the type. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h index d5882c7..4364bf5 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h @@ -461,7 +461,7 @@ namespace ignite * @param val String. * @param len String length (characters). */ - void WriteString(const char* val, const int32_t len); + void WriteString(const char* val, int32_t len); /** * Write string. @@ -470,12 +470,32 @@ namespace ignite * @param val String. * @param len String length (characters). */ - void WriteString(const char* fieldName, const char* val, const int32_t len); + void WriteString(const char* fieldName, const char* val, int32_t len); + + /** + * Write string. + * + * @param val String. + */ + void WriteString(const std::string& val) + { + WriteString(val.c_str(), static_cast<int32_t>(val.size())); + } + + /** + * Write string. + * + * @param fieldName Field name. + * @param val String. + */ + void WriteString(const char* fieldName, const std::string& val) + { + WriteString(fieldName, val.c_str(), static_cast<int32_t>(val.size())); + } /** * Start string array write. * - * @param typ Collection type. * @return Session ID. */ int32_t WriteStringArray(); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/include/ignite/impl/interop/interop_output_stream.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/interop/interop_output_stream.h b/modules/platforms/cpp/binary/include/ignite/impl/interop/interop_output_stream.h index 9df3b1f..810b7c0 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/interop/interop_output_stream.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/interop/interop_output_stream.h @@ -144,6 +144,14 @@ namespace ignite void WriteInt64(const int64_t val); /** + * Write signed 64-byte integer. + * + * @param pos Position. + * @param val Value. + */ + void WriteInt64(const int32_t pos, const int64_t val); + + /** * Write signed 64-byte integer array. * * @param val Value. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp index 38e7670..b48e790 100644 --- a/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp +++ b/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp @@ -15,6 +15,8 @@ * limitations under the License. */ +#include <cassert> + #include <ignite/impl/interop/interop_stream_position_guard.h> #include <ignite/impl/interop/interop_input_stream.h> http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp index 6fd5aea..5e37887 100644 --- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp +++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp @@ -38,7 +38,7 @@ namespace ignite BinaryReaderImpl::BinaryReaderImpl(InteropInputStream* stream, BinaryIdResolver* idRslvr, int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff, int32_t footerBegin, int32_t footerEnd, BinaryOffsetType::Type schemaType) : - stream(stream), idRslvr(idRslvr), pos(pos), usrType(usrType), typeId(typeId), + stream(stream), idRslvr(idRslvr), pos(pos), usrType(usrType), typeId(typeId), hashCode(hashCode), len(len), rawOff(rawOff), rawMode(false), elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0), footerBegin(footerBegin), footerEnd(footerEnd), schemaType(schemaType) { @@ -55,9 +55,9 @@ namespace ignite int8_t BinaryReaderImpl::ReadInt8() { - return ReadRaw<int8_t>(BinaryUtils::ReadInt8); + return ReadRaw<int8_t>(BinaryUtils::ReadInt8); } - + int32_t BinaryReaderImpl::ReadInt8Array(int8_t* res, const int32_t len) { return ReadRawArray<int8_t>(res, len, BinaryUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE); @@ -445,6 +445,26 @@ namespace ignite return ReadStringInternal(res, len); } + void BinaryReaderImpl::ReadString(std::string& res) + { + CheckRawMode(true); + CheckSingleMode(true); + + int8_t hdr = stream->ReadInt8(); + + if (hdr == IGNITE_HDR_NULL) + res.clear(); + + if (hdr != IGNITE_TYPE_STRING) + ThrowOnInvalidHeader(IGNITE_TYPE_STRING, hdr); + + int32_t realLen = stream->ReadInt32(); + + res.resize(static_cast<size_t>(realLen)); + + stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen); + } + int32_t BinaryReaderImpl::ReadString(const char* fieldName, char* res, const int32_t len) { CheckRawMode(false); @@ -526,7 +546,7 @@ namespace ignite return realLen; } else if (hdr != IGNITE_HDR_NULL) - ThrowOnInvalidHeader(IGNITE_TYPE_ARRAY, hdr); + ThrowOnInvalidHeader(IGNITE_TYPE_STRING, hdr); return -1; } @@ -650,7 +670,7 @@ namespace ignite CollectionType::Type BinaryReaderImpl::ReadCollectionType() { InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream); - + return ReadCollectionTypeUnprotected(); } @@ -958,7 +978,7 @@ namespace ignite { int32_t cnt = stream->ReadInt32(); - if (cnt != 0) + if (cnt != 0) { elemId = ++elemIdGen; elemCnt = cnt; http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp index 637173b..277d210 100644 --- a/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp +++ b/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp @@ -15,10 +15,13 @@ * limitations under the License. */ +#include <vector> +#include <map> +#include <algorithm> + #include <ignite/common/concurrent.h> #include "ignite/impl/binary/binary_type_manager.h" -#include <algorithm> using namespace ignite::common::concurrent; @@ -98,10 +101,14 @@ namespace ignite bool BinaryTypeManager::ProcessPendingUpdates(IgniteError& err) { + CsLockGuard guard(cs); + if (!updater) - return false; + { + err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Updater is not set"); - CsLockGuard guard(cs); + return false; + } for (std::vector<SPSnap>::iterator it = pending->begin(); it != pending->end(); ++it) { @@ -111,7 +118,11 @@ namespace ignite continue; // Snapshot has been processed already. if (!updater->Update(*pendingSnap, err)) + { + err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not send update"); + return false; // Stop as we cannot move further. + } std::map<int32_t, SPSnap>::iterator elem = snapshots->lower_bound(pendingSnap->GetTypeId()); @@ -140,25 +151,33 @@ namespace ignite return true; } + void BinaryTypeManager::SetUpdater(BinaryTypeUpdater* updater) + { + CsLockGuard guard(cs); + + this->updater = updater; + } + SPSnap BinaryTypeManager::GetMeta(int32_t typeId) { - { // Locking scope. - CsLockGuard guard(cs); + CsLockGuard guard(cs); - std::map<int32_t, SPSnap>::iterator it = snapshots->find(typeId); + std::map<int32_t, SPSnap>::iterator it = snapshots->find(typeId); - if (it != snapshots->end() && it->second.Get()) - return it->second; + if (it != snapshots->end() && it->second.Get()) + return it->second; - for (int32_t i = 0; i < pending->size(); ++i) - { - SPSnap& snap = (*pending)[i]; + for (int32_t i = 0; i < pending->size(); ++i) + { + SPSnap& snap = (*pending)[i]; - if (snap.Get()->GetTypeId() == typeId) - return snap; - } + if (snap.Get()->GetTypeId() == typeId) + return snap; } + if (!updater) + throw IgniteError(IgniteError::IGNITE_ERR_BINARY, "Metadata updater is not available."); + IgniteError err; SPSnap snap = updater->GetMeta(typeId, err); @@ -166,11 +185,7 @@ namespace ignite IgniteError::ThrowIfNeeded(err); // Caching meta snapshot for faster access in future. - { // Locking scope. - CsLockGuard guard(cs); - - snapshots->insert(std::make_pair(typeId, snap)); - } + snapshots->insert(std::make_pair(typeId, snap)); return snap; } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/binary/src/impl/interop/interop_output_stream.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/interop/interop_output_stream.cpp b/modules/platforms/cpp/binary/src/impl/interop/interop_output_stream.cpp index ab58f1e..3e8160d 100644 --- a/modules/platforms/cpp/binary/src/impl/interop/interop_output_stream.cpp +++ b/modules/platforms/cpp/binary/src/impl/interop/interop_output_stream.cpp @@ -141,6 +141,13 @@ namespace ignite IGNITE_INTEROP_OUT_WRITE(val, int64_t, 8); } + void InteropOutputStream::WriteInt64(const int32_t pos, const int64_t val) + { + EnsureCapacity(pos + 8); + + *reinterpret_cast<int64_t*>(data + pos) = val; + } + void InteropOutputStream::WriteInt64Array(const int64_t* val, const int32_t len) { IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len << 3); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/common/include/ignite/common/platform_utils.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/platform_utils.h b/modules/platforms/cpp/common/include/ignite/common/platform_utils.h index a46caba..d9d5ec4 100644 --- a/modules/platforms/cpp/common/include/ignite/common/platform_utils.h +++ b/modules/platforms/cpp/common/include/ignite/common/platform_utils.h @@ -92,6 +92,12 @@ namespace ignite IGNITE_IMPORT_EXPORT bool IsValidDirectory(const std::string& path); /** + * Deletes provided filesystem element if exists. + * @return @c true if the provided path exists. + */ + IGNITE_IMPORT_EXPORT bool DeletePath(const std::string& path); + + /** * Write file separator to a stream. * @param ostr Stream. * @return The same stream for chaining. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/common/include/ignite/common/utils.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h index 792bd60..81b5432 100644 --- a/modules/platforms/cpp/common/include/ignite/common/utils.h +++ b/modules/platforms/cpp/common/include/ignite/common/utils.h @@ -23,6 +23,7 @@ #include <string> #include <sstream> #include <algorithm> +#include <iterator> #include <ignite/common/common.h> #include <ignite/common/platform_utils.h> @@ -72,6 +73,67 @@ namespace ignite IGNITE_IMPORT_EXPORT void StripSurroundingWhitespaces(std::string& str); /** + * Skip leading spaces. + * + * @param begin Iterator to the beginning of the character sequence. + * @param end Iterator to the end of the character sequence. + * @return Iterator to first non-blanc character. + */ + template<typename Iterator> + Iterator SkipLeadingSpaces(Iterator begin, Iterator end) + { + Iterator res = begin; + + while (isspace(*res) && res != end) + ++res; + + return res; + } + + /** + * Skip trailing spaces. + * + * @param begin Iterator to the beginning of the character sequence. + * @param end Iterator to the end of the character sequence. + * @return Iterator to last non-blanc character. + */ + template<typename Iterator> + Iterator SkipTrailingSpaces(Iterator begin, Iterator end) + { + Iterator res = end - 1; + + while (isspace(*res) && res != begin - 1) + --res; + + return res + 1; + } + + /** + * Remove leading and trailing spaces. + * + * @param begin Iterator to the beginning of the character sequence. + * @param end Iterator to the end of the character sequence. + * @return String without leading and trailing spaces. + */ + template<typename Iterator> + std::string StripSurroundingWhitespaces(Iterator begin, Iterator end) + { + std::string res; + + if (begin >= end) + return res; + + Iterator skipped_leading = SkipLeadingSpaces(begin, end); + Iterator skipped_trailing = SkipTrailingSpaces(skipped_leading, end); + + res.reserve(skipped_trailing - skipped_leading); + + std::copy(skipped_leading, skipped_trailing, std::back_inserter(res)); + + return res; + } + + /** * Get string representation of long in decimal form. * * @param val Long value to be converted to string. http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp b/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp index 2cbbd1d..cc8970f 100644 --- a/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp +++ b/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp @@ -15,7 +15,8 @@ * limitations under the License. */ -#include <time.h> +#include <cstdio> +#include <ctime> #include <sys/stat.h> #include <sys/time.h> @@ -23,6 +24,7 @@ #include <dlfcn.h> #include <glob.h> #include <unistd.h> +#include <ftw.h> #include <ignite/common/utils.h> @@ -92,6 +94,18 @@ namespace ignite return stat(path.c_str(), &pathStat) != -1 && S_ISDIR(pathStat.st_mode); } + static int rmFiles(const char *pathname, const struct stat *sbuf, int type, struct FTW *ftwb) + { + remove(pathname); + + return 0; + } + + bool DeletePath(const std::string& path) + { + return nftw(path.c_str(), rmFiles, 10, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) == 0; + } + StdCharOutStream& Fs(StdCharOutStream& ostr) { ostr.put('/'); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/common/os/win/src/common/platform_utils.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/os/win/src/common/platform_utils.cpp b/modules/platforms/cpp/common/os/win/src/common/platform_utils.cpp index c2244c5..b3f403d 100644 --- a/modules/platforms/cpp/common/os/win/src/common/platform_utils.cpp +++ b/modules/platforms/cpp/common/os/win/src/common/platform_utils.cpp @@ -16,6 +16,7 @@ */ #include <time.h> +#include <vector> #include <windows.h> @@ -92,6 +93,28 @@ namespace ignite return attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0; } + bool DeletePath(const std::string& path) + { + std::vector<TCHAR> path0(path.begin(), path.end()); + path0.push_back('\0'); + path0.push_back('\0'); + + SHFILEOPSTRUCT fileop; + fileop.hwnd = NULL; + fileop.wFunc = FO_DELETE; + fileop.pFrom = &path0[0]; + fileop.pTo = NULL; + fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT; + + fileop.fAnyOperationsAborted = FALSE; + fileop.lpszProgressTitle = NULL; + fileop.hNameMappings = NULL; + + int ret = SHFileOperation(&fileop); + + return ret == 0; + } + StdCharOutStream& Fs(StdCharOutStream& ostr) { ostr.put('\\'); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/configure.ac ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/configure.ac b/modules/platforms/cpp/configure.ac index 33584a6..dd47fa7 100644 --- a/modules/platforms/cpp/configure.ac +++ b/modules/platforms/cpp/configure.ac @@ -59,6 +59,17 @@ AC_ARG_ENABLE([core], [core=true] ) +AC_ARG_ENABLE([thin-client], + [AS_HELP_STRING([--enable-thin-client],[build Thin C++ client [default=yes]])], + [ case "${enableval}" in + yes) thin_client=true ;; + no) thin_client=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-thin-client) ;; + esac + ], + [thin_client=true] +) + AC_ARG_ENABLE([node], [AS_HELP_STRING([--enable-node],[build stand-alone node binary [default=yes]])], [ case "${enableval}" in @@ -81,6 +92,7 @@ AC_ARG_ENABLE([tests], AM_CONDITIONAL([COND_ODBC], [test "x$odbc" = "xtrue"]) AM_CONDITIONAL([COND_CORE], [test "x$core" = "xtrue"]) +AM_CONDITIONAL([COND_THIN_CLIENT], [test "x$thin_client" = "xtrue"]) AM_CONDITIONAL([COND_NODE], [test "x$node" = "xtrue"]) AM_CONDITIONAL([COND_TESTS], [test "x$tests" = "xtrue"]) @@ -102,6 +114,10 @@ AC_CONFIG_FILES([ \ core/ignite.pc \ jni/include/Makefile \ jni/Makefile \ + thin-client/include/Makefile \ + thin-client/Makefile \ + thin-client-test/include/Makefile \ + thin-client-test/Makefile \ ignite/Makefile \ ]) http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/configure.acrel ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/configure.acrel b/modules/platforms/cpp/configure.acrel index d73769d..349f759 100644 --- a/modules/platforms/cpp/configure.acrel +++ b/modules/platforms/cpp/configure.acrel @@ -59,6 +59,17 @@ AC_ARG_ENABLE([core], [core=true] ) +AC_ARG_ENABLE([thin-client], + [AS_HELP_STRING([--enable-thin-client],[build Thin C++ client [default=yes]])], + [ case "${enableval}" in + yes) thin_client=true ;; + no) thin_client=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-thin-client) ;; + esac + ], + [thin_client=true] +) + AC_ARG_ENABLE([node], [AS_HELP_STRING([--enable-node],[build stand-alone node binary [default=yes]])], [ case "${enableval}" in @@ -71,6 +82,7 @@ AC_ARG_ENABLE([node], AM_CONDITIONAL([COND_ODBC], [test "x$odbc" = "xtrue"]) AM_CONDITIONAL([COND_CORE], [test "x$core" = "xtrue"]) +AM_CONDITIONAL([COND_THIN_CLIENT], [test "x$thin_client" = "xtrue"]) AM_CONDITIONAL([COND_NODE], [test "x$node" = "xtrue"]) AC_CONFIG_FILES([ \ @@ -87,6 +99,8 @@ AC_CONFIG_FILES([ \ core/ignite.pc \ jni/include/Makefile \ jni/Makefile \ + thin-client/include/Makefile \ + thin-client/Makefile \ ignite/Makefile \ ]) http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj index 0b0166f..f8dee2f 100644 --- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj +++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj @@ -219,4 +219,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> \ No newline at end of file +</Project> http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters index b16877c..3d6e01a 100644 --- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters +++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters @@ -125,39 +125,36 @@ <Filter Include="Code\Types"> <UniqueIdentifier>{fb43524e-3694-44ee-b153-770cd9cf6c7a}</UniqueIdentifier> </Filter> - <Filter Include="Code\Types"> - <UniqueIdentifier>{fb43524e-3694-44ee-b153-770cd9cf6c7a}</UniqueIdentifier> - </Filter> </ItemGroup> <ItemGroup> - <None Include="..\..\config\cache-test-32.xml"> + <None Include="..\..\config\invalid.xml"> <Filter>Configs</Filter> </None> <None Include="..\..\config\cache-test.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-test-default.xml"> + <None Include="..\..\config\cache-test-32.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-query-32.xml"> + <None Include="..\..\config\cache-test-default.xml"> <Filter>Configs</Filter> </None> <None Include="..\..\config\cache-query.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-query-default.xml"> + <None Include="..\..\config\cache-query-32.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-query-continuous-32.xml"> + <None Include="..\..\config\cache-query-default.xml"> <Filter>Configs</Filter> </None> <None Include="..\..\config\cache-query-continuous.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-query-continuous-default.xml"> + <None Include="..\..\config\cache-query-continuous-32.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\invalid.xml"> + <None Include="..\..\config\cache-query-continuous-default.xml"> <Filter>Configs</Filter> </None> <None Include="..\..\config\cache-identity.xml"> @@ -169,15 +166,15 @@ <None Include="..\..\config\cache-identity-default.xml"> <Filter>Configs</Filter> </None> - <None Include="..\..\config\cache-store-default.xml"> - <Filter>Configs</Filter> - </None> <None Include="..\..\config\cache-store.xml"> <Filter>Configs</Filter> </None> <None Include="..\..\config\cache-store-32.xml"> <Filter>Configs</Filter> </None> + <None Include="..\..\config\cache-store-default.xml"> + <Filter>Configs</Filter> + </None> <None Include="..\..\config\isolated.xml"> <Filter>Configs</Filter> </None> http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core-test/src/cache_query_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp index 8375bad..d5a3617 100644 --- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp +++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp @@ -34,6 +34,7 @@ #include "ignite/ignite.h" #include "ignite/ignition.h" #include "ignite/test_utils.h" +#include "teamcity_messages.h" using namespace boost::unit_test; @@ -963,6 +964,9 @@ BOOST_AUTO_TEST_CASE(TestSqlQuery) */ BOOST_AUTO_TEST_CASE(TestSqlQueryDistributedJoins) { + if (JetBrains::underTeamcity()) + return; + Cache<int, QueryPerson> cache1 = GetPersonCache(); Cache<int, QueryRelation> cache2 = GetRelationCache(); @@ -1241,6 +1245,9 @@ BOOST_AUTO_TEST_CASE(TestSqlFieldsQueryBasic) */ BOOST_AUTO_TEST_CASE(TestSqlFieldsQueryDistributedJoins) { + if (JetBrains::underTeamcity()) + return; + Cache<int, QueryPerson> cache1 = GetPersonCache(); Cache<int, QueryRelation> cache2 = GetRelationCache(); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core/include/ignite/cache/mutable_cache_entry.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/mutable_cache_entry.h b/modules/platforms/cpp/core/include/ignite/cache/mutable_cache_entry.h index 0481a5e..543e3cd 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/mutable_cache_entry.h +++ b/modules/platforms/cpp/core/include/ignite/cache/mutable_cache_entry.h @@ -15,12 +15,14 @@ * limitations under the License. */ +/** + * @file + * Declares ignite::cache::MutableCacheEntry class template. + */ + #ifndef _IGNITE_CACHE_MUTABLE_CACHE_ENTRY #define _IGNITE_CACHE_MUTABLE_CACHE_ENTRY -#include <ignite/common/common.h> -#include <ignite/cache/cache_entry.h> - namespace ignite { namespace cache http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core/include/ignite/ignite_binding.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/ignite_binding.h b/modules/platforms/cpp/core/include/ignite/ignite_binding.h index fe060c1..8ff5ad9 100644 --- a/modules/platforms/cpp/core/include/ignite/ignite_binding.h +++ b/modules/platforms/cpp/core/include/ignite/ignite_binding.h @@ -15,6 +15,11 @@ * limitations under the License. */ +/** + * @file + * Declares ignite::IgniteBinding class. + */ + #ifndef _IGNITE_IGNITE_BINDING #define _IGNITE_IGNITE_BINDING http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h index 04d2e98..7daed35 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h +++ b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h @@ -33,7 +33,7 @@ namespace ignite /** * Interop external memory. */ - class IGNITE_IMPORT_EXPORT InteropExternalMemory : public interop::InteropMemory + class IGNITE_IMPORT_EXPORT InteropExternalMemory : public InteropMemory { public: /** http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/core/namespaces.dox ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/namespaces.dox b/modules/platforms/cpp/core/namespaces.dox index 49379e6..60e8cf7 100644 --- a/modules/platforms/cpp/core/namespaces.dox +++ b/modules/platforms/cpp/core/namespaces.dox @@ -26,29 +26,29 @@ /** * Apache %Ignite API. */ - namespace ignite - { - /** - * %Ignite Binary Objects API. - */ - namespace binary - { - // Empty. - } +namespace ignite +{ + /** + * %Ignite Binary Objects API. + */ + namespace binary + { + // Empty. + } - /** - * %Ignite %Transaction API. - */ - namespace transactions - { - // Empty. - } + /** + * %Ignite %Transaction API. + */ + namespace transactions + { + // Empty. + } - /** - * %Ignite %Cache API. - */ - namespace cache - { + /** + * %Ignite %Cache API. + */ + namespace cache + { /** * Contains APIs for cache events. */ @@ -57,11 +57,11 @@ // Empty. } - /** - * Contains APIs for creating and executing cache queries. - */ - namespace query - { + /** + * Contains APIs for creating and executing cache queries. + */ + namespace query + { /** * Contains APIs for continuous queries. */ @@ -69,7 +69,21 @@ { // Empty. } - } - } - } + } + } + + /** + * %Ignite Thin Client API. + */ + namespace thin + { + /** + * %Ignite Thin Client Cache API. + */ + namespace cache + { + // Empty. + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/cpp.dxg ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/cpp.dxg b/modules/platforms/cpp/cpp.dxg index d25d978..2f571f8 100644 --- a/modules/platforms/cpp/cpp.dxg +++ b/modules/platforms/cpp/cpp.dxg @@ -1715,8 +1715,8 @@ GENERATE_LEGEND = YES DOT_CLEANUP = YES -;INPUT=core binary common -;EXCLUDE=core/include/ignite/impl core/os/linux/include/ignite/impl core/os/linux/src/impl core/os/win/include/ignite/impl core/os/win/src/impl core/src/impl binary/include/ignite/impl binary/src/impl common/include/ignite/common common/os -;STRIP_FROM_PATH=core/include/ignite core/src binary/include/ignite binary/src +;INPUT=core binary common thin-client +;EXCLUDE=core/include/ignite/impl core/os/linux/include/ignite/impl core/os/linux/src/impl core/os/win/include/ignite/impl core/os/win/src/impl core/src/impl binary/include/ignite/impl binary/src/impl common/include/ignite/common common/os thin-client/include/ignite/impl thin-client/src +;STRIP_FROM_PATH=core/include/ignite core/src binary/include/ignite binary/src thin-client/src ;OUTPUT_DIRECTORY=../../clients/target/cppdoc ;PROJECT_LOGO=../../../assembly/docfiles/ignite_logo.png http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am index 89e27dd..87e3c89 100644 --- a/modules/platforms/cpp/odbc-test/Makefile.am +++ b/modules/platforms/cpp/odbc-test/Makefile.am @@ -84,6 +84,7 @@ ignite_odbc_tests_SOURCES = \ src/errors_test.cpp \ src/odbc_test_suite.cpp \ src/types_test.cpp \ + src/authentication_test.cpp \ ../odbc/src/log.cpp \ ../odbc/src/cursor.cpp \ ../odbc/src/diagnostic/diagnostic_record.cpp \ http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/include/test_utils.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/test_utils.h b/modules/platforms/cpp/odbc-test/include/test_utils.h index 786c2be..9faf89d 100644 --- a/modules/platforms/cpp/odbc-test/include/test_utils.h +++ b/modules/platforms/cpp/odbc-test/include/test_utils.h @@ -108,6 +108,11 @@ namespace ignite_test * @return New node. */ ignite::Ignite StartNode(const char* cfgFile, const char* name); + + /** + * Remove all the LFS artifacts. + */ + void ClearLfs(); } #endif // _IGNITE_ODBC_TEST_TEST_UTILS \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/src/authentication_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/authentication_test.cpp b/modules/platforms/cpp/odbc-test/src/authentication_test.cpp index 0f11d44..c746d5e 100644 --- a/modules/platforms/cpp/odbc-test/src/authentication_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/authentication_test.cpp @@ -32,7 +32,7 @@ #include "test_utils.h" #include "odbc_test_suite.h" -#include "../../core-test/include/ignite/test_type.h" +#include "test_type.h" using namespace ignite; using namespace ignite::common; @@ -65,11 +65,11 @@ struct AuthenticationTestSuiteFixture : odbc::OdbcTestSuite AuthenticationTestSuiteFixture() : OdbcTestSuite() { + ClearLfs(); + grid = StartAdditionalNode("NodeMain"); grid.SetActive(true); - - grid.GetCache<int64_t, TestType>("cache").Clear(); } /** @@ -77,9 +77,7 @@ struct AuthenticationTestSuiteFixture : odbc::OdbcTestSuite */ virtual ~AuthenticationTestSuiteFixture() { - ExecQuery("DROP USER test"); - - grid.GetCache<int64_t, TestType>("cache").Clear(); + // No-op. } /** @@ -139,8 +137,6 @@ BOOST_AUTO_TEST_CASE(TestConnectionUserOperationsQuery) { Connect(MakeDefaultConnectionString()); - ExecQuery("DROP USER \"test\""); - SQLRETURN ret = ExecQuery("CREATE USER \"test\" WITH PASSWORD 'somePass'"); ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_DBC, dbc); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/src/queries_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp index 7561e32..73727dd 100644 --- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp @@ -39,6 +39,7 @@ #include "ignite/impl/binary/binary_utils.h" #include "ignite/binary/binary_object.h" +#include "teamcity/teamcity_messages.h" #include "test_type.h" #include "complex_type.h" #include "test_utils.h" @@ -803,6 +804,9 @@ BOOST_AUTO_TEST_CASE(TestNullFields) BOOST_AUTO_TEST_CASE(TestDistributedJoins) { + if (JetBrains::underTeamcity()) + return; + // Starting additional node. Ignite node1 = StartAdditionalNode("Node1"); Ignite node2 = StartAdditionalNode("Node2"); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/src/test_utils.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/test_utils.cpp b/modules/platforms/cpp/odbc-test/src/test_utils.cpp index 6d9ed6b..9c1aca9 100644 --- a/modules/platforms/cpp/odbc-test/src/test_utils.cpp +++ b/modules/platforms/cpp/odbc-test/src/test_utils.cpp @@ -121,4 +121,21 @@ namespace ignite_test return Ignition::Start(cfg, name); } + + std::string AppendPath(const std::string& base, const std::string& toAdd) + { + std::stringstream stream; + + stream << base << ignite::common::Fs << toAdd; + + return stream.str(); + } + + void ClearLfs() + { + std::string home = ignite::jni::ResolveIgniteHome(); + std::string workDir = AppendPath(home, "work"); + + ignite::common::DeletePath(workDir); + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc-test/src/utility_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/utility_test.cpp b/modules/platforms/cpp/odbc-test/src/utility_test.cpp index a66860f..f2955b7 100644 --- a/modules/platforms/cpp/odbc-test/src/utility_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/utility_test.cpp @@ -24,6 +24,7 @@ #include <ignite/impl/binary/binary_writer_impl.h> #include <ignite/odbc/utility.h> +#include <ignite/common/utils.h> using namespace ignite::utility; @@ -34,7 +35,7 @@ BOOST_AUTO_TEST_CASE(TestUtilityRemoveSurroundingSpaces) std::string inStr(" \r \n \t some meaningfull data \n\n \t \r "); std::string expectedOutStr("some meaningfull data"); - std::string realOutStr(RemoveSurroundingSpaces(inStr.begin(), inStr.end())); + std::string realOutStr(ignite::common::StripSurroundingWhitespaces(inStr.begin(), inStr.end())); BOOST_REQUIRE(expectedOutStr == realOutStr); } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc/include/ignite/odbc/config/config_tools.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/config_tools.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/config_tools.h index 5731191..9c376d8 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/config_tools.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/config_tools.h @@ -20,7 +20,6 @@ #include <string> #include <vector> -#include <sstream> #include "ignite/odbc/end_point.h" http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h index d58479c..152da66 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h @@ -23,18 +23,14 @@ #endif //min #include <stdint.h> -#include <ctime> #include <string> -#include <algorithm> -#include <sstream> #include <ignite/common/utils.h> #include <ignite/common/decimal.h> #include "ignite/impl/binary/binary_reader_impl.h" #include "ignite/impl/binary/binary_writer_impl.h" -#include <iterator> namespace ignite { @@ -43,67 +39,6 @@ namespace ignite /** Using common version of the util. */ using common::IntoLower; - /** - * Skip leading spaces. - * - * @param begin Iterator to the beginning of the character sequence. - * @param end Iterator to the end of the character sequence. - * @return Iterator to first non-blanc character. - */ - template<typename Iterator> - Iterator SkipLeadingSpaces(Iterator begin, Iterator end) - { - Iterator res = begin; - - while (isspace(*res) && res != end) - ++res; - - return res; - } - - /** - * Skip trailing spaces. - * - * @param begin Iterator to the beginning of the character sequence. - * @param end Iterator to the end of the character sequence. - * @return Iterator to last non-blanc character. - */ - template<typename Iterator> - Iterator SkipTrailingSpaces(Iterator begin, Iterator end) - { - Iterator res = end - 1; - - while (isspace(*res) && res != begin - 1) - --res; - - return res + 1; - } - - /** - * Remove leading and trailing spaces. - * - * @param begin Iterator to the beginning of the character sequence. - * @param end Iterator to the end of the character sequence. - * @return String without leading and trailing spaces. - */ - template<typename Iterator> - std::string RemoveSurroundingSpaces(Iterator begin, Iterator end) - { - std::string res; - - if (begin >= end) - return res; - - Iterator skipped_leading = SkipLeadingSpaces(begin, end); - Iterator skipped_trailing = SkipTrailingSpaces(skipped_leading, end); - - res.reserve(skipped_trailing - skipped_leading); - - std::copy(skipped_leading, skipped_trailing, std::back_inserter(res)); - - return res; - } - template<typename T> T* GetPointerWithOffset(T* ptr, size_t offset) { http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj index 374695b..352913e 100644 --- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj +++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj @@ -94,13 +94,12 @@ <Optimization>Disabled</Optimization> <SDLCheck>false</SDLCheck> <AdditionalIncludeDirectories>$(OPENSSL_HOME_X86)\include;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories> - <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> <DelayLoadDLLs> </DelayLoadDLLs> </Link> @@ -117,7 +116,6 @@ <GenerateDebugInformation>true</GenerateDebugInformation> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> <DelayLoadDLLs> </DelayLoadDLLs> </Link> @@ -138,7 +136,6 @@ <OptimizeReferences>true</OptimizeReferences> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> @@ -157,7 +154,6 @@ <OptimizeReferences>true</OptimizeReferences> <ModuleDefinitionFile>module.def</ModuleDefinitionFile> <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(OPENSSL_HOME)\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemGroup> http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc/src/config/config_tools.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/config/config_tools.cpp b/modules/platforms/cpp/odbc/src/config/config_tools.cpp index f0d956f..f53f49d 100644 --- a/modules/platforms/cpp/odbc/src/config/config_tools.cpp +++ b/modules/platforms/cpp/odbc/src/config/config_tools.cpp @@ -17,10 +17,13 @@ #include <cctype> #include <algorithm> +#include <sstream> -#include "ignite/odbc/utility.h" -#include "ignite/odbc/config/config_tools.h" -#include "ignite/odbc/config/configuration.h" +#include <ignite/common/utils.h> + +#include <ignite/odbc/utility.h> +#include <ignite/odbc/config/config_tools.h> +#include <ignite/odbc/config/configuration.h> namespace ignite { @@ -69,7 +72,7 @@ namespace ignite const char* addrBegin = parsedAddr.data() + addrBeginPos; const char* addrEnd = parsedAddr.data() + parsedAddr.size(); - std::string addr = utility::RemoveSurroundingSpaces(addrBegin, addrEnd); + std::string addr = common::StripSurroundingWhitespaces(addrBegin, addrEnd); if (!addr.empty()) { @@ -198,7 +201,7 @@ namespace ignite uint16_t ParsePort(const std::string& value, diagnostic::DiagnosticRecordStorage* diag) { - std::string port = utility::RemoveSurroundingSpaces(value.begin(), value.end()); + std::string port = common::StripSurroundingWhitespaces(value.begin(), value.end()); if (!common::AllOf(port.begin(), port.end(), &isdigit)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/odbc/src/config/connection_string_parser.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/config/connection_string_parser.cpp b/modules/platforms/cpp/odbc/src/config/connection_string_parser.cpp index b32c2ec..d23c2cb 100644 --- a/modules/platforms/cpp/odbc/src/config/connection_string_parser.cpp +++ b/modules/platforms/cpp/odbc/src/config/connection_string_parser.cpp @@ -93,8 +93,8 @@ namespace ignite const char* value_begin = connect_str.data() + attr_eq_pos + 1; const char* value_end = connect_str.data() + connect_str.size(); - std::string key = utility::RemoveSurroundingSpaces(key_begin, key_end); - std::string value = utility::RemoveSurroundingSpaces(value_begin, value_end); + std::string key = common::StripSurroundingWhitespaces(key_begin, key_end); + std::string value = common::StripSurroundingWhitespaces(value_begin, value_end); if (value[0] == '{' && value[value.size() - 1] == '}') value = value.substr(1, value.size() - 2); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/project/vs/ignite.sln ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/project/vs/ignite.sln b/modules/platforms/cpp/project/vs/ignite.sln index 01f12f9..cf2e487 100644 --- a/modules/platforms/cpp/project/vs/ignite.sln +++ b/modules/platforms/cpp/project/vs/ignite.sln @@ -26,6 +26,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\common\proj EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jni", "..\..\jni\project\vs\jni.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "thin-client", "..\..\thin-client\project\vs\thin-client.vcxproj", "{5C037386-B5F5-4A58-9EE2-3D3A508AA866}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "thin-client-test", "..\..\thin-client-test\project\vs\thin-client-test.vcxproj", "{5662F10A-9C40-45D6-AFF8-E93573FEAABA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -98,8 +102,27 @@ Global {4F7E4917-4612-4B96-9838-025711ADE391}.Release|Win32.Build.0 = Release|Win32 {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64 {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|Win32.ActiveCfg = Debug|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|Win32.Build.0 = Debug|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|x64.ActiveCfg = Debug|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|x64.Build.0 = Debug|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|Win32.ActiveCfg = Release|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|Win32.Build.0 = Release|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|x64.ActiveCfg = Release|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|x64.Build.0 = Release|x64 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Debug|Win32.ActiveCfg = Debug|Win32 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Debug|Win32.Build.0 = Debug|Win32 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Debug|x64.ActiveCfg = Debug|x64 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Debug|x64.Build.0 = Debug|x64 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Release|Win32.ActiveCfg = Release|Win32 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Release|Win32.Build.0 = Release|Win32 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Release|x64.ActiveCfg = Release|x64 + {5662F10A-9C40-45D6-AFF8-E93573FEAABA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3761BFB8-4345-4AC4-BE04-5ACB1DCA842C} + EndGlobalSection EndGlobal http://git-wip-us.apache.org/repos/asf/ignite/blob/ed658597/modules/platforms/cpp/project/vs/ignite.slnrel ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/project/vs/ignite.slnrel b/modules/platforms/cpp/project/vs/ignite.slnrel index 6a37bf4..187ff6a 100644 --- a/modules/platforms/cpp/project/vs/ignite.slnrel +++ b/modules/platforms/cpp/project/vs/ignite.slnrel @@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\common\proj EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jni", "..\..\jni\project\vs\jni.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "thin-client", "..\..\thin-client\project\vs\thin-client.vcxproj", "{5C037386-B5F5-4A58-9EE2-3D3A508AA866}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release|x64 = Release|x64 @@ -68,8 +70,19 @@ Global {4F7E4917-4612-4B96-9838-025711ADE391}.Release|Win32.Build.0 = Release|Win32 {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64 {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|Win32.ActiveCfg = Debug|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|Win32.Build.0 = Debug|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|x64.ActiveCfg = Debug|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Debug|x64.Build.0 = Debug|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|Win32.ActiveCfg = Release|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|Win32.Build.0 = Release|Win32 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|x64.ActiveCfg = Release|x64 + {5C037386-B5F5-4A58-9EE2-3D3A508AA866}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3761BFB8-4345-4AC4-BE04-5ACB1DCA842C} + EndGlobalSection EndGlobal
