2006-03-03 Audrius Meskauskas <[EMAIL PROTECTED]>
* gnu/java/rmi/dgc/DGCImpl.java: More comments, boilerplate fix.
java/rmi/dgc/Lease.java: Boilerplate fix.
Index: gnu/java/rmi/dgc/DGCImpl.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/rmi/dgc/DGCImpl.java,v
retrieving revision 1.8
diff -u -r1.8 DGCImpl.java
--- gnu/java/rmi/dgc/DGCImpl.java 3 Mar 2006 15:54:42 -0000 1.8
+++ gnu/java/rmi/dgc/DGCImpl.java 4 Mar 2006 18:38:31 -0000
@@ -1,41 +1,40 @@
/* DGCImpl.java --
- Copyright (c) 1996, 1997, 1998, 1999, 2002, 2005
- Free Software Foundation, Inc.
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2005
+ Free Software Foundation, Inc.
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+This file is part of GNU Classpath.
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
package gnu.java.rmi.dgc;
@@ -67,11 +66,15 @@
* The DGCImpl extends UnicastServerRef and not UnicastRemoteObject, because
* UnicastRemoteObject must exportObject automatically.
*/
-
- private static final long LEASE_VALUE = 600000L;
+
+ /**
+ * This defauld lease value is used if the lease value, passed to the
+ * [EMAIL PROTECTED] #dirty} is equal to zero.
+ */
+ static final long LEASE_VALUE = 600000L;
// leaseCache caches a LeaseRecord associated with a vmid
- private Hashtable leaseCache = new Hashtable();
+ Hashtable leaseCache = new Hashtable();
public DGCImpl() throws RemoteException
{
@@ -90,24 +93,24 @@
public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
throws RemoteException
{
- System.out.println("Dirty for "+lease.getValue());
VMID vmid = lease.getVMID();
if (vmid == null)
vmid = new VMID();
- long leaseValue = LEASE_VALUE;
- // long leaseValue = lease.getValue();
+
+ long leaseValue = lease.getValue();
+ if (leaseValue <= 0)
+ leaseValue = LEASE_VALUE;
+
lease = new Lease(vmid, leaseValue);
- synchronized (leaseCache)
+ LeaseRecord lr = (LeaseRecord) leaseCache.get(vmid);
+ if (lr != null)
+ lr.reset(leaseValue);
+ else
{
- LeaseRecord lr = (LeaseRecord) leaseCache.get(vmid);
- if (lr != null)
- lr.reset(leaseValue);
- else
- {
- lr = new LeaseRecord(vmid, leaseValue);
- leaseCache.put(vmid, lr);
- }
+ lr = new LeaseRecord(vmid, leaseValue, ids);
+ leaseCache.put(vmid, lr);
}
+
return (lease);
}
@@ -130,17 +133,23 @@
/**
* LeaseRecord associates a vmid to expireTime.
*/
- private static class LeaseRecord
+ static class LeaseRecord
{
/**
* The lease id.
*/
- private VMID vmid;
+ final VMID vmid;
/**
* The lease expiration time.
*/
- private long expireTime;
+ long expireTime;
+
+ /**
+ * The array of ObjeID's that must be protected from being garbage
+ * collected.
+ */
+ final ObjID [] objects;
/**
* Create the new lease record.
@@ -148,10 +157,11 @@
* @param vmid lease id.
* @param leaseValue lease value
*/
- LeaseRecord(VMID vmid, long leaseValue)
+ LeaseRecord(VMID vmid, long leaseValue, ObjID [] an_objects)
{
this.vmid = vmid;
reset(leaseValue);
+ objects = an_objects;
}
/**
Index: java/rmi/dgc/Lease.java
===================================================================
RCS file: /sources/classpath/classpath/java/rmi/dgc/Lease.java,v
retrieving revision 1.5
diff -u -r1.5 Lease.java
--- java/rmi/dgc/Lease.java 3 Mar 2006 15:54:42 -0000 1.5
+++ java/rmi/dgc/Lease.java 4 Mar 2006 18:38:42 -0000
@@ -1,40 +1,40 @@
/* Lease.java
- Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+This file is part of GNU Classpath.
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
package java.rmi.dgc;