[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
how tc.active works  XML
Forum Index -> Terracotta Platform
Author Message
valdeslz

neo

Joined: 07/11/2012 23:59:42
Messages: 3
Offline

Hi!

I have read in the documentation [http://terracotta.org/documentation/technical-faq] that if I want my application to check that the Terracotta process is alive at runtime I need to check the system property "tc.active".

After doing a test I do not understand how this property works. My test is:

1) Start Terracotta Server
2) Start my application and print "tc.active". Its value is true - I think this is correct because Terracotta is alive.
3) Stop Terracotta
4) Print now "tc.active". Its value is true again - I think this is wrong, because Terracotta in not alive.

Could someone give an explanation? Os there another way to detect when Terracotta is alive programmatically?

Regards
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1465
Offline

Hi ,

I have few queries to understand your use case better :

Have you configured "Boolean.getBoolean("tc.active")" in your client source ??
If yes once Terracotta Active server is down , so your client is now disconnected from server and should be stopped, now how you are printing tc.active again??

Rakesh Joshi
Terracotta.
valdeslz

neo

Joined: 07/11/2012 23:59:42
Messages: 3
Offline

Hi!

My use case is: I have a Spring based web application. I used ehcache for caching my application data and I use Terracotta for it. This application has a servlet that publish monitoring information, and I want to check with it if Terracotta is alive and running. My servlet calls Boolean.getBoolean("tc.active") to discover if Terracotta is alive or not.

So the process is:
1) Start Terracotta Server
2) Start my application and ask my servlet. It prints "tc.active".
3) Stop Terracotta -> so I loose my application data, but it is still up - I only use Terracotta for caching data.
4) Ask my servlet again. It prints now "tc.active". Its value is true again - I think this is wrong, because Terracotta in not alive.

My question is when "tc.active" value is changed. Because I suppossed that its value would be set to false when Terracotta is not active.

Maybe I am doing something wrong. But what I really want is to check if Terracotta is alive from a servlet as I have described.

Thanks!
klalithr

consul

Joined: 01/23/2011 10:58:07
Messages: 466
Offline

Use the below code ... or simillar


public static void main(String[] args) throws Exception {
CacheManager cacheManager = CacheManager.getInstance();
CacheCluster cluster = cacheManager.getCluster(ClusterScheme.TERRACOTTA);
boolean test = cluster.isClusterOnline();

while (test) {
Thread.sleep(1000);
System.out.println("Still connected");
test = cluster.isClusterOnline();
}

System.out.println("Disconnected");

while (!test) {
Thread.sleep(1000);
System.out.println("Still disconnected");
test = cluster.isClusterOnline();
}

System.out.println("Connected");
}

Karthik Lalithraj (Terracotta)
valdeslz

neo

Joined: 07/11/2012 23:59:42
Messages: 3
Offline

That solution works perfectly for me.

Thanks!!!!
 
Forum Index -> Terracotta Platform
Go to:   
Powered by JForum 2.1.7 © JForum Team