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:26 UTC
[11/21] - hotrod serialization with custom JBoss Marshaller
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BNodeExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BNodeExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BNodeExternalizer.java
new file mode 100644
index 0000000..4bcaf40
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BNodeExternalizer.java
@@ -0,0 +1,74 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiAnonResource> 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/infinispan/externalizer/BaseExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BaseExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BaseExternalizer.java
new file mode 100644
index 0000000..8f15a09
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BaseExternalizer.java
@@ -0,0 +1,80 @@
+/*
+ * 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.externalizer;
+
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.jboss.marshalling.Creator;
+import org.jboss.marshalling.Externalizer;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Base class merging the functionality from JBoss Marshalling and JBoss Infinispan for externalizers
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public abstract class BaseExternalizer<T> implements Externalizer, AdvancedExternalizer<T> {
+
+
+ /**
+ * Write the external representation of an object. The object's class and the externalizer's class will
+ * already have been written.
+ *
+ * @param subject the object to externalize
+ * @param output the output
+ * @throws java.io.IOException if an error occurs
+ */
+ @Override
+ public void writeExternal(Object subject, ObjectOutput output) throws IOException {
+ writeObject(output, (T)subject);
+ }
+
+ /**
+ * Create an instance of a type. The object may then be initialized from {@code input}, or that may be deferred
+ * to the {@code readExternal()} method. Instances may simply delegate the task to the given {@code Creator}.
+ * Note that this method is called only on the leaf class, so externalizers for non-final classes that initialize
+ * the instance from the stream need to be aware of this.
+ *
+ * @param subjectType the type of object to create
+ * @param input the input
+ * @param defaultCreator the configured creator
+ * @return the new instance
+ * @throws java.io.IOException if an error occurs
+ * @throws ClassNotFoundException if a class could not be found during read
+ */
+ @Override
+ public Object createExternal(Class<?> subjectType, ObjectInput input, Creator defaultCreator) throws IOException, ClassNotFoundException {
+ return readObject(input);
+ }
+
+ /**
+ * Read the external representation of an object. The object will already be instantiated, but may be uninitialized, when
+ * this method is called.
+ *
+ * @param subject the object to read
+ * @param input the input
+ * @throws java.io.IOException if an error occurs
+ * @throws ClassNotFoundException if a class could not be found during read
+ */
+ @Override
+ public void readExternal(Object subject, ObjectInput input) throws IOException, ClassNotFoundException {
+ // no-op
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BooleanLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BooleanLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BooleanLiteralExternalizer.java
new file mode 100644
index 0000000..73793bf
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/BooleanLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiBooleanLiteral> 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/infinispan/externalizer/DateLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DateLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DateLiteralExternalizer.java
new file mode 100644
index 0000000..532d70e
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DateLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiDateLiteral> 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/infinispan/externalizer/DoubleLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DoubleLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DoubleLiteralExternalizer.java
new file mode 100644
index 0000000..66b40f9
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/DoubleLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiDoubleLiteral> 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/infinispan/externalizer/ExternalizerIds.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/ExternalizerIds.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/ExternalizerIds.java
new file mode 100644
index 0000000..eced367
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/ExternalizerIds.java
@@ -0,0 +1,43 @@
+/*
+ * 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.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/infinispan/externalizer/IntLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/IntLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/IntLiteralExternalizer.java
new file mode 100644
index 0000000..3f2052a
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/IntLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiIntLiteral> 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/infinispan/externalizer/StringLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/StringLiteralExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/StringLiteralExternalizer.java
new file mode 100644
index 0000000..015698c
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/StringLiteralExternalizer.java
@@ -0,0 +1,79 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiStringLiteral> 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/infinispan/externalizer/TripleExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/TripleExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/TripleExternalizer.java
new file mode 100644
index 0000000..562475d
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/TripleExternalizer.java
@@ -0,0 +1,149 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiTriple> 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/infinispan/externalizer/UriExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/UriExternalizer.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/UriExternalizer.java
new file mode 100644
index 0000000..cfd9dc2
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/externalizer/UriExternalizer.java
@@ -0,0 +1,136 @@
+/*
+ * 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.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 extends BaseExternalizer<KiWiUriResource> 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/remote/CustomClassExternalizerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassExternalizerFactory.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassExternalizerFactory.java
new file mode 100644
index 0000000..d68bda5
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassExternalizerFactory.java
@@ -0,0 +1,70 @@
+/*
+ * 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.remote;
+
+import org.apache.marmotta.kiwi.infinispan.externalizer.*;
+import org.jboss.marshalling.ClassExternalizerFactory;
+import org.jboss.marshalling.Externalizer;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class CustomClassExternalizerFactory implements ClassExternalizerFactory {
+
+ Map<Class<?>,Externalizer> externalizers = new HashMap<>();
+
+ public CustomClassExternalizerFactory() {
+
+ addExternalizer(new UriExternalizer());
+ addExternalizer(new BNodeExternalizer());
+ addExternalizer(new BooleanLiteralExternalizer());
+ addExternalizer(new DateLiteralExternalizer());
+ addExternalizer(new DoubleLiteralExternalizer());
+ addExternalizer(new IntLiteralExternalizer());
+ addExternalizer(new StringLiteralExternalizer());
+ addExternalizer(new TripleExternalizer());
+
+ }
+
+ private void addExternalizer(BaseExternalizer e) {
+ for(Class c : (Set <Class>)e.getTypeClasses()) {
+ externalizers.put(c,e);
+ }
+ }
+
+ /**
+ * Look up a custom externalizer for a given object class. If no such externalizer exists, returns {@code null}.
+ *
+ * @param type the type to be externalized
+ * @return the externalizer, or {@code null} if there is none
+ */
+ @Override
+ public Externalizer getExternalizer(Class<?> type) {
+ if(externalizers.containsKey(type)) {
+ return externalizers.get(type);
+ } else {
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassTable.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassTable.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassTable.java
new file mode 100644
index 0000000..05d9283
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomClassTable.java
@@ -0,0 +1,113 @@
+/*
+ * 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.remote;
+
+import org.apache.marmotta.kiwi.infinispan.externalizer.*;
+import org.jboss.marshalling.ClassTable;
+import org.jboss.marshalling.Marshaller;
+import org.jboss.marshalling.Unmarshaller;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A custom class table to allow for efficient serialization and deserialization of KiWi triple store objects
+ * and their externalizers.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class CustomClassTable implements ClassTable {
+
+ Writer writer;
+
+ Map<Integer,Class> classLookup;
+ Map<Class,Integer> idLookup;
+
+
+ public CustomClassTable() {
+ classLookup = new HashMap<>();
+ idLookup = new HashMap<>();
+
+ register(new BNodeExternalizer());
+ register(new BooleanLiteralExternalizer());
+ register(new DateLiteralExternalizer());
+ register(new DoubleLiteralExternalizer());
+ register(new IntLiteralExternalizer());
+ register(new StringLiteralExternalizer());
+ register(new TripleExternalizer());
+ register(new UriExternalizer());
+
+ classLookup.put(11, BaseExternalizer.class);
+ idLookup.put(BaseExternalizer.class,11);
+
+ writer = new Writer() {
+ @Override
+ public void writeClass(Marshaller marshaller, Class<?> clazz) throws IOException {
+ marshaller.writeByte((byte) ((int)idLookup.get(clazz)));
+ }
+ };
+
+ }
+
+ private void register(BaseExternalizer e) {
+ // for each externalizer, we register the externalizer itself using its own ID, as well as the type managed
+ // by this externalizer using its ID+1 (we anyways use prime numbers for ids, so this is safe)
+
+ classLookup.put(e.getId(), e.getClass());
+ idLookup.put(e.getClass(), e.getId());
+
+ Class type = (Class) e.getTypeClasses().iterator().next();
+ classLookup.put(e.getId()+1, type);
+ idLookup.put(type,e.getId()+1);
+ }
+
+ /**
+ * Determine whether the given class reference is a valid predefined reference.
+ *
+ * @param clazz the candidate class
+ * @return the class writer, or {@code null} to use the default mechanism
+ * @throws java.io.IOException if an I/O error occurs
+ */
+ @Override
+ public Writer getClassWriter(Class<?> clazz) throws IOException {
+ if(idLookup.containsKey(clazz)) {
+ return writer;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Read a class from the stream. The class will have been written by the
+ * {@link #getClassWriter(Class)} method's {@code Writer} instance, as defined above.
+ *
+ * @param unmarshaller the unmarshaller to read from
+ * @return the class
+ * @throws java.io.IOException if an I/O error occurs
+ * @throws ClassNotFoundException if a class could not be found
+ */
+ @Override
+ public Class<?> readClass(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+ int id = unmarshaller.readByte();
+
+ return classLookup.get(id);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomJBossMarshaller.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomJBossMarshaller.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomJBossMarshaller.java
new file mode 100644
index 0000000..428b397
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/CustomJBossMarshaller.java
@@ -0,0 +1,41 @@
+/*
+ * 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.remote;
+
+import org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller;
+import org.infinispan.commons.marshall.jboss.DefaultContextClassResolver;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class CustomJBossMarshaller extends AbstractJBossMarshaller {
+
+ public CustomJBossMarshaller() {
+ super();
+ baseCfg.setClassResolver(
+ new DefaultContextClassResolver(this.getClass().getClassLoader()));
+
+ baseCfg.setClassExternalizerFactory (new CustomClassExternalizerFactory());
+ baseCfg.setClassTable(new CustomClassTable());
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/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
new file mode 100644
index 0000000..a4a4e38
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManager.java
@@ -0,0 +1,154 @@
+/*
+ * 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.remote;
+
+import org.apache.marmotta.kiwi.caching.CacheManager;
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.model.rdf.*;
+
+import java.util.Map;
+
+/**
+ * Implementation of an Infinispan cache manager with a remote (client-server) cache.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class InfinispanRemoteCacheManager implements CacheManager {
+
+ private KiWiConfiguration configuration;
+
+ public InfinispanRemoteCacheManager(KiWiConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+
+ /**
+ * 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
+ */
+ @Override
+ public Map<Long, KiWiNode> getNodeCache() {
+ return null;
+ }
+
+ /**
+ * Return the triple id -> triple cache from the cache manager. This cache is used for speeding up the
+ * construction of query results.
+ *
+ * @return
+ */
+ @Override
+ public Map<Long, KiWiTriple> getTripleCache() {
+ return null;
+ }
+
+ /**
+ * Return the uri -> KiWiUriResource cache from the cache manager. This cache is used when constructing new
+ * KiWiUriResources to avoid a database lookup.
+ *
+ * @return
+ */
+ @Override
+ public Map<String, KiWiUriResource> getUriCache() {
+ return null;
+ }
+
+ /**
+ * Return the anonId -> KiWiAnonResource cache from the cache manager. This cache is used when constructing new
+ * KiWiAnonResources to avoid a database lookup.
+ *
+ * @return
+ */
+ @Override
+ public Map<String, KiWiAnonResource> getBNodeCache() {
+ return null;
+ }
+
+ /**
+ * Return the literal cache key -> KiWiLiteral cache from the cache manager. This cache is used when constructing new
+ * KiWiLiterals to avoid a database lookup.
+ *
+ * @return
+ * @see org.apache.marmotta.commons.sesame.model.LiteralCommons#createCacheKey(String, java.util.Locale, String)
+ */
+ @Override
+ public Map<String, KiWiLiteral> getLiteralCache() {
+ return null;
+ }
+
+ /**
+ * Return the URI -> namespace cache from the cache manager. Used for looking up namespaces
+ *
+ * @return
+ */
+ @Override
+ public Map<String, KiWiNamespace> getNamespaceUriCache() {
+ return null;
+ }
+
+ /**
+ * Return the prefix -> namespace cache from the cache manager. Used for looking up namespaces
+ *
+ * @return
+ */
+ @Override
+ public Map<String, KiWiNamespace> getNamespacePrefixCache() {
+ return null;
+ }
+
+ /**
+ * Create and return the cache used by the CacheTripleRegistry. This is an unlimited synchronous replicated
+ * cache and should be used with care.
+ *
+ * @return
+ */
+ @Override
+ public Map<Long, Long> getRegistryCache() {
+ return null;
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ public Map getCacheByName(String name) {
+ return null;
+ }
+
+ /**
+ * Clear all caches managed by this cache manager.
+ */
+ @Override
+ public void clear() {
+
+ }
+
+ /**
+ * Shutdown this cache manager instance. Will shutdown the underlying EHCache cache manager.
+ */
+ @Override
+ public void shutdown() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManagerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManagerFactory.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManagerFactory.java
new file mode 100644
index 0000000..a1047fb
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/infinispan/remote/InfinispanRemoteCacheManagerFactory.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.remote;
+
+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 InfinispanRemoteCacheManagerFactory implements CacheManagerFactory {
+
+ public InfinispanRemoteCacheManagerFactory() {
+ }
+
+ /**
+ * 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 InfinispanRemoteCacheManager(configuration);
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManager.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManager.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManager.java
deleted file mode 100644
index 6f5034a..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManager.java
+++ /dev/null
@@ -1,154 +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.remote;
-
-import org.apache.marmotta.kiwi.caching.CacheManager;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.model.rdf.*;
-
-import java.util.Map;
-
-/**
- * Implementation of an Infinispan cache manager with a remote (client-server) cache.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class InfinispanRemoteCacheManager implements CacheManager {
-
- private KiWiConfiguration configuration;
-
- public InfinispanRemoteCacheManager(KiWiConfiguration configuration) {
- this.configuration = configuration;
- }
-
-
- /**
- * 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
- */
- @Override
- public Map<Long, KiWiNode> getNodeCache() {
- return null;
- }
-
- /**
- * Return the triple id -> triple cache from the cache manager. This cache is used for speeding up the
- * construction of query results.
- *
- * @return
- */
- @Override
- public Map<Long, KiWiTriple> getTripleCache() {
- return null;
- }
-
- /**
- * Return the uri -> KiWiUriResource cache from the cache manager. This cache is used when constructing new
- * KiWiUriResources to avoid a database lookup.
- *
- * @return
- */
- @Override
- public Map<String, KiWiUriResource> getUriCache() {
- return null;
- }
-
- /**
- * Return the anonId -> KiWiAnonResource cache from the cache manager. This cache is used when constructing new
- * KiWiAnonResources to avoid a database lookup.
- *
- * @return
- */
- @Override
- public Map<String, KiWiAnonResource> getBNodeCache() {
- return null;
- }
-
- /**
- * Return the literal cache key -> KiWiLiteral cache from the cache manager. This cache is used when constructing new
- * KiWiLiterals to avoid a database lookup.
- *
- * @return
- * @see org.apache.marmotta.commons.sesame.model.LiteralCommons#createCacheKey(String, java.util.Locale, String)
- */
- @Override
- public Map<String, KiWiLiteral> getLiteralCache() {
- return null;
- }
-
- /**
- * Return the URI -> namespace cache from the cache manager. Used for looking up namespaces
- *
- * @return
- */
- @Override
- public Map<String, KiWiNamespace> getNamespaceUriCache() {
- return null;
- }
-
- /**
- * Return the prefix -> namespace cache from the cache manager. Used for looking up namespaces
- *
- * @return
- */
- @Override
- public Map<String, KiWiNamespace> getNamespacePrefixCache() {
- return null;
- }
-
- /**
- * Create and return the cache used by the CacheTripleRegistry. This is an unlimited synchronous replicated
- * cache and should be used with care.
- *
- * @return
- */
- @Override
- public Map<Long, Long> getRegistryCache() {
- return null;
- }
-
- /**
- * 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
- */
- @Override
- public Map getCacheByName(String name) {
- return null;
- }
-
- /**
- * Clear all caches managed by this cache manager.
- */
- @Override
- public void clear() {
-
- }
-
- /**
- * Shutdown this cache manager instance. Will shutdown the underlying EHCache cache manager.
- */
- @Override
- public void shutdown() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManagerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManagerFactory.java b/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManagerFactory.java
deleted file mode 100644
index a0152d1..0000000
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/java/org/apache/marmotta/kiwi/remote/InfinispanRemoteCacheManagerFactory.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.remote;
-
-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 InfinispanRemoteCacheManagerFactory implements CacheManagerFactory {
-
- public InfinispanRemoteCacheManagerFactory() {
- }
-
- /**
- * 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 InfinispanRemoteCacheManager(configuration);
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.caching.CacheManagerFactory
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.caching.CacheManagerFactory b/libraries/kiwi/kiwi-caching-infinispan/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.caching.CacheManagerFactory
index 4fd2bec..d354758 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.caching.CacheManagerFactory
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.caching.CacheManagerFactory
@@ -1,2 +1,2 @@
-org.apache.marmotta.kiwi.embedded.InfinispanEmbeddedCacheManagerFactory
-org.apache.marmotta.kiwi.remote.InfinispanRemoteCacheManagerFactory
+org.apache.marmotta.kiwi.infinispan.embedded.InfinispanEmbeddedCacheManagerFactory
+org.apache.marmotta.kiwi.infinispan.remote.InfinispanRemoteCacheManagerFactory
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ExternalizerTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ExternalizerTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ExternalizerTest.java
index 74f63d2..94121f3 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ExternalizerTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ExternalizerTest.java
@@ -19,7 +19,8 @@ package org.apache.marmotta.kiwi.test;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.marmotta.commons.vocabulary.XSD;
-import org.apache.marmotta.kiwi.externalizer.*;
+import org.apache.marmotta.kiwi.infinispan.externalizer.*;
+import org.apache.marmotta.kiwi.infinispan.remote.CustomJBossMarshaller;
import org.apache.marmotta.kiwi.model.rdf.*;
import org.infinispan.commons.marshall.AdvancedExternalizer;
import org.infinispan.commons.marshall.StreamingMarshaller;
@@ -56,7 +57,7 @@ public class ExternalizerTest {
private static Logger log = LoggerFactory.getLogger(ExternalizerTest.class);
- private static StreamingMarshaller marshaller;
+ private static StreamingMarshaller marshaller, hotrod;
@BeforeClass
@@ -89,6 +90,7 @@ public class ExternalizerTest {
marshaller = cacheManager.getCache().getAdvancedCache().getComponentRegistry().getCacheMarshaller();
+ hotrod = new CustomJBossMarshaller();
}
@@ -187,7 +189,7 @@ public class ExternalizerTest {
Assert.assertEquals(origin,destination1);
- log.info("- testing externalizer with infinispan marshaller ...");
+ log.info("- testing externalizer with infinispan cluster marshaller ...");
byte[] bytes = marshaller.objectToByteBuffer(origin);
log.info(" object {}: serialized with {} bytes", origin, bytes.length);
@@ -196,6 +198,17 @@ public class ExternalizerTest {
Assert.assertEquals(origin, destination2);
+
+
+ log.info("- testing externalizer with infinispan hotrod marshaller ...");
+
+ byte[] bytesH = hotrod.objectToByteBuffer(origin);
+ log.info(" object {}: serialized with {} bytes", origin, bytesH.length);
+
+ Object destination3 = hotrod.objectFromByteBuffer(bytesH);
+
+ Assert.assertEquals(origin, destination3);
+
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/InfinispanClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/InfinispanClusterTest.java b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/InfinispanClusterTest.java
index 0522262..c35a492 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/InfinispanClusterTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/InfinispanClusterTest.java
@@ -17,7 +17,7 @@
package org.apache.marmotta.kiwi.test;
-import org.apache.marmotta.kiwi.caching.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.test.cluster.BaseClusterTest;
import org.junit.BeforeClass;
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/CacheManagerType.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/CacheManagerType.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/CacheManagerType.java
deleted file mode 100644
index 25dc7b8..0000000
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/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.caching;
-
-/**
- * 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.embedded.InfinispanEmbeddedCacheManagerFactory"),
-
- /**
- * Cache backend based on Infinispan using a client-server setup (Hotrod)
- */
- INFINISPAN_HOTROD("org.apache.marmotta.kiwi.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/2f22f5ca/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
new file mode 100644
index 0000000..783a79d
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/config/CacheManagerType.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;
+
+/**
+ * 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/2f22f5ca/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 7ffee6a..fb9fb2c 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
@@ -17,7 +17,6 @@
*/
package org.apache.marmotta.kiwi.config;
-import org.apache.marmotta.kiwi.caching.CacheManagerType;
import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f22f5ca/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 f23bfc4..12a57b0 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.caching.CacheManagerType;
+import org.apache.marmotta.kiwi.config.CacheManagerType;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class BaseClusterTest {
+ public static final int REGISTRY_TESTS = 10000;
private static Logger log = LoggerFactory.getLogger(BaseClusterTest.class);
private static int datacenterIds = 1;
@@ -106,6 +107,23 @@ public abstract class BaseClusterTest {
}
+ @Test
+ public void testRegistry() {
+
+ log.info("testing synchronized registry ...");
+
+ for(int i=0; i < REGISTRY_TESTS; i++) {
+ cacheManagerSync1.getRegistryCache().put((long)i,(long)i);
+
+ Long j = cacheManagerSync1.getRegistryCache().get((long)i);
+ Long k = cacheManagerSync2.getRegistryCache().get((long)i);
+
+ Assert.assertEquals("objects in same cache were not identical!", (long)i, (long)j);
+ Assert.assertEquals("objects in caches 1 and 2 were not identical!", (long)i, (long)k);
+ }
+
+ }
+
protected static class ClusterTestSupport {
CacheManagerType type;