You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/10/26 22:16:58 UTC

[geode-native] branch develop updated: GEODE-3424: Added examples - Basic cache example. - AuthInitialize example.

This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9d03f52  GEODE-3424: Added examples  - Basic cache example.  - AuthInitialize example.
9d03f52 is described below

commit 9d03f52dc63c1a7839337782b38d85b0f8b7faab
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Thu Oct 26 15:15:07 2017 -0700

    GEODE-3424: Added examples
     - Basic cache example.
     - AuthInitialize example.
---
 .../Apache.Geode.Examples.AuthInitialize.csproj    | 62 +++++++++++++++++
 .../ExampleAuthInitialize.cs                       | 31 +++++++++
 .../Program.cs                                     | 34 ++++++++++
 .../Apache.Geode.Examples.AuthInitialize/README.md | 24 +++++++
 .../Apache.Geode.Examples.Cache.csproj             | 77 ++++++++++++++++++++++
 .../dotnet/Apache.Geode.Examples.Cache/Program.cs  | 51 ++++++++++++++
 .../dotnet/Apache.Geode.Examples.Cache/README.md   | 22 +++++++
 examples/dotnet/Apache.Geode.Examples.sln          | 33 ++++++++++
 examples/dotnet/README.md                          | 14 ++++
 9 files changed, 348 insertions(+)

