Edit 'Building Embedded (Peer & Server) Cache Applications' and 'Building Locator Application' sections.

This commit is contained in:
John Blum
2019-09-03 21:20:26 -07:00
parent 6e64704fd8
commit 5379d9164d
2 changed files with 36 additions and 41 deletions

View File

@@ -88,7 +88,7 @@ public SpringBootApacheGeodeClientCacheApplication {
----
[[geode-peercache-applications]]
=== Embedded (Peer & Server) Cache Applications
=== Building Embedded (Peer & Server) Cache Applications
What if you want to build an embedded, peer `Cache` application instead?
@@ -97,15 +97,15 @@ to join this member to a (possibly) existing cluster (of data servers) as a peer
Remember the 2nd goal in Spring Boot's {spring-boot-docs-html}/#getting-started-introducing-spring-boot[documentation]:
> "_Be opinionated out of the box but get out of the way quickly as requirements start to diverge from the defaults._"
> _Be opinionated out of the box but get out of the way quickly as requirements start to diverge from the defaults._
It is the 2nd part, "_get out of the way quickly as requirements start to diverge from the defaults_"
that I refer to here.
If your application requirements require you to use Spring Boot to configure and bootstrap an embedded,
peer `Cache` Apache Geode or Pivotal GemFire application, then simply declare your intentions with either SDG's
If your application requirements demand you use Spring Boot to configure and bootstrap an embedded, peer `Cache`
Apache Geode or Pivotal GemFire application, then simply declare your intentions with either SDG's
{spring-data-geode-javadoc}/org/springframework/data/gemfire/config/annotation/PeerCacheApplication.html[`@PeerCacheApplication`] annotation,
or alternatively, if you need to enable connections from other cache client apps, use the SDG
or alternatively, if you need to enable connections from `ClientCache` apps as well, use the SDG
{spring-data-geode-javadoc}/org/springframework/data/gemfire/config/annotation/CacheServerApplication.html[`@CacheServerApplication`] annotation:
.Spring Boot, Apache Geode/Pivotal GemFire CacheServer Application
@@ -126,18 +126,18 @@ It is merely a peer member in the GemFire/Geode cluster (a.k.a. distributed syst
By explicitly declaring the `@CacheServerApplication` annotation, you are telling Spring Boot that you do not want
the default, `ClientCache` instance, but rather an embedded, peer `Cache` instance with a `CacheServer` component,
which enables connections from cache client apps.
which enables connections from `ClientCache` apps.
I can also enable 2 other GemFire/Geode services, an embedded _Locator_, which allows either clients or even other peers
You can also enable 2 other GemFire/Geode services, an embedded _Locator_, which allows clients or even other peers
to "locate" servers in a cluster, as well as an embedded _Manager_, which allows the GemFire/Geode application process
to be managed and/or monitored using {apache-geode-docs}/tools_modules/gfsh/chapter_overview.html[_Gfsh_],
GemFire/Geode's shell tool:
to be managed and monitored using {apache-geode-docs}/tools_modules/gfsh/chapter_overview.html[_Gfsh_], GemFire/Geode's
shell tool:
.Spring Boot, Apache Geode/Pivotal GemFire CacheServer Application with _Locator_ and _Manager_ services enabled
[source,java]
----
@SpringBootApplication
@CacheServerApplication(name = "MySpringBootApacheGeodeCacheServerApplication")
@CacheServerApplication(name = "SpringBootApacheGeodeCacheServerApplication")
@EnableLocator
@EnableManager
public SpringBootApacheGeodeCacheServerApplication {
@@ -148,7 +148,7 @@ public SpringBootApacheGeodeCacheServerApplication {
}
----
Then, you can even use _Gfsh_ to connect to and manage this server:
Then, you can use _Gfsh_ to connect to and manage this server:
[source,text]
----
@@ -282,7 +282,7 @@ public SpringBootApacheGeodeCacheServerApplication {
----
TIP: Notice I configured the `SpringBootApacheGeodeCacheServerApplication` class, `@CacheServerApplication` annotation,
`locators` property with the host and port (i.e. "localhost[11235]") on which I started my _Locator_ using _Gfsh_.
`locators` property with the host and port (i.e. "_localhost[11235]_") on which I started my _Locator_ using _Gfsh_.
After running your Spring Boot, Apache Geode `CacheServer` application again, and then running `list members` in _Gfsh_,
you should see:
@@ -318,15 +318,15 @@ Client Connections : 0
----
In both scenarios, the Spring Boot configured and bootstrapped Apache Geode (or Pivotal GemFire) server
and the _Gfsh_ _Locator_ and Servers formed a cluster.
and the _Gfsh_ _Locator_ and _Server_ formed a cluster.
While you can use either approach and Spring does not care, it is far more convenient to use Spring Boot and your IDE
to form a small cluster while developing. By leveraging Spring profiles, it is far simpler to configure and start
a small cluster much faster.
to form a small cluster while developing. By leveraging Spring profiles, it is far simpler and much faster to
configure and start a small cluster.
Plus, this is useful for rapidly prototyping, testing and debugging your entire, end-to-end application
and system architecture, all right from the comfort and familiarity of your IDE of choice. No addition tooling
(e.g. _Gfsh_) knowledge is required to get started quickly and easily.
and system architecture, all right from the comfort and familiarity of your IDE of choice. No additional tooling
(e.g. _Gfsh_) or knowledge is required to get started quickly and easily.
Just _build_ and _run_ it!
@@ -337,7 +337,7 @@ due to port conflicts.
TIP: See the Appendix, <<geode-cluster-configuration-bootstrapping>> for more details.
[[geode-locator-applications]]
=== Locator Applications
=== Building Locator Applications
In addition to `ClientCache`, `CacheServer` and peer `Cache` applications, SDG, and by extension SBDG, now supports
Locator-based, Spring Boot applications.
@@ -349,10 +349,10 @@ Microservices architecture where you need to scale-up the number of app instance
A Locator is also used by joining members of an existing cluster to scale-out and increase capacity of the logically
pooled system resources (i.e. Memory, CPU and Disk). A Locator maintains metadata that is sent to the clients to
enable capabilities like single-hop data access, thereby routing data access operations to the data node in the cluster
enable capabilities like single-hop data access, routing data access operations to the data node in the cluster
maintaining the data of interests. A Locator also maintains load information for servers in the cluster, which enables
the load to be uniformly distributed and also provide fail-over services to a redundant member if the primary fails.
A Locator provides many more benefit and you are encouraged to read
the load to be uniformly distributed across the cluster while also providing fail-over services to a redundant member
if the primary fails. A Locator provides many more benefit and you are encouraged to read
the {apache-geode-docs}/configuring/running/running_the_locator.html[documentation] for more details.
As shown above, a Locator service can be embedded in either a peer `Cache` or `CacheServer`, Spring Boot application
@@ -364,13 +364,13 @@ using the SDG `@EnableLocator` annotation:
@EnableLocator
@CacheServerApplication
@SpringBootApplication
class SpringBootWithEmbeddedLocatorAndCacheServerApplication { ... }
class SpringBootCacheServerWithEmbeddedLocatorApplication { ... }
----
However, it is more common to start standalone Locator JVM processes. This useful when you want to increase
the resiliency of your cluster in face of network and process failures, which are bound to happen. If a Locator JVM
process crashes or gets severed from the cluster due to a network failure, then having multiple Locators provides a
degree of redundancy in order to improve on the cluster's availability (HA).
higher degree of availability (HA) through redundancy.
Not to worry though, if all Locators in the cluster go down, then the cluster will still remain intact.
You simply won't be able to add more peer members (i.e. scale-up the number of data nodes in the cluster)
@@ -408,22 +408,22 @@ First, let's startup 2 Locators using our Apache Geode Locator, Spring Boot appl
.SpringBootApacheGeodeLocatorApplication class
[source,java]
----
include::{docs-src-dir}/example/app/locator/SpringBootApacheGeodeLocatorApplication.java[class]
include::{docs-src-dir}/org/springframework/geode/docs/example/app/locator/SpringBootApacheGeodeLocatorApplication.java[tags=class]
----
We also need to vary our configuration for each Locator app instance.
We also need to vary the configuration for each Locator app instance.
Apache Geode and Pivotal GemFire requires each peer member in the cluster to be uniquely named. We can set the name
of the Locator by using the `spring.data.gemfire.locator.name` SDG property as a JVM System Property in your IDE's Run
Configuration Profile for our application main class like so: `--Dspring.data.gemfire.locator=SpringLocatorOne`.
We name the second instance, "SpringLocatorTwo".
of the Locator by using the `spring.data.gemfire.locator.name` SDG property set as a JVM System Property in your IDE's
Run Configuration Profile for the application main class like so: `--Dspring.data.gemfire.locator.name=SpringLocatorOne`.
We name the second Locator app instance, "_SpringLocatorTwo_".
Additionally, we must vary the port numbers that the Locator's use to listen for connections. By default,
Additionally, we must vary the port numbers that the Locators use to listen for connections. By default,
an Apache Geode or Pivotal GemFire Locator listens on port `10334`. We can set the Locator port using the
`spring.data.gemfire.locator.port` property.
`spring.data.gemfire.locator.port` SDG property.
For our first Locator app instance (i.e. "SpringLocatorOne"), we also enable the "manager" Profile so that
we can connect to the Locators using _Gfsh_.
For our first Locator app instance (i.e. "_SpringLocatorOne_"), we also enable the "_manager_" Profile so that
we can connect to the Locator using _Gfsh_.
Our IDE Run Configuration Profile for our first Locator app instance appears as:
@@ -513,7 +513,7 @@ Class Path:
Press <enter> to exit!
----
Next, start up the second Locator app instance (you should see similar log output again) and then connect to
Next, start up the second Locator app instance (you should see log output similar to above). Then, connect to
the cluster of Locators using _Gfsh_:
.Cluster of Locators
@@ -541,17 +541,15 @@ gfsh>list members
---------------- | ------------------------------------------------------------------------
SpringLocatorOne | 10.99.199.24(SpringLocatorOne:30043:locator)<ec><v0>:41000 [Coordinator]
SpringLocatorTwo | 10.99.199.24(SpringLocatorTwo:30077:locator)<ec><v1>:41001
gfsh>
----
Using our `SpringBootApacheGeodeCacheServerApplication` main class from the previous section, we can configure
and bootstrap an Apache Geode `CacheServer` application with Spring Boot and connect it to our cluster of Locators.
.SpringBootApacheGeodeLocatorApplication class
.SpringBootApacheGeodeCacheServerApplication class
[source,java]
----
include::{docs-src-dir}/example/app/server/SpringBootApacheGeodeServerApplication.java[class]
include::{docs-src-dir}/org/springframework/geode/docs/example/app/server/SpringBootApacheGeodeCacheServerApplication.java[tags=class]
----
Simply enable the "clustered" Profile by using a IDE Run Configuration similar to:
@@ -569,7 +567,6 @@ gfsh>list members
SpringLocatorOne | 10.99.199.24(SpringLocatorOne:30043:locator)<ec><v0>:41000 [Coordinator]
SpringLocatorTwo | 10.99.199.24(SpringLocatorTwo:30077:locator)<ec><v1>:41001
SpringServer | 10.99.199.24(SpringServer:30216)<v2>:41002
----
Finally, we can even start additional Locators and Servers connected to this cluster using _Gfsh_:
@@ -609,8 +606,6 @@ SpringLocatorTwo | 10.99.199.24(SpringLocatorTwo:30077:locator)<ec><v1>:41001
SpringServer | 10.99.199.24(SpringServer:30216)<v2>:41002
GfshLocator | 10.99.199.24(GfshLocator:30259:locator)<ec><v3>:41003
GfshServer | 10.99.199.24(GfshServer:30295)<v4>:41004
gfsh>
----
You simply must be careful to vary the ports is all and name your peer members appropriately. With Spring,

View File

@@ -25,7 +25,7 @@ John Blum
:pivotal-gemfire-javadoc: https://gemfire-{pivotal-gemfire-version}-javadocs.docs.pivotal.io/
:pivotal-gemfire-website: https://pivotal.io/pivotal-gemfire
:spring-boot-docs: https://docs.spring.io/spring-boot/docs/current/reference
:spring-boot-docs-html: {spring-boot-docs}/html
:spring-boot-docs-html: {spring-boot-docs}/htmlsingle
:spring-boot-javadoc: https://docs.spring.io/spring-boot/docs/current/api
:spring-boot-website: https://spring.io/projects/spring-boot
:spring-boot-data-geode-javadoc: https://docs.spring.io/autorepo/docs/spring-boot-data-geode-build/1.0.0.BUILD-SNAPSHOT/api/