[P2play-commit] SF.net SVN: p2play: [26] trunk/P2Play
Status: Pre-Alpha
Brought to you by:
tisoft
|
From: <ti...@us...> - 2007-01-22 12:36:37
|
Revision: 26
http://p2play.svn.sourceforge.net/p2play/?rev=26&view=rev
Author: tisoft
Date: 2007-01-22 04:36:37 -0800 (Mon, 22 Jan 2007)
Log Message:
-----------
moved stuff from P2Play to P2PlayBoot since it is needed for bootstraping
Modified Paths:
--------------
trunk/P2Play/.classpath
trunk/P2Play/.project
trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component
trunk/P2PlayBoot/.classpath
trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPMessage.java
Added Paths:
-----------
trunk/P2PlayBoot/lib/FreePastry.jar
trunk/P2PlayBoot/lib/sources/FreePastry-source.zip
trunk/P2PlayBoot/lib/xpp3-1.1.3.4d_b2.jar
trunk/P2PlayBoot/lib/xstream-1.1.3.jar
trunk/P2PlayBoot/src/org/p2play/net/
trunk/P2PlayBoot/src/org/p2play/net/pastry/
trunk/P2PlayBoot/src/org/p2play/net/pastry/DefaultNodeHandler.java
trunk/P2PlayBoot/src/org/p2play/net/pastry/NodeHandler.java
trunk/P2PlayBoot/src/org/p2play/net/pastry/Pastry.java
trunk/P2PlayBoot/src/org/p2play/net/pastry/time/
Removed Paths:
-------------
trunk/P2Play/lib/FreePastry.jar
trunk/P2Play/lib/sources/FreePastry-source.zip
trunk/P2Play/lib/xpp3-1.1.3.4d_b2.jar
trunk/P2Play/lib/xstream-1.1.3.jar
trunk/P2Play/src/org/p2play/net/pastry/
Modified: trunk/P2Play/.classpath
===================================================================
--- trunk/P2Play/.classpath 2007-01-22 12:31:10 UTC (rev 25)
+++ trunk/P2Play/.classpath 2007-01-22 12:36:37 UTC (rev 26)
@@ -2,11 +2,9 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry exported="true" kind="lib" path="lib/FreePastry.jar" sourcepath="lib/sources/FreePastry-source.zip"/>
<classpathentry exported="true" kind="lib" path="lib/javolution.jar" sourcepath="lib/sources/javolution-4.1.0-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/pnuts.jar" sourcepath="lib/sources/pnuts-1.2-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/jdom.jar" sourcepath="lib/sources/jdom-1.0.zip"/>
- <classpathentry exported="true" kind="lib" path="lib/xstream-1.1.3.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/xpp3-1.1.3.4d_b2.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/P2PlayBoot"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/P2Play/.project
===================================================================
--- trunk/P2Play/.project 2007-01-22 12:31:10 UTC (rev 25)
+++ trunk/P2Play/.project 2007-01-22 12:36:37 UTC (rev 26)
@@ -6,12 +6,25 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>
</projectDescription>
Deleted: trunk/P2Play/lib/FreePastry.jar
===================================================================
(Binary files differ)
Deleted: trunk/P2Play/lib/sources/FreePastry-source.zip
===================================================================
(Binary files differ)
Deleted: trunk/P2Play/lib/xpp3-1.1.3.4d_b2.jar
===================================================================
(Binary files differ)
Deleted: trunk/P2Play/lib/xstream-1.1.3.jar
===================================================================
(Binary files differ)
Modified: trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component 2007-01-22 12:31:10 UTC (rev 25)
+++ trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component 2007-01-22 12:36:37 UTC (rev 26)
@@ -7,12 +7,6 @@
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/P2Play/P2Play">
<dependency-type>uses</dependency-type>
</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/xstream-1.1.3.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/xpp3-1.1.3.4d_b2.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/pnuts.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
@@ -22,9 +16,6 @@
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/javolution.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/FreePastry.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/P2PlayBoot/P2PlayBoot">
<dependency-type>uses</dependency-type>
</dependent-module>
@@ -34,6 +25,15 @@
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/commons-logging-1.1.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
+<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/xstream-1.1.3.jar">
+<dependency-type>uses</dependency-type>
+</dependent-module>
+<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/xpp3-1.1.3.4d_b2.jar">
+<dependency-type>uses</dependency-type>
+</dependent-module>
+<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/FreePastry.jar">
+<dependency-type>uses</dependency-type>
+</dependent-module>
<property name="context-root" value="P2PlayAdmin"/>
<property name="java-output-path" value="build/classes"/>
</wb-module>
Modified: trunk/P2PlayBoot/.classpath
===================================================================
--- trunk/P2PlayBoot/.classpath 2007-01-22 12:31:10 UTC (rev 25)
+++ trunk/P2PlayBoot/.classpath 2007-01-22 12:36:37 UTC (rev 26)
@@ -2,8 +2,10 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/P2Play"/>
<classpathentry exported="true" kind="lib" path="lib/commons-vfs-20070107.jar" sourcepath="lib/sources/commons-vfs-20070107-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.jar" sourcepath="lib/sources/commons-logging-1.1-src.zip"/>
+ <classpathentry exported="true" kind="lib" path="lib/xstream-1.1.3.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/xpp3-1.1.3.4d_b2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/FreePastry.jar" sourcepath="lib/sources/FreePastry-source.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Copied: trunk/P2PlayBoot/lib/FreePastry.jar (from rev 18, trunk/P2Play/lib/FreePastry.jar)
===================================================================
(Binary files differ)
Copied: trunk/P2PlayBoot/lib/sources/FreePastry-source.zip (from rev 18, trunk/P2Play/lib/sources/FreePastry-source.zip)
===================================================================
(Binary files differ)
Copied: trunk/P2PlayBoot/lib/xpp3-1.1.3.4d_b2.jar (from rev 18, trunk/P2Play/lib/xpp3-1.1.3.4d_b2.jar)
===================================================================
(Binary files differ)
Copied: trunk/P2PlayBoot/lib/xstream-1.1.3.jar (from rev 18, trunk/P2Play/lib/xstream-1.1.3.jar)
===================================================================
(Binary files differ)
Added: trunk/P2PlayBoot/src/org/p2play/net/pastry/DefaultNodeHandler.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/DefaultNodeHandler.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/net/pastry/DefaultNodeHandler.java 2007-01-22 12:36:37 UTC (rev 26)
@@ -0,0 +1,73 @@
+package org.p2play.net.pastry;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.p2play.net.pastry.NodeHandler;
+import org.p2play.net.pastry.Pastry;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastImpl;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+import rice.persistence.LRUCache;
+import rice.persistence.MemoryStorage;
+import rice.persistence.StorageManagerImpl;
+
+public class DefaultNodeHandler implements NodeHandler {
+ private Node node;
+
+ private Map<String, Past> pastMap = new HashMap<String, Past>();
+
+ private Map<String, Scribe> scribeMap = new HashMap<String, Scribe>();
+
+ private static DefaultNodeHandler staticNode;
+
+ public Node getNode() {
+ if (node == null)
+ throw new RuntimeException("Node not initialized!");
+ return node;
+ }
+
+ public Past getPast(String instance) {
+ Past past = pastMap.get(instance);
+
+ if (past == null) {
+ past = new PastImpl(node, new StorageManagerImpl(node
+ .getIdFactory(), new MemoryStorage(node.getIdFactory()),
+ new LRUCache(new MemoryStorage(node.getIdFactory()), 100,
+ node.getEnvironment())), 3, instance);
+
+ pastMap.put(instance, past);
+ }
+
+ return past;
+ }
+
+ public Scribe getScribe(String instance) {
+ Scribe scribe = scribeMap.get(instance);
+
+ if (scribe == null) {
+ scribe = new ScribeImpl(getNode(), instance);
+
+ scribeMap.put(instance, scribe);
+ }
+
+ return scribe;
+ }
+
+ public DefaultNodeHandler(Node node) {
+ super();
+ this.node = node;
+ this.pastMap=new HashMap<String, Past>();
+ this.scribeMap=new HashMap<String, Scribe>();
+ }
+
+}
Added: trunk/P2PlayBoot/src/org/p2play/net/pastry/NodeHandler.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/NodeHandler.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/net/pastry/NodeHandler.java 2007-01-22 12:36:37 UTC (rev 26)
@@ -0,0 +1,11 @@
+package org.p2play.net.pastry;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.scribe.Scribe;
+
+public interface NodeHandler {
+ public Node getNode();
+ public Past getPast(String instance);
+ public Scribe getScribe(String instance);
+}
Copied: trunk/P2PlayBoot/src/org/p2play/net/pastry/Pastry.java (from rev 18, trunk/P2Play/src/org/p2play/net/pastry/Pastry.java)
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/Pastry.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/net/pastry/Pastry.java 2007-01-22 12:36:37 UTC (rev 26)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.net.pastry;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
+import org.p2play.net.pastry.time.NTPTimeSource;
+
+import rice.environment.Environment;
+import rice.environment.logging.LogManager;
+import rice.environment.params.simple.SimpleParameters;
+import rice.p2p.commonapi.Node;
+import rice.pastry.NodeIdFactory;
+import rice.pastry.PastryNode;
+import rice.pastry.socket.SocketPastryNodeFactory;
+import rice.pastry.standard.RandomNodeIdFactory;
+
+public class Pastry {
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remoteHost
+ * the remote host to boot into
+ * @param remotePort
+ * the port on the remote host to boot into
+ * @param externalHost
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(String remoteHost, int remotePort,
+ String externalHost, int localPort) throws IOException {
+ return boot(InetAddress.getByName(remoteHost), remotePort, InetAddress
+ .getByName(externalHost), localPort);
+ }
+
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remoteHost
+ * the remote host to boot into
+ * @param remotePort
+ * the port on the remote host to boot into
+ * @param externalHost
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetAddress remoteHost, int remotePort,
+ InetAddress externalHost, int localPort) throws IOException {
+ return boot(new InetSocketAddress(remoteHost, remotePort),
+ externalHost, localPort);
+ }
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remote
+ * the boot node
+ * @param externalAddress
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetSocketAddress remote,
+ InetAddress externalAddress, int localPort) throws IOException {
+ return boot(remote,externalAddress,localPort,null);
+ }
+
+
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remote
+ * the boot node
+ * @param externalAddress
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetSocketAddress remote,
+ InetAddress externalAddress, int localPort, LogManager logManager) throws IOException {
+ PastryNode node;
+
+ Environment environment = new Environment(null, null, null,
+ NTPTimeSource.getTimeSource(), logManager, new SimpleParameters(
+ new String[]{"mmog"}, null), null);
+ NodeIdFactory nidFactory = new RandomNodeIdFactory(environment);
+ SocketPastryNodeFactory factory = new SocketPastryNodeFactory(
+ nidFactory, externalAddress, localPort, environment, null);
+
+ node = factory.newNode(factory.getNodeHandle(remote));
+
+ while (!node.isReady()) {
+ // delay so we don't busy-wait
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ }
+ }
+
+ return node;
+ }
+}
Copied: trunk/P2PlayBoot/src/org/p2play/net/pastry/time (from rev 18, trunk/P2Play/src/org/p2play/net/pastry/time)
Modified: trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPMessage.java
===================================================================
--- trunk/P2Play/src/org/p2play/net/pastry/time/NTPMessage.java 2007-01-16 13:11:11 UTC (rev 18)
+++ trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPMessage.java 2007-01-22 12:36:37 UTC (rev 26)
@@ -32,10 +32,9 @@
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Random;
-import org.p2play.util.NetRandom;
-
/**
* This class represents a NTP message, as specified in RFC 2030. The message
* format is compatible with all versions of NTP and SNTP.
@@ -75,7 +74,7 @@
* @author Adam Buckley
*/
public class NTPMessage {
- private static NetRandom random=new NetRandom();
+ private static Random random=new Random();
/**
* This is a two-bit code warning of an impending leap second to be
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|