use of java.rmi.dgc.Lease in project jdk8u_jdk by JetBrains.
the class DGCImpl method dirty.
/**
* 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".
*/
public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease) {
VMID vmid = lease.getVMID();
/*
* The server specifies the lease value; the client has
* no say in the matter.
*/
long duration = leaseValue;
if (dgcLog.isLoggable(Log.VERBOSE)) {
dgcLog.log(Log.VERBOSE, "vmid = " + vmid);
}
// create a VMID if one wasn't supplied
if (vmid == null) {
vmid = new VMID();
if (dgcLog.isLoggable(Log.BRIEF)) {
String clientHost;
try {
clientHost = RemoteServer.getClientHost();
} catch (ServerNotActiveException e) {
clientHost = "<unknown host>";
}
dgcLog.log(Log.BRIEF, " assigning vmid " + vmid + " to client " + clientHost);
}
}
lease = new Lease(vmid, duration);
// record lease information
synchronized (leaseTable) {
LeaseInfo info = leaseTable.get(vmid);
if (info == null) {
leaseTable.put(vmid, new LeaseInfo(vmid, duration));
if (checker == null) {
checker = scheduler.scheduleWithFixedDelay(new Runnable() {
public void run() {
checkLeases();
}
}, leaseCheckInterval, leaseCheckInterval, TimeUnit.MILLISECONDS);
}
} else {
info.renew(duration);
}
}
for (ObjID id : ids) {
if (dgcLog.isLoggable(Log.VERBOSE)) {
dgcLog.log(Log.VERBOSE, "id = " + id + ", vmid = " + vmid + ", duration = " + duration);
}
ObjectTable.referenced(id, sequenceNum, vmid);
}
// return the VMID used
return lease;
}
Aggregations