[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Messages posted by: kadirb  XML
Profile for kadirb -> Messages posted by kadirb [14]
Author Message
Hello its been long time topic but i wanted to write some more idea about this.
This is low power super computer:
http://www.kickstarter.com/projects/adapteva/parallella-a-supercomputer-for-everyone

Parallela , its the most powerful low power opencl board.If someone makes distributed board from this , with this device you can make very fast cache server with low power.
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 ?

on writeAll ,

User user = (User)value;
User usr2 = entityManager.find(User.class,user.getGid());
if(usr2 != null) {
entityManager.remove( usr2 );
}
entityManager.persist(user);

do i need to remove and persist back ? but this is not effective solution ?
why there is no updateAll method ?

thats why i asked for.
here is my all code:

Code:
 package bts;
 
 import model.User;
 import net.sf.ehcache.CacheEntry;
 import net.sf.ehcache.CacheException;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 import net.sf.ehcache.statistics.LiveCacheStatisticsImpl;
 import net.sf.ehcache.writer.CacheWriter;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
 import java.util.Collection;
 
 /**
  * Created with IntelliJ IDEA.
  * User: apple
  * Date: 16.07.2012
  * Time: 17:06
  * To change this template use File | Settings | File Templates.
  */
 public class UserTrackWriter implements CacheWriter {
 
 
     private Ehcache cache = null;
     private EntityManager entityManager;
     private EntityManagerFactory emf;
 
 
     //private SqlSession session = null;
 
     public UserTrackWriter(Ehcache cache) {
         super();
         this.cache = cache;
         emf = Persistence.createEntityManagerFactory("UserDB");
         entityManager = emf.createEntityManager( );
     }
 
     @Override
     public CacheWriter clone(Ehcache arg0) throws CloneNotSupportedException {
         throw new CloneNotSupportedException("CsvWriter cannot be cloned!");
     }
 
     @Override
     public void delete(CacheEntry arg0) throws CacheException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void dispose() throws CacheException {
         /*if (session != null) {
             //session.close();
         }*/
     }
 
     @Override
     public void init() {
         //LOG.info("Logger is initialized...");
         LiveCacheStatisticsImpl cacheStats = new LiveCacheStatisticsImpl (cache);
         //LOG.info("cache stats -> "+cacheStats.toString());
         //LOG.info("cache queue length ->" + cacheStats.getWriterQueueLength());
 
 
 
         cache.removeAll();
     }
 
 
     @Override
     public void write(final Element element) throws CacheException {
         //LOG.info("Inside single write function....");
         /*ArrayList<Element> arr = new ArrayList<Element>();
         arr.add(element);
         writeAll(arr);*/
     }
 
     //INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6) ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
 
     @Override
     public void writeAll(final Collection<Element> elements) throws CacheException {
         //LOG.info("Inside multiple write function - start....");
         entityManager.getTransaction().begin();
         int count = 0;
         for (Element element : elements) {
             final Object value = element.getObjectValue();
 
             if (value != null &&  value instanceof User){
                 User user = (User)value;
                 User usr2 = entityManager.find(User.class,user.getGid());
                 if(usr2 != null) {
                     entityManager.remove( usr2 );
                 }
                 entityManager.persist(user);
                 count++;
                 if(count == 1024*16) {
                     entityManager.flush();
                 }
             }
         }
         entityManager.getTransaction().commit();
     }
 
 
 
     @Override
     public void deleteAll(Collection<CacheEntry> elements) throws CacheException {
         // TODO Auto-generated method stub
         entityManager.getTransaction().begin();
         int count = 0;
         for (CacheEntry element : elements) {
             final Object value = element.getElement().getObjectValue();
             if (value != null &&  value instanceof User){
                 User user = (User)value;
                 User usr2 = entityManager.find(User.class,user.getGid());
                 if(usr2 != null) {
                     entityManager.remove( usr2 );
                 }
                 count++;
                 if(count == 1024*16) {
                     entityManager.flush();
                 }
             }
         }
         entityManager.getTransaction().commit();
     }
 }
 
 
do you mean existing key will call writeAll back?
so i will need to check key exists on db on writeAll method?
This is my XML file
<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>
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 ?
Hello , i want to sync ehcache with ObjectDB , so i wanted to use CacheWriter for that.
For static data storage on background , ObjectDB will store datas.

There is 2 methods for batching on CacheWriter ;

writeAll
and
deleteAll

but there is no refresh ? why ? sometimes i need to update data and i need to sync db with cache.

Do i need delete and add back for data change ? but this gives me penalty on performance.

CacheWriter needs update...
1-) http://pastebin.com/2qyBg3jz
31-Jan-2012 22:00:51 org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:409)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:337)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)