diff --git a/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj
new file mode 100644
index 0000000..f95ca2c
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Apache.Geode.Examples.AuthInitialize.csproj
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Geode.Examples.AuthInitialize</RootNamespace>
+    <AssemblyName>Apache.Geode.Examples.AuthInitialize</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Apache.Geode">
+      <HintPath>Y:\build64\clicache\src\Debug\Apache.Geode.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="Microsoft.CSharp" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ExampleAuthInitialize.cs" />
+    <Compile Include="Program.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="README.md" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/examples/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs
new file mode 100644
index 0000000..583ac23
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/ExampleAuthInitialize.cs
@@ -0,0 +1,31 @@
+using System;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.AuthInitialize
+{
+  class ExampleAuthInitialize : IAuthInitialize
+  {
+    public ExampleAuthInitialize()
+    {
+      // TODO initialize your resources here
+      Console.Out.WriteLine("ExampleAuthInitialize::ExampleAuthInitialize called");
+    }
+
+    public void Close()
+    {
+      // TODO close your resources here
+      Console.Out.WriteLine("ExampleAuthInitialize::Close called");
+    }
+
+    public Properties<string, object> GetCredentials(Properties<string, string> props, string server)
+    {
+      // TODO get your username and password
+      Console.Out.WriteLine("ExampleAuthInitialize::GetCredentials called");
+
+      var credentials = new Properties<string, object>();
+      credentials.Insert("username", "john");
+      credentials.Insert("password", "secret");
+      return credentials;
+    }
+  }
+}
diff --git a/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs
new file mode 100644
index 0000000..76c8772
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/Program.cs
@@ -0,0 +1,34 @@
+using System;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.AuthInitialize
+{
+  class Program
+  {
+    static void Main(string[] args)
+    {
+      var cacheFactory = CacheFactory.CreateCacheFactory()
+          .Set("log-level", "none")
+          .SetAuthInitialize(new ExampleAuthInitialize());
+
+      var cache = cacheFactory.Create();
+      var poolFactory = cache.GetPoolFactory()
+          .AddLocator("localhost", 10334);
+      poolFactory.Create("pool", cache);
+      var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+          .SetPoolName("pool");
+      var region = regionFactory.Create<string, string>("region");
+
+      region["a"] = "1";
+      region["b"] = "2";
+
+      var a = region["a"];
+      var b = region["b"];
+
+      Console.Out.WriteLine("a = " + a);
+      Console.Out.WriteLine("b = " + b);
+
+      cache.Close();
+    }
+  }
+}
diff --git a/examples/dotnet/Apache.Geode.Examples.AuthInitialize/README.md b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/README.md
new file mode 100644
index 0000000..c79fc8c
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.AuthInitialize/README.md
@@ -0,0 +1,24 @@
+# AuthInitialize Example
+This example shows how to create and register a custom `IAuthIntialize` authentication
+handler. 
+
+## Prerequisites
+* Install [Apache Geode](https://geode.apache.org)
+* Build and install [Apache Geode Native](https://github.com/apache/geode-native)
+
+## Running
+* Start Geode Server and create region.
+  ```
+  gfsh>start locator --name=locator
+  gfsh>start server --name=server
+  gfsh>create region --name=region --type=PARTITION
+  ```
+* Execute `Apache.Geode.Examples.AuthInitialize.exe`.
+  
+  output:
+  ```
+  ExampleAuthInitialize::ExampleAuthInitialize called
+  ExampleAuthInitialize::GetCredentials called
+  a = 1
+  b = 2
+  ```
diff --git a/examples/dotnet/Apache.Geode.Examples.Cache/Apache.Geode.Examples.Cache.csproj b/examples/dotnet/Apache.Geode.Examples.Cache/Apache.Geode.Examples.Cache.csproj
new file mode 100644
index 0000000..b108c40
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.Cache/Apache.Geode.Examples.Cache.csproj
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Geode.Examples.Cache</RootNamespace>
+    <AssemblyName>Apache.Geode.Examples.Cache</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Apache.Geode">
+      <HintPath>Y:\build64\clicache\src\Debug\Apache.Geode.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="Microsoft.CSharp" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="README.md" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/examples/dotnet/Apache.Geode.Examples.Cache/Program.cs b/examples/dotnet/Apache.Geode.Examples.Cache/Program.cs
new file mode 100644
index 0000000..90cbc3f
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.Cache/Program.cs
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+using System;
+using Apache.Geode.Client;
+
+namespace Apache.Geode.Examples.Cache
+{
+  class Program
+  {
+    static void Main(string[] args)
+    {
+      var cacheFactory = CacheFactory.CreateCacheFactory()
+          .Set("log-level", "none");
+      var cache = cacheFactory.Create();
+
+      var poolFactory = cache.GetPoolFactory()
+          .AddLocator("localhost", 10334);
+      poolFactory.Create("pool", cache);
+
+      var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+          .SetPoolName("pool");
+      var region = regionFactory.Create<string, string>("region");
+
+      region["a"] = "1";
+      region["b"] = "2";
+
+      var a = region["a"];
+      var b = region["b"];
+
+      Console.Out.WriteLine("a = " + a);
+      Console.Out.WriteLine("b = " + b);
+
+      cache.Close();
+    }
+  }
+}
diff --git a/examples/dotnet/Apache.Geode.Examples.Cache/README.md b/examples/dotnet/Apache.Geode.Examples.Cache/README.md
new file mode 100644
index 0000000..cb8111f
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.Cache/README.md
@@ -0,0 +1,22 @@
+# Cache Example
+This is a very simple example showing how to create a `Cache` using the `CacheFactory`,
+configure a `Pool` with a `PoolFactory`, and configure a `Region` with a `RegionFactory`.
+
+## Prerequisites
+* Install [Apache Geode](https://geode.apache.org)
+* Build and install [Apache Geode Native](https://github.com/apache/geode-native)
+
+## Running
+* Start Geode Server and create region.
+  ```
+  gfsh>start locator --name=locator
+  gfsh>start server --name=server
+  gfsh>create region --name=region --type=PARTITION
+  ```
+* Execute `Apache.Geode.Examples.Cache.exe`.
+  
+  output:
+  ```
+  a = 1
+  b = 2
+  ```
diff --git a/examples/dotnet/Apache.Geode.Examples.sln b/examples/dotnet/Apache.Geode.Examples.sln
new file mode 100644
index 0000000..74295f0
--- /dev/null
+++ b/examples/dotnet/Apache.Geode.Examples.sln
@@ -0,0 +1,33 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Geode.Examples.Cache", "Apache.Geode.Examples.Cache\Apache.Geode.Examples.Cache.csproj", "{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Geode.Examples.AuthInitialize", "Apache.Geode.Examples.AuthInitialize\Apache.Geode.Examples.AuthInitialize.csproj", "{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CB7AB243-26A9-4B20-8ED9-5D35D12F9FF3}"
+	ProjectSection(SolutionItems) = preProject
+		README.md = README.md
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x64 = Debug|x64
+		Release|x64 = Release|x64
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Debug|x64.ActiveCfg = Debug|x64
+		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Debug|x64.Build.0 = Debug|x64
+		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Release|x64.ActiveCfg = Release|x64
+		{15ACFB5B-0D2C-4C38-9236-7AF01874A84F}.Release|x64.Build.0 = Release|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Debug|x64.ActiveCfg = Debug|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Debug|x64.Build.0 = Debug|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Release|x64.ActiveCfg = Release|x64
+		{047FC72E-F06D-4F3A-9EF3-B66FAE4B6C36}.Release|x64.Build.0 = Release|x64
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/examples/dotnet/README.md b/examples/dotnet/README.md
new file mode 100644
index 0000000..9b66b74
--- /dev/null
+++ b/examples/dotnet/README.md
@@ -0,0 +1,14 @@
+# Geode Native .NET Examples
+
+## Prerequisites
+* Install [Apache Geode](https://geode.apache.org)
+* Build and install [Apache Geode Native](https://github.com/apache/geode-native)
+
+## Examples
+* [Apache.Geode.Examples.AuthInitialize](Apache.Geode.Examples.Cache/README.md)
+* [Apache.Geode.Examples.Cache](Apache.Geode.Examples.Cache/README.md)
+
+## Using
+1) Open `Apache.Geode.Examples.sln` in [Visual Studio 2015](https://www.visualstudio.com/)
+or newer.
+2) Update `Apache.Geode` reference in each project to the `Apache.Geode.dll` assembly.
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].