Hi John-
So, to get you going with your original question...
*> So, how do I begin as a java client?*
geode-dependencies.jar is not really relevant to your original question nor
your *approach* (which I rather like, because it exemplifies how a user
approaches development and using Geode OOTB).
However, real quick, since it was brought up... geode-dependencies.jar is a
Manifest-only JAR. It's not supposed to have any contents, other than a
META-INF/MANIFEST.MF file identifying the dependencies (potentially)
required by Apache Geode at runtime. This technique is quite useful in
listing/including dependencies by using a single JAR file.
In that "standard" Java JAR file Manifest is a Class-Path header that
references the libs (i.e. dependencies) in $GEODE/lib used by Apache Geode
at runtime, which is only applicable when you are using a "downloaded"
installation. This JAR does not exist in Maven Central, nor should it.
This JAR is used (internally) by *Gfsh* (to set the classpath) when
launching/forking Locators/Servers using 'start [locator|server]' command.
~~~~
However, your *approach* was using *Maven* (or *Gradle*) to consume Apache
Geode and use it in a [client cache] application scenario, connecting to a
pre-existing cluster (presumably).
IMO, and I am definitely biased here, *Spring Data Geode* is the easiest
way to get started with Apache Geode, especially programmatically, using
your IDE and defining your project with *Maven* or *Gradle*.
1. First, there is already a single artifact (when using SDG)...
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
<version>1.0.0.APACHE-GEODE-INCUBATING-M3</version>
</dependency>
This will transitively pull in all the necessary Apache Geode JARs as well
(e.g. geode-core, geode-cq, geode-wan, etc).
2. It is highly simple (and familiar) to create a simple client cache
application using SDG (with the new Annotation configuration model that was
inspired by *Spring Boot *for users who are familiar with the *Spring's
programming model *and* Spring Boot's *convention over configuration
approach).
So, with SD Geode, you can easily create a Apache Geode cache client
application, connected up to your cluster, with something similar to the
following...
@SpringBootApplication
public class DemoGeodeClientApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(DemoGeodeClientApplication.class, args);
}
@Resource(name = "Echo")
private Region<String, String> echo;
@Override
public void run(String... args) throws Exception {
for (String key : args) {
String value = echo.get(key);
assertThat(key).isEqualTo(value);
System.err.printf("Client says [%1$s]; Server says [%2$s]%n", key,
value);
}
}
@ClientCacheApplication(name = "DemoEchoClient", locators = {
@ClientCacheApplication.Locator(port = 10334)}
static class GeodeClientConfiguration {
@Bean(name = "Echo")
ClientRegionFactoryBean<String, String> echoRegion(GemFireCache
gemfireCache) {
ClientRegionFactoryBean<String, String> echoRegion = new
ClientRegionFactoryBean<>();
echoRegion.setCache(gemfireCache);
echoRegion.setClose(false);
echoRegion.setShortcut(ClientRegionShortcut.PROXY);
return echoRegion;
}
}
}
NOTE: the complete client code example is here
<https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/client/DemoGeodeClientApplication.java>
[9].
This is a simple example demonstrating how to setup a Geode cache client (
ClientCache) application connected to a Geode cluster, defined by a Locator
on the default port, *10334*. The relevant configuration is from the
@ClientCacheApplication annotation down. Obviously, Spring Boot's
CommandLineRunner is completely optional and was only used for
demonstration purposes.
It is a simple matter to switch the client from a Locator to a direct
Server connection (on the default Geode Server port of *40404*)) by using
the embedded to @ClientCacheApplication.Server annotation rather than
@ClientCacheApplication.Locator.
Essentially, the Geode Server just sets up a local Region, "Echo" (
DataPolicy.NORMAL
<http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/DataPolicy.html#NORMAL>
[1],
Scope.LOCAL
<http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/Scope.html#LOCAL>
[2])
having a *CacheLoader
<http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/CacheLoader.html>*
[3]
(here
<https://github.com/jxblum/contacts-application/blob/apache-geode/contacts-core/src/main/java/example/app/geode/cache/loader/EchoCacheLoader.java>
[4])
that echo's the key as the value.
3. Now, you can setup a Locator and/or Server using *Gfsh* as in the "*Apache
Geode in 15 minutes or less
<http://geode.incubator.apache.org/docs/guide/getting_started/15_minute_quickstart_gfsh.html>*"
[5] (which really does not show you how to get a client going), or
following the "*Geode in 5 minutes
<https://cwiki.apache.org/confluence/display/GEODE/Index#Index-Geodein5minutesGeodein5minutes>*"
[6], or forget all that fuss and just follow my lead by using the same
approach as my cache client application code above and configure a Geode
Server with SDG's new Annotation configuration model (e.g. here
<https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/server/DemoGeodeServerApplication.java>
[7])
and *run everything from your IDE*.
It is also an easy matter to switch Region types in the Server configuration
<https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/server/DemoGeodeServerApplication.java#L53>
[8]
if you have more than 1 Server in your cluster and need to replicate data
amongst them. Simply change the RegionFactoryBean to the appropriate type
(for example, PartitionedRegionFactoryBean).
4. Since this Server (from #3 above) includes the @EnableLocator and
@EnableManager annotations in it's configuration, it embeds a Geode Locator
in the Geode (Cache) Server JVM process and also starts an embedded Manager
allowing you to connect to *Gfsh* (as well), so you can do things like
this...
$ gfsh
_________________________ __
/ _____/ ______/ ______/ /____/ /
/ / __/ /___ /_____ / _____ /
/ /__/ / ____/ _____/ / / / /
/______/_/ /______/_/ /_/ 1.0.0-incubating.M3
Monitor and Manage Apache Geode (incubating)
gfsh>connect
Connecting to Locator at [host=localhost, port=10334] ..
Connecting to Manager at [host=10.99.199.3, port=1099] ..
Successfully connected to: [host=10.99.199.3, port=1099]
gfsh>list members
Name | Id
-------------- | ----------------------------------------------
DemoEchoServer | 10.99.199.3(DemoEchoServer:15520)<ec><v0>:1024
gfsh>describe member --name=DemoEchoServer
Name : DemoEchoServer
Id : 10.99.199.3(DemoEchoServer:15520)<ec><v0>:1024
Host : 10.99.199.3
Regions : Echo
PID : 15520
Groups :
Used Heap : 67M
Max Heap : 3641M
Working Dir :
/Users/jblum/pivdev/spring-data-examples-workspace/contacts-application-workspace/configuration-example/target
Log file :
/Users/jblum/pivdev/spring-data-examples-workspace/contacts-application-workspace/configuration-example/target
Locators : localhost[10334]
Cache Server Information
Server Bind :
Server Port : 40404
Running : true
Client Connections : 0
gfsh>list regions
List of regions
---------------
Echo
gfsh>describe region --name=/Echo
.........................................................................
Name : Echo
Data Policy : normal
Hosting Members : DemoEchoServer
Non-Default Attributes Shared By Hosting Members
Type | Name | Value
------ | ------------ | ----------------------------------------------
Region | size | 2
| cache-loader | example.app.geode.cache.loader.EchoCacheLoader
| scope | local
gfsh>get --region=/Echo --key=test
Result : true
Key Class : java.lang.String
Key : test
Value Class : java.lang.String
Value : test
gfsh>describe region --name=/Echo
.........................................................................
Name : Echo
Data Policy : normal
Hosting Members : DemoEchoServer
Non-Default Attributes Shared By Hosting Members
Type | Name | Value
------ | ------------ | ----------------------------------------------
Region | size | 3
| cache-loader | example.app.geode.cache.loader.EchoCacheLoader
| scope | local
gfsh>
5. Of course, you will need the *Spring Boot* dependencies. That is as
simple as inheriting from the *Spring Boot* parent
<https://github.com/jxblum/contacts-application/blob/apache-geode/pom.xml#L8-L12>
[10],
as I have done in my *Contacts Application* RI project.
6. There is no step 6, ;-)
By using SDG, you can tap into the power of the whole *Spring* ecosystem,
still using the same, "familiar" *programming model* across all
technologies (*Spring Security*, *Spring Integration*, *Spring Batch*, *Spring
Cloud* [*Data Flow*], other *Spring Data* projects, etc).
Additionally, you take advantage of all the features available in SDG to
develop feature-rich, robust applications that use Apache Geode, such as
the SD *Repository* infrastructure
<http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#gemfire-repositories>
[11],
POJO mapping
<http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#mapping>
[12],
or the Function Definition/Execution
<http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#function-annotations>
[13]
annotation model, etc.
I have plans to make Region creation/configuration even simpler under the
new Annotation configuration model, among many other things.
Documentation + more examples are a WIP since this is a relatively new
development. A few references that show more of this new Annotation
configuration model in action...
1. Contacts Application configuration examples (see src and tests) -
https://github.com/jxblum/contacts-application/tree/apache-geode/configuration-example
2. Blog discussing recent developments, next steps, etc -
https://spring.io/blog/2016/10/11/spring-data-geode-1-0-0-apache-geode-incubating-m3-released
3. Current Annotation model implementation (beginning with the @EnableXXXX
annotations) -
https://github.com/spring-projects/spring-data-gemfire/tree/master/src/main/java/org/springframework/data/gemfire/config/annotation
And, as always, if you have specific questions, please ask. Hope this
helps.
Cheers!
John
[1]
http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/DataPolicy.html#NORMAL
[2]
http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/Scope.html#LOCAL
[3]
http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/CacheLoader.html
[4]
https://github.com/jxblum/contacts-application/blob/apache-geode/contacts-core/src/main/java/example/app/geode/cache/loader/EchoCacheLoader.java
[5]
http://geode.incubator.apache.org/docs/guide/getting_started/15_minute_quickstart_gfsh.html
[6]
https://cwiki.apache.org/confluence/display/GEODE/Index#Index-Geodein5minutesGeodein5minutes
[7]
https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/server/DemoGeodeServerApplication.java
[8]
https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/server/DemoGeodeServerApplication.java#L53
[9]
https://github.com/jxblum/contacts-application/blob/apache-geode/configuration-example/src/main/java/demo/app/client/DemoGeodeClientApplication.java
[10]
https://github.com/jxblum/contacts-application/blob/apache-geode/pom.xml#L8-L12
[11]
http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#gemfire-repositories
[12]
http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#mapping
[13]
http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#function-annotations
On Mon, Oct 24, 2016 at 6:59 PM, Jared Stewart <[email protected]> wrote:
> It might be worth noting that we have an open improvement filed (
> https://issues.apache.org/jira/browse/GEODE-22) to create a geode
> artifact that will bring in geode-core, geode-cq, geode-json etc to make it
> simpler for a user to get started in the future.
>
> On Oct 24, 2016, at 6:45 PM, Kirk Lund <[email protected]> wrote:
>
> geode-dependencies.jar contains a MANIFEST that adds several other jars to
> the classpath including geode-core.
>
> The client API is currently in geode-core.
>
> -Kirk
>
> On Monday, October 24, 2016, Mark Secrist <[email protected]> wrote:
>
>> Yep - I got that wrong. In both cases. It looks like in M3 anyway,
>> geode-dependencies is mostly empty. You'll want geode-core, which has
>> ClientCache and the other client APIs. Sorry about that. Looks like things
>> may have changed over the releases. Also for the final 1.0.0 release,
>> expect the packages to change from com.gemstone.gemfire to org.apache.geode.
>>
>> Mark
>>
>> On Mon, Oct 24, 2016 at 7:30 PM, John D. Ament <[email protected]>
>> wrote:
>>
>>>
>>>
>>> On Mon, Oct 24, 2016 at 9:26 PM Mark Secrist <[email protected]>
>>> wrote:
>>>
>>>> You'll just need geode-dependencies.jar on your classpath for the
>>>> client. You can use the references found here as an example of configuring
>>>> Maven or Gradle.
>>>> http://geode.incubator.apache.org/releases/
>>>>
>>>>
>>> What's the difference between these two JARs?
>>>
>>>
>>>> Instead of referencing geode-core, you'll reference geode-dependencies
>>>> as the artifact id. The Maven repo is the Apache one at:
>>>> https://dist.apache.org/repos/dist/release/incubator/geode/
>>>>
>>>>
>>> That's not a maven repo. Everything seems to be in central though. I
>>> also see the 1.0.0 staging repo in nexus, but for now i'm fine with an
>>> earlier release.
>>>
>>>
>>>>
>>>> On Mon, Oct 24, 2016 at 6:39 PM, John D. Ament <[email protected]>
>>>> wrote:
>>>>
>>>>> Ok - but do I use the "geode-core" maven coordinate? Its not clear
>>>>> from http://geode.incubator.apache.org/releases/ that this is the
>>>>> client lib.
>>>>>
>>>>> On 2016-10-24 20:15 (-0400), Mark Secrist <[email protected]> wrote:
>>>>> > There's here:
>>>>> > http://geode.incubator.apache.org/docs/guide/basic_config/th
>>>>> e_cache/managing_a_client_cache.html
>>>>> >
>>>>> > And, the section in GitHub you reference shows a HelloWorld client.
>>>>> The
>>>>> > "Geode in 5 minutes" shows starting a locator and a server to
>>>>> represent the
>>>>> > cluster and how to create a client to put data into the region.
>>>>> There are
>>>>> > of course a lot of basic concepts left out, like how you configure a
>>>>> client
>>>>> > cache and the region that acts as a proxy to the server. However, the
>>>>> > basics are there.
>>>>> >
>>>>> > To be more clear, the connection as a client requires a ClientCache
>>>>> object
>>>>> > configured, typically using a clientCache.xml file as shown in the
>>>>> Geode
>>>>> > documentation. This configures the client to point to the locator.
>>>>> This
>>>>> > allows servers to come and go without affecting the client. The Geode
>>>>> > documentation shows configuring a ClientCache with an xml file that
>>>>> defines
>>>>> > the regions (proxy regions) to configure where the name of the
>>>>> region on
>>>>> > the client (proxy) side matches the name of the server side region
>>>>> where
>>>>> > the data will actually reside. The GitHub example shows the same
>>>>> > configuration done 100% using Java API calls.
>>>>> >
>>>>> > So, the steps on the client:
>>>>> >
>>>>> > 1. Create a ClientCache object
>>>>> > 2. Configure ClientCache with regerence to locator (via pool
>>>>> > configuration) and proxy regions. This can either be done by
>>>>> explicit API
>>>>> > calls using the ClientRegionFactory or by reading in a cache.xml
>>>>> file
>>>>> > 3. Get the region desired from the client cache
>>>>> > 4. Invoke gets & puts as needed
>>>>
>>>>
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > On Mon, Oct 24, 2016 at 5:59 PM, John D. Ament <
>>>>> [email protected]>
>>>>> > wrote:
>>>>> >
>>>>> > > Hi,
>>>>> > >
>>>>> > > Reading through the geode docs, it seems like there's a key piece
>>>>> missing
>>>>> > > - how do I actually connect as a client?
>>>>> > >
>>>>> > > If I look here http://geode.incubator.apache.
>>>>> org/docs/guide/developing/
>>>>> > > book_intro.html, I don't see anything obvious - e.g. what maven
>>>>> > > coordinates to use to get a reference, or what to download. Seems
>>>>> like I
>>>>> > > need to build from source.
>>>>> > >
>>>>> > > If I look at https://github.com/apache/incu
>>>>> bator-geode/blob/develop/
>>>>>
>>>> > > README.md , I get a bit more worrisome (especially as an IPMC
>>>>> member).
>>>>>
>>>> > > The client section links me to 3 pivotal websites and one cwiki
>>>>> entry. If
>>>>> > > I want just a plain java client, no real information available (in
>>>>> fact,
>>>>> > > the Java client line isn't a link).
>>>>> > >
>>>>> > > So, how do I begin as a java client? And at what point does geode
>>>>> update
>>>>> > > their links for internal docs? For the record, the pivotal docs
>>>>> up first
>>>>> > > in searches
>>>>> > >
>>>>> > > John
>>>>> > >
>>>>> >
>>>>> >
>>>>> >
>>>>>
>>>> > --
>>>>> >
>>>>> > *Mark Secrist | Sr Manager, **Global Education Delivery*
>>>>> >
>>>>> > [email protected]
>>>>> >
>>>>> > 970.214.4567 Mobile
>>>>> >
>>>>> > *pivotal.io <http://www.pivotal.io/>*
>>>>> >
>>>>> > Follow Us: Twitter <http://www.twitter.com/pivotal> | LinkedIn
>>>>> > <http://www.linkedin.com/company/pivotalsoftware> | Facebook
>>>>> > <http://www.facebook.com/pivotalsoftware> | YouTube
>>>>> > <http://www.youtube.com/gopivotal> | Google+
>>>>> > <https://plus.google.com/105320112436428794490>
>>>>> >
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> *Mark Secrist | Sr Manager, **Global Education Delivery*
>>>>
>>>> [email protected]
>>>>
>>>> 970.214.4567 Mobile
>>>>
>>>> *pivotal.io <http://www.pivotal.io/>*
>>>>
>>>> Follow Us: Twitter <http://www.twitter.com/pivotal> | LinkedIn
>>>> <http://www.linkedin.com/company/pivotalsoftware> | Facebook
>>>> <http://www.facebook.com/pivotalsoftware> | YouTube
>>>> <http://www.youtube.com/gopivotal> | Google+
>>>> <https://plus.google.com/105320112436428794490>
>>>>
>>>
>>
>>
>> --
>>
>> *Mark Secrist | Sr Manager, **Global Education Delivery*
>>
>> [email protected]
>>
>> 970.214.4567 Mobile
>>
>> *pivotal.io <http://www.pivotal.io/>*
>>
>> Follow Us: Twitter <http://www.twitter.com/pivotal> | LinkedIn
>> <http://www.linkedin.com/company/pivotalsoftware> | Facebook
>> <http://www.facebook.com/pivotalsoftware> | YouTube
>> <http://www.youtube.com/gopivotal> | Google+
>> <https://plus.google.com/105320112436428794490>
>>
>
>
--
-John
503-504-8657
john.blum10101 (skype)