2-) http://pastebin.com/Uq0tfe2d
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tc="http://www.terracotta.org/config">
<tc-properties>
<property value="100000" name="l2.l1reconnect.timeout.millis"/>
</tc-properties>
<servers>
<server host="localhost" name="localhost">
<dso-port bind="0.0.0.0">9510</dso-port>
<jmx-port bind="0.0.0.0">9520</jmx-port>
<data>terracotta/server-data</data>
<logs>terracotta/server-logs</logs>
<statistics>terracotta/cluster-statistics</statistics>
</server>
</servers>

<clients>
<logs>terracotta/client-logs</logs>
<modules>
<module name="tim-ehcache-1.7" version="1.7.6"/>
<module name="terracotta-toolkit-1.4" version="4.0.0"/>
</modules>
</clients>
</tc:tc-config>

Hello ,
I'm currently having big problem on Terracotta when i try to run on tomcat7;


Error Shown here:
http://pastebin.com/2qyBg3jz


My Tomcat JVM Options shown below :
http://paste2.org/p/1890043


My tc-config.xml file inside my web project:
http://pastebin.com/Uq0tfe2d


I run on localhost:
start-tc-server.bat

although i did everything , the problem still persists.
Please help ;(
Whats wrong ? Someone can help please?
Hello I'm currently making new project on Spring DSL + Terracotta Ehcache
I am currently in dilemma now.
I've read sample codes on Ehcache ,
There are lots of CacheManager creation types:
1-) CacheManager manager = new CacheManager();
2-) CacheManager manager = CacheManager.getInstance();
3-) CacheManager manager = CacheManager.create();
4-) CacheManager manager = new CacheManager("ehcache.xml");
etc...

Whats difference between them?

My Spring DSL Service code is like that :
http://pastebin.com/3g5DnQnX

is it good to use it like this?

And what about Servlets , is it good to use
ThreadLocal CacheManager per Thread better ? or just singleton better solution for high performance?

Thanks for help now...
Hello I'm currently making new project on Spring DSL + Terracotta Ehcache
I am currently in dilemma now.
I've read sample codes on Ehcache ,
There are lots of CacheManager creation types:
1-) CacheManager manager = new CacheManager();
2-) CacheManager manager = CacheManager.getInstance();
3-) CacheManager manager = CacheManager.create();
4-) CacheManager manager = new CacheManager("ehcache.xml");
etc...

Whats difference between them?

My Spring DSL Service code is like that :
http://pastebin.com/3g5DnQnX

is it good to use it like this?

And what about Servlets , is it good to use
ThreadLocal CacheManager per Thread better ? or just singleton better solution for high performance?

Thanks for help now...

Hello ,
yesterday i ve heard about new project from AMD,
Aparapi : OpenCL Solution on full java side.

And i ve seen some gpu based database plans.
http://wiki.postgresql.org/images/6/65/Pgopencl.pdf

It would be great if terracotta ehcache would work on GPU with the help of
AMD Aparapi , and its really easy to implement.
No OpenCL code need...


Another trick is ,
Terracotta is using TCP layer it would be good for big transmissions to use UDT ( Reliable UDP ) makes Terracotta booosts much.

 
Profile for kadirb -> Messages posted by kadirb [14]
Go to:   
Powered by JForum 2.1.7 © JForum Team