[e-cvs] cvs commit: e/src/jsrc/org/erights/e/ui/elmer package.html
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Sun, 22 Jul 2001 01:29:55 -0400
markm 01/07/22 01:29:55
Modified: src/jsrc/net/captp/jcomm Introducer.java LocatorUnum.java
ProxyConnection.java Sturdifier.java SturdyRef.java
src/jsrc/net/captp/tables SwissTable.java Vine.java
src/jsrc/org/erights/e/elib/prim VTable.java
src/jsrc/org/erights/e/extern/timer Timer.java
src/jsrc/org/erights/e/ui/elmer package.html
Added: src/jsrc/net/captp/jcomm LookupHandler.java
Log:
initial connection gets farther
Revision Changes Path
1.10 +27 -3 e/src/jsrc/net/captp/jcomm/Introducer.java
Index: Introducer.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/Introducer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Introducer.java 2001/07/14 12:57:21 1.9
+++ Introducer.java 2001/07/22 05:29:55 1.10
@@ -22,6 +22,7 @@
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import net.captp.tables.SwissTable;
+import net.vattp.data.EARL;
import net.vattp.data.NetConfig;
import net.vattp.data.StartUpProtocol;
import net.vattp.data.VatIdentity;
@@ -68,7 +69,7 @@
Timer persistentTimer)
{
Introducer itr = new Introducer(optProps, entropy, persistentTimer);
- Sturdifier sturd = new Sturdifier(itr);
+ Sturdifier sturd = new Sturdifier(itr, persistentTimer);
Object[] result = { itr, sturd };
return result;
}
@@ -141,6 +142,24 @@
}
/**
+ * For use by the Sturdifier
+ */
+ /*package*/ SwissTable getSwissTable() {
+ if (isOnTheAir()) {
+ return myOptSwissTable;
+ } else {
+ throw new RuntimeException("not yet onTheAir");
+ }
+ }
+
+ /**
+ *
+ */
+ /*package*/ String getVatID() {
+ return myOptVatIdentity.getVatID();
+ }
+
+ /**
* Produce a SturdyRef given a URI.
*
* @param uri An E format ("<cap://...>") URI string referring to some object
@@ -148,7 +167,12 @@
* @return A SturdyRef matching the given URI
*/
public SturdyRef sturdyFromURI(String uri) throws MalformedURLException {
- throw new RuntimeException("XXX not yet implemented");
+ EARL earl = new EARL(uri);
+ return new SturdyRef(getLocatorUnum(),
+ earl.searchPath(),
+ earl.vatID(),
+ earl.swissNumber(),
+ earl.expiration());
}
/**
@@ -159,7 +183,7 @@
* @return An E format ("<cap://...>") URI string matching the SturdyRef
*/
public String sturdyToURI(SturdyRef ref) {
- throw new RuntimeException("XXX not yet implemented");
+ return ref.exportRef();
}
/**
1.3 +1 -1 e/src/jsrc/net/captp/jcomm/LocatorUnum.java
Index: LocatorUnum.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/LocatorUnum.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocatorUnum.java 2001/07/14 12:57:21 1.2
+++ LocatorUnum.java 2001/07/22 05:29:55 1.3
@@ -52,7 +52,7 @@
}
/**
- * The basic operation underlying 'SturdyRef.liveRef()'. This is where
+ * The basic operation underlying 'SturdyRef.promiseRef()'. This is where
* a reference to a remote object actually gets the various underlying comm
* systems connected so that we can send messages.
*
1.15 +4 -1 e/src/jsrc/net/captp/jcomm/ProxyConnection.java
Index: ProxyConnection.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyConnection.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ProxyConnection.java 2001/07/14 12:57:21 1.14
+++ ProxyConnection.java 2001/07/22 05:29:55 1.15
@@ -252,7 +252,10 @@
myImports = new ImportsTable();
myExports = new ExportsTable();
- myRemoteNonceLocator = null; //XXX for now
+ //XXX for now
+ LookupHandler lookupHandler = new LookupHandler(this);
+ myRemoteNonceLocator = lookupHandler.myResolver.getProxy();
+
myGiftVows = new GiftVowTable(myRemoteNonceLocator);
myNearGifts = new NearGiftTable();
myLocalNonceLocator = new NonceLocator(myGiftVows,
1.4 +39 -8 e/src/jsrc/net/captp/jcomm/Sturdifier.java
Index: Sturdifier.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/Sturdifier.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Sturdifier.java 2001/05/03 08:58:44 1.3
+++ Sturdifier.java 2001/07/22 05:29:55 1.4
@@ -18,9 +18,15 @@
Contributor(s): ______________________________________.
*/
+
import java.io.IOException;
+import java.math.BigInteger;
import java.util.Date;
+import net.captp.tables.SwissTable;
+import net.captp.tables.Vine;
+import net.vattp.data.NetConfig;
import org.erights.e.elib.base.TextWriter;
+import org.erights.e.extern.timer.Timer;
/**
* Enables one to make SturdyRefs for an object, even if one is in a
@@ -31,13 +37,14 @@
public class Sturdifier {
Introducer myIntroducer;
+ Timer myPersistentTimer;
/**
*
*/
- public Sturdifier(Introducer introducer)
- {
+ public Sturdifier(Introducer introducer, Timer persistentTimer) {
myIntroducer = introducer;
+ myPersistentTimer = persistentTimer;
}
/**
@@ -49,7 +56,7 @@
* @return A new SturdyRef for the indicated object
*/
public SturdyRef run(Object obj) {
- return run(obj, null);
+ return run(obj, Long.MAX_VALUE);
}
/**
@@ -57,12 +64,36 @@
*
* @param obj The object for which a SturdyRef is desired
* @param optExpirationDate The date after which the SturdyRef will not
- * longer be guaranteed to be valid. If null,
- * then it's always valid.
+ * longer be guaranteed to be valid. If
+ * Long.MAX_VALUE, then it's always valid.
* @return A new SturdyRef for the indicated object
*/
- public SturdyRef run(Object obj, Date optExpirationDate) {
- throw new RuntimeException("XXX not yet implemented");
+ public SturdyRef run(Object obj, long optExpirationDate) {
+ SwissTable swissTable = myIntroducer.getSwissTable();
+ BigInteger swissNum = swissTable.getNewSwiss(obj);
+
+ /*
+ * We don't bother checking for Long.MAX_VALUE == optExpirationDate,
+ * which is technically a XXX bug: these registrations will expire
+ * before the year 300,000,000. Assuming no processes stay live that
+ * long, I think it's safe to assume that a future upgrade of E will
+ * rescue such persistent state before then. Let's call this the
+ * "Year Three Hundred Million problem".
+ *
+ * We don't bother capturing the Timeout returned by cancellable
+ * below, as this API provides no mean for cancelling these
+ * registrations.
+ */
+ long duration = optExpirationDate - myPersistentTimer.now();
+ myPersistentTimer.cancellable(duration, new Vine(obj));
+
+ NetConfig netConfig = myIntroducer.getNetConfig();
+ LocatorUnum locatorUnum = myIntroducer.getLocatorUnum();
+ return new SturdyRef(locatorUnum,
+ netConfig.getSearchPath(),
+ myIntroducer.getVatID(),
+ swissNum,
+ optExpirationDate);
}
/**
@@ -72,7 +103,7 @@
if (myIntroducer.isOnTheAir()) {
out.print("<sturdyRef On The Air>");
} else {
- out.print("<SturdyRef Off The Air>");
+ out.print("<sturdyRef Off The Air>");
}
}
}
1.7 +3 -3 e/src/jsrc/net/captp/jcomm/SturdyRef.java
Index: SturdyRef.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/SturdyRef.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SturdyRef.java 2001/07/14 12:57:21 1.6
+++ SturdyRef.java 2001/07/22 05:29:55 1.7
@@ -42,7 +42,7 @@
/** the Vat in which mySwissNum is bound to something */
private String myHostID;
- /** Bound to an object with the vat identified by myHostID */
+ /** Bound to an object in the vat identified by myHostID */
private BigInteger mySwissNum;
/** How long is the object obligated to stay around? */
@@ -51,9 +51,9 @@
/**
* Package scope constructor for a new SturdyRef.
*
- * @param registar The LocatorUnum which maintains the new ref's registration
+ * @param locatorUnum The LocatorUnum which maintains the new ref's registration
* @param searchPath Hints about how to find the new ref's home vat
- * @param objectID Swiss number of the object that the new ref designates
+ * @param swissNum Swiss number of the object that the new ref designates
*/
/*package*/ SturdyRef(LocatorUnum locatorUnum,
ConstList searchPath,
1.1 e/src/jsrc/net/captp/jcomm/LookupHandler.java
Index: LookupHandler.java
===================================================================
package net.captp.jcomm;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.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.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import java.math.BigInteger;
/**
* A handler for the special remote reference at position zero to the other
* side's NonceLocator
*
* @author Mark S. Miller
*/
/*package*/ class LookupHandler extends RemoteHandler {
/**
* Construct a new LookupHandler.
*
* @param connection The ProxyConnection to communicate via.
*/
/*package*/ LookupHandler(ProxyConnection conn) {
super(conn, 0, null);
}
}
1.5 +7 -5 e/src/jsrc/net/captp/tables/SwissTable.java
Index: SwissTable.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/tables/SwissTable.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SwissTable.java 2001/07/14 12:57:21 1.4
+++ SwissTable.java 2001/07/22 05:29:55 1.5
@@ -32,7 +32,7 @@
import org.erights.e.meta.java.math.BigIntegerSugar;
/**
- * A weak-value table mapping from SwissNumber to references. <p>
+ * A weak-value table mapping from SwissNumbers to references. <p>
*
* There are two cases: 1) NEAR references to Selfish objects. 2) Everything
* else. For case #1, a backwards weak-key table is also maintained, such
@@ -91,14 +91,14 @@
/**
* Lookup an object by SwissNumber. <p>
*
- * If not found, throw an IndexOutOfBoundsException. This leaves us the
- * option of accepting null as a valid value in the future.
+ * If not found, throw an IndexOutOfBoundsException. This is necessary
+ * since null is a valid return value. (By decree, the SwissNumber 0
+ * designates null.)
*/
public Object lookupSwiss(BigInteger swissNum)
throws IndexOutOfBoundsException {
if (swissNum.signum() == 0) {
- //Since Weak*Maps can't handle nulls, we handle it ourselves. By
- //decree, the SwissNumber 0 designates null.
+ //Since Weak*Maps can't handle nulls, we handle it ourselves.
return null;
}
Object optResult = mySwissToRef.get(swissNum, null);
@@ -110,8 +110,10 @@
BigInteger swissHash = BigIntegerSugar.cryptoHash(swissNum);
OneArgFunc[] dbs = (OneArgFunc[])mySwissDBs.getKeys(OneArgFunc.class);
for (int i = 0; i < dbs.length; i++) {
+ //give each fault handler a chance
dbs[i].run(swissHash);
}
+ //try one more time
return mySwissToRef.get(swissNum);
}
1.6 +13 -2 e/src/jsrc/net/captp/tables/Vine.java
Index: Vine.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/tables/Vine.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Vine.java 2001/05/01 08:42:03 1.5
+++ Vine.java 2001/07/22 05:29:55 1.6
@@ -29,9 +29,12 @@
*
* Part of the 3-party live introduction mechanism.
*/
-public class Vine implements PassByProxy {
+public class Vine implements PassByProxy, Runnable {
+
/**
- * The remote reference we hold onto. All we do is hold onto it. Really.
+ * The remote reference we hold onto. <p>
+ *
+ * All we do is hold onto it. Really.
*/
private Object myRemote;
@@ -44,4 +47,12 @@
}
myRemote = remote;
}
+
+ /**
+ * When asked to run(), we do nothing; really. <p>
+ *
+ * This way we can be scheduled to hold on to myRemote until we're run()
+ * and dropped.
+ */
+ public void run() {}
}
1.31 +11 -5 e/src/jsrc/org/erights/e/elib/prim/VTable.java
Index: VTable.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/VTable.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- VTable.java 2001/04/08 21:15:12 1.30
+++ VTable.java 2001/07/22 05:29:55 1.31
@@ -189,11 +189,17 @@
if (script == null) {
script = myOptOtherwise;
if (script == null) {
- String diagnostic = ( self == null
- ? "<null> "
- : "<" + self.getClass()
- + ":" + self + "> ")
- + verb + "/" + args.length;
+ String selfStr;
+ if (null == self) {
+ selfStr = "<null> ";
+ } else {
+ String typeName = self.getClass().getName();
+ int lastDot = typeName.lastIndexOf('.');
+ //don't need to check for -1
+ typeName = typeName.substring(lastDot+1);
+ selfStr = "<" + typeName + ":" + self + "> ";
+ }
+ String diagnostic = selfStr + verb + "/" + args.length;
throw ExceptionMgr.asSafe(new NoSuchMethodException(diagnostic));
}
}
1.13 +28 -4 e/src/jsrc/org/erights/e/extern/timer/Timer.java
Index: Timer.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/extern/timer/Timer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Timer.java 2001/04/15 05:04:28 1.12
+++ Timer.java 2001/07/22 05:29:55 1.13
@@ -20,6 +20,10 @@
*/
import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
import java.util.Date;
import org.erights.e.elib.base.TextWriter;
import org.erights.e.elib.base.Thunk;
@@ -47,6 +51,14 @@
static private final Object[] NO_ARGS = {};
+ static private final DateFormat SortableFormat =
+ new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss:SSS-zz");
+
+ static {
+ TimeZone gmt = TimeZone.getTimeZone("GMT");
+ SortableFormat.setTimeZone(gmt);
+ }
+
/** The single permitted instance of this class */
static private Timer TheTimer = new Timer();
@@ -68,11 +80,23 @@
return System.currentTimeMillis();
}
+ /**
+ * Shows millis since epoch as a sortable absolute date string that can
+ * be included in a filename or a single URI field (no "#"s or "/"s). <p>
+ *
+ * The actual format is "yyyy.MM.dd-HH:mm:ss:SSS-zz" as interpreter by
+ * {@link java.text.SimpleDateFormat}.
+ */
+ public String millisToDate(long millis) {
+ return SortableFormat.format(new Date(millis));
+ }
+
/**
- * Shows millis as an absolute date string.
+ * Given a sortableDate string in the format returned by millisToDate,
+ * return the corresponding number of seconds since the epoch.
*/
- public String date(long millis) {
- return new Date(millis).toString();
+ public long dateToMillis(String sortableDate) throws ParseException {
+ return SortableFormat.parse(sortableDate).getTime();
}
/**
@@ -85,7 +109,7 @@
* @return A Timeout object that can be used to cancel or identify the
* timeout.
*/
- private Timeout cancellable(long deltaMillis, Runnable target) {
+ public Timeout cancellable(long deltaMillis, Runnable target) {
Timeout newTimeout = new Timeout(myThread, target);
myThread.setTimeout(false, deltaMillis, newTimeout);
return newTimeout;
1.2 +1 -1 e/src/jsrc/org/erights/e/ui/elmer/package.html
Index: package.html
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/ui/elmer/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 2000/10/02 20:34:12 1.1
+++ package.html 2001/07/22 05:29:55 1.2
@@ -5,7 +5,7 @@
</head>
<body bgcolor="#FFFFFF">
-<p>E's Swing-based command-line interpreter, and the Editor for <a href="http://www.erights.org/e/Vector_updoc.txt">Updoc</a>
+<p>E's Swing-based command-line interpreter, and the Editor for <a href="http://www.erights.org/elang/tools/Updoc.html">Updoc</a>
documents.</p>
@author Mark S. Miller
</body>