Ingite node in SpringBoot App

classic Classic list List threaded Threaded
22 messages Options
12
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Ingite node in SpringBoot App

I've created a SpringBoot App that includes code to start an Ignite
standalone node and populates a cache. The logic is wrapped in a
PostConstruct method on a Bean. However Ignite server stops as soon as app
returns from the method to start Ignite server and populate cache. I would
like to be able to connect to the server from a thin client embedded on a
different app.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Evgeniy Rudenko Evgeniy Rudenko
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Can you share code of your Bean to check?

On Thu, Oct 17, 2019 at 10:11 PM niamin <[hidden email]> wrote:
I've created a SpringBoot App that includes code to start an Ignite
standalone node and populates a cache. The logic is wrapped in a
PostConstruct method on a Bean. However Ignite server stops as soon as app
returns from the method to start Ignite server and populate cache. I would
like to be able to connect to the server from a thin client embedded on a
different app.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


--
Best regards,
Evgeniy
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

In reply to this post by niamin
springbeans.zip
<http://apache-ignite-users.70518.x6.nabble.com/file/t2637/springbeans.zip>  

Here you go. I've tried with @PostConstruct and EventListener but in both
occasions Ignite engine stops immediately after application bootstrap with
the following:

[09:32:03] Ignite node stopped OK [uptime=00:00:01.168]





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Evgeniy Rudenko Evgeniy Rudenko
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

This happens because you create your node inside try () statement. So it is being stopped as soon as try section ends. If you want to keep it active change code to
try  {
Ignite ignite = Ignition.start("example-ignite.xml");

On Fri, Oct 18, 2019 at 4:35 PM niamin <[hidden email]> wrote:
springbeans.zip
<http://apache-ignite-users.70518.x6.nabble.com/file/t2637/springbeans.zip

Here you go. I've tried with @PostConstruct and EventListener but in both
occasions Ignite engine stops immediately after application bootstrap with
the following:

[09:32:03] Ignite node stopped OK [uptime=00:00:01.168]





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


--
Best regards,
Evgeniy
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Thanks! That worked. Now when I try to fetch object using thin client from a
seperate process I get no object. However, when I fetch object using the
same server process I get object.  Difference on fetching object is the
usage of Ignite or IgniteClient. Attached is the client driver.

IgniteClientStarter.java
<http://apache-ignite-users.70518.x6.nabble.com/file/t2637/IgniteClientStarter.java>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Looks like it is something with the using ARInvoiceId as key. All the other
combinations of key/value(String/String, String/ARInovice) can be retrieved
from thin client. I also serialized the ARInvoiceId object to a file from
client project and was able to to deserialize successfully from the server
project. So still not sure why using ARInvoiceId as key is not working



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

In reply to this post by niamin
Looks like it is something with the using ARInvoiceId as key. All the other
combinations of key/value(String/String, String/ARInovice) can be retrieved
from thin client. I also serialized the ARInvoiceId object to a file from
client project and was able to to deserialize successfully from the server
project. So still not sure why using ARInvoiceId as key is not working



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

In reply to this post by niamin
Hello!

Can you publish a complete Spring reproducer project?

The only thing I have noticed outright is that you call load() before the app (and Ignite) is started.

Regards,
--
Ilya Kasnacheev


пт, 18 окт. 2019 г. в 23:51, niamin <[hidden email]>:
Looks like it is something with the using ARInvoiceId as key. All the other
combinations of key/value(String/String, String/ARInovice) can be retrieved
from thin client. I also serialized the ARInvoiceId object to a file from
client project and was able to to deserialize successfully from the server
project. So still not sure why using ARInvoiceId as key is not working



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Unable to upload since the projects are larger than 5 MB. Can you share your
google id?

Thanks,
Naushad





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Hello!

You can share a link to the file. This way, everybody can look.

Regards,
--
Ilya Kasnacheev


вт, 22 окт. 2019 г. в 00:12, niamin <[hidden email]>:
Unable to upload since the projects are larger than 5 MB. Can you share your
google id?

Thanks,
Naushad





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

In reply to this post by niamin
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Hello!

Unfortunately I'm not able to run it, as I'm getting

[ERROR] Failed to execute goal on project IgniteCacheLoader: Could not resolve dependencies for project com.gpc.rpm:IgniteCacheLoader:jar:0.0.1-SNAPSHOT: Could not find artifact com.gpc.rpm:ignite-bo:jar:0.0.1-SNAPSHOT -> [Help 1]

Maybe you need to share something else?

Regards,
--
Ilya Kasnacheev


niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Here is the link to the dependency. You will need to add to drop it to your
local maven repo at the desired directory:

https://drive.google.com/open?id=1z9TexorvaoQhhDVJp5YlUM6z6eQm32iW



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Hello!

Can you please also supply me with steps to reproduce? What do I have to run and in which order? Because I don't see any strange behavior yet.

Regards,
--
Ilya Kasnacheev


вт, 22 окт. 2019 г. в 17:50, niamin <[hidden email]>:
Here is the link to the dependency. You will need to add to drop it to your
local maven repo at the desired directory:

https://drive.google.com/open?id=1z9TexorvaoQhhDVJp5YlUM6z6eQm32iW



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

1. Run the IgniteCacheLoader project. This should start an Ignite node with
the cache named FOO populated with 100 entries. The executeTransaction()
method within IgniteCacheLoader5.java validates that a fetch operation works
successfully.
2. Run the ignite-client project in parallel. However, the process never
enters the if block(print statement not printed or running through a
debugger will validate that) of IgniteClientStarter.java at line 99
indicating a cache miss. Only difference is that cache is accessed from a
remote client. Please note that while debugging I observed the
clientCache.size(null) (line 97 of IgniteClientStarter.java) does return a
value of 100



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Update:
I updated IgniteClientStarter.java to use Ignite instead of IgniteClient.
Now I can see that the 'new' node joins the cluster and starts cache with
mode=PARTITIONED. Also cache fetch is successful. This is still not optimal
as I would like to use the 'new' node in client mode to avoid loading cache
locally.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Hello!

I start ignite-client but it never does anything, and in thread dump I don't see any relevant threads.

Can you perhaps make the error more apparent? I have trouble understanding your scenario.

You can start client node (by setting cfg.clientMode=true) to avoid having cache data locally.

Regards,
--
Ilya Kasnacheev


чт, 24 окт. 2019 г. в 04:34, niamin <[hidden email]>:
Update:
I updated IgniteClientStarter.java to use Ignite instead of IgniteClient.
Now I can see that the 'new' node joins the cluster and starts cache with
mode=PARTITIONED. Also cache fetch is successful. This is still not optimal
as I would like to use the 'new' node in client mode to avoid loading cache
locally.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

The is no error rather failed use case. I expected the following statement to
be a cache hit:

 ARInvoice arInvoice = clientCache.get(arInvoiceId);

And subsequently, the following statement to be printed on console:

 System.out.println("retrieved deserialized successfully from cache " +
arInvoice.getArInvoiceId().getInvoiceSiteNo());

The above statement is not printed out which is states it is a cache miss. I
also confirmed it by running the client on debug mode on an IDE.

The same use case works successfully on Ignite server i.e. the
IgniteCacheLoader project. So the question is why is there a cache miss from
IgniteClient? It seems to work with Ignite server.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

Hello!

I don't think that IgniteClientStarter is called at all, since I have added debug logging to it, but it doesn't print anything.  Are you sure that it runs?

Regards,
--
Ilya Kasnacheev


пт, 25 окт. 2019 г. в 16:19, niamin <[hidden email]>:
The is no error rather failed use case. I expected the following statement to
be a cache hit:

 ARInvoice arInvoice = clientCache.get(arInvoiceId);

And subsequently, the following statement to be printed on console:

 System.out.println("retrieved deserialized successfully from cache " +
arInvoice.getArInvoiceId().getInvoiceSiteNo());

The above statement is not printed out which is states it is a cache miss. I
also confirmed it by running the client on debug mode on an IDE.

The same use case works successfully on Ignite server i.e. the
IgniteCacheLoader project. So the question is why is there a cache miss from
IgniteClient? It seems to work with Ignite server.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Re: Ingite node in SpringBoot App

I am running from my IDE and i can confirm that it runs. Below are some
output from console:

2019-10-27 17:09:13.172  INFO 8601 --- [ange-worker-#38]
o.a.i.i.p.cache.GridCacheProcessor       : Finish proxy initialization,
cacheName=FOO, localNodeId=bf4963b5-8a84-4c66-8709-23b043c4f9bd
2019-10-27 17:09:15.909  INFO 8601 --- [-notifier-timer]
o.a.i.i.p.cluster.GridUpdateNotifier     : Your version is up to date.
*retrieved deserialized successfully from cache 1688
loaded 0 in 4915milliseconds*
2019-10-27 17:09:35.798  INFO 8601 --- [           main]
o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService
'applicationTaskExecutor'
2019-10-27 17:09:36.140  INFO 8601 --- [           main]
o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9090
(http) with context path ''
2019-10-27 17:09:36.141  INFO 8601 --- [           main]
c.g.r.i.IgniteClientApplication          : Started IgniteClientApplication
in 67.137 seconds (JVM running for 68.972)
2019-10-27 17:10:08.121  INFO 8601 --- [eout-worker-#23]
org.apache.ignite.internal.IgniteKernal  :
Metrics for local node (to disable set 'metricsLogFrequency' to 0)
    ^-- Node [id=bf4963b5, uptime=00:01:00.026]
    ^-- H/N/C [hosts=1, nodes=2, CPUs=8]
    ^-- CPU [cur=0.17%, avg=0.71%, GC=0%]
    ^-- PageMemory [pages=0]
    ^-- Heap [used=70MB, free=98.07%, comm=493MB]
    ^-- Off-heap [used=0MB, free=-1%, comm=0MB]
    ^-- Outbound messages queue [size=0]
    ^-- Public thread pool [active=0, idle=0, qSize=0]
    ^-- System thread pool [active=0, idle=0, qSize=0]



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
12