You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/03/05 13:24:27 UTC

[12/21] git commit: - hotrod serialization with custom JBoss Marshaller

- hotrod serialization with custom JBoss Marshaller


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2f22f5ca
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2f22f5ca
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2f22f5ca

Branch: refs/heads/MARMOTTA-450
Commit: 2f22f5cab74cb46d2ffa1b32627a1b71d004542d
Parents: 4cc2d1d
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Tue Mar 4 17:29:15 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Tue Mar 4 17:29:15 2014 +0100

----------------------------------------------------------------------
 .../kiwi/test/cluster/HazelcastClusterTest.java |   2 +-
 .../InfinispanEmbeddedCacheManager.java         | 517 -------------------
 .../InfinispanEmbeddedCacheManagerFactory.java  |  44 --
 .../kiwi/externalizer/BNodeExternalizer.java    |  74 ---
 .../BooleanLiteralExternalizer.java             |  72 ---
 .../externalizer/DateLiteralExternalizer.java   |  72 ---
 .../externalizer/DoubleLiteralExternalizer.java |  72 ---
 .../kiwi/externalizer/ExternalizerIds.java      |  43 --
 .../externalizer/IntLiteralExternalizer.java    |  72 ---
 .../externalizer/StringLiteralExternalizer.java |  79 ---
 .../kiwi/externalizer/TripleExternalizer.java   | 149 ------
 .../kiwi/externalizer/UriExternalizer.java      | 136 -----
 .../InfinispanEmbeddedCacheManager.java         | 517 +++++++++++++++++++
 .../InfinispanEmbeddedCacheManagerFactory.java  |  44 ++
 .../externalizer/BNodeExternalizer.java         |  74 +++
 .../externalizer/BaseExternalizer.java          |  80 +++
 .../BooleanLiteralExternalizer.java             |  72 +++
 .../externalizer/DateLiteralExternalizer.java   |  72 +++
 .../externalizer/DoubleLiteralExternalizer.java |  72 +++
 .../externalizer/ExternalizerIds.java           |  43 ++
 .../externalizer/IntLiteralExternalizer.java    |  72 +++
 .../externalizer/StringLiteralExternalizer.java |  79 +++
 .../externalizer/TripleExternalizer.java        | 149 ++++++
 .../externalizer/UriExternalizer.java           | 136 +++++
 .../remote/CustomClassExternalizerFactory.java  |  70 +++
 .../infinispan/remote/CustomClassTable.java     | 113 ++++
 .../remote/CustomJBossMarshaller.java           |  41 ++
 .../remote/InfinispanRemoteCacheManager.java    | 154 ++++++
 .../InfinispanRemoteCacheManagerFactory.java    |  44 ++
 .../remote/InfinispanRemoteCacheManager.java    | 154 ------
 .../InfinispanRemoteCacheManagerFactory.java    |  44 --
 ...he.marmotta.kiwi.caching.CacheManagerFactory |   4 +-
 .../marmotta/kiwi/test/ExternalizerTest.java    |  19 +-
 .../kiwi/test/InfinispanClusterTest.java        |   2 +-
 .../marmotta/kiwi/caching/CacheManagerType.java |  58 ---
 .../marmotta/kiwi/config/CacheManagerType.java  |  58 +++
 .../marmotta/kiwi/config/KiWiConfiguration.java |   1 -
 .../kiwi/test/cluster/BaseClusterTest.java      |  20 +-
 38 files changed, 1929 insertions(+), 1595 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastClusterTest.java b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastClusterTest.java
index c53b704..5cbbe7f 100644
--- a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastClusterTest.java
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastClusterTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.marmotta.kiwi.test.cluster;
 
-import org.apache.marmotta.kiwi.caching.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CacheManagerType;
 import org.junit.BeforeClass;
 
 /**

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManager.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManager.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManager.java
deleted file mode 100644
index 85ed56b..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManager.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.kiwi.embedded;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.marmotta.kiwi.caching.CacheManager;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.externalizer.*;
-import org.infinispan.Cache;
-import org.infinispan.commons.CacheException;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.configuration.cache.CacheMode;
-import org.infinispan.configuration.cache.Configuration;
-import org.infinispan.configuration.cache.ConfigurationBuilder;
-import org.infinispan.configuration.global.GlobalConfiguration;
-import org.infinispan.configuration.global.GlobalConfigurationBuilder;
-import org.infinispan.context.Flag;
-import org.infinispan.distribution.ch.SyncConsistentHashFactory;
-import org.infinispan.eviction.EvictionStrategy;
-import org.infinispan.lifecycle.ComponentStatus;
-import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A class for managing the different caches that are used by the triple store.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class InfinispanEmbeddedCacheManager implements CacheManager {
-
-    private static Logger log = LoggerFactory.getLogger(InfinispanEmbeddedCacheManager.class);
-
-    public static final String NODE_CACHE = "node-cache";
-    public static final String TRIPLE_CACHE = "triple-cache";
-    public static final String URI_CACHE = "uri-cache";
-    public static final String BNODE_CACHE = "bnode-cache";
-    public static final String LITERAL_CACHE = "literal-cache";
-    public static final String NAMESPACE_URI_CACHE = "namespace-uri-cache";
-    public static final String NAMESPACE_PREFIX_CACHE = "namespace-prefix-cache";
-    public static final String LOADER_CACHE = "loader-cache";
-    public static final String REGISTRY_CACHE = "registry-cache";
-
-    private EmbeddedCacheManager cacheManager;
-
-    // default configuration: distributed cache, 100000 entries, 300 seconds expiration, 60 seconds idle
-    private Configuration defaultConfiguration;
-
-    private KiWiConfiguration config;
-
-    private Cache nodeCache, tripleCache, uriCache, literalCache, bnodeCache, nsPrefixCache, nsUriCache, registryCache;
-
-
-    /**
-     * Create a new cache manager with its own automatically created Infinispan instance.
-     *
-     * @param config
-     */
-    public InfinispanEmbeddedCacheManager(KiWiConfiguration config) {
-
-
-        this.config = config;
-
-        try {
-            switch (config.getCacheMode()) {
-                case DISTRIBUTED:
-                    buildDistributedConfiguration(getExternalizers());
-                    break;
-                case REPLICATED:
-                    buildReplicatedConfiguration(getExternalizers());
-                    break;
-                case LOCAL:
-                    buildLocalConfiguration();
-                    break;
-            }
-        } catch (IOException ex) {
-            log.warn("error while building cache cluster configuration, reverting to local cache");
-            buildLocalConfiguration();
-        }
-
-
-    }
-
-    /**
-     * Build a local cache configuration.
-     * <p/>
-     * In local cache mode, the cache is not shared among the servers in a cluster. Each machine keeps a local cache.
-     * This allows quick startups and eliminates network traffic in the cluster, but subsequent requests to different
-     * cluster members cannot benefit from the cached data.
-     */
-    protected void buildLocalConfiguration() {
-        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
-                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
-                .globalJmxStatistics()
-                    .jmxDomain("org.apache.marmotta.kiwi")
-                    .allowDuplicateDomains(true)
-                .build();
-
-        defaultConfiguration = new ConfigurationBuilder()
-                .clustering()
-                    .cacheMode(CacheMode.LOCAL)
-                .eviction()
-                    .strategy(EvictionStrategy.LIRS)
-                    .maxEntries(100000)
-                .expiration()
-                    .lifespan(5, TimeUnit.MINUTES)
-                    .maxIdle(1, TimeUnit.MINUTES)
-                .build();
-        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
-
-        log.info("initialised Infinispan local cache manager");
-    }
-
-    /**
-     * Build a distributed cache configuration.
-     * <p/>
-     * In distributed cache mode, the cluster forms a big hash table used as a cache. This allows to make efficient
-     * use of the large amount of memory available, but requires cache rebalancing and a lot of network transfers,
-     * especially in case cluster members are restarted often.
-     */
-    protected void buildDistributedConfiguration(AdvancedExternalizer...externalizers) throws IOException {
-        String jgroupsXml = IOUtils.toString(InfinispanEmbeddedCacheManager.class.getResourceAsStream("/jgroups-kiwi.xml"));
-
-        jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", config.getClusterAddress()));
-        jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", config.getClusterPort()));
-
-
-        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
-                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
-                .transport()
-                    .defaultTransport()
-                    .clusterName(config.getClusterName())
-                    .machineId("instance-" + config.getDatacenterId())
-                    .addProperty("configurationXml", jgroupsXml)
-                .globalJmxStatistics()
-                    .jmxDomain("org.apache.marmotta.kiwi")
-                    .allowDuplicateDomains(true)
-                .serialization()
-                    .addAdvancedExternalizer(externalizers)
-                .build();
-
-        defaultConfiguration = new ConfigurationBuilder()
-                .clustering()
-                    .cacheMode(CacheMode.DIST_ASYNC)
-                    .async()
-                        .asyncMarshalling()
-                    .l1()
-                        .lifespan(5, TimeUnit.MINUTES)
-                    .hash()
-                        .numOwners(2)
-                        .numSegments(40)
-                        .consistentHashFactory(new SyncConsistentHashFactory())
-                    .stateTransfer()
-                        .fetchInMemoryState(false)
-                .eviction()
-                    .strategy(EvictionStrategy.LIRS)
-                    .maxEntries(100000)
-                .expiration()
-                    .lifespan(30, TimeUnit.MINUTES)
-                    .maxIdle(10, TimeUnit.MINUTES)
-                .build();
-        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
-
-        log.info("initialised Infinispan distributed cache manager (cluster name: {})",  globalConfiguration.transport().clusterName());
-
-    }
-
-    /**
-     * Build a replicated cache configuration.
-     * <p/>
-     * In replicated cache mode, each node in the cluster has an identical copy of all cache data. This allows
-     * very efficient cache lookups and reduces the rebalancing effort, but requires more memory.
-     */
-    protected void buildReplicatedConfiguration(AdvancedExternalizer...externalizers) throws IOException {
-        String jgroupsXml = IOUtils.toString(InfinispanEmbeddedCacheManager.class.getResourceAsStream("/jgroups-kiwi.xml"));
-
-        jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", config.getClusterAddress()));
-        jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", config.getClusterPort()));
-
-
-        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
-                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
-                .transport()
-                    .defaultTransport()
-                    .clusterName(config.getClusterName())
-                    .machineId("instance-" + config.getDatacenterId())
-                    .addProperty("configurationXml", jgroupsXml)
-                .globalJmxStatistics()
-                    .jmxDomain("org.apache.marmotta.kiwi")
-                    .allowDuplicateDomains(true)
-                .serialization()
-                    .addAdvancedExternalizer(externalizers)
-                .build();
-
-        defaultConfiguration = new ConfigurationBuilder()
-                .clustering()
-                    .cacheMode(CacheMode.REPL_ASYNC)
-                    .async()
-                        .asyncMarshalling()
-                    .stateTransfer()
-                        .fetchInMemoryState(false)
-                .eviction()
-                    .strategy(EvictionStrategy.LIRS)
-                    .maxEntries(100000)
-                .expiration()
-                    .lifespan(30, TimeUnit.MINUTES)
-                    .maxIdle(10, TimeUnit.MINUTES)
-                .build();
-        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
-
-        log.info("initialised Infinispan replicated cache manager (cluster name: {})",  globalConfiguration.transport().clusterName());
-    }
-
-
-    protected boolean isClustered() {
-        return config.getCacheMode() == org.apache.marmotta.kiwi.config.CacheMode.DISTRIBUTED ||
-               config.getCacheMode() == org.apache.marmotta.kiwi.config.CacheMode.REPLICATED;
-    }
-
-
-    private AdvancedExternalizer[] getExternalizers() {
-        return new AdvancedExternalizer[] {
-                new TripleExternalizer(),
-                new UriExternalizer(),
-                new BNodeExternalizer(),
-                new StringLiteralExternalizer(),
-                new DateLiteralExternalizer(),
-                new BooleanLiteralExternalizer(),
-                new IntLiteralExternalizer(),
-                new DoubleLiteralExternalizer()
-        };
-    }
-
-    /**
-     * Return the node id -> node cache from the cache manager. This cache is heavily used to lookup
-     * nodes when querying or loading triples and should therefore have a decent size (default 500.000 elements).
-     *
-     * @return an EHCache Cache instance containing the node id -> node mappings
-     */
-    public Cache getNodeCache() {
-        if(nodeCache == null) {
-            Configuration nodeConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                    .eviction()
-                        .maxEntries(1000000)
-                    .expiration()
-                        .lifespan(60, TimeUnit.MINUTES)
-                        .maxIdle(30, TimeUnit.MINUTES)
-                    .build();
-            cacheManager.defineConfiguration(NODE_CACHE, nodeConfiguration);
-
-            nodeCache = cacheManager.getCache(NODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-
-        return nodeCache;
-    }
-
-    /**
-     * Return the triple id -> triple cache from the cache manager. This cache is used for speeding up the
-     * construction of query results.
-     *
-     * @return
-     */
-    public Cache getTripleCache() {
-        if(tripleCache == null) {
-            Configuration tripleConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                    .clustering()
-                        .cacheMode(CacheMode.LOCAL)
-                    .eviction()
-                        .maxEntries(config.getTripleCacheSize())
-                    .expiration()
-                        .lifespan(60, TimeUnit.MINUTES)
-                        .maxIdle(30, TimeUnit.MINUTES)
-                    .build();
-            cacheManager.defineConfiguration(TRIPLE_CACHE, tripleConfiguration);
-
-            tripleCache = cacheManager.getCache(TRIPLE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return tripleCache;
-    }
-
-
-    /**
-     * Return the uri -> KiWiUriResource cache from the cache manager. This cache is used when constructing new
-     * KiWiUriResources to avoid a database lookup.
-     *
-     * @return
-     */
-    public Cache getUriCache() {
-        if(uriCache == null) {
-            Configuration uriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                    .eviction()
-                        .maxEntries(config.getUriCacheSize())
-                    .build();
-            cacheManager.defineConfiguration(URI_CACHE, uriConfiguration);
-
-            uriCache = cacheManager.getCache(URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return uriCache;
-    }
-
-
-    /**
-     * Return the anonId -> KiWiAnonResource cache from the cache manager. This cache is used when constructing new
-     * KiWiAnonResources to avoid a database lookup.
-     *
-     * @return
-     */
-    public Cache getBNodeCache() {
-        if(bnodeCache == null) {
-            Configuration bnodeConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                    .eviction()
-                        .maxEntries(config.getBNodeCacheSize())
-                    .build();
-            cacheManager.defineConfiguration(BNODE_CACHE, bnodeConfiguration);
-
-            bnodeCache = cacheManager.getCache(BNODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return bnodeCache;
-    }
-
-    /**
-     * Return the literal cache key -> KiWiLiteral cache from the cache manager. This cache is used when constructing new
-     * KiWiLiterals to avoid a database lookup.
-     *
-     * @see org.apache.marmotta.commons.sesame.model.LiteralCommons#createCacheKey(String, java.util.Locale, String)
-     * @return
-     */
-    public Cache getLiteralCache() {
-        if(literalCache == null) {
-            Configuration literalConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                    .eviction()
-                        .maxEntries(config.getLiteralCacheSize())
-                    .build();
-            cacheManager.defineConfiguration(LITERAL_CACHE, literalConfiguration);
-
-            literalCache = cacheManager.getCache(LITERAL_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return literalCache;
-    }
-
-
-    /**
-     * Return the URI -> namespace cache from the cache manager. Used for looking up namespaces
-     * @return
-     */
-    public Cache getNamespaceUriCache() {
-        if(nsUriCache == null) {
-            if(isClustered()) {
-                Configuration nsuriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                        .clustering()
-                            .cacheMode(CacheMode.REPL_ASYNC)
-                        .eviction()
-                            .maxEntries(config.getNamespaceCacheSize())
-                        .expiration()
-                            .lifespan(1, TimeUnit.DAYS)
-                        .build();
-                cacheManager.defineConfiguration(NAMESPACE_URI_CACHE, nsuriConfiguration);
-            } else {
-                Configuration nsuriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                        .eviction()
-                            .maxEntries(config.getNamespaceCacheSize())
-                        .expiration()
-                            .lifespan(1, TimeUnit.HOURS)
-                        .build();
-                cacheManager.defineConfiguration(NAMESPACE_URI_CACHE, nsuriConfiguration);
-            }
-
-            nsUriCache = cacheManager.getCache(NAMESPACE_URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return nsUriCache;
-    }
-
-    /**
-     * Return the prefix -> namespace cache from the cache manager. Used for looking up namespaces
-     * @return
-     */
-    public Cache getNamespacePrefixCache() {
-        if(nsPrefixCache == null) {
-            if(isClustered()) {
-                Configuration nsprefixConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                        .clustering()
-                            .cacheMode(CacheMode.REPL_ASYNC)
-                        .eviction()
-                            .maxEntries(config.getNamespaceCacheSize())
-                        .expiration()
-                            .lifespan(1, TimeUnit.DAYS)
-                        .build();
-                cacheManager.defineConfiguration(NAMESPACE_PREFIX_CACHE, nsprefixConfiguration);
-
-            } else {
-                Configuration nsprefixConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
-                        .eviction()
-                            .maxEntries(config.getNamespaceCacheSize())
-                        .expiration()
-                            .lifespan(1, TimeUnit.HOURS)
-                        .build();
-                cacheManager.defineConfiguration(NAMESPACE_PREFIX_CACHE, nsprefixConfiguration);
-
-            }
-            nsPrefixCache = cacheManager.getCache(NAMESPACE_PREFIX_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return nsPrefixCache;
-    }
-
-
-
-
-    /**
-     * Create and return the cache used by the CacheTripleRegistry. This is an unlimited synchronous replicated
-     * cache and should be used with care.
-     * @return
-     */
-    public Cache getRegistryCache() {
-        if(registryCache == null) {
-            if(isClustered()) {
-                Configuration registryConfiguration = new ConfigurationBuilder()
-                    .clustering()
-                        .cacheMode(CacheMode.REPL_SYNC)
-                        .sync()
-                            .replTimeout(15, TimeUnit.SECONDS)
-                    .eviction()
-                        .strategy(EvictionStrategy.NONE)
-                    .build();
-                cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration);
-            } else {
-                Configuration registryConfiguration = new ConfigurationBuilder()
-                    .clustering()
-                        .cacheMode(CacheMode.LOCAL)
-                    .eviction()
-                        .strategy(EvictionStrategy.NONE)
-                    .build();
-                cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration);
-            }
-
-            registryCache = cacheManager.getCache(REGISTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-        return registryCache;
-    }
-
-    /**
-     * Get the cache with the given name from the cache manager. Can be used to request additional
-     * caches from the cache manager that are not covered by explicit methods.
-     *
-     * @param name
-     * @return
-     */
-    public synchronized Cache getCacheByName(String name) {
-        if(!cacheManager.cacheExists(name)) {
-            cacheManager.defineConfiguration(name, new ConfigurationBuilder().read(defaultConfiguration).build());
-        }
-        return cacheManager.getCache(name).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-
-    }
-
-    /**
-     * Clear all caches managed by this cache manager.
-     */
-    public void clear() {
-        Set<String> set =  cacheManager.getCacheNames();
-        Iterator<String> iterator =  set.iterator();
-        while(iterator.hasNext()){
-            String cacheName = iterator.next();
-            Cache<String,Object> cache = cacheManager.getCache(cacheName);
-            cache.clear();
-        }
-
-        nodeCache     = null;
-        tripleCache   = null;
-        uriCache      = null;
-        literalCache  = null;
-        bnodeCache    = null;
-        nsPrefixCache = null;
-        nsUriCache    = null;
-        registryCache = null;
-    }
-
-    /**
-     * Shutdown this cache manager instance. Will shutdown the underlying EHCache cache manager.
-     */
-    public void shutdown() {
-        try {
-            if(cacheManager.getStatus() == ComponentStatus.RUNNING) {
-                log.warn("shutting down cache manager ...");
-//                if(cacheManager.getTransport() != null) {
-//                    log.info("... shutting down transport ...");
-//                    cacheManager.getTransport().stop();
-//                }
-                log.info("... shutting down main component ...");
-                cacheManager.stop();
-                log.info("... done!");
-            }
-        } catch (CacheException ex) {
-            log.warn("error shutting down cache: {}", ex.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManagerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManagerFactory.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManagerFactory.java
deleted file mode 100644
index 13ffcfd..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/embedded/InfinispanEmbeddedCacheManagerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.embedded;
-
-import org.apache.marmotta.kiwi.caching.CacheManager;
-import org.apache.marmotta.kiwi.caching.CacheManagerFactory;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class InfinispanEmbeddedCacheManagerFactory implements CacheManagerFactory {
-
-    public InfinispanEmbeddedCacheManagerFactory() {
-    }
-
-    /**
-     * Create a new cache manager instance using the KiWiConfiguration passed as argument.
-     *
-     * @param configuration KiWi configuration used by the underlying triple store
-     * @return a new cache manager instance for this triple store
-     */
-    @Override
-    public CacheManager createCacheManager(KiWiConfiguration configuration) {
-        return new InfinispanEmbeddedCacheManager(configuration);
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BNodeExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BNodeExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BNodeExternalizer.java
deleted file mode 100644
index 6fd89a5..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BNodeExternalizer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class BNodeExternalizer implements AdvancedExternalizer<KiWiAnonResource> {
-
-
-    @Override
-    public Set<Class<? extends KiWiAnonResource>> getTypeClasses() {
-        return Util.<Class<? extends KiWiAnonResource>>asSet(KiWiAnonResource.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.BNODE;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiAnonResource object) throws IOException {
-        output.writeLong(object.getId());
-        output.writeInt(object.stringValue().length());
-        output.writeChars(object.stringValue());
-        output.writeLong(object.getCreated().getTime());
-    }
-
-    @Override
-    public KiWiAnonResource readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-        int len = input.readInt();
-
-        char[] anonId = new char[len];
-        for(int i=0; i<len; i++) {
-            anonId[i] = input.readChar();
-        }
-
-        Date created = new Date(input.readLong());
-
-        KiWiAnonResource r = new KiWiAnonResource(new String(anonId),created);
-        r.setId(id);
-
-        return r;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BooleanLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BooleanLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BooleanLiteralExternalizer.java
deleted file mode 100644
index ffb45d3..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/BooleanLiteralExternalizer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiBooleanLiteral;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class BooleanLiteralExternalizer implements AdvancedExternalizer<KiWiBooleanLiteral> {
-
-    @Override
-    public Set<Class<? extends KiWiBooleanLiteral>> getTypeClasses() {
-        return Util.<Class<? extends KiWiBooleanLiteral>>asSet(KiWiBooleanLiteral.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.BOOL_LITERAL;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiBooleanLiteral object) throws IOException {
-        output.writeLong(object.getId());
-        output.writeBoolean(object.booleanValue());
-        output.writeObject(object.getDatatype());
-
-        output.writeLong(object.getCreated().getTime());
-
-    }
-
-    @Override
-    public KiWiBooleanLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-        boolean content = input.readBoolean();
-
-        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
-
-        Date created = new Date(input.readLong());
-
-        KiWiBooleanLiteral r = new KiWiBooleanLiteral(content, dtype, created);
-        r.setId(id);
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DateLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DateLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DateLiteralExternalizer.java
deleted file mode 100644
index afe83a4..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DateLiteralExternalizer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiDateLiteral;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class DateLiteralExternalizer implements AdvancedExternalizer<KiWiDateLiteral> {
-
-    @Override
-    public Set<Class<? extends KiWiDateLiteral>> getTypeClasses() {
-        return Util.<Class<? extends KiWiDateLiteral>>asSet(KiWiDateLiteral.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.DATE_LITERAL;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiDateLiteral object) throws IOException {
-        output.writeLong(object.getId());
-        output.writeLong(object.getDateContent().getTime());
-        output.writeObject(object.getDatatype());
-
-        output.writeLong(object.getCreated().getTime());
-
-    }
-
-    @Override
-    public KiWiDateLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-        Date content = new Date(input.readLong());
-
-        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
-
-        Date created = new Date(input.readLong());
-
-        KiWiDateLiteral r = new KiWiDateLiteral(content, dtype, created);
-        r.setId(id);
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DoubleLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DoubleLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DoubleLiteralExternalizer.java
deleted file mode 100644
index d153998..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/DoubleLiteralExternalizer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiDoubleLiteral;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class DoubleLiteralExternalizer implements AdvancedExternalizer<KiWiDoubleLiteral> {
-
-    @Override
-    public Set<Class<? extends KiWiDoubleLiteral>> getTypeClasses() {
-        return Util.<Class<? extends KiWiDoubleLiteral>>asSet(KiWiDoubleLiteral.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.DOUBLE_LITERAL;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiDoubleLiteral object) throws IOException {
-        output.writeLong(object.getId());
-        output.writeDouble(object.getDoubleContent());
-        output.writeObject(object.getDatatype());
-
-        output.writeLong(object.getCreated().getTime());
-
-    }
-
-    @Override
-    public KiWiDoubleLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-        double content = input.readDouble();
-
-        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
-
-        Date created = new Date(input.readLong());
-
-        KiWiDoubleLiteral r = new KiWiDoubleLiteral(content, dtype, created);
-        r.setId(id);
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/ExternalizerIds.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/ExternalizerIds.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/ExternalizerIds.java
deleted file mode 100644
index 5be8cbe..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/ExternalizerIds.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class ExternalizerIds {
-
-    public static final int TRIPLE = 13;
-
-    public static final int URI = 17;
-
-    public static final int BNODE = 23;
-
-    public static final int STRING_LITERAL = 19;
-
-    public static final int INT_LITERAL = 39;
-
-    public static final int DOUBLE_LITERAL = 37;
-
-    public static final int DATE_LITERAL = 29;
-
-    public static final int BOOL_LITERAL = 31;
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/IntLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/IntLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/IntLiteralExternalizer.java
deleted file mode 100644
index da71798..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/IntLiteralExternalizer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiIntLiteral;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class IntLiteralExternalizer implements AdvancedExternalizer<KiWiIntLiteral> {
-
-    @Override
-    public Set<Class<? extends KiWiIntLiteral>> getTypeClasses() {
-        return Util.<Class<? extends KiWiIntLiteral>>asSet(KiWiIntLiteral.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.INT_LITERAL;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiIntLiteral object) throws IOException {
-        output.writeLong(object.getId());
-        output.writeLong(object.getIntContent());
-        output.writeObject(object.getDatatype());
-
-        output.writeLong(object.getCreated().getTime());
-
-    }
-
-    @Override
-    public KiWiIntLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-        long content = input.readLong();
-
-        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
-
-        Date created = new Date(input.readLong());
-
-        KiWiIntLiteral r = new KiWiIntLiteral(content, dtype, created);
-        r.setId(id);
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/StringLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/StringLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/StringLiteralExternalizer.java
deleted file mode 100644
index 178c76a..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/StringLiteralExternalizer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.commons.io.DataIO;
-import org.apache.marmotta.kiwi.model.rdf.KiWiStringLiteral;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class StringLiteralExternalizer implements AdvancedExternalizer<KiWiStringLiteral> {
-
-    @Override
-    public Set<Class<? extends KiWiStringLiteral>> getTypeClasses() {
-        return Util.<Class<? extends KiWiStringLiteral>>asSet(KiWiStringLiteral.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.STRING_LITERAL;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiStringLiteral object) throws IOException {
-        output.writeLong(object.getId());
-
-        DataIO.writeString(output, object.getContent());
-        DataIO.writeString(output, object.getLanguage());
-
-        output.writeObject(object.getDatatype());
-
-        output.writeLong(object.getCreated().getTime());
-
-    }
-
-    @Override
-    public KiWiStringLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-
-        String content = DataIO.readString(input);
-        String lang    = DataIO.readString(input);
-
-        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
-
-        Date created = new Date(input.readLong());
-
-        KiWiStringLiteral r = new KiWiStringLiteral(content, lang != null ? Locale.forLanguageTag(lang) : null, dtype, created);
-        r.setId(id);
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/TripleExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/TripleExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/TripleExternalizer.java
deleted file mode 100644
index 60793c1..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/TripleExternalizer.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.marmotta.commons.io.DataIO;
-import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
-import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
-import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * An externalizer for Infinispan allowing to more efficiently transport triples by only serializing the node
- * IDs instead of the whole nodes.
- */
-public class TripleExternalizer implements AdvancedExternalizer<KiWiTriple> {
-
-
-    public static final int MODE_DEFAULT = 1;
-    public static final int MODE_PREFIX  = 2;
-
-
-    @Override
-    public Set<Class<? extends KiWiTriple>> getTypeClasses() {
-        return Util.<Class<? extends KiWiTriple>>asSet(KiWiTriple.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.TRIPLE;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiTriple object) throws IOException {
-        output.writeLong(object.getId());
-
-        // in case subject and object are both uris we use a special prefix-compressed mode
-        if(object.getSubject().isUriResource() && object.getObject().isUriResource()) {
-            String sUri = object.getSubject().stringValue();
-            String oUri = object.getObject().stringValue();
-
-            String prefix = StringUtils.getCommonPrefix(sUri,oUri);
-
-            output.writeByte(MODE_PREFIX);
-            DataIO.writeString(output,prefix);
-
-            output.writeLong(object.getSubject().getId());
-            DataIO.writeString(output, sUri.substring(prefix.length()));
-            output.writeLong(object.getSubject().getCreated().getTime());
-
-            output.writeObject(object.getPredicate());
-
-            output.writeLong(object.getObject().getId());
-            DataIO.writeString(output, oUri.substring(prefix.length()));
-            output.writeLong(object.getObject().getCreated().getTime());
-        } else {
-            output.writeByte(MODE_DEFAULT);
-
-            output.writeObject(object.getSubject());
-            output.writeObject(object.getPredicate());
-            output.writeObject(object.getObject());
-        }
-
-        output.writeObject(object.getContext());
-        output.writeObject(object.getCreator());
-        output.writeBoolean(object.isDeleted());
-        output.writeBoolean(object.isInferred());
-        output.writeBoolean(object.isNewTriple());
-        output.writeLong(object.getCreated().getTime());
-        if(object.getDeletedAt() != null) {
-            output.writeLong(object.getDeletedAt().getTime());
-        } else {
-            output.writeLong(0);
-        }
-    }
-
-    @Override
-    public KiWiTriple readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-
-        KiWiTriple result = new KiWiTriple();
-        result.setId(input.readLong());
-
-        int mode = input.readByte();
-        if(mode == MODE_PREFIX) {
-            String prefix = DataIO.readString(input);
-
-            long sId = input.readLong();
-            String sUri = prefix + DataIO.readString(input);
-            long sTime = input.readLong();
-            KiWiUriResource s = new KiWiUriResource(sUri);
-            s.setId(sId);
-            s.setCreated(new Date(sTime));
-            result.setSubject(s);
-
-            result.setPredicate((KiWiUriResource) input.readObject());
-
-            long oId = input.readLong();
-            String oUri = prefix + DataIO.readString(input);
-            long oTime = input.readLong();
-            KiWiUriResource o = new KiWiUriResource(oUri);
-            o.setId(oId);
-            o.setCreated(new Date(oTime));
-            result.setObject(o);
-
-        } else {
-            result.setSubject((KiWiResource) input.readObject());
-            result.setPredicate((KiWiUriResource) input.readObject());
-            result.setObject((KiWiNode) input.readObject());
-        }
-        result.setContext((KiWiResource) input.readObject());
-        result.setCreator((KiWiResource) input.readObject());
-        result.setDeleted(input.readBoolean());
-        result.setInferred(input.readBoolean());
-        result.setNewTriple(input.readBoolean());
-
-        result.setCreated(new Date(input.readLong()));
-
-        long deletedAt = input.readLong();
-        if(deletedAt > 0) {
-            result.setDeletedAt(new Date(deletedAt));
-        }
-
-
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/UriExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/UriExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/UriExternalizer.java
deleted file mode 100644
index 3db4d4e..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/externalizer/UriExternalizer.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.marmotta.kiwi.externalizer;
-
-import org.apache.marmotta.commons.io.DataIO;
-import org.apache.marmotta.commons.vocabulary.XSD;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
-import org.infinispan.commons.marshall.AdvancedExternalizer;
-import org.infinispan.commons.util.Util;
-import org.openrdf.model.vocabulary.*;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class UriExternalizer implements AdvancedExternalizer<KiWiUriResource> {
-
-    private static final int PREFIX_UNKNOWN = 0;
-    private static final int PREFIX_XSD     = 1;
-    private static final int PREFIX_RDF     = 2;
-    private static final int PREFIX_RDFS    = 3;
-    private static final int PREFIX_SKOS    = 4;
-    private static final int PREFIX_DC      = 5;
-    private static final int PREFIX_DCT     = 6;
-    private static final int PREFIX_OWL     = 7;
-
-    @Override
-    public Set<Class<? extends KiWiUriResource>> getTypeClasses() {
-        return Util.<Class<? extends KiWiUriResource>>asSet(KiWiUriResource.class);
-    }
-
-    @Override
-    public Integer getId() {
-        return ExternalizerIds.URI;
-    }
-
-    @Override
-    public void writeObject(ObjectOutput output, KiWiUriResource object) throws IOException {
-        output.writeLong(object.getId());
-
-        // compression for commonly used constant prefixes
-        if(object.stringValue().startsWith(XSD.NAMESPACE)) {
-            output.writeByte(PREFIX_XSD);
-            DataIO.writeString(output, object.stringValue().substring(XSD.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(RDF.NAMESPACE)) {
-            output.writeByte(PREFIX_RDF);
-            DataIO.writeString(output, object.stringValue().substring(RDF.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(RDFS.NAMESPACE)) {
-            output.writeByte(PREFIX_RDFS);
-            DataIO.writeString(output, object.stringValue().substring(RDFS.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(SKOS.NAMESPACE)) {
-            output.writeByte(PREFIX_SKOS);
-            DataIO.writeString(output, object.stringValue().substring(SKOS.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(DC.NAMESPACE)) {
-            output.writeByte(PREFIX_DC);
-            DataIO.writeString(output, object.stringValue().substring(DC.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(DCTERMS.NAMESPACE)) {
-            output.writeByte(PREFIX_DCT);
-            DataIO.writeString(output, object.stringValue().substring(DCTERMS.NAMESPACE.length()));
-        } else if(object.stringValue().startsWith(OWL.NAMESPACE)) {
-            output.writeByte(PREFIX_OWL);
-            DataIO.writeString(output, object.stringValue().substring(OWL.NAMESPACE.length()));
-        } else {
-            output.writeByte(PREFIX_UNKNOWN);
-            DataIO.writeString(output, object.stringValue());
-        }
-
-        output.writeLong(object.getCreated().getTime());
-    }
-
-    @Override
-    public KiWiUriResource readObject(ObjectInput input) throws IOException, ClassNotFoundException {
-        long id = input.readLong();
-
-        int prefixMode = input.readByte();
-        String uriPrefix = "";
-        String uriSuffix = DataIO.readString(input);
-
-        switch (prefixMode) {
-            case PREFIX_XSD:
-                uriPrefix = XSD.NAMESPACE;
-                break;
-            case PREFIX_RDF:
-                uriPrefix = RDF.NAMESPACE;
-                break;
-            case PREFIX_RDFS:
-                uriPrefix = RDFS.NAMESPACE;
-                break;
-            case PREFIX_SKOS:
-                uriPrefix = SKOS.NAMESPACE;
-                break;
-            case PREFIX_DC:
-                uriPrefix = DC.NAMESPACE;
-                break;
-            case PREFIX_DCT:
-                uriPrefix = DCTERMS.NAMESPACE;
-                break;
-            case PREFIX_OWL:
-                uriPrefix = OWL.NAMESPACE;
-                break;
-            default:
-                uriPrefix = "";
-                break;
-        }
-
-        Date created = new Date(input.readLong());
-
-        KiWiUriResource r = new KiWiUriResource(uriPrefix + uriSuffix,created);
-        r.setId(id);
-
-        return r;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManager.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManager.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManager.java
new file mode 100644
index 0000000..5cf5953
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManager.java
@@ -0,0 +1,517 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.infinispan.embedded;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.kiwi.caching.CacheManager;
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.infinispan.externalizer.*;
+import org.infinispan.Cache;
+import org.infinispan.commons.CacheException;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.configuration.cache.CacheMode;
+import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.infinispan.configuration.global.GlobalConfiguration;
+import org.infinispan.configuration.global.GlobalConfigurationBuilder;
+import org.infinispan.context.Flag;
+import org.infinispan.distribution.ch.SyncConsistentHashFactory;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A class for managing the different caches that are used by the triple store.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class InfinispanEmbeddedCacheManager implements CacheManager {
+
+    private static Logger log = LoggerFactory.getLogger(InfinispanEmbeddedCacheManager.class);
+
+    public static final String NODE_CACHE = "node-cache";
+    public static final String TRIPLE_CACHE = "triple-cache";
+    public static final String URI_CACHE = "uri-cache";
+    public static final String BNODE_CACHE = "bnode-cache";
+    public static final String LITERAL_CACHE = "literal-cache";
+    public static final String NAMESPACE_URI_CACHE = "namespace-uri-cache";
+    public static final String NAMESPACE_PREFIX_CACHE = "namespace-prefix-cache";
+    public static final String LOADER_CACHE = "loader-cache";
+    public static final String REGISTRY_CACHE = "registry-cache";
+
+    private EmbeddedCacheManager cacheManager;
+
+    // default configuration: distributed cache, 100000 entries, 300 seconds expiration, 60 seconds idle
+    private Configuration defaultConfiguration;
+
+    private KiWiConfiguration config;
+
+    private Cache nodeCache, tripleCache, uriCache, literalCache, bnodeCache, nsPrefixCache, nsUriCache, registryCache;
+
+
+    /**
+     * Create a new cache manager with its own automatically created Infinispan instance.
+     *
+     * @param config
+     */
+    public InfinispanEmbeddedCacheManager(KiWiConfiguration config) {
+
+
+        this.config = config;
+
+        try {
+            switch (config.getCacheMode()) {
+                case DISTRIBUTED:
+                    buildDistributedConfiguration(getExternalizers());
+                    break;
+                case REPLICATED:
+                    buildReplicatedConfiguration(getExternalizers());
+                    break;
+                case LOCAL:
+                    buildLocalConfiguration();
+                    break;
+            }
+        } catch (IOException ex) {
+            log.warn("error while building cache cluster configuration, reverting to local cache");
+            buildLocalConfiguration();
+        }
+
+
+    }
+
+    /**
+     * Build a local cache configuration.
+     * <p/>
+     * In local cache mode, the cache is not shared among the servers in a cluster. Each machine keeps a local cache.
+     * This allows quick startups and eliminates network traffic in the cluster, but subsequent requests to different
+     * cluster members cannot benefit from the cached data.
+     */
+    protected void buildLocalConfiguration() {
+        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
+                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
+                .globalJmxStatistics()
+                    .jmxDomain("org.apache.marmotta.kiwi")
+                    .allowDuplicateDomains(true)
+                .build();
+
+        defaultConfiguration = new ConfigurationBuilder()
+                .clustering()
+                    .cacheMode(CacheMode.LOCAL)
+                .eviction()
+                    .strategy(EvictionStrategy.LIRS)
+                    .maxEntries(100000)
+                .expiration()
+                    .lifespan(5, TimeUnit.MINUTES)
+                    .maxIdle(1, TimeUnit.MINUTES)
+                .build();
+        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
+
+        log.info("initialised Infinispan local cache manager");
+    }
+
+    /**
+     * Build a distributed cache configuration.
+     * <p/>
+     * In distributed cache mode, the cluster forms a big hash table used as a cache. This allows to make efficient
+     * use of the large amount of memory available, but requires cache rebalancing and a lot of network transfers,
+     * especially in case cluster members are restarted often.
+     */
+    protected void buildDistributedConfiguration(AdvancedExternalizer...externalizers) throws IOException {
+        String jgroupsXml = IOUtils.toString(InfinispanEmbeddedCacheManager.class.getResourceAsStream("/jgroups-kiwi.xml"));
+
+        jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", config.getClusterAddress()));
+        jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", config.getClusterPort()));
+
+
+        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
+                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
+                .transport()
+                    .defaultTransport()
+                    .clusterName(config.getClusterName())
+                    .machineId("instance-" + config.getDatacenterId())
+                    .addProperty("configurationXml", jgroupsXml)
+                .globalJmxStatistics()
+                    .jmxDomain("org.apache.marmotta.kiwi")
+                    .allowDuplicateDomains(true)
+                .serialization()
+                    .addAdvancedExternalizer(externalizers)
+                .build();
+
+        defaultConfiguration = new ConfigurationBuilder()
+                .clustering()
+                    .cacheMode(CacheMode.DIST_ASYNC)
+                    .async()
+                        .asyncMarshalling()
+                    .l1()
+                        .lifespan(5, TimeUnit.MINUTES)
+                    .hash()
+                        .numOwners(2)
+                        .numSegments(40)
+                        .consistentHashFactory(new SyncConsistentHashFactory())
+                    .stateTransfer()
+                        .fetchInMemoryState(false)
+                .eviction()
+                    .strategy(EvictionStrategy.LIRS)
+                    .maxEntries(100000)
+                .expiration()
+                    .lifespan(30, TimeUnit.MINUTES)
+                    .maxIdle(10, TimeUnit.MINUTES)
+                .build();
+        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
+
+        log.info("initialised Infinispan distributed cache manager (cluster name: {})",  globalConfiguration.transport().clusterName());
+
+    }
+
+    /**
+     * Build a replicated cache configuration.
+     * <p/>
+     * In replicated cache mode, each node in the cluster has an identical copy of all cache data. This allows
+     * very efficient cache lookups and reduces the rebalancing effort, but requires more memory.
+     */
+    protected void buildReplicatedConfiguration(AdvancedExternalizer...externalizers) throws IOException {
+        String jgroupsXml = IOUtils.toString(InfinispanEmbeddedCacheManager.class.getResourceAsStream("/jgroups-kiwi.xml"));
+
+        jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", config.getClusterAddress()));
+        jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", config.getClusterPort()));
+
+
+        GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
+                .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
+                .transport()
+                    .defaultTransport()
+                    .clusterName(config.getClusterName())
+                    .machineId("instance-" + config.getDatacenterId())
+                    .addProperty("configurationXml", jgroupsXml)
+                .globalJmxStatistics()
+                    .jmxDomain("org.apache.marmotta.kiwi")
+                    .allowDuplicateDomains(true)
+                .serialization()
+                    .addAdvancedExternalizer(externalizers)
+                .build();
+
+        defaultConfiguration = new ConfigurationBuilder()
+                .clustering()
+                    .cacheMode(CacheMode.REPL_ASYNC)
+                    .async()
+                        .asyncMarshalling()
+                    .stateTransfer()
+                        .fetchInMemoryState(false)
+                .eviction()
+                    .strategy(EvictionStrategy.LIRS)
+                    .maxEntries(100000)
+                .expiration()
+                    .lifespan(30, TimeUnit.MINUTES)
+                    .maxIdle(10, TimeUnit.MINUTES)
+                .build();
+        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
+
+        log.info("initialised Infinispan replicated cache manager (cluster name: {})",  globalConfiguration.transport().clusterName());
+    }
+
+
+    protected boolean isClustered() {
+        return config.getCacheMode() == org.apache.marmotta.kiwi.config.CacheMode.DISTRIBUTED ||
+               config.getCacheMode() == org.apache.marmotta.kiwi.config.CacheMode.REPLICATED;
+    }
+
+
+    private AdvancedExternalizer[] getExternalizers() {
+        return new AdvancedExternalizer[] {
+                new TripleExternalizer(),
+                new UriExternalizer(),
+                new BNodeExternalizer(),
+                new StringLiteralExternalizer(),
+                new DateLiteralExternalizer(),
+                new BooleanLiteralExternalizer(),
+                new IntLiteralExternalizer(),
+                new DoubleLiteralExternalizer()
+        };
+    }
+
+    /**
+     * Return the node id -> node cache from the cache manager. This cache is heavily used to lookup
+     * nodes when querying or loading triples and should therefore have a decent size (default 500.000 elements).
+     *
+     * @return an EHCache Cache instance containing the node id -> node mappings
+     */
+    public Cache getNodeCache() {
+        if(nodeCache == null) {
+            Configuration nodeConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                    .eviction()
+                        .maxEntries(1000000)
+                    .expiration()
+                        .lifespan(60, TimeUnit.MINUTES)
+                        .maxIdle(30, TimeUnit.MINUTES)
+                    .build();
+            cacheManager.defineConfiguration(NODE_CACHE, nodeConfiguration);
+
+            nodeCache = cacheManager.getCache(NODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+
+        return nodeCache;
+    }
+
+    /**
+     * Return the triple id -> triple cache from the cache manager. This cache is used for speeding up the
+     * construction of query results.
+     *
+     * @return
+     */
+    public Cache getTripleCache() {
+        if(tripleCache == null) {
+            Configuration tripleConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                    .clustering()
+                        .cacheMode(CacheMode.LOCAL)
+                    .eviction()
+                        .maxEntries(config.getTripleCacheSize())
+                    .expiration()
+                        .lifespan(60, TimeUnit.MINUTES)
+                        .maxIdle(30, TimeUnit.MINUTES)
+                    .build();
+            cacheManager.defineConfiguration(TRIPLE_CACHE, tripleConfiguration);
+
+            tripleCache = cacheManager.getCache(TRIPLE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return tripleCache;
+    }
+
+
+    /**
+     * Return the uri -> KiWiUriResource cache from the cache manager. This cache is used when constructing new
+     * KiWiUriResources to avoid a database lookup.
+     *
+     * @return
+     */
+    public Cache getUriCache() {
+        if(uriCache == null) {
+            Configuration uriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                    .eviction()
+                        .maxEntries(config.getUriCacheSize())
+                    .build();
+            cacheManager.defineConfiguration(URI_CACHE, uriConfiguration);
+
+            uriCache = cacheManager.getCache(URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return uriCache;
+    }
+
+
+    /**
+     * Return the anonId -> KiWiAnonResource cache from the cache manager. This cache is used when constructing new
+     * KiWiAnonResources to avoid a database lookup.
+     *
+     * @return
+     */
+    public Cache getBNodeCache() {
+        if(bnodeCache == null) {
+            Configuration bnodeConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                    .eviction()
+                        .maxEntries(config.getBNodeCacheSize())
+                    .build();
+            cacheManager.defineConfiguration(BNODE_CACHE, bnodeConfiguration);
+
+            bnodeCache = cacheManager.getCache(BNODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return bnodeCache;
+    }
+
+    /**
+     * Return the literal cache key -> KiWiLiteral cache from the cache manager. This cache is used when constructing new
+     * KiWiLiterals to avoid a database lookup.
+     *
+     * @see org.apache.marmotta.commons.sesame.model.LiteralCommons#createCacheKey(String, java.util.Locale, String)
+     * @return
+     */
+    public Cache getLiteralCache() {
+        if(literalCache == null) {
+            Configuration literalConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                    .eviction()
+                        .maxEntries(config.getLiteralCacheSize())
+                    .build();
+            cacheManager.defineConfiguration(LITERAL_CACHE, literalConfiguration);
+
+            literalCache = cacheManager.getCache(LITERAL_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return literalCache;
+    }
+
+
+    /**
+     * Return the URI -> namespace cache from the cache manager. Used for looking up namespaces
+     * @return
+     */
+    public Cache getNamespaceUriCache() {
+        if(nsUriCache == null) {
+            if(isClustered()) {
+                Configuration nsuriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                        .clustering()
+                            .cacheMode(CacheMode.REPL_ASYNC)
+                        .eviction()
+                            .maxEntries(config.getNamespaceCacheSize())
+                        .expiration()
+                            .lifespan(1, TimeUnit.DAYS)
+                        .build();
+                cacheManager.defineConfiguration(NAMESPACE_URI_CACHE, nsuriConfiguration);
+            } else {
+                Configuration nsuriConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                        .eviction()
+                            .maxEntries(config.getNamespaceCacheSize())
+                        .expiration()
+                            .lifespan(1, TimeUnit.HOURS)
+                        .build();
+                cacheManager.defineConfiguration(NAMESPACE_URI_CACHE, nsuriConfiguration);
+            }
+
+            nsUriCache = cacheManager.getCache(NAMESPACE_URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return nsUriCache;
+    }
+
+    /**
+     * Return the prefix -> namespace cache from the cache manager. Used for looking up namespaces
+     * @return
+     */
+    public Cache getNamespacePrefixCache() {
+        if(nsPrefixCache == null) {
+            if(isClustered()) {
+                Configuration nsprefixConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                        .clustering()
+                            .cacheMode(CacheMode.REPL_ASYNC)
+                        .eviction()
+                            .maxEntries(config.getNamespaceCacheSize())
+                        .expiration()
+                            .lifespan(1, TimeUnit.DAYS)
+                        .build();
+                cacheManager.defineConfiguration(NAMESPACE_PREFIX_CACHE, nsprefixConfiguration);
+
+            } else {
+                Configuration nsprefixConfiguration = new ConfigurationBuilder().read(defaultConfiguration)
+                        .eviction()
+                            .maxEntries(config.getNamespaceCacheSize())
+                        .expiration()
+                            .lifespan(1, TimeUnit.HOURS)
+                        .build();
+                cacheManager.defineConfiguration(NAMESPACE_PREFIX_CACHE, nsprefixConfiguration);
+
+            }
+            nsPrefixCache = cacheManager.getCache(NAMESPACE_PREFIX_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return nsPrefixCache;
+    }
+
+
+
+
+    /**
+     * Create and return the cache used by the CacheTripleRegistry. This is an unlimited synchronous replicated
+     * cache and should be used with care.
+     * @return
+     */
+    public Cache getRegistryCache() {
+        if(registryCache == null) {
+            if(isClustered()) {
+                Configuration registryConfiguration = new ConfigurationBuilder()
+                    .clustering()
+                        .cacheMode(CacheMode.REPL_SYNC)
+                        .sync()
+                            .replTimeout(15, TimeUnit.SECONDS)
+                    .eviction()
+                        .strategy(EvictionStrategy.NONE)
+                    .build();
+                cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration);
+            } else {
+                Configuration registryConfiguration = new ConfigurationBuilder()
+                    .clustering()
+                        .cacheMode(CacheMode.LOCAL)
+                    .eviction()
+                        .strategy(EvictionStrategy.NONE)
+                    .build();
+                cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration);
+            }
+
+            registryCache = cacheManager.getCache(REGISTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+        return registryCache;
+    }
+
+    /**
+     * Get the cache with the given name from the cache manager. Can be used to request additional
+     * caches from the cache manager that are not covered by explicit methods.
+     *
+     * @param name
+     * @return
+     */
+    public synchronized Cache getCacheByName(String name) {
+        if(!cacheManager.cacheExists(name)) {
+            cacheManager.defineConfiguration(name, new ConfigurationBuilder().read(defaultConfiguration).build());
+        }
+        return cacheManager.getCache(name).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+
+    }
+
+    /**
+     * Clear all caches managed by this cache manager.
+     */
+    public void clear() {
+        Set<String> set =  cacheManager.getCacheNames();
+        Iterator<String> iterator =  set.iterator();
+        while(iterator.hasNext()){
+            String cacheName = iterator.next();
+            Cache<String,Object> cache = cacheManager.getCache(cacheName);
+            cache.clear();
+        }
+
+        nodeCache     = null;
+        tripleCache   = null;
+        uriCache      = null;
+        literalCache  = null;
+        bnodeCache    = null;
+        nsPrefixCache = null;
+        nsUriCache    = null;
+        registryCache = null;
+    }
+
+    /**
+     * Shutdown this cache manager instance. Will shutdown the underlying EHCache cache manager.
+     */
+    public void shutdown() {
+        try {
+            if(cacheManager.getStatus() == ComponentStatus.RUNNING) {
+                log.warn("shutting down cache manager ...");
+//                if(cacheManager.getTransport() != null) {
+//                    log.info("... shutting down transport ...");
+//                    cacheManager.getTransport().stop();
+//                }
+                log.info("... shutting down main component ...");
+                cacheManager.stop();
+                log.info("... done!");
+            }
+        } catch (CacheException ex) {
+            log.warn("error shutting down cache: {}", ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManagerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManagerFactory.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManagerFactory.java
new file mode 100644
index 0000000..f3aa8cb
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/embedded/InfinispanEmbeddedCacheManagerFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.kiwi.infinispan.embedded;
+
+import org.apache.marmotta.kiwi.caching.CacheManager;
+import org.apache.marmotta.kiwi.caching.CacheManagerFactory;
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class InfinispanEmbeddedCacheManagerFactory implements CacheManagerFactory {
+
+    public InfinispanEmbeddedCacheManagerFactory() {
+    }
+
+    /**
+     * Create a new cache manager instance using the KiWiConfiguration passed as argument.
+     *
+     * @param configuration KiWi configuration used by the underlying triple store
+     * @return a new cache manager instance for this triple store
+     */
+    @Override
+    public CacheManager createCacheManager(KiWiConfiguration configuration) {
+        return new InfinispanEmbeddedCacheManager(configuration);
+    }
+}