Category Archives: Infinispan

Infinispan

Infinispan is an in-memory,distributed,key/vale (NoSql) Cache written for JVM.Infinispan is a clusterd cache enabling to scale horizontally by adding multiple node’s/computing power
You can configure various parameters in infinispan like
1) When to persist the data in back-end
2) When to purge the expired Entries
3) How many entries to keep in memory
Infinispan Ships with support for many backends like for
Cassandra
JDBC
SingleFileStore
HBase
LevelDbStore
I have integrated Infinispan 5.0.x with Hbase 0.94.12 and posting the code here


public class HbaseTest {

public static ConfigurationBuilder getConfigurationBuilder() throws IOException{
ConfigurationBuilder b = new ConfigurationBuilder();
File file = new File("/root/Downloads/infinispan-quickstart-master/embedded-cache/src/main/resources/hbase.properties");
FileInputStream fileInput = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInput);
b.versioning().disable();
b.loaders()
.addStore(HBaseCacheStoreConfigurationBuilder.class).hbaseZookeeperQuorumHost("192.xx.xx.xx").
hbaseZookeeperClientPort(2181).purgeOnStartup(false).purgerThreads(10)
.async().flushLockTimeout(10000l).threadPoolSize(10).withProperties(properties)
.autoCreateTable(false).entryTable("InfinispanTest").entryColumnFamily("sd").
expirationTable("InfinispanExpired").expirationColumnFamily("sd");//defining HBase specific configurations
b.loaders().passivation(false);
b.eviction().maxEntries(10000000);

b.expiration().wakeUpInterval(100, TimeUnit.SECONDS).reaperEnabled(false);
b.jmxStatistics().enabled(true);
return b;
}

public static void main(String args[]) throws IOException, InterruptedException, CacheLoaderException{

Scanner scn=new Scanner(System.in);
Configuration ca=getConfigurationBuilder().build();
DefaultCacheManager cm=new DefaultCacheManager(ca);

Cache c=cm.getCache("example")// gets a new cache instance with name "example"

.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES);
long beforeTime=System.currentTimeMillis();

for(int i=0;i<100;i++){ c.put("e_"+i,100+""); } System.out.println("Total time "+(System.currentTimeMillis()-beforeTime)); c.stop(); } }