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/17 11:23:14 UTC
[23/32] git commit: start cleaning up the modules that depend on KiWi
so they do not depend on a specific caching backend
start cleaning up the modules that depend on KiWi so they do not depend on a specific caching backend
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/766bef0a
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/766bef0a
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/766bef0a
Branch: refs/heads/develop
Commit: 766bef0a758e7e766cd57336eb6c68aa67e1c1b6
Parents: 673b4f9
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Wed Mar 5 13:22:43 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Wed Mar 5 13:22:43 2014 +0100
----------------------------------------------------------------------
.../kiwi/test/cluster/HazelcastClusterTest.java | 4 +-
.../HazelcastRepositoryConnectionTest.java | 4 +-
.../test/cluster/HazelcastRepositoryTest.java | 4 +-
.../remote/InfinispanRemoteCacheManager.java | 1 +
.../kiwi/test/embedded/EmbeddedClusterTest.java | 4 +-
.../EmbeddedRepositoryConnectionTest.java | 4 +-
.../test/embedded/EmbeddedRepositoryTest.java | 4 +-
.../kiwi/test/remote/HotRodClusterTest.java | 4 +-
.../kiwi/test/remote/HotRodPersistenceTest.java | 4 +-
.../remote/HotRodRepositoryConnectionTest.java | 6 +-
.../kiwi/test/remote/HotRodRepositoryTest.java | 4 +-
.../marmotta/kiwi/config/CacheManagerType.java | 58 ------
.../marmotta/kiwi/config/CachingBackends.java | 58 ++++++
.../marmotta/kiwi/config/KiWiConfiguration.java | 10 +-
.../kiwi/persistence/KiWiPersistence.java | 4 +-
.../kiwi/test/cluster/BaseClusterTest.java | 8 +-
libraries/kiwi/pom.xml | 4 +-
.../platform/backend/kiwi/KiWiOptions.java | 51 +++++
.../backend/kiwi/KiWiStoreProvider.java | 116 +++++------
.../main/resources/config-defaults.properties | 12 +-
.../resources/config-descriptions.properties | 31 ++-
platform/marmotta-core/pom.xml | 11 --
.../platform/core/api/cache/CachingService.java | 32 +++-
.../platform/core/model/config/CoreOptions.java | 36 ++++
.../core/services/cache/CachingServiceImpl.java | 192 +++----------------
.../config/ConfigurationServiceImpl.java | 69 +++----
.../services/http/HttpClientServiceImpl.java | 19 +-
.../modules/MarmottaResourceServiceImpl.java | 4 +-
.../core/startup/MarmottaStartupService.java | 33 ++--
.../main/resources/config-defaults.properties | 10 +-
.../resources/config-descriptions.properties | 29 +--
.../user/services/AccountServiceImpl.java | 4 +-
32 files changed, 374 insertions(+), 460 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/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 5cbbe7f..1683541 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.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.junit.BeforeClass;
/**
@@ -30,7 +30,7 @@ public class HazelcastClusterTest extends BaseClusterTest {
@BeforeClass
public static void setup() {
- ClusterTestSupport s = new ClusterTestSupport(CacheManagerType.HAZELCAST);
+ ClusterTestSupport s = new ClusterTestSupport(CachingBackends.HAZELCAST);
s.setup();
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryConnectionTest.java b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryConnectionTest.java
index ef75821..7b0be4b 100644
--- a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryConnectionTest.java
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryConnectionTest.java
@@ -17,8 +17,8 @@
package org.apache.marmotta.kiwi.test.cluster;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.config.CacheMode;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -44,7 +44,7 @@ public class HazelcastRepositoryConnectionTest extends RepositoryConnectionTest
config.setClustered(false);
config.setClusterPort(61222);
config.setCacheMode(CacheMode.DISTRIBUTED);
- config.setCacheManager(CacheManagerType.HAZELCAST);
+ config.setCachingBackend(CachingBackends.HAZELCAST);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryTest.java b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryTest.java
index 3b080ef..b686d77 100644
--- a/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryTest.java
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/test/java/org/apache/marmotta/kiwi/test/cluster/HazelcastRepositoryTest.java
@@ -17,8 +17,8 @@
package org.apache.marmotta.kiwi.test.cluster;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.config.CacheMode;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -44,7 +44,7 @@ public class HazelcastRepositoryTest extends RepositoryTest {
config.setClustered(true);
config.setClusterPort(61222);
config.setCacheMode(CacheMode.DISTRIBUTED);
- config.setCacheManager(CacheManagerType.HAZELCAST);
+ config.setCachingBackend(CachingBackends.HAZELCAST);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java
index 8455fdd..5fb6a67 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java
@@ -55,6 +55,7 @@ public class InfinispanRemoteCacheManager implements CacheManager {
.port(configuration.getClusterPort())
.marshaller(new CustomJBossMarshaller())
.socketTimeout(configuration.getClusterTimeout())
+ .connectionTimeout(configuration.getClusterTimeout())
.build();
cacheManager = new RemoteCacheManager(remoteCfg);
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedClusterTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedClusterTest.java
index 7405e0f..cfd61eb 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedClusterTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedClusterTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test.embedded;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.test.cluster.BaseClusterTest;
import org.junit.BeforeClass;
@@ -31,7 +31,7 @@ public class EmbeddedClusterTest extends BaseClusterTest {
@BeforeClass
public static void setup() {
- ClusterTestSupport s = new ClusterTestSupport(CacheManagerType.INFINISPAN_CLUSTERED);
+ ClusterTestSupport s = new ClusterTestSupport(CachingBackends.INFINISPAN_CLUSTERED);
s.setup();
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryConnectionTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryConnectionTest.java
index 8fffa88..910d16f 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryConnectionTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryConnectionTest.java
@@ -17,8 +17,8 @@
package org.apache.marmotta.kiwi.test.embedded;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.config.CacheMode;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -45,7 +45,7 @@ public class EmbeddedRepositoryConnectionTest extends RepositoryConnectionTest {
config.setClusterPort(61222);
config.setCacheMode(CacheMode.LOCAL);
config.setClusterTimeout(10000);
- config.setCacheManager(CacheManagerType.INFINISPAN_CLUSTERED);
+ config.setCachingBackend(CachingBackends.INFINISPAN_CLUSTERED);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryTest.java
index 3796d68..acb51a7 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/embedded/EmbeddedRepositoryTest.java
@@ -17,8 +17,8 @@
package org.apache.marmotta.kiwi.test.embedded;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.config.CacheMode;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -45,7 +45,7 @@ public class EmbeddedRepositoryTest extends RepositoryTest {
config.setClusterPort(61222);
config.setCacheMode(CacheMode.LOCAL);
config.setClusterTimeout(10000);
- config.setCacheManager(CacheManagerType.INFINISPAN_CLUSTERED);
+ config.setCachingBackend(CachingBackends.INFINISPAN_CLUSTERED);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodClusterTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodClusterTest.java
index 3f4fa2a..14544c3 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodClusterTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodClusterTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test.remote;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.test.cluster.BaseClusterTest;
import org.junit.BeforeClass;
@@ -46,7 +46,7 @@ public class HotRodClusterTest extends BaseClusterTest {
@BeforeClass
public static void setup() {
- ClusterTestSupport s = new ClusterTestSupport(CacheManagerType.INFINISPAN_HOTROD);
+ ClusterTestSupport s = new ClusterTestSupport(CachingBackends.INFINISPAN_HOTROD);
KiWiConfiguration base = s.buildBaseConfiguration();
base.setClusterAddress("127.0.0.1");
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodPersistenceTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodPersistenceTest.java
index 406fa9c..61ad5fc 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodPersistenceTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodPersistenceTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test.remote;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.test.PersistenceTest;
import org.junit.ClassRule;
@@ -37,6 +37,6 @@ public class HotRodPersistenceTest extends PersistenceTest {
kiwiConfig.setClusterAddress("127.0.0.1");
kiwiConfig.setClusterPort(61222);
- kiwiConfig.setCacheManager(CacheManagerType.INFINISPAN_HOTROD);
+ kiwiConfig.setCachingBackend(CachingBackends.INFINISPAN_HOTROD);
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryConnectionTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryConnectionTest.java
index 7890df0..b28c79b 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryConnectionTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryConnectionTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test.remote;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -47,8 +47,8 @@ public class HotRodRepositoryConnectionTest extends RepositoryConnectionTest {
config.setClusterAddress("127.0.0.1");
config.setClustered(true);
config.setClusterPort(61222);
- config.setClusterTimeout(10000);
- config.setCacheManager(CacheManagerType.INFINISPAN_HOTROD);
+ config.setClusterTimeout(1000);
+ config.setCachingBackend(CachingBackends.INFINISPAN_HOTROD);
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryTest.java
index a026114..26ab7d6 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/remote/HotRodRepositoryTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test.remote;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -49,7 +49,7 @@ public class HotRodRepositoryTest extends RepositoryTest {
config.setClustered(true);
config.setClusterPort(61222);
config.setClusterTimeout(10000);
- config.setCacheManager(CacheManagerType.INFINISPAN_HOTROD);
+ config.setCachingBackend(CachingBackends.INFINISPAN_HOTROD);
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CacheManagerType.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CacheManagerType.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CacheManagerType.java
deleted file mode 100644
index 783a79d..0000000
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CacheManagerType.java
+++ /dev/null
@@ -1,58 +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.config;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public enum CacheManagerType {
-
- /**
- * Simple in-memory cache backend using the Guava library; no clustering support
- */
- GUAVA("org.apache.marmotta.kiwi.caching.GuavaCacheManagerFactory"),
-
- /**
- * Cache backend based on Infinispan using a dynamic cluster setup (UDP multicast)
- */
- INFINISPAN_CLUSTERED("org.apache.marmotta.kiwi.infinispan.embedded.InfinispanEmbeddedCacheManagerFactory"),
-
- /**
- * Cache backend based on Infinispan using a client-server setup (Hotrod)
- */
- INFINISPAN_HOTROD("org.apache.marmotta.kiwi.infinispan.remote.InfinispanRemoteCacheManagerFactory"),
-
-
- /**
- * Cache backend based on Hazelcast using a dynamic cluster setup
- */
- HAZELCAST("org.apache.marmotta.kiwi.hazelcast.caching.HazelcastCacheManagerFactory");
-
-
- CacheManagerType(String factoryClass) {
- this.factoryClass = factoryClass;
- }
-
- private String factoryClass;
-
- public String getFactoryClass() {
- return factoryClass;
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CachingBackends.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CachingBackends.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CachingBackends.java
new file mode 100644
index 0000000..9698259
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CachingBackends.java
@@ -0,0 +1,58 @@
+/*
+ * 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.config;
+
+/**
+ * Enumeration of the different caching backends currently supported
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public enum CachingBackends {
+
+ /**
+ * Simple in-memory cache backend using the Guava library; no clustering support
+ */
+ GUAVA("org.apache.marmotta.kiwi.caching.GuavaCacheManagerFactory"),
+
+ /**
+ * Cache backend based on Infinispan using a dynamic cluster setup (UDP multicast)
+ */
+ INFINISPAN_CLUSTERED("org.apache.marmotta.kiwi.infinispan.embedded.InfinispanEmbeddedCacheManagerFactory"),
+
+ /**
+ * Cache backend based on Infinispan using a client-server setup (Hotrod)
+ */
+ INFINISPAN_HOTROD("org.apache.marmotta.kiwi.infinispan.remote.InfinispanRemoteCacheManagerFactory"),
+
+
+ /**
+ * Cache backend based on Hazelcast using a dynamic cluster setup
+ */
+ HAZELCAST("org.apache.marmotta.kiwi.hazelcast.caching.HazelcastCacheManagerFactory");
+
+
+ CachingBackends(String factoryClass) {
+ this.factoryClass = factoryClass;
+ }
+
+ private String factoryClass;
+
+ public String getFactoryClass() {
+ return factoryClass;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/KiWiConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/KiWiConfiguration.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/KiWiConfiguration.java
index 6cf8ab4..0e1ce3f 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/KiWiConfiguration.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/KiWiConfiguration.java
@@ -95,7 +95,7 @@ public class KiWiConfiguration {
* Fully qualified class name of the cache manager factory to use. Falls back to the Guava
* cache manager if not found
*/
- private CacheManagerType cacheManager = CacheManagerType.GUAVA;
+ private CachingBackends cachingBackend = CachingBackends.GUAVA;
private int nodeCacheSize = 1000000;
@@ -306,16 +306,16 @@ public class KiWiConfiguration {
* Fully qualified class name of the cache manager factory to use. Falls back to the Guava
* cache manager if not found
*/
- public CacheManagerType getCacheManager() {
- return cacheManager;
+ public CachingBackends getCachingBackend() {
+ return cachingBackend;
}
/**
* Fully qualified class name of the cache manager factory to use. Falls back to the Guava
* cache manager if not found
*/
- public void setCacheManager(CacheManagerType cacheManager) {
- this.cacheManager = cacheManager;
+ public void setCachingBackend(CachingBackends cachingBackend) {
+ this.cachingBackend = cachingBackend;
}
/**
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
index 54e60a9..be4536e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
@@ -131,10 +131,10 @@ public class KiWiPersistence {
private void initCachePool() {
try {
- Class factory = Class.forName(configuration.getCacheManager().getFactoryClass());
+ Class factory = Class.forName(configuration.getCachingBackend().getFactoryClass());
cacheManager = ((CacheManagerFactory)factory.newInstance()).createCacheManager(configuration);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
- log.warn("cache manager factory {} not found on classpath (error: {}); falling back to Guava in-memory cache backend!", configuration.getCacheManager(), e.getMessage());
+ log.warn("cache manager factory {} not found on classpath (error: {}); falling back to Guava in-memory cache backend!", configuration.getCachingBackend(), e.getMessage());
CacheManagerFactory factory = new GuavaCacheManagerFactory();
cacheManager = factory.createCacheManager(configuration);
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/cluster/BaseClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/cluster/BaseClusterTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/cluster/BaseClusterTest.java
index d5f7e16..939ba30 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/cluster/BaseClusterTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/cluster/BaseClusterTest.java
@@ -18,7 +18,7 @@
package org.apache.marmotta.kiwi.test.cluster;
import org.apache.marmotta.kiwi.caching.CacheManager;
-import org.apache.marmotta.kiwi.config.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource;
import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
@@ -159,9 +159,9 @@ public abstract class BaseClusterTest {
protected static class ClusterTestSupport {
- CacheManagerType type;
+ CachingBackends type;
- public ClusterTestSupport(CacheManagerType type) {
+ public ClusterTestSupport(CachingBackends type) {
this.type = type;
}
@@ -205,7 +205,7 @@ public abstract class BaseClusterTest {
}
config.setDatacenterId(datacenterIds++);
config.setClustered(true);
- config.setCacheManager(type);
+ config.setCachingBackend(type);
config.setClusterPort(port);
KiWiStore store = new KiWiStore(config);
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/libraries/kiwi/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/pom.xml b/libraries/kiwi/pom.xml
index f47b8de..034464a 100644
--- a/libraries/kiwi/pom.xml
+++ b/libraries/kiwi/pom.xml
@@ -44,12 +44,12 @@
<configuration>
<systemPropertyVariables>
<!-- enable or pass on command line for testing local PostgreSQL -->
- <postgresql.url>jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</postgresql.url>
+ <postgresql.url>jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3&socketTimeout=2</postgresql.url>
<postgresql.user>lmf</postgresql.user>
<postgresql.pass>lmf</postgresql.pass>
<!-- enable or pass on command line for testing local MySQL -->
- <mysql.url>jdbc:mysql://localhost:3306/kiwitest</mysql.url>
+ <mysql.url>jdbc:mysql://localhost:3306/kiwitest?socketTimeout=2000</mysql.url>
<mysql.user>lmf</mysql.user>
<mysql.pass>lmf</mysql.pass>
</systemPropertyVariables>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiOptions.java
----------------------------------------------------------------------
diff --git a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiOptions.java b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiOptions.java
new file mode 100644
index 0000000..c9eff98
--- /dev/null
+++ b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiOptions.java
@@ -0,0 +1,51 @@
+/*
+ * 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.platform.backend.kiwi;
+
+/**
+ * Class with static constants for configuration options.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class KiWiOptions {
+ public static final String SPARQL_STRATEGY = "sparql.strategy";
+ public static final String DATACENTER_ID = "database.datacenter.id";
+ public static final String FULLTEXT_ENABLED = "database.fulltext.enabled";
+ public static final String FULLTEXT_LANGUAGES = "database.fulltext.languages";
+ public static final String DEBUG_SLOWQUERIES = "database.debug.slowqueries";
+ public static final String CLUSTERING_ENABLED = "clustering.enabled";
+ public static final String CACHING_LITERAL_SIZE = "caching.literal.size";
+ public static final String CACHING_BNODE_SIZE = "caching.bnode.size";
+ public static final String CACHING_URI_SIZE = "caching.uri.size";
+ public static final String CACHING_TRIPLE_SIZE = "caching.triple.size";
+ public static final String CLUSTERING_NAME = "clustering.name";
+ public static final String CACHING_QUERY_ENABLED = "caching.query.enabled";
+ public static final String CONTEXTS_DEFAULT = "contexts.default";
+ public static final String CONTEXTS_INFERRED = "contexts.inferred";
+ public static final String CLUSTERING_PORT = "clustering.port";
+ public static final String CLUSTERING_ADDRESS = "clustering.address";
+
+ public static final String DATABASE_URL = "database.url";
+ public static final String DATABASE_USER = "database.user";
+ public static final String DATABASE_PASSWORD = "database.password";
+
+ public static final String TRIPLES_BATCHCOMMIT = "database.triples.batchcommit";
+ public static final String TRIPLES_BATCHSIZE = "database.triples.batchsize";
+ public static final String CLUSTERING_BACKEND = "clustering.backend";
+ public static final String CLUSTERING_MODE = "clustering.mode";
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
----------------------------------------------------------------------
diff --git a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
index 29cc2b0..2091b0e 100644
--- a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
+++ b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
@@ -18,6 +18,8 @@
package org.apache.marmotta.platform.backend.kiwi;
import com.google.common.collect.ImmutableList;
+import org.apache.marmotta.kiwi.config.CacheMode;
+import org.apache.marmotta.kiwi.config.CachingBackends;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.exception.DriverNotFoundException;
import org.apache.marmotta.kiwi.persistence.KiWiDialect;
@@ -30,7 +32,6 @@ import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.api.triplestore.SesameService;
import org.apache.marmotta.platform.core.api.triplestore.StoreProvider;
import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
-import org.infinispan.manager.EmbeddedCacheManager;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.NotifyingSail;
import org.openrdf.sail.Sail;
@@ -60,25 +61,6 @@ import javax.inject.Inject;
@ApplicationScoped
public class KiWiStoreProvider implements StoreProvider {
- public static final String SPARQL_STRATEGY = "sparql.strategy";
- public static final String DATACENTER_ID = "database.datacenter.id";
- public static final String FULLTEXT_ENABLED = "database.fulltext.enabled";
- public static final String FULLTEXT_LANGUAGES = "database.fulltext.languages";
- public static final String DEBUG_SLOWQUERIES = "database.debug.slowqueries";
- public static final String CLUSTERING_ENABLED = "clustering.enabled";
- public static final String CACHING_LITERAL_SIZE = "caching.literal.size";
- public static final String CACHING_BNODE_SIZE = "caching.bnode.size";
- public static final String CACHING_URI_SIZE = "caching.uri.size";
- public static final String CACHING_TRIPLE_SIZE = "caching.triple.size";
- public static final String CLUSTERING_NAME = "clustering.name";
- public static final String CACHING_QUERY_ENABLED = "caching.query.enabled";
- public static final String CACHING_QUERY_SIZE = "caching.query.size";
- public static final String CACHING_QUERY_LIMIT = "caching.query.limit";
- public static final String CONTEXTS_DEFAULT = "contexts.default";
- public static final String CONTEXTS_INFERRED = "contexts.inferred";
- public static final String CLUSTERING_PORT = "clustering.port";
- public static final String CLUSTERING_ADDRESS = "clustering.address";
-
@Inject
private Logger log;
@@ -89,9 +71,6 @@ public class KiWiStoreProvider implements StoreProvider {
private SesameService sesameService;
- @Inject
- private EmbeddedCacheManager cacheManager;
-
/**
* Create the store provided by this SailProvider
*
@@ -117,44 +96,37 @@ public class KiWiStoreProvider implements StoreProvider {
throw dnf;
}
- String jdbcUrl = configurationService.getStringConfiguration("database.url");
- String dbUser = configurationService.getStringConfiguration("database.user");
- String dbPass = configurationService.getStringConfiguration("database.password");
-
- KiWiConfiguration configuration = new KiWiConfiguration(configurationService.getStringConfiguration(CLUSTERING_NAME, "Marmotta") + " KiWi", jdbcUrl, dbUser, dbPass, dialect, configurationService.getDefaultContext(), configurationService.getInferredContext());
- configuration.setQueryLoggingEnabled(configurationService.getBooleanConfiguration(DEBUG_SLOWQUERIES, false));
- configuration.setTripleBatchCommit(configurationService.getBooleanConfiguration("database.triples.batchcommit", true));
- configuration.setTripleBatchSize(configurationService.getIntConfiguration("database.triples.batchsize", 10000));
-
- configuration.setDatacenterId(configurationService.getIntConfiguration(DATACENTER_ID,0));
- configuration.setFulltextEnabled(configurationService.getBooleanConfiguration(FULLTEXT_ENABLED, true));
- configuration.setFulltextLanguages(configurationService.getListConfiguration(FULLTEXT_LANGUAGES, ImmutableList.of("en")));
-
- configuration.setClustered(configurationService.getBooleanConfiguration(CLUSTERING_ENABLED, false));
- configuration.setClusterName(configurationService.getStringConfiguration(CLUSTERING_NAME, "Marmotta"));
-
- configuration.setLiteralCacheSize(configurationService.getIntConfiguration(CACHING_LITERAL_SIZE, 100000));
- configuration.setBNodeCacheSize(configurationService.getIntConfiguration(CACHING_BNODE_SIZE, 10000));
- configuration.setUriCacheSize(configurationService.getIntConfiguration(CACHING_URI_SIZE, 500000));
- configuration.setTripleCacheSize(configurationService.getIntConfiguration(CACHING_TRIPLE_SIZE, 100000));
-
- configuration.setClusterPort(configurationService.getIntConfiguration(CLUSTERING_PORT, 46655));
- configuration.setClusterAddress(configurationService.getStringConfiguration(CLUSTERING_ADDRESS, "228.6.7.8"));
-
- NotifyingSail base = new KiWiStore(configuration, cacheManager);
-
- /*
- if(configurationService.getBooleanConfiguration(CACHING_QUERY_ENABLED,true)) {
- log.info(" - enabling query caching support");
- KiWiQueryCacheConfiguration qcfg = new KiWiQueryCacheConfiguration();
- qcfg.setMaxCacheSize(configurationService.getIntConfiguration(CACHING_QUERY_SIZE, 100000));
- qcfg.setMaxEntrySize(configurationService.getIntConfiguration(CACHING_QUERY_LIMIT, 150));
- base = new KiWiCachingSail(base, qcfg);
- }
- */
+ String jdbcUrl = configurationService.getStringConfiguration(KiWiOptions.DATABASE_URL);
+ String dbUser = configurationService.getStringConfiguration(KiWiOptions.DATABASE_USER);
+ String dbPass = configurationService.getStringConfiguration(KiWiOptions.DATABASE_PASSWORD);
+
+ KiWiConfiguration configuration = new KiWiConfiguration(configurationService.getStringConfiguration(KiWiOptions.CLUSTERING_NAME, "Marmotta") + " KiWi", jdbcUrl, dbUser, dbPass, dialect, configurationService.getDefaultContext(), configurationService.getInferredContext());
+ configuration.setQueryLoggingEnabled(configurationService.getBooleanConfiguration(KiWiOptions.DEBUG_SLOWQUERIES, false));
+ configuration.setTripleBatchCommit(configurationService.getBooleanConfiguration(KiWiOptions.TRIPLES_BATCHCOMMIT, true));
+ configuration.setTripleBatchSize(configurationService.getIntConfiguration(KiWiOptions.TRIPLES_BATCHSIZE, 10000));
+
+ configuration.setDatacenterId(configurationService.getIntConfiguration(KiWiOptions.DATACENTER_ID,0));
+ configuration.setFulltextEnabled(configurationService.getBooleanConfiguration(KiWiOptions.FULLTEXT_ENABLED, true));
+ configuration.setFulltextLanguages(configurationService.getListConfiguration(KiWiOptions.FULLTEXT_LANGUAGES, ImmutableList.of("en")));
+
+ configuration.setClustered(configurationService.getBooleanConfiguration(KiWiOptions.CLUSTERING_ENABLED, false));
+ configuration.setClusterName(configurationService.getStringConfiguration(KiWiOptions.CLUSTERING_NAME, "Marmotta"));
+
+ configuration.setLiteralCacheSize(configurationService.getIntConfiguration(KiWiOptions.CACHING_LITERAL_SIZE, 100000));
+ configuration.setBNodeCacheSize(configurationService.getIntConfiguration(KiWiOptions.CACHING_BNODE_SIZE, 10000));
+ configuration.setUriCacheSize(configurationService.getIntConfiguration(KiWiOptions.CACHING_URI_SIZE, 500000));
+ configuration.setTripleCacheSize(configurationService.getIntConfiguration(KiWiOptions.CACHING_TRIPLE_SIZE, 100000));
+
+ configuration.setClusterPort(configurationService.getIntConfiguration(KiWiOptions.CLUSTERING_PORT, 46655));
+ configuration.setClusterAddress(configurationService.getStringConfiguration(KiWiOptions.CLUSTERING_ADDRESS, "228.6.7.8"));
+
+ configuration.setCachingBackend(CachingBackends.valueOf(configurationService.getStringConfiguration(KiWiOptions.CLUSTERING_BACKEND, "GUAVA")));
+ configuration.setCacheMode(CacheMode.valueOf(configurationService.getStringConfiguration(KiWiOptions.CLUSTERING_MODE,"LOCAL")));
+
+ NotifyingSail base = new KiWiStore(configuration);
- if("native".equalsIgnoreCase(configurationService.getStringConfiguration(SPARQL_STRATEGY))) {
+ if("native".equalsIgnoreCase(configurationService.getStringConfiguration(KiWiOptions.SPARQL_STRATEGY))) {
log.info(" - enabling native SPARQL support");
base = new KiWiSparqlSail(base);
}
@@ -196,19 +168,19 @@ public class KiWiStoreProvider implements StoreProvider {
public void configurationChanged(@Observes ConfigurationChangedEvent e) {
log.info("configuration changed: {}", e.getKeys());
- if(e.containsChangedKey(SPARQL_STRATEGY) ||
- e.containsChangedKey(DATACENTER_ID) ||
- e.containsChangedKey(CONTEXTS_DEFAULT) ||
- e.containsChangedKey(CONTEXTS_INFERRED) ||
- e.containsChangedKey(FULLTEXT_ENABLED) ||
- e.containsChangedKey(FULLTEXT_LANGUAGES) ||
- e.containsChangedKey(DEBUG_SLOWQUERIES) ||
- e.containsChangedKey(CLUSTERING_ENABLED) ||
- e.containsChangedKey(CACHING_LITERAL_SIZE) ||
- e.containsChangedKey(CACHING_TRIPLE_SIZE) ||
- e.containsChangedKey(CACHING_URI_SIZE) ||
- e.containsChangedKey(CACHING_BNODE_SIZE) ||
- e.containsChangedKey(CACHING_QUERY_ENABLED)
+ if(e.containsChangedKey(KiWiOptions.SPARQL_STRATEGY) ||
+ e.containsChangedKey(KiWiOptions.DATACENTER_ID) ||
+ e.containsChangedKey(KiWiOptions.CONTEXTS_DEFAULT) ||
+ e.containsChangedKey(KiWiOptions.CONTEXTS_INFERRED) ||
+ e.containsChangedKey(KiWiOptions.FULLTEXT_ENABLED) ||
+ e.containsChangedKey(KiWiOptions.FULLTEXT_LANGUAGES) ||
+ e.containsChangedKey(KiWiOptions.DEBUG_SLOWQUERIES) ||
+ e.containsChangedKey(KiWiOptions.CLUSTERING_ENABLED) ||
+ e.containsChangedKey(KiWiOptions.CACHING_LITERAL_SIZE) ||
+ e.containsChangedKey(KiWiOptions.CACHING_TRIPLE_SIZE) ||
+ e.containsChangedKey(KiWiOptions.CACHING_URI_SIZE) ||
+ e.containsChangedKey(KiWiOptions.CACHING_BNODE_SIZE) ||
+ e.containsChangedKey(KiWiOptions.CACHING_QUERY_ENABLED)
) {
log.info("KiWi backend configuration changed, re-initialising triple store");
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-defaults.properties b/platform/backends/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
index 7fdbb11..0e33673 100644
--- a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
+++ b/platform/backends/marmotta-backend-kiwi/src/main/resources/config-defaults.properties
@@ -74,10 +74,12 @@ caching.uri.size = 500000
caching.bnode.size = 10000
caching.triple.size = 100000
-caching.query.enabled = true
-caching.query.limit = 150
-caching.query.size = 100000
-
-
+# Turn on cluster-specific configuration options (e.g. replicated and distributed caching, synchronization, ...)
+clustering.enabled = false
+clustering.name = Marmotta
+clustering.mode = REPLICATED
+clustering.address = 228.6.7.8
+clustering.port = 46655
+clustering.backend = GUAVA
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
----------------------------------------------------------------------
diff --git a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties b/platform/backends/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
index b2394e9..3cb207b 100644
--- a/platform/backends/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
+++ b/platform/backends/marmotta-backend-kiwi/src/main/resources/config-descriptions.properties
@@ -64,10 +64,29 @@ caching.bnode.size.type = java.lang.Integer(10|0|*)
caching.triple.size.description = size of triple lookup cache
caching.triple.size.type = java.lang.Integer(10|0|*)
-caching.query.enabled.description = enable query caching (performance improvement but requires more memory)
-caching.query.enabled.type = java.lang.Boolean
-caching.query.size.description = size of query cache
-caching.query.size.type = java.lang.Integer(10|0|*)
-caching.query.limit.description = maximum result size to cache
-caching.query.limit.type = java.lang.Integer(10|0|*)
+clustering.enabled.description = Turn on cluster-specific configuration options (e.g. replicated and distributed caching, synchronization, ...)
+clustering.enabled.type = java.lang.Boolean
+
+clustering.name.description = Cluster name to use in cluster configuration (e.g. cache cluster name)
+clustering.name.type = java.lang.String
+
+clustering.mode.description = Set the cache mode for the KiWi triple store. The following cluster modes are available: \
+ LOCAL: 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. \
+ DISTRIBUTED: 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. \
+ REPLICATED: 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.
+clustering.mode.type = java.lang.Enum("LOCAL"|"DISTRIBUTED"|"REPLICATED")
+
+clustering.address.description = Set the address used for sending UDP multicast packages in the cluster or the name of the remote server
+clustering.address.type = java.lang.String
+
+clustering.port.description = Set the port used for sending UDP multicast packages in the cluster or the port on the remote server
+clustering.port.type = java.lang.Integer(1|1024|65535)
+
+clustering.backend.description = Caching backend used by KiWi (either Guava, Infinispan Cluster, Infinispan Hotrod, Hazelcast or EHCache)
+clustering.backend.type = java.lang.enum("GUAVA","INFINISPAN_CLUSTER","INFINISPAN_HOTROD", "HAZELCAST", "EHCACHE")
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/pom.xml b/platform/marmotta-core/pom.xml
index 3c2bb95..85030fe 100644
--- a/platform/marmotta-core/pom.xml
+++ b/platform/marmotta-core/pom.xml
@@ -335,17 +335,6 @@
<artifactId>marmotta-client-js</artifactId>
</dependency>
- <!-- Persistence -->
- <dependency>
- <groupId>org.infinispan</groupId>
- <artifactId>infinispan-core</artifactId>
- </dependency>
- <!-- TODO: we still use our own CDI implementation here...
- <dependency>
- <groupId>org.infinispan</groupId>
- <artifactId>infinispan-cdi</artifactId>
- </dependency>
- -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/cache/CachingService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/cache/CachingService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/cache/CachingService.java
index 00cb18f..e405d0c 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/cache/CachingService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/cache/CachingService.java
@@ -17,28 +17,44 @@
*/
package org.apache.marmotta.platform.core.api.cache;
-import org.infinispan.Cache;
-import org.infinispan.manager.EmbeddedCacheManager;
-
import javax.enterprise.inject.spi.InjectionPoint;
import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
/**
- * Add file description here!
+ * Simple caching functionality for the Marmotta Platform modules. Note that the KiWi triplestore (and other
+ * triple stores) come with their own custom caching implementations.
* <p/>
* User: sschaffe
*/
public interface CachingService {
+ /**
+ * Inject a cache at the given injection point. Creates a new cache if needed.
+ *
+ * @param injectionPoint
+ * @return
+ */
+ public ConcurrentMap getCache(InjectionPoint injectionPoint);
- public Cache getCache(InjectionPoint injectionPoint);
-
+ /**
+ * Return the names of all caches registered in the caching service
+ * @return
+ */
public Set<String> getCacheNames();
+ /**
+ * Clear all caches registered in the caching service
+ */
public void clearAll();
- public Cache getCacheByName(String cacheName);
+ /**
+ * Get the cache with the given name. Creates a new cache if needed.
+ *
+ * @param cacheName
+ * @return
+ */
+ public ConcurrentMap getCacheByName(String cacheName);
- public EmbeddedCacheManager getCacheManager();
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/config/CoreOptions.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/config/CoreOptions.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/config/CoreOptions.java
new file mode 100644
index 0000000..38c7a2b
--- /dev/null
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/model/config/CoreOptions.java
@@ -0,0 +1,36 @@
+/*
+ * 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.platform.core.model.config;
+
+/**
+ * Class with static constants for configuration options
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class CoreOptions {
+ public static final String BASE_URI = "kiwi.context";
+ public static final String SERVER_URI = "kiwi.host";
+
+ public static final String CACHING_EXPIRATION = "caching.expiration";
+ public static final String CACHING_MAXIMUM_SIZE = "caching.maximum_size";
+
+ // HTTP connection service
+ public static final String HTTP_MAX_CONNECTIONS = "core.http.max_connections";
+ public static final String HTTP_MAX_CONNECTIONS_PER_ROUTE = "core.http.max_connections_per_route";
+ public static final String HTTP_CLIENT_CACHE_ENABLE = "core.http.client_cache_enable";
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/cache/CachingServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/cache/CachingServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/cache/CachingServiceImpl.java
index f53cdc6..3498e69 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/cache/CachingServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/cache/CachingServiceImpl.java
@@ -17,23 +17,13 @@
*/
package org.apache.marmotta.platform.core.services.cache;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
import org.apache.marmotta.platform.core.api.cache.CachingService;
import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.events.SystemRestartingEvent;
+import org.apache.marmotta.platform.core.model.config.CoreOptions;
import org.apache.marmotta.platform.core.qualifiers.cache.MarmottaCache;
-import org.infinispan.Cache;
-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.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 javax.annotation.PostConstruct;
@@ -43,9 +33,10 @@ import javax.enterprise.event.Observes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
-import java.io.IOException;
-import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
/**
@@ -56,11 +47,6 @@ import java.util.concurrent.TimeUnit;
@ApplicationScoped
public class CachingServiceImpl implements CachingService {
- public static final String CLUSTERING_PORT = "clustering.port";
- public static final String CLUSTERING_ADDRESS = "clustering.address";
- public static final String CLUSTERING_ENABLED = "clustering.enabled";
- public static final String CLUSTERING_MODE = "clustering.mode";
-
/**
* Get the seam logger for issuing logging statements.
*/
@@ -70,12 +56,8 @@ public class CachingServiceImpl implements CachingService {
@Inject
private ConfigurationService configurationService;
- private EmbeddedCacheManager cacheManager;
-
- private GlobalConfiguration globalConfiguration;
- // default configuration: distributed cache, 100000 entries, 300 seconds expiration, 60 seconds idle
- private Configuration defaultConfiguration;
+ private Map<String,Cache> caches;
public CachingServiceImpl() {
@@ -84,158 +66,53 @@ public class CachingServiceImpl implements CachingService {
@PostConstruct
public void initialize() {
- boolean clustered = configurationService.getBooleanConfiguration(CLUSTERING_ENABLED, false);
- String cacheMode = configurationService.getStringConfiguration(CLUSTERING_MODE,"replicated");
-
-
- log.info("Apache Marmotta Caching Service starting up ({}) ...", clustered ? "cluster name: " + configurationService.getStringConfiguration("clustering.name", "Marmotta") : "single host" );
- if(clustered && (StringUtils.equalsIgnoreCase(cacheMode,"replicated") || StringUtils.equalsIgnoreCase(cacheMode, "distributed"))) {
-
- try {
- String jgroupsXml = IOUtils.toString(CachingService.class.getResourceAsStream("/jgroups-marmotta.xml"));
-
- jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", configurationService.getStringConfiguration(CLUSTERING_ADDRESS, "228.6.7.8")));
- jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", configurationService.getIntConfiguration(CLUSTERING_PORT, 46655)));
-
- globalConfiguration = new GlobalConfigurationBuilder()
- .transport()
- .defaultTransport()
- .clusterName(configurationService.getStringConfiguration("clustering.name", "Marmotta"))
- .machineId(configurationService.getServerName())
- .addProperty("configurationXml", jgroupsXml)
- .globalJmxStatistics()
- .jmxDomain("org.apache.marmotta.platform")
- .allowDuplicateDomains(true)
- .build();
- } catch (IOException ex) {
- log.warn("error loading JGroups configuration from archive: {}", ex.getMessage());
- log.warn("some configuration options will not be available");
-
- globalConfiguration = new GlobalConfigurationBuilder()
- .transport()
- .defaultTransport()
- .clusterName(configurationService.getStringConfiguration("clustering.name", "Marmotta"))
- .machineId(configurationService.getServerName())
- .addProperty("configurationFile", "jgroups-marmotta.xml")
- .globalJmxStatistics()
- .jmxDomain("org.apache.marmotta.platform")
- .allowDuplicateDomains(true)
- .build();
- }
-
-
- if(StringUtils.equalsIgnoreCase(cacheMode, "distributed")) {
- 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();
- } else {
- 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();
- }
- } else {
- globalConfiguration = new GlobalConfigurationBuilder()
- .globalJmxStatistics()
- .jmxDomain("org.apache.marmotta.platform")
- .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 cache manager ({})", globalConfiguration.isClustered() ? "cluster name: "+globalConfiguration.transport().clusterName() : "single host");
+ caches = new HashMap<>();
}
/**
* Return the cache with the name provided to the KiWiCache annotation of the injection.
- *
- *
+ *
+ *
* Usage: <code><pre>
* @Inject @KiWiCache("cache-name")
* private Ehcache cache;
* </pre></code>
- *
- *
+ *
+ *
* @param injectionPoint
* @return
*/
@Override
@Produces @MarmottaCache("")
- public Cache getCache(InjectionPoint injectionPoint) {
+ public ConcurrentMap getCache(InjectionPoint injectionPoint) {
String cacheName = injectionPoint.getAnnotated().getAnnotation(MarmottaCache.class).value();
return getCacheByName(cacheName);
}
- /**
- * Allow CDI injection of the default cache
- * @return
- */
- @Produces
- public Configuration getDefaultConfiguration() {
- return defaultConfiguration;
- }
-
@Override
- public Cache getCacheByName(String cacheName) {
- return cacheManager.getCache(cacheName, true);
+ public ConcurrentMap getCacheByName(String cacheName) {
+ synchronized (caches) {
+ if(!caches.containsKey(cacheName)) {
+ Cache c = CacheBuilder.newBuilder()
+ .expireAfterAccess(configurationService.getIntConfiguration(CoreOptions.CACHING_EXPIRATION,30), TimeUnit.MINUTES)
+ .maximumSize(configurationService.getLongConfiguration(CoreOptions.CACHING_MAXIMUM_SIZE,10000L))
+ .build();
+ caches.put(cacheName,c);
+ }
+ }
+
+ return caches.get(cacheName).asMap();
}
@Override
public Set<String> getCacheNames() {
- return cacheManager.getCacheNames();
+ return caches.keySet();
}
- @Override
- @Produces
- @ApplicationScoped
- public EmbeddedCacheManager getCacheManager() {
- return cacheManager;
- }
/**
@@ -244,31 +121,20 @@ public class CachingServiceImpl implements CachingService {
*/
public void systemRestart(@Observes SystemRestartingEvent e) {
log.warn("system restarted, flushing caches ...");
- cacheManager.stop();
- cacheManager.start();
+ caches.clear();
}
@Override
public void clearAll() {
- 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();
- }
+ caches.clear();
}
@PreDestroy
public void destroy() {
log.info("Apache Marmotta Caching Service shutting down ...");
- if(cacheManager.getStatus() == ComponentStatus.RUNNING) {
- log.info("- shutting down Infinispan cache manager ...");
- cacheManager.stop();
- log.info(" ... success!");
- }
+ caches.clear();
log.info("Apache Marmotta Caching Service shut down successfully.");
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
index 152ebbf..416d9c4 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
@@ -17,6 +17,29 @@
*/
package org.apache.marmotta.platform.core.services.config;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.commons.configuration.*;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.marmotta.platform.core.api.config.ConfigurationService;
+import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
+import org.apache.marmotta.platform.core.events.ConfigurationServiceInitEvent;
+import org.apache.marmotta.platform.core.events.LoggingStartEvent;
+import org.apache.marmotta.platform.core.model.config.CoreOptions;
+import org.apache.marmotta.platform.core.util.FallbackConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.servlet.ServletContext;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
@@ -26,53 +49,13 @@ import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
+import java.util.*;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.inject.Inject;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.servlet.ServletContext;
-
-import org.apache.commons.configuration.AbstractConfiguration;
-import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.MapConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
-import org.apache.marmotta.platform.core.events.ConfigurationServiceInitEvent;
-import org.apache.marmotta.platform.core.events.LoggingStartEvent;
-import org.apache.marmotta.platform.core.util.FallbackConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-
/**
* This service offers access to the system configuration of the LMF and takes care of initialising the system
* properly on startup.
@@ -417,7 +400,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
@Override
public String getBaseUri() {
- return getStringConfiguration("kiwi.context");
+ return getStringConfiguration(CoreOptions.BASE_URI);
}
/**
@@ -440,7 +423,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
*/
@Override
public String getServerUri() {
- String serverUrl = getStringConfiguration("kiwi.host");
+ String serverUrl = getStringConfiguration(CoreOptions.SERVER_URI);
if (serverUrl.endsWith("/"))
return serverUrl;
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/http/HttpClientServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/http/HttpClientServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/http/HttpClientServiceImpl.java
index 7d27576..94258f3 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/http/HttpClientServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/http/HttpClientServiceImpl.java
@@ -50,11 +50,11 @@ import org.apache.marmotta.platform.core.api.statistics.StatisticsService;
import org.apache.marmotta.platform.core.api.task.Task;
import org.apache.marmotta.platform.core.api.task.TaskManagerService;
import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
+import org.apache.marmotta.platform.core.model.config.CoreOptions;
import org.apache.marmotta.platform.core.qualifiers.cache.MarmottaCache;
import org.apache.marmotta.platform.core.services.http.response.LastModifiedResponseHandler;
import org.apache.marmotta.platform.core.services.http.response.StatusCodeResponseHandler;
import org.apache.marmotta.platform.core.services.http.response.StringBodyResponseHandler;
-import org.infinispan.Cache;
import org.slf4j.Logger;
import javax.annotation.PostConstruct;
@@ -68,6 +68,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -101,7 +102,7 @@ public class HttpClientServiceImpl implements HttpClientService {
@Inject
@MarmottaCache("http-client-cache")
- private Cache httpCache;
+ private ConcurrentMap httpCache;
private HttpClient httpClient;
private IdleConnectionMonitorThread idleConnectionMonitorThread;
@@ -293,8 +294,8 @@ public class HttpClientServiceImpl implements HttpClientService {
schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
- cm.setMaxTotal(configurationService.getIntConfiguration("core.http.max_connections", 20));
- cm.setDefaultMaxPerRoute(configurationService.getIntConfiguration("core.http.max_connections_per_route", 10));
+ cm.setMaxTotal(configurationService.getIntConfiguration(CoreOptions.HTTP_MAX_CONNECTIONS, 20));
+ cm.setDefaultMaxPerRoute(configurationService.getIntConfiguration(CoreOptions.HTTP_MAX_CONNECTIONS_PER_ROUTE, 10));
final DefaultHttpClient hc = new DefaultHttpClient(cm, httpParams);
hc.setRedirectStrategy(new LMFRedirectStrategy());
@@ -302,13 +303,13 @@ public class HttpClientServiceImpl implements HttpClientService {
hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);
hc.addRequestInterceptor(new LMFRequestUserAgent(userAgentString));
- if (configurationService.getBooleanConfiguration("core.http.client_cache_enable", true)) {
+ if (configurationService.getBooleanConfiguration(CoreOptions.HTTP_CLIENT_CACHE_ENABLE, true)) {
CacheConfig cacheConfig = new CacheConfig();
// FIXME: Hardcoded constants - is this useful?
cacheConfig.setMaxCacheEntries(1000);
cacheConfig.setMaxObjectSize(81920);
- final HttpCacheStorage cacheStore = new InfinispanHttpCacheStorage(httpCache);
+ final HttpCacheStorage cacheStore = new MapHttpCacheStorage(httpCache);
this.httpClient = new MonitoredHttpClient(new CachingHttpClient(hc, cacheStore, cacheConfig));
} else {
@@ -809,14 +810,14 @@ public class HttpClientServiceImpl implements HttpClientService {
- private static class InfinispanHttpCacheStorage implements HttpCacheStorage {
+ private static class MapHttpCacheStorage implements HttpCacheStorage {
- Cache<String, byte[]> cache;
+ ConcurrentMap<String, byte[]> cache;
private final HttpCacheEntrySerializer serializer;
- private InfinispanHttpCacheStorage(Cache<String, byte[]> cache) {
+ private MapHttpCacheStorage(ConcurrentMap<String, byte[]> cache) {
this.cache = cache;
this.serializer = new DefaultHttpCacheEntrySerializer();
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/MarmottaResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/MarmottaResourceServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/MarmottaResourceServiceImpl.java
index 0b837e1..480f541 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/MarmottaResourceServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/MarmottaResourceServiceImpl.java
@@ -27,7 +27,6 @@ import org.apache.marmotta.platform.core.api.modules.ResourceEntry;
import org.apache.marmotta.platform.core.events.SystemStartupEvent;
import org.apache.marmotta.platform.core.model.module.ModuleConfiguration;
import org.apache.marmotta.platform.core.qualifiers.cache.MarmottaCache;
-import org.infinispan.Cache;
import org.slf4j.Logger;
import javax.annotation.PostConstruct;
@@ -39,6 +38,7 @@ import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
/**
* A service for resolving and accessing resources contained in the Apache Marmotta modules. The resource service takes care
@@ -64,7 +64,7 @@ public class MarmottaResourceServiceImpl implements MarmottaResourceService {
@Inject @MarmottaCache("resource-cache")
- private Cache resourceCache;
+ private ConcurrentMap resourceCache;
/**
* Used for detecting the mime type of resources contained in KiWi modules
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/startup/MarmottaStartupService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/startup/MarmottaStartupService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/startup/MarmottaStartupService.java
index 07bc0cc..6929501 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/startup/MarmottaStartupService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/startup/MarmottaStartupService.java
@@ -17,18 +17,8 @@
*/
package org.apache.marmotta.platform.core.startup;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
-
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang3.StringUtils;
import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.api.modules.ModuleService;
import org.apache.marmotta.platform.core.api.triplestore.SesameService;
@@ -36,14 +26,23 @@ import org.apache.marmotta.platform.core.api.ui.MarmottaSystrayLink;
import org.apache.marmotta.platform.core.api.user.UserService;
import org.apache.marmotta.platform.core.events.SesameStartupEvent;
import org.apache.marmotta.platform.core.events.SystemStartupEvent;
+import org.apache.marmotta.platform.core.model.config.CoreOptions;
import org.apache.marmotta.platform.core.model.module.ModuleConfiguration;
import org.apache.marmotta.platform.core.util.CDIContext;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+
/**
* This service unifies the different steps in the Apache Marmotta startup. It offers several methods
* for triggering the different startup sequences and can be used e.g. by web applications or
@@ -231,8 +230,8 @@ public class MarmottaStartupService {
if(!isSetup) {
log.info("SETUP: Setting up initial host and resource configuration ({}) ...", hostUrl);
- configurationService.setConfiguration("kiwi.context", contextUrl);
- configurationService.setConfiguration("kiwi.host", hostUrl);
+ configurationService.setConfiguration(CoreOptions.BASE_URI, contextUrl);
+ configurationService.setConfiguration(CoreOptions.SERVER_URI, hostUrl);
configurationService.setConfiguration("kiwi.setup.host", true);
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/config-defaults.properties b/platform/marmotta-core/src/main/resources/config-defaults.properties
index 4ac724d..a6cbad2 100644
--- a/platform/marmotta-core/src/main/resources/config-defaults.properties
+++ b/platform/marmotta-core/src/main/resources/config-defaults.properties
@@ -199,13 +199,9 @@ contexts.inferred = ${kiwi.context}context/inferred
###############################################################################
-# Clustering Configuration
+# Clustering/Caching Configuration
###############################################################################
+caching.maximum_size = 10000
+caching.expiration = 30
-# Turn on cluster-specific configuration options (e.g. replicated and distributed caching, synchronization, ...)
-clustering.enabled = false
-clustering.name = Marmotta
-clustering.mode = REPLICATED
-clustering.address = 228.6.7.8
-clustering.port = 46655
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-core/src/main/resources/config-descriptions.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/config-descriptions.properties b/platform/marmotta-core/src/main/resources/config-descriptions.properties
index 0599619..b9ffa57 100644
--- a/platform/marmotta-core/src/main/resources/config-descriptions.properties
+++ b/platform/marmotta-core/src/main/resources/config-descriptions.properties
@@ -160,30 +160,13 @@ statistics.enabled.type = java.lang.Boolean
-clustering.enabled.description = Turn on cluster-specific configuration options (e.g. replicated and distributed caching, synchronization, ...)
-clustering.enabled.type = java.lang.Boolean
-
-clustering.name.description = Cluster name to use in cluster configuration (e.g. cache cluster name)
-clustering.name.type = java.lang.String
-
-clustering.mode.description = Set the cache mode for this KiWi triple store. The following cluster modes are available: \
- LOCAL: 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. \
- DISTRIBUTED: 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. \
- REPLICATED: 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.
-clustering.mode.type = java.lang.Enum("LOCAL"|"DISTRIBUTED"|"REPLICATED")
-
-clustering.address.description = Set the address used for sending UDP multicast packages in the cluster
-clustering.address.type = java.lang.String
-
-clustering.port.description = Set the port used for sending UDP multicast packages in the cluster
-clustering.port.type = java.lang.Integer(1|1024|65535)
-
contexts.default.description = Default context to use for triples in case no explicit context selected (may be empty)
contexts.default.type = java.lang.String
contexts.inferred.description = Context to use for storing triples inferred automatically be the reasoner (may not be empty)
contexts.inferred.type = java.lang.String
+
+
+caching.maximum_size.description = Maximum number of entries for in-memory caches used by the Marmotta Platform
+caching.maximum_size.type = java.lang.Integer(1|1000|10000000)
+caching.expiration.description = Maximum minutes of inactivity before a cache entry expires from the in-memory caches
+caching.expiration.type = java.lang.Integer(1|5|1440)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/766bef0a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/services/AccountServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/services/AccountServiceImpl.java b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/services/AccountServiceImpl.java
index 90b502e..1cd0128 100644
--- a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/services/AccountServiceImpl.java
+++ b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/services/AccountServiceImpl.java
@@ -30,7 +30,6 @@ import org.apache.marmotta.platform.core.qualifiers.cache.MarmottaCache;
import org.apache.marmotta.platform.user.api.AccountService;
import org.apache.marmotta.platform.user.model.UserAccount;
import org.apache.marmotta.platform.user.model.UserAccount.PasswordHash;
-import org.infinispan.Cache;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.slf4j.Logger;
@@ -43,6 +42,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
@ApplicationScoped
public class AccountServiceImpl implements AccountService {
@@ -58,7 +58,7 @@ public class AccountServiceImpl implements AccountService {
@Inject
@MarmottaCache("user-cache")
- private Cache userCache;
+ private ConcurrentMap userCache;
private PasswordHash hashAlgo;