You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by Dharam Thacker <dh...@gmail.com> on 2018/05/23 13:37:39 UTC

Spring data gemfire functions

Hi John/Team,

Is there any way we can deploy application jar with functions created using
spring data geode via Gfsh or any other utility?

For few apps, I have servers started from GFSH.

Thanks,
Dharam

Re: Spring data gemfire functions

Posted by John Blum <jb...@pivotal.io>.
Hi Dharam-

First, I apologize for the extremely late response here.

I have been busy working on a few SD releases (for *Ingalls* and *Kay*) and
I have been trying to get the first milestone bits out for my new
project, *Spring
Boot for Apache Geode & Pivotal GemFire (SBDG)* [1], which is nearly
complete.  In short SBDG is going to be an exciting new way to use the full
power of Apache Geode in a *Spring* context.

Also, another project I have been working on, which is still in stealth
mode, is the *Spring Test for Apache Geode & Pivotal GemFire* *(STDG)*
project, [2].  This project will take slightly longer to complete
(especially with docs), but will offer a very comprehensive way to both
Unit and Integration test Apache Geode (or Pivotal GemFire) effectively, in
a Spring context, without side effects and without all the gotchas in
Apache Geode, for which there are many, that make it so difficult to test
reliably.  This project is capturing all these little nuances and then
performs the proper setup and tear-down so the user does not have to.
Anyway, more on these projects later.


Regarding your question...

*> Is there any way we can deploy application jar with functions created
using spring data geode via Gfsh or any other utility? *

First, based on people's responses, I can see there is still much confusion
(or doubt) and misconceptions around how SDG works, and more importantly,
how SDG and Apache Geode work together.

For instance...

* The *Gfsh* `deploy` command will NOT recognize SDG-defined Functions.
This is unfortunate.

* It is not always as simple as "refreshing" the *Spring* ApplicationContext
.

The last bullet assumes the user has either 1) configured & bootstrapped
the Apache Geode server with *Spring* in the first place, or 2)
alternatively, embedded a *Spring* container in the Apache Geode server JVM
process using the SDG SpringContextBootstrappingInitializer [3] or finally
3) used the *Gfsh* `start server` command, `--spring-xml-location` option
to configure the Geode server process with *Spring* (XML).

Still, that does not address "how" the *Spring* container is able to
"resolve" the (SDG-defined) Function (POJO) classes given Functions, when
deployed used *Gfsh's* `deploy` command are loaded with a separate
ClassLoader, and Java's class loading mechanics is, by default, a
parent-first delegation model (for Security reasons).

It is actually possible to do (I did something similar back in the day
for *Citi
Group*, actually), but it is very tricky to setup properly and you still
have the issue, as *Swapnil* states, of "refreshing" the *Spring*
ApplicationContext when the new/modified Function definitions are uploaded
again using the `deploy` command.  Refreshing the ApplicationContext is not
always desirable either if you have different beans defined in the *Spring*
context, with different lifecycles and guarantees, e.g. when the *Spring*
context is actually hosting a legitimate (embedded) "application".


*So, where does this leave us???*

Well, you inspired me and I came up with a new solution!  See DATAGEODE-120
[4] for more details.

I also have built an example [5], complete with documentation, even, \o/.

I figured rather than regurgitate all that I went through in email, which
was rather involved and would have resulted in a short BOOK, I put all of
it into a README for others to benefit from as well.  I start by recapping
what is already in place today and what will be possible with the addition
of DATAGEODE-120 into SDG.  So, you are probably the most interested in
this section [6], which begins our journey in the...

"*New Way to Function*", ;-)

Again, this idea was inspired by your question(s), and actually has been a
problem I have long pondered and even discussed with the Pivotal GemFire
team.  This is the answer!

But, I would appreciate your feedback and experience trying this example,
using it in your environment before DATAGEODE-120 finds its way into SD*
for Apache Geode* *Lovelace* release.

The bits containing the support for DATAGEODE-120 is available in the
*Spring* libs-snapshot *Repository*, at...


http://repo.spring.io/libs-snapshot/org/springframework/data/spring-data-geode/2.1.0.DATAGEODE-120-SNAPSHOT/spring-data-geode-2.1.0.DATAGEODE-120-SNAPSHOT.jar


Best regards,
John


[1] https://github.com/spring-projects/spring-boot-data-geode
[2] https://github.com/spring-projects/spring-test-data-geode
[3]
https://docs.spring.io/spring-data/geode/docs/current/reference/html/#gemfire-bootstrap
[4] https://jira.spring.io/browse/DATAGEODE-120
[5]
https://github.com/jxblum/contacts-application/tree/master/geode-to-spring-function-example
[6]
https://github.com/jxblum/contacts-application/tree/master/geode-to-spring-function-example#implementing--deploying-functions-with-sdg--gfsh


On Wed, May 23, 2018 at 7:47 AM, Swapnil Bawaskar <sb...@pivotal.io>
wrote:

> You can refresh your application context
> <http://techdive.in/spring/spring-refresh-application-context> after
> deploying the function from gfsh. A function that does this may work.
>
> On Wed, May 23, 2018 at 7:40 AM Mark Secrist <ms...@pivotal.io> wrote:
>
>> I think the only way this would work is if the GemFire servers were
>> started using Spring configuration.
>>
>> On Wed, May 23, 2018 at 8:38 AM, Dharam Thacker <
>> dharamthacker88@gmail.com> wrote:
>>
>>> Thanks Jinmei!
>>>
>>> But would that recognize spring data geode function annotations as well
>>> (@GemfireFunction) ? I did try and it shows deployment successful.
>>>
>>> But "gfsh list functions" does not show anything to me.
>>>
>>> Thanks,
>>> Dharam
>>>
>>> On Wed, May 23, 2018, 20:03 Jinmei Liao <ji...@pivotal.io> wrote:
>>>
>>>> You can use deploy command in gfsh:
>>>> https://geode.apache.org/docs/guide/13/tools_modules/gfsh/
>>>> command-pages/deploy.html
>>>>
>>>> On Wed, May 23, 2018, 6:37 AM Dharam Thacker <dh...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi John/Team,
>>>>>
>>>>> Is there any way we can deploy application jar with functions created
>>>>> using spring data geode via Gfsh or any other utility?
>>>>>
>>>>> For few apps, I have servers started from GFSH.
>>>>>
>>>>> Thanks,
>>>>> Dharam
>>>>>
>>>>
>>
>>
>> --
>>
>> *Mark Secrist | Director, **Global Education Delivery*
>>
>> msecrist@pivotal.io
>>
>> 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
john.blum10101 (skype)

Re: Spring data gemfire functions

Posted by Swapnil Bawaskar <sb...@pivotal.io>.
You can refresh your application context
<http://techdive.in/spring/spring-refresh-application-context> after
deploying the function from gfsh. A function that does this may work.

On Wed, May 23, 2018 at 7:40 AM Mark Secrist <ms...@pivotal.io> wrote:

> I think the only way this would work is if the GemFire servers were
> started using Spring configuration.
>
> On Wed, May 23, 2018 at 8:38 AM, Dharam Thacker <dharamthacker88@gmail.com
> > wrote:
>
>> Thanks Jinmei!
>>
>> But would that recognize spring data geode function annotations as well
>> (@GemfireFunction) ? I did try and it shows deployment successful.
>>
>> But "gfsh list functions" does not show anything to me.
>>
>> Thanks,
>> Dharam
>>
>> On Wed, May 23, 2018, 20:03 Jinmei Liao <ji...@pivotal.io> wrote:
>>
>>> You can use deploy command in gfsh:
>>>
>>> https://geode.apache.org/docs/guide/13/tools_modules/gfsh/command-pages/deploy.html
>>>
>>> On Wed, May 23, 2018, 6:37 AM Dharam Thacker <dh...@gmail.com>
>>> wrote:
>>>
>>>> Hi John/Team,
>>>>
>>>> Is there any way we can deploy application jar with functions created
>>>> using spring data geode via Gfsh or any other utility?
>>>>
>>>> For few apps, I have servers started from GFSH.
>>>>
>>>> Thanks,
>>>> Dharam
>>>>
>>>
>
>
> --
>
> *Mark Secrist | Director, **Global Education Delivery*
>
> msecrist@pivotal.io
>
> 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>
>

Re: Spring data gemfire functions

Posted by Mark Secrist <ms...@pivotal.io>.
I think the only way this would work is if the GemFire servers were started
using Spring configuration.

On Wed, May 23, 2018 at 8:38 AM, Dharam Thacker <dh...@gmail.com>
wrote:

> Thanks Jinmei!
>
> But would that recognize spring data geode function annotations as well
> (@GemfireFunction) ? I did try and it shows deployment successful.
>
> But "gfsh list functions" does not show anything to me.
>
> Thanks,
> Dharam
>
> On Wed, May 23, 2018, 20:03 Jinmei Liao <ji...@pivotal.io> wrote:
>
>> You can use deploy command in gfsh:
>> https://geode.apache.org/docs/guide/13/tools_modules/gfsh/
>> command-pages/deploy.html
>>
>> On Wed, May 23, 2018, 6:37 AM Dharam Thacker <dh...@gmail.com>
>> wrote:
>>
>>> Hi John/Team,
>>>
>>> Is there any way we can deploy application jar with functions created
>>> using spring data geode via Gfsh or any other utility?
>>>
>>> For few apps, I have servers started from GFSH.
>>>
>>> Thanks,
>>> Dharam
>>>
>>


-- 

*Mark Secrist | Director, **Global Education Delivery*

msecrist@pivotal.io

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>

Re: Spring data gemfire functions

Posted by Dharam Thacker <dh...@gmail.com>.
Thanks Jinmei!

But would that recognize spring data geode function annotations as well
(@GemfireFunction) ? I did try and it shows deployment successful.

But "gfsh list functions" does not show anything to me.

Thanks,
Dharam

On Wed, May 23, 2018, 20:03 Jinmei Liao <ji...@pivotal.io> wrote:

> You can use deploy command in gfsh:
>
> https://geode.apache.org/docs/guide/13/tools_modules/gfsh/command-pages/deploy.html
>
> On Wed, May 23, 2018, 6:37 AM Dharam Thacker <dh...@gmail.com>
> wrote:
>
>> Hi John/Team,
>>
>> Is there any way we can deploy application jar with functions created
>> using spring data geode via Gfsh or any other utility?
>>
>> For few apps, I have servers started from GFSH.
>>
>> Thanks,
>> Dharam
>>
>

Re: Spring data gemfire functions

Posted by Jinmei Liao <ji...@pivotal.io>.
You can use deploy command in gfsh:
https://geode.apache.org/docs/guide/13/tools_modules/gfsh/command-pages/deploy.html

On Wed, May 23, 2018, 6:37 AM Dharam Thacker <dh...@gmail.com>
wrote:

> Hi John/Team,
>
> Is there any way we can deploy application jar with functions created
> using spring data geode via Gfsh or any other utility?
>
> For few apps, I have servers started from GFSH.
>
> Thanks,
> Dharam
>