[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
ping server alive ? how ?  XML
Forum Index -> Ehcache
Author Message
kadirb

journeyman

Joined: 01/23/2012 07:06:47
Messages: 14
Offline

hello , how can i check server and cache is alive?
public final boolean ping() {
Status status = cache.getStatus();
return status == Status.STATUS_ALIVE;
}

this can help ?
alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 464
Offline

What is the cache topology you're using ? What's the cache's config ?
This check above wouldn't tell you anything about any network status. It only says that the Cache is usable, from it's lifecycle perspective.

Alex Snaps (Terracotta engineer)
kadirb

journeyman

Joined: 01/23/2012 07:06:47
Messages: 14
Offline

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true" monitoring="autodetect"
dynamicConfig="false">
<diskStore path="java.io.tmpdir"/>
<terracottaConfig url="localhost:9510" />

<!-- Specify cache storage location -->
<!-- <diskStore path="/tmp/jprofessional/cache"/> -->
<cache name="test" maxElementsInMemory="50" maxElementsOnDisk="5000" eternal="false" overflowToDisk="false" diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off"
>
<terracotta clustered="true" consistency="eventual"/>
<cacheWriter writeBatching="true" writeMode="write-behind" writeBehindConcurrency="2" maxWriteDelay="5" rateLimitPerSecond="5" >
<cacheWriterFactory class="bts.UserTrackWriterFactory"/>
</cacheWriter>

<searchable>
<searchAttribute name="id" expression="value.getId()"/>
<searchAttribute name="gid" expression="value.getGid()"/>
</searchable>

</cache>

</ehcache>
kadirb

journeyman

Joined: 01/23/2012 07:06:47
Messages: 14
Offline

This is my XML file
sghose

journeyman

Joined: 06/26/2012 11:11:30
Messages: 46
Offline

Hi,

Try using the dev console. If you would like to do it programmatically, use CacheCluster API to check if the cluster is online.

Cheers

Sourabh Ghose - Terracotta Solution Architect
[WWW]
kadirb

journeyman

Joined: 01/23/2012 07:06:47
Messages: 14
Offline

cachecluster api ?
how ?

i've cache object and 1 cachamanager object.
how can i access cachecluster to ping server to check alive?

can you give simple ping code example ?

alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 464
Offline

I'm confused what you are trying to achieve.
From a high level perspective, if you can interact with the cache, the server should be there...

Are you trying to do something like :
Code:
if(server.ping()) 
   cache.use(); 
 else
   doSomethingElse();
?

Cause that wouldn't make much sense...
If you want resilience, you should look at non-stop caches here:
http://ehcache.org/documentation/configuration/non-stop-cache

If you want to monitor the cluster, you should probably indeed look into using the dev-console, or use JMX directly...

Alex Snaps (Terracotta engineer)
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team