jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1178477 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/cluster/ main/java/org/apache/jackrabbit/mk/server/ test/java/org/apache/jackrabbit/mk/cluster/
Date Mon, 03 Oct 2011 17:43:58 GMT
Author: dpfister
Date: Mon Oct  3 17:43:58 2011
New Revision: 1178477

URL: http://svn.apache.org/viewvc?rev=1178477&view=rev
Log:
Clustering: add basic test

Added:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java
  (with props)
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java
  (with props)
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java?rev=1178477&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java
(added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java
Mon Oct  3 17:43:58 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.jackrabbit.mk.cluster;
+
+import java.net.InetSocketAddress;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.client.Client;
+
+public class ClusterNode {
+
+    private MicroKernel mk;
+    private String lastRevision;
+
+	public ClusterNode(MicroKernel mk) {
+		this.mk = mk;
+	}
+	
+	public void join(InetSocketAddress addr) {
+		Client client = new Client(addr);
+		String headRevision = client.getHeadRevision();
+		if (lastRevision == null) {
+			lastRevision = headRevision;
+		}
+	}
+}

Propchange: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/cluster/ClusterNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java?rev=1178477&r1=1178476&r2=1178477&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
Mon Oct  3 17:43:58 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.mk.server;
 
 import java.io.EOFException;
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
@@ -93,7 +94,6 @@ public class Server {
                     }
                 } catch (IOException e) {
                     /* ignore */
-                    e.printStackTrace();
                 }
             }
         }, "Acceptor").start();
@@ -132,6 +132,13 @@ public class Server {
         }
     }
     
+    public InetSocketAddress getAddress() {
+    	if (!started.get() || stopped.get()) {
+    		return null;
+    	}
+    	return (InetSocketAddress) ss.getLocalSocketAddress();
+    }
+    
     /**
      * Internal servlet that handles all requests to this server.
      */

Added: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java?rev=1178477&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java
(added)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java
Mon Oct  3 17:43:58 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.jackrabbit.mk.cluster;
+
+import org.apache.jackrabbit.mk.MicroKernelFactory;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.server.Server;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BasicTest {
+	
+	private MicroKernel mk1;
+	private Server server;
+	
+	private MicroKernel mk2;
+	
+    @Before
+    public void setUp() throws Exception {
+    	mk1 = MicroKernelFactory.getInstance("fs:{homeDir}/target/mk1;clean");
+    	mk2 = MicroKernelFactory.getInstance("fs:{homeDir}/target/mk2;clean");
+    }
+    
+    @After
+    public void tearDown() {
+    	if (mk1 != null) {
+    		mk1.dispose();
+    	}
+    	if (mk2 != null) {
+    		mk2.dispose();
+    	}
+    	if (server != null) {
+    		server.stop();
+    	}
+    }
+    
+    @Test
+    public void test() throws Exception {
+    	server = new Server(mk1);
+    	server.setPort(0);
+    	server.start();
+    	
+    	ClusterNode cn = new ClusterNode(mk2);
+    	cn.join(server.getAddress());
+    			
+    	mk1.commit("/", "+\"test\":{}", mk1.getHeadRevision(), null);
+    	mk2.getNodes("/test", mk2.getHeadRevision());
+    }
+}

Propchange: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/cluster/BasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message