marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject [09/32] git commit: copied serializers to Hazelcast backend
Date Mon, 17 Mar 2014 10:23:00 GMT
copied serializers to Hazelcast backend


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

Branch: refs/heads/develop
Commit: 4d26a1be6ad78aef2b565b837918485ada6e305d
Parents: 27a9c26
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Mon Mar 3 18:37:35 2014 +0100
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Mon Mar 3 18:37:35 2014 +0100

----------------------------------------------------------------------
 .../caching/HazelcastCacheManager.java          |  26 ++++
 .../caching/HazelcastCacheManagerFactory.java   |  26 ++++
 .../hazelcast/serializer/BNodeSerializer.java   |  72 +++++++++
 .../serializer/BooleanLiteralSerializer.java    |  71 +++++++++
 .../serializer/DateLiteralSerializer.java       |  71 +++++++++
 .../serializer/DoubleLiteralSerializer.java     |  70 +++++++++
 .../hazelcast/serializer/ExternalizerIds.java   |  43 ++++++
 .../serializer/IntLiteralSerializer.java        |  71 +++++++++
 .../serializer/StringLiteralSerializer.java     |  78 ++++++++++
 .../hazelcast/serializer/TripleSerializer.java  | 148 +++++++++++++++++++
 .../hazelcast/serializer/UriSerializer.java     | 134 +++++++++++++++++
 .../apache/marmotta/kiwi/test/ClusterTest.java  |   4 +-
 .../marmotta/kiwi/caching/CacheManagerType.java |  58 ++++++++
 .../marmotta/kiwi/config/KiWiConfiguration.java |  11 +-
 .../kiwi/persistence/KiWiPersistence.java       |   4 +-
 15 files changed, 878 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManager.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManager.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManager.java
new file mode 100644
index 0000000..83ba267
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManager.java
@@ -0,0 +1,26 @@
+/*
+ * 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.hazelcast.caching;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class HazelcastCacheManager {
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManagerFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManagerFactory.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManagerFactory.java
new file mode 100644
index 0000000..dee0b13
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/caching/HazelcastCacheManagerFactory.java
@@ -0,0 +1,26 @@
+/*
+ * 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.hazelcast.caching;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class HazelcastCacheManagerFactory {
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BNodeSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BNodeSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BNodeSerializer.java
new file mode 100644
index 0000000..4462537
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BNodeSerializer.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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class BNodeSerializer implements StreamSerializer<KiWiAnonResource> {
+
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.BNODE;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BooleanLiteralSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BooleanLiteralSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BooleanLiteralSerializer.java
new file mode 100644
index 0000000..0246e35
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/BooleanLiteralSerializer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.kiwi.model.rdf.KiWiBooleanLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class BooleanLiteralSerializer implements StreamSerializer<KiWiBooleanLiteral>
{
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.BOOL_LITERAL;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DateLiteralSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DateLiteralSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DateLiteralSerializer.java
new file mode 100644
index 0000000..1ddd75d
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DateLiteralSerializer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.kiwi.model.rdf.KiWiDateLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class DateLiteralSerializer implements StreamSerializer<KiWiDateLiteral> {
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.DATE_LITERAL;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DoubleLiteralSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DoubleLiteralSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DoubleLiteralSerializer.java
new file mode 100644
index 0000000..61ba8e4
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/DoubleLiteralSerializer.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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.kiwi.model.rdf.KiWiDoubleLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class DoubleLiteralSerializer implements StreamSerializer<KiWiDoubleLiteral>
{
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.DOUBLE_LITERAL;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/ExternalizerIds.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/ExternalizerIds.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/ExternalizerIds.java
new file mode 100644
index 0000000..641beca
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/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.hazelcast.serializer;
+
+/**
+ * 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/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/IntLiteralSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/IntLiteralSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/IntLiteralSerializer.java
new file mode 100644
index 0000000..12d49b4
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/IntLiteralSerializer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.kiwi.model.rdf.KiWiIntLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class IntLiteralSerializer implements StreamSerializer<KiWiIntLiteral> {
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.INT_LITERAL;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/StringLiteralSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/StringLiteralSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/StringLiteralSerializer.java
new file mode 100644
index 0000000..6531aa0
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/StringLiteralSerializer.java
@@ -0,0 +1,78 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.commons.io.DataIO;
+import org.apache.marmotta.kiwi.model.rdf.KiWiStringLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class StringLiteralSerializer implements StreamSerializer<KiWiStringLiteral>
{
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.STRING_LITERAL;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/TripleSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/TripleSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/TripleSerializer.java
new file mode 100644
index 0000000..cb2de2a
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/TripleSerializer.java
@@ -0,0 +1,148 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+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 java.io.IOException;
+import java.util.Date;
+
+/**
+ * An externalizer for Infinispan allowing to more efficiently transport triples by only
serializing the node
+ * IDs instead of the whole nodes.
+ */
+public class TripleSerializer implements StreamSerializer<KiWiTriple> {
+
+
+    public static final int MODE_DEFAULT = 1;
+    public static final int MODE_PREFIX  = 2;
+
+
+
+    @Override
+    public int getTypeId() {
+        return ExternalizerIds.TRIPLE;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/UriSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/UriSerializer.java
b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/UriSerializer.java
new file mode 100644
index 0000000..0f235d5
--- /dev/null
+++ b/libraries/kiwi/kiwi-caching-hazelcast/src/main/java/org/apache/marmotta/kiwi/hazelcast/serializer/UriSerializer.java
@@ -0,0 +1,134 @@
+/*
+ * 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.hazelcast.serializer;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+import org.apache.marmotta.commons.io.DataIO;
+import org.apache.marmotta.commons.vocabulary.XSD;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.openrdf.model.vocabulary.*;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class UriSerializer implements StreamSerializer<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 int getTypeId() {
+        return ExternalizerIds.URI;
+    }
+
+    @Override
+    public void write(ObjectDataOutput 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 read(ObjectDataInput input) throws IOException {
+        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;
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
index 0b6823c..981e595 100644
--- a/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
+++ b/libraries/kiwi/kiwi-caching-infinispan/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
@@ -58,7 +58,7 @@ public class ClusterTest {
                 new H2Dialect());
         config1.setDatacenterId(1);
         config1.setClustered(true);
-        config1.setCacheManagerFactory(InfinispanEmbeddedCacheManagerFactory.class.getName());
+        config1.setCacheManager(InfinispanEmbeddedCacheManagerFactory.class.getName());
 
         config2 = new KiWiConfiguration(
                 "default-H2",
@@ -67,7 +67,7 @@ public class ClusterTest {
                 new H2Dialect());
         config2.setDatacenterId(2);
         config2.setClustered(true);
-        config2.setCacheManagerFactory(InfinispanEmbeddedCacheManagerFactory.class.getName());
+        config2.setCacheManager(InfinispanEmbeddedCacheManagerFactory.class.getName());
 
 
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/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
new file mode 100644
index 0000000..25dc7b8
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/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.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/4d26a1be/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 a445112..7ffee6a 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,6 +17,7 @@
  */
 package org.apache.marmotta.kiwi.config;
 
+import org.apache.marmotta.kiwi.caching.CacheManagerType;
 import org.apache.marmotta.kiwi.persistence.KiWiDialect;
 
 import java.util.ArrayList;
@@ -95,7 +96,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 String cacheManagerFactory = "org.apache.marmotta.kiwi.caching.GuavaCacheManagerFactory";
+    private CacheManagerType cacheManager = CacheManagerType.GUAVA;
 
     private int nodeCacheSize = 1000000;
 
@@ -300,16 +301,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 String getCacheManagerFactory() {
-        return cacheManagerFactory;
+    public CacheManagerType getCacheManager() {
+        return cacheManager;
     }
 
     /**
      * Fully qualified class name of the cache manager factory to use. Falls back to the
Guava
      * cache manager if not found
      */
-    public void setCacheManagerFactory(String cacheManagerFactory) {
-        this.cacheManagerFactory = cacheManagerFactory;
+    public void setCacheManager(CacheManagerType cacheManager) {
+        this.cacheManager = cacheManager;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4d26a1be/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 6d81065..54e60a9 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.getCacheManagerFactory());
+            Class factory = Class.forName(configuration.getCacheManager().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.getCacheManagerFactory(), e.getMessage());
+            log.warn("cache manager factory {} not found on classpath (error: {}); falling
back to Guava in-memory cache backend!", configuration.getCacheManager(), e.getMessage());
 
             CacheManagerFactory factory = new GuavaCacheManagerFactory();
             cacheManager = factory.createCacheManager(configuration);


Mime
View raw message