/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class implements the guts of the server-side distributed GC
* algorithm
*
* @author Ann Wollrath
*/
/* dgc system log */
new GetPropertyAction("sun.rmi.dgc.logLevel"))));
/** lease duration to grant to clients */
/** lease check interval; default is half of lease grant duration */
private static final long leaseCheckInterval =
/** thread pool for scheduling delayed tasks */
/** remote implementation of DGC interface for this VM */
/** table that maps VMID to LeaseInfo */
/** checks for lease expiration */
/**
* Return the remote implementation of the DGC interface for
* this VM.
*/
return dgc;
}
/**
* Construct a new server-side remote object collector at
* a particular port. Disallow construction from outside.
*/
private DGCImpl() {}
/**
* The dirty call adds the VMID "vmid" to the set of clients
* that hold references to the object associated with the ObjID
* id. The long "sequenceNum" is used to detect late dirty calls. If
* the VMID "vmid" is null, a VMID will be generated on the
* server (for use by the client in subsequent calls) and
* returned.
*
* The client must call the "dirty" method to renew the lease
* before the "lease" time expires or all references to remote
* objects in this VM that the client holds are considered
* "unreferenced".
*/
/*
* The server specifies the lease value; the client has
* no say in the matter.
*/
long duration = leaseValue;
}
// create a VMID if one wasn't supplied
try {
} catch (ServerNotActiveException e) {
clientHost = "<unknown host>";
}
" to client " + clientHost);
}
}
// record lease information
synchronized (leaseTable) {
new Runnable() {
public void run() {
checkLeases();
}
},
}
} else {
}
}
}
}
// return the VMID used
return lease;
}
/**
* The clean call removes the VMID from the set of clients
* that hold references to the object associated with the LiveRef
* ref. The sequence number is used to detect late clean calls. If the
* argument "strong" is true, then the clean call is a result of a
* failed "dirty" call, thus the sequence number for the VMID needs
* to be remembered until the client goes away.
*/
{
}
}
}
/**
* Register interest in receiving a callback when this VMID
* becomes inaccessible.
*/
synchronized (leaseTable) {
} else {
}
}
}
/**
* Remove notification request.
*/
synchronized (leaseTable) {
}
}
}
/**
* Check if leases have expired. If a lease has expired, remove
* it from the table and notify all interested parties that the
* VMID is essentially "dead".
*
* @return if true, there are leases outstanding; otherwise leases
* no longer need to be checked
*/
private void checkLeases() {
/* List of vmids that need to be removed from the leaseTable */
/* Build a list of leaseInfo objects that need to have
* targets removed from their notifySet. Remove expired
* leases from leaseTable.
*/
synchronized (leaseTable) {
}
}
if (leaseTable.isEmpty()) {
}
}
/* Notify and unegister targets without holding the lock on
* the leaseTable so we avoid deadlock.
*/
}
}
}
static {
/*
* "Export" the singleton DGCImpl in a context isolated from
* the arbitrary current thread context.
*/
try {
/*
* Put remote collector object in table by hand to prevent
* listen on port. (UnicastServerRef.exportObject would
* cause transport to listen.)
*/
try {
new UnicastRef(ref), true);
} catch (RemoteException e) {
throw new Error(
"exception initializing server-side DGC", e);
}
} finally {
}
return null;
}
});
}
private static class LeaseInfo {
long expiration;
}
if (newExpiration > expiration)
}
if (expiration < time) {
}
return true;
} else {
return false;
}
}
}
}