moleske commented on a change in pull request #6597: URL: https://github.com/apache/geode/pull/6597#discussion_r650151991
########## File path: geode-docs/getting_started/intro_to_clients.html.md.erb ########## @@ -0,0 +1,357 @@ +<!-- +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. +--> + +<% set_title("Introduction to", product_name_long, "Clients") %> + +This section provides basic starting points for a variety of <%=vars.product_name_long %> clients, along +with very rudimentary connect, put, get operations, and then a reference to more in-depth docs and examples on +how to use the client. + +For an in-depth look at how to use <%=vars.product_name_long%> clients, see [Client/Server Configuration](../topologies_and_comm/cs_configuration/chapter_overview.html). + +## <a id="client-intro-installing"></a>Installing <%=vars.product_name_long%> + +You can download <%=vars.product_name_long%> from the website, run a Docker image, or install with homebrew on OSX. +See [How to Install Apache Geode](installation/install_standalone.html) for details. + +## <a id="client-intro-starting"></a>Starting an <%=vars.product_name_long%> Cluster + +For client tests and examples, start a simple cluster and create an example region. + +Start an <%=vars.product_name_long%> cluster with one locator and one server. + +``` +$ gfsh +gfsh> start locator +gfsh> start server +``` + +Create a region called "helloWorld". + +``` +gfsh> create region --name=helloWorld --type=PARTITION +``` + +When you are through running client tests and examples, shut down the <%=vars.product_name_long%> cluster: + +``` +gfsh> shutdown --include-locators=true +``` + +## <a id="client-intro-java"></a><%=vars.product_name_long%> Java Client + +**Maven Dependencies** + +Declare the following dependency and replace $VERSION, with the version of <%=vars.product_name_long%> that you have installed. + +``` +<dependencies> + <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-core</artifactId> + <version>$VERSION</version> + </dependency> +</dependencies> +``` + +**Gradle Dependencies** + +``` +dependencies { + compile "org.apache.geode:geode-core:$VERSION" +} +``` + +Connect to the server from your application + +``` +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; + +public class HelloWorld { + + public static void main(String[] args) { + ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334).create(); + + System.out.println(cache.getDefaultPool().getLocators()); + + cache.close(); + } +} +``` + +The information printed out should match the host and port of your <%=vars.product_name_long%> instance locators and should resemble + +``` +[/127.0.0.1:10334] +``` + +**Simple Put and Get with <%=vars.product_name_long%> Java client** + +``` +public static void main(String[] args) { +ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334).create(); + + Region<String, String> + helloWorldRegion = + cache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY).create("helloWorld"); + + helloWorldRegion.put("1", "HelloWorldValue"); + String value1 = helloWorldRegion.get("1"); + System.out.println(value1); + + cache.close(); +} +``` + +Build and run the application. This puts the key ‘1’ with a value of ‘HelloWorldValue’ into the +‘helloWorld’ region, then retrieves and prints the value of key ‘1’. + +**Additional Resources** + +- [Apache Geode Examples GitHub Repo](https://github.com/apache/geode-examples) +- [Apache Geode Javadocs](https://geode.apache.org/releases/latest/javadoc/index.html) + +## <a id="client-intro-spring-boot"></a>Spring Boot Client For Apache Geode + +Spring Boot for Apache Geode provides a powerful abstraction that simplifies the developer +experience when using Spring Boot and Apache Geode. The best way to get started with Spring Boot +for Apache Geode, is by creating a project using [Spring™ initializr](https://start.spring.io/). + +Add the ‘Spring for Apache Geode’ dependency and then select either ‘Generate’, which creates a zip +file to import into your IDE or ‘Explore’, which opens a build file based on your Project selection +(Maven or Gradle) + +**Maven Dependencies** + +Your Maven pom.xml file should include something similar to + +``` +<properties> + ... + <spring-geode.version>1.4.3</spring-geode.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.geode</groupId> + <artifactId>spring-geode-starter</artifactId> + </dependency> +… +</dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.geode</groupId> + <artifactId>spring-geode-bom</artifactId> + <version>${spring-geode.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> +``` + +**Gradle Dependencies** + +Your Gradle gradle.build file should include something similar to + +``` +ext { + set('springGeodeVersion', "1.4.3") +} + +dependencies { + implementation 'org.springframework.geode:spring-geode-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} +dependencyManagement { + imports { + mavenBom "org.springframework.geode:spring-geode-bom:${springGeodeVersion}" + } +} +``` + +1. Connect to Geode from your application +2. Open your web browser to [Spring™ initializr](https://start.spring.io/). + +3. Click ‘Add Dependencies’. Search for the ‘Spring for Apache Geode’ dependency and add it to your project. Select ‘Generate’, which creates a zip file. Import this file into your IDE. + +4. With your Geode cluster running, build and run the application (without making any other changes). + +5. In the console output, you should see something similar to (starting with Spring Boot for Apache Geode v1.4.2+) + + ``` + 2021-03-19 11:27:14.532 INFO 8730 --- [ main] o.s.g.c.a.ClusterAwareConfiguration : Successfully connected to localhost[40404] + 2021-03-19 11:27:14.537 INFO 8730 --- [ main] o.s.g.c.a.ClusterAwareConfiguration : Successfully connected to localhost[10334] + 2021-03-19 11:27:14.538 INFO 8730 --- [ main] o.s.g.c.a.ClusterAwareConfiguration : Cluster was found; Auto-configuration made [2] successful connection(s) + 2021-03-19 11:27:14.538 INFO 8730 --- [ main] o.s.g.c.a.ClusterAwareConfiguration : Spring Boot application is running in a client/server topology using a standalone Apache Geode-based cluster + ``` + +This confirms that without adding any additional code, the application was able to connect to our Geode Cluster. + +**Building an Application with Spring Boot for Apache Geode.** + +Spring Boot for Apache Geode is very powerful and robust. We recommend looking at the Spring Boot for Apache Geode documentation and examples for your next steps in working with this dependency. + +**Additional Resources** + +- [Spring Boot for Apache Geode Reference Guide](https://docs.spring.io/spring-boot-data-geode-build/1.4.x/reference/html5/) + +## <a id="client-intro-native"></a><%=vars.product_name_long%> Native Clients + +To begin using the <%=vars.product_name_long%> Native Clients, you must first build the <%=vars.product_name_long%> Native Client libraries from the source code. +You can download the <%=vars.product_name_long%> Native Source code here +`https://geode.apache.org/releases`, then refer to the `BUILDING.md]` file in the source release to compile the libraries. Review comment: There's an extra `]` in `BUILDING.md]` ########## File path: geode-docs/getting_started/intro_to_clients.html.md.erb ########## @@ -0,0 +1,357 @@ +<!-- +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. +--> + +<% set_title("Introduction to", product_name_long, "Clients") %> + +This section provides basic starting points for a variety of <%=vars.product_name_long %> clients, along +with very rudimentary connect, put, get operations, and then a reference to more in-depth docs and examples on +how to use the client. + +For an in-depth look at how to use <%=vars.product_name_long%> clients, see [Client/Server Configuration](../topologies_and_comm/cs_configuration/chapter_overview.html). + +## <a id="client-intro-installing"></a>Installing <%=vars.product_name_long%> + +You can download <%=vars.product_name_long%> from the website, run a Docker image, or install with homebrew on OSX. +See [How to Install Apache Geode](installation/install_standalone.html) for details. + +## <a id="client-intro-starting"></a>Starting an <%=vars.product_name_long%> Cluster + +For client tests and examples, start a simple cluster and create an example region. + +Start an <%=vars.product_name_long%> cluster with one locator and one server. + +``` +$ gfsh +gfsh> start locator +gfsh> start server +``` + +Create a region called "helloWorld". + +``` +gfsh> create region --name=helloWorld --type=PARTITION +``` + +When you are through running client tests and examples, shut down the <%=vars.product_name_long%> cluster: + +``` +gfsh> shutdown --include-locators=true +``` + +## <a id="client-intro-java"></a><%=vars.product_name_long%> Java Client + +**Maven Dependencies** + +Declare the following dependency and replace $VERSION, with the version of <%=vars.product_name_long%> that you have installed. + +``` +<dependencies> + <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-core</artifactId> + <version>$VERSION</version> + </dependency> +</dependencies> +``` + +**Gradle Dependencies** + +``` +dependencies { + compile "org.apache.geode:geode-core:$VERSION" Review comment: `compile` is deprecated and will be removed in the next version of gradle. `implementation` should be used ########## File path: geode-docs/getting_started/intro_to_clients.html.md.erb ########## @@ -0,0 +1,357 @@ +<!-- +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. +--> + +<% set_title("Introduction to", product_name_long, "Clients") %> + +This section provides basic starting points for a variety of <%=vars.product_name_long %> clients, along +with very rudimentary connect, put, get operations, and then a reference to more in-depth docs and examples on +how to use the client. + +For an in-depth look at how to use <%=vars.product_name_long%> clients, see [Client/Server Configuration](../topologies_and_comm/cs_configuration/chapter_overview.html). + +## <a id="client-intro-installing"></a>Installing <%=vars.product_name_long%> + +You can download <%=vars.product_name_long%> from the website, run a Docker image, or install with homebrew on OSX. +See [How to Install Apache Geode](installation/install_standalone.html) for details. + +## <a id="client-intro-starting"></a>Starting an <%=vars.product_name_long%> Cluster + +For client tests and examples, start a simple cluster and create an example region. + +Start an <%=vars.product_name_long%> cluster with one locator and one server. + +``` +$ gfsh +gfsh> start locator +gfsh> start server +``` + +Create a region called "helloWorld". + +``` +gfsh> create region --name=helloWorld --type=PARTITION +``` + +When you are through running client tests and examples, shut down the <%=vars.product_name_long%> cluster: + +``` +gfsh> shutdown --include-locators=true +``` + +## <a id="client-intro-java"></a><%=vars.product_name_long%> Java Client + +**Maven Dependencies** + +Declare the following dependency and replace $VERSION, with the version of <%=vars.product_name_long%> that you have installed. + +``` +<dependencies> + <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-core</artifactId> + <version>$VERSION</version> + </dependency> +</dependencies> +``` + +**Gradle Dependencies** + +``` +dependencies { + compile "org.apache.geode:geode-core:$VERSION" +} +``` + +Connect to the server from your application + +``` +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; + +public class HelloWorld { + + public static void main(String[] args) { + ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334).create(); + + System.out.println(cache.getDefaultPool().getLocators()); + + cache.close(); + } +} +``` + +The information printed out should match the host and port of your <%=vars.product_name_long%> instance locators and should resemble + +``` +[/127.0.0.1:10334] +``` + +**Simple Put and Get with <%=vars.product_name_long%> Java client** + +``` +public static void main(String[] args) { +ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334).create(); + + Region<String, String> + helloWorldRegion = + cache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY).create("helloWorld"); + + helloWorldRegion.put("1", "HelloWorldValue"); + String value1 = helloWorldRegion.get("1"); + System.out.println(value1); + + cache.close(); +} +``` + +Build and run the application. This puts the key ‘1’ with a value of ‘HelloWorldValue’ into the +‘helloWorld’ region, then retrieves and prints the value of key ‘1’. + +**Additional Resources** + +- [Apache Geode Examples GitHub Repo](https://github.com/apache/geode-examples) +- [Apache Geode Javadocs](https://geode.apache.org/releases/latest/javadoc/index.html) + +## <a id="client-intro-spring-boot"></a>Spring Boot Client For Apache Geode + +Spring Boot for Apache Geode provides a powerful abstraction that simplifies the developer +experience when using Spring Boot and Apache Geode. The best way to get started with Spring Boot +for Apache Geode, is by creating a project using [Spring™ initializr](https://start.spring.io/). + +Add the ‘Spring for Apache Geode’ dependency and then select either ‘Generate’, which creates a zip +file to import into your IDE or ‘Explore’, which opens a build file based on your Project selection +(Maven or Gradle) + +**Maven Dependencies** + +Your Maven pom.xml file should include something similar to + +``` +<properties> + ... + <spring-geode.version>1.4.3</spring-geode.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.geode</groupId> + <artifactId>spring-geode-starter</artifactId> + </dependency> +… +</dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.geode</groupId> + <artifactId>spring-geode-bom</artifactId> + <version>${spring-geode.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> +``` + +**Gradle Dependencies** + +Your Gradle gradle.build file should include something similar to + +``` +ext { + set('springGeodeVersion', "1.4.3") +} + +dependencies { + implementation 'org.springframework.geode:spring-geode-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} +dependencyManagement { + imports { + mavenBom "org.springframework.geode:spring-geode-bom:${springGeodeVersion}" + } +} +``` + +1. Connect to Geode from your application Review comment: I got confused here because I thought the maven/gradle snippets above was all I needed. But after rereading I saw that I was actually not supposed to do this by hand, but use spring initializer to generate the project -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
