You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/10/15 08:23:06 UTC

ignite git commit: IGNITE-8972: CPP Thin Client: added example.

Repository: ignite
Updated Branches:
  refs/heads/master 55e034ab6 -> 712067373


IGNITE-8972: CPP Thin Client: added example.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/71206737
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/71206737
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/71206737

Branch: refs/heads/master
Commit: 712067373996d6dedfee1dd5699948ddfa14a5ad
Parents: 55e034a
Author: Igor Sapego <ig...@gmail.com>
Authored: Mon Oct 15 11:22:58 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Oct 15 11:22:58 2018 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/examples/Makefile.am      |   1 +
 modules/platforms/cpp/examples/configure.ac     |   1 +
 .../cpp/examples/project/vs/ignite-examples.sln |   6 +
 .../thin-client-put-get-example/Makefile.am     |  53 ++++++++
 .../vs/thin-client-put-get-example.vcxproj      | 107 ++++++++++++++++
 .../thin-client-put-get-example.vcxproj.filters |  35 +++++
 .../src/thin_client_put_get_example.cpp         | 127 +++++++++++++++++++
 7 files changed, 330 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/Makefile.am b/modules/platforms/cpp/examples/Makefile.am
index 29b140b..d7a49b7 100644
--- a/modules/platforms/cpp/examples/Makefile.am
+++ b/modules/platforms/cpp/examples/Makefile.am
@@ -23,5 +23,6 @@ SUBDIRS = \
     query-example \
 	continuous-query-example \
 	compute-example \
+	thin-client-put-get-example \
     include
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/configure.ac b/modules/platforms/cpp/examples/configure.ac
index 8cf7cf7..9c1acdd 100644
--- a/modules/platforms/cpp/examples/configure.ac
+++ b/modules/platforms/cpp/examples/configure.ac
@@ -58,6 +58,7 @@ AC_CONFIG_FILES([ \
     query-example/Makefile \
     continuous-query-example/Makefile \
     compute-example/Makefile \
+    thin-client-put-get-example/Makefile \
 ])
 
 AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/project/vs/ignite-examples.sln
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/project/vs/ignite-examples.sln b/modules/platforms/cpp/examples/project/vs/ignite-examples.sln
index bf83743..aeff805 100644
--- a/modules/platforms/cpp/examples/project/vs/ignite-examples.sln
+++ b/modules/platforms/cpp/examples/project/vs/ignite-examples.sln
@@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "put-get-example", "..\..\pu
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compute-example", "..\..\compute-example\project\vs\compute-example.vcxproj", "{18BB0A18-8213-472A-81A0-9D9753697135}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "thin-client-put-get-example", "..\..\thin-client-put-get-example\project\vs\thin-client-put-get-example.vcxproj", "{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Release|x64 = Release|x64
@@ -37,6 +39,10 @@ Global
 		{18BB0A18-8213-472A-81A0-9D9753697135}.Release|x64.Build.0 = Release|x64
 		{18BB0A18-8213-472A-81A0-9D9753697135}.Release|x86.ActiveCfg = Release|Win32
 		{18BB0A18-8213-472A-81A0-9D9753697135}.Release|x86.Build.0 = Release|Win32
+		{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}.Release|x64.ActiveCfg = Release|x64
+		{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}.Release|x64.Build.0 = Release|x64
+		{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}.Release|x86.ActiveCfg = Release|Win32
+		{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/thin-client-put-get-example/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/thin-client-put-get-example/Makefile.am b/modules/platforms/cpp/examples/thin-client-put-get-example/Makefile.am
new file mode 100644
index 0000000..f9f7345
--- /dev/null
+++ b/modules/platforms/cpp/examples/thin-client-put-get-example/Makefile.am
@@ -0,0 +1,53 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS =-I m4
+
+noinst_PROGRAMS = ignite-thin-client-put-get-example
+
+AM_CPPFLAGS = \
+    -I@top_srcdir@/include \
+    -I@top_srcdir@/../thin-client/include \
+    -I@top_srcdir@/../thin-client/os/linux/include \
+    -I@top_srcdir@/../common/include \
+    -I@top_srcdir@/../common/os/linux/include \
+    -I@top_srcdir@/../binary/include \
+    -D__STDC_LIMIT_MACROS \
+    -D__STDC_CONSTANT_MACROS
+
+AM_CXXFLAGS = \
+    -Wall \
+    -std=c++03
+
+ignite_thin_client_put_get_example_LDADD = \
+    @top_srcdir@/../thin-client/libignite-thin-client.la \
+    -lpthread
+
+ignite_thin_client_put_get_example_LDFLAGS = \
+    -static-libtool-libs
+
+ignite_thin_client_put_get_example_SOURCES = \
+    src/thin_client_put_get_example.cpp
+
+run-check: check
+	./ignite-thin-client-put-get-example -p
+
+clean-local: clean-check
+	$(RM) *.gcno *.gcda
+
+clean-check:
+	$(RM) $(ignite_thin_client_put_get_example_OBJECTS)

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj b/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj
new file mode 100644
index 0000000..12c8a98
--- /dev/null
+++ b/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{8F045A49-A1C8-45B5-B9E4-FFB323AD1060}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>igniteexamples</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\common\os\win\include;..\..\..\..\common\include;..\..\..\..\binary\include;..\..\..\..\thin-client\os\win\include;..\..\..\..\thin-client\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>ignite.binary.lib;ignite.thin-client.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\..\..\project\vs\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+    </Link>
+    <PostBuildEvent>
+      <Command>copy "$(ProjectDir)..\..\..\..\project\vs\$(Platform)\$(Configuration)\ignite.common.dll" "$(OutDir)"
+copy "$(ProjectDir)..\..\..\..\project\vs\$(Platform)\$(Configuration)\ignite.thin-client.dll" "$(OutDir)"</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\common\os\win\include;..\..\..\..\common\include;..\..\..\..\binary\include;..\..\..\..\thin-client\os\win\include;..\..\..\..\thin-client\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>ignite.binary.lib;ignite.thin-client.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\..\..\project\vs\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+    </Link>
+    <PostBuildEvent>
+      <Command>copy "$(ProjectDir)..\..\..\..\project\vs\$(Platform)\$(Configuration)\ignite.common.dll" "$(OutDir)"
+copy "$(ProjectDir)..\..\..\..\project\vs\$(Platform)\$(Configuration)\ignite.thin-client.dll" "$(OutDir)"</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\src\thin_client_put_get_example.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\..\include\ignite\examples\address.h" />
+    <ClInclude Include="..\..\..\include\ignite\examples\organization.h" />
+    <ClInclude Include="..\..\..\include\ignite\examples\person.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\config\thin_client_put_get_example.xml" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj.filters b/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj.filters
new file mode 100644
index 0000000..41d4998
--- /dev/null
+++ b/modules/platforms/cpp/examples/thin-client-put-get-example/project/vs/thin-client-put-get-example.vcxproj.filters
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <ClInclude Include="..\..\..\include\ignite\examples\address.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\include\ignite\examples\organization.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\include\ignite\examples\person.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Config">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\src\thin_client_put_get_example.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\config\thin_client_put_get_example.xml">
+      <Filter>Config</Filter>
+    </None>
+  </ItemGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/71206737/modules/platforms/cpp/examples/thin-client-put-get-example/src/thin_client_put_get_example.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/thin-client-put-get-example/src/thin_client_put_get_example.cpp b/modules/platforms/cpp/examples/thin-client-put-get-example/src/thin_client_put_get_example.cpp
new file mode 100644
index 0000000..252ad3d
--- /dev/null
+++ b/modules/platforms/cpp/examples/thin-client-put-get-example/src/thin_client_put_get_example.cpp
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+#include <stdint.h>
+#include <iostream>
+
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/cache/cache_client.h>
+
+#include "ignite/examples/organization.h"
+
+using namespace ignite;
+using namespace thin;
+using namespace cache;
+
+using namespace examples;
+
+/*
+ * Execute individual Put and Get operations.
+ *
+ * @param cache Cache instance.
+ */
+void PutGet(CacheClient<int32_t, Organization>& cache) 
+{
+    // Create new Organization to store in cache.
+    Organization org("Microsoft", Address("1096 Eddy Street, San Francisco, CA", 94109));
+
+    // Put organization to cache.
+    cache.Put(1, org);
+
+    // Get recently created employee as a strongly-typed fully de-serialized instance.
+    Organization orgFromCache = cache.Get(1);
+
+    std::cout <<  ">>> Retrieved organization instance from cache: " << std::endl;
+    std::cout << orgFromCache.ToString() << std::endl;
+    std::cout << std::endl;
+}
+
+/*
+ * Execute bulk Put and Get operations.
+ *
+ * @param cache Cache instance.
+ */
+void PutGetAll(CacheClient<int32_t, Organization>& cache)
+{
+    // Create new Organizations to store in cache.
+    Organization org1("Microsoft", Address("1096 Eddy Street, San Francisco, CA", 94109));
+    Organization org2("Red Cross", Address("184 Fidler Drive, San Antonio, TX", 78205));
+
+    // Put created data entries to cache.
+    std::map<int, Organization> vals;
+
+    vals[1] = org1;
+    vals[2] = org2;
+
+    cache.PutAll(vals);
+
+    // Get recently created organizations as a strongly-typed fully de-serialized instances.
+    std::set<int> keys;
+
+    keys.insert(1);
+    keys.insert(2);
+
+    std::map<int, Organization> valsFromCache;
+    cache.GetAll(keys, valsFromCache);
+
+    std::cout <<  ">>> Retrieved organization instances from cache: " << std::endl;
+
+    for (std::map<int, Organization>::iterator it = valsFromCache.begin(); it != valsFromCache.end(); ++it)
+        std::cout <<  it->second.ToString() << std::endl;
+
+    std::cout << std::endl;
+}
+
+int main()
+{
+    IgniteClientConfiguration cfg;
+
+    cfg.SetEndPoints("127.0.0.1");
+
+    try
+    {
+        // Start a client.
+        IgniteClient client = IgniteClient::Start(cfg);
+
+        std::cout << std::endl;
+        std::cout << ">>> Cache put-get example started." << std::endl;
+        std::cout << std::endl;
+
+        // Get cache instance.
+        CacheClient<int32_t, Organization> cache = client.GetOrCreateCache<int32_t, Organization>("PutGetExample");
+
+        // Clear cache.
+        cache.Clear();
+
+        PutGet(cache);
+        PutGetAll(cache);
+    }
+    catch (IgniteError& err)
+    {
+        std::cout << "An error occurred: " << err.GetText() << std::endl;
+
+        return err.GetCode();
+    }
+
+    std::cout << std::endl;
+    std::cout << ">>> Example finished, press 'Enter' to exit ..." << std::endl;
+    std::cout << std::endl;
+
+    std::cin.get();
+
+    return 0;
+}
\ No newline at end of file