APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.rmi.transport

pack-priv final Class DGCClient

extends Object
Class Inheritance
Imports
java.io.InvalidClassException, java.lang.ref.PhantomReference, .ReferenceQueue, java.rmi.UnmarshalException, .RemoteException, java.util.HashMap, .HashSet, .Iterator, .List, .Map, .Set, java.rmi.dgc.DGC, .Lease, .VMID, java.rmi.server.ObjID, sun.rmi.runtime.Log, .RuntimeUtil, sun.rmi.server.UnicastRef, .Util

DGCClient implements the client-side of the RMI distributed garbage collection system. The external interface to DGCClient is the "registerRefs" method. When a LiveRef to a remote object enters the VM, it needs to be registered with the DGCClient to participate in distributed garbage collection. When the first LiveRef to a particular remote object is registered, a "dirty" call is made to the server-side distributed garbage collector for the remote object, which returns a lease guaranteeing that the server-side DGC will not collect the remote object for a certain period of time. While LiveRef instances to remote objects on a particular server exist, the DGCClient periodically sends more "dirty" calls to renew its lease. The DGCClient tracks the local reachability of registered LiveRef instances (using phantom references). When the LiveRef instance for a particular remote object becomes garbage collected locally, a "clean" call is made to the server-side distributed garbage collector, indicating that the server no longer needs to keep the remote object alive for this client.
Authors
Ann Wollrath, Peter Jones
See Also
sun.rmi.transport.DGCImpl

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DGCClient.EndpointEntry

EndpointEntry encapsulates the client-side DGC information specific to a particular Endpoint.

Field Summary

Modifier and TypeField and Description
private static final int
cleanFailureRetries

retry count for clean calls that fail with ConnectException

private static final long
cleanInterval

maximum interval between retries of failed clean calls

private static final ObjID
dgcID

ObjID for server-side DGC object

private static final int
dirtyFailureRetries

minimum retry count for dirty calls that fail

private static final ObjID[]
emptyObjIDArray

constant empty ObjID array for lease renewal optimization

private static final long
gcInterval

maximum interval between complete garbage collections of local heap

private static final long
leaseValue

lease duration to request (usually ignored by server)

private static long
nextSequenceNum

next sequence number for DGC calls (access synchronized on class)

private static VMID
vmid

unique identifier for this VM as a client of DGC

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static long
computeRenewTime(long grantTime, long duration)

Given the length of a lease and the time that it was granted, compute the absolute time at which it should be renewed, giving room for reasonable computational and communication delays.

private static synchronized long
getNextSequenceNum()

Get the next sequence number to be used for a dirty or clean operation from this VM.

pack-priv static void
registerRefs(Endpoint ep, List<LiveRef> refs)

Register the LiveRef instances in the supplied list to participate in distributed garbage collection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanFailureRetriesback to summary
private static final int cleanFailureRetries

retry count for clean calls that fail with ConnectException

cleanIntervalback to summary
private static final long cleanInterval

maximum interval between retries of failed clean calls

dgcIDback to summary
private static final ObjID dgcID

ObjID for server-side DGC object

dirtyFailureRetriesback to summary
private static final int dirtyFailureRetries

minimum retry count for dirty calls that fail

emptyObjIDArrayback to summary
private static final ObjID[] emptyObjIDArray

constant empty ObjID array for lease renewal optimization

gcIntervalback to summary
private static final long gcInterval

maximum interval between complete garbage collections of local heap

leaseValueback to summary
private static final long leaseValue

lease duration to request (usually ignored by server)

nextSequenceNumback to summary
private static long nextSequenceNum

next sequence number for DGC calls (access synchronized on class)

vmidback to summary
private static VMID vmid

unique identifier for this VM as a client of DGC

Constructor Detail

DGCClientback to summary
private DGCClient()

Method Detail

computeRenewTimeback to summary
private static long computeRenewTime(long grantTime, long duration)

Given the length of a lease and the time that it was granted, compute the absolute time at which it should be renewed, giving room for reasonable computational and communication delays.

getNextSequenceNumback to summary
private static synchronized long getNextSequenceNum()

Get the next sequence number to be used for a dirty or clean operation from this VM. This method should only be called while synchronized on the EndpointEntry whose data structures the operation affects.

registerRefsback to summary
pack-priv static void registerRefs(Endpoint ep, List<LiveRef> refs)

Register the LiveRef instances in the supplied list to participate in distributed garbage collection. All of the LiveRefs in the list must be for remote objects at the given endpoint.

sun.rmi.transport back to summary

private Class DGCClient.EndpointEntry

extends Object
Class Inheritance

EndpointEntry encapsulates the client-side DGC information specific to a particular Endpoint. Of most significance is the table that maps LiveRef value to RefEntry objects and the renew/clean thread that handles asynchronous client-side DGC operations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DGCClient.EndpointEntry.CleanRequest

CleanRequest holds the data for the parameters of a clean call that needs to be made.

private class
DGCClient.EndpointEntry.RefEntry

RefEntry encapsulates the client-side DGC information specific to a particular LiveRef value.

private class
DGCClient.EndpointEntry.RenewCleanThread

RenewCleanThread handles the asynchronous client-side DGC activity for this entry: renewing the leases and making clean calls.

Field Summary

Modifier and TypeField and Description
private DGC
dgc

synthesized reference to the remote server-side DGC

private long
dirtyFailureDuration

(average) elapsed time for recent failed dirty calls

private int
dirtyFailures

count of recent dirty calls that have failed

private long
dirtyFailureStartTime

absolute time of first recent failed dirty call

private Endpoint
endpoint

the endpoint that this entry is for

private static Map<Endpoint, DGCClient.EndpointEntry>
endpointTable

global endpoint table: maps Endpoint to EndpointEntry

private long
expirationTime

absolute time current lease to this endpoint will expire

private static GC.LatencyRequest
gcLatencyRequest

handle for GC latency request (for future cancellation)

private boolean
interruptible

true if renew/clean thread may be interrupted

private Set<DGCClient.EndpointEntry.RefEntry>
invalidRefs

set of RefEntry instances from last (failed) dirty call

private Set<DGCClient.EndpointEntry.CleanRequest>
pendingCleans

set of clean calls that need to be made

private ReferenceQueue<LiveRef>
refQueue

reference queue for phantom references

private Map<LiveRef, DGCClient.EndpointEntry.RefEntry>
refTable

table of refs held for endpoint: maps LiveRef to RefEntry

private boolean
removed

true if this entry has been removed from the global table

private Thread
renewCleanThread

renew/clean thread for handling lease renewals and clean calls

private long
renewTime

absolute time to renew current lease to this endpoint

Constructor Summary

AccessConstructor and Description
private
EndpointEntry(final Endpoint endpoint)

Method Summary

Modifier and TypeMethod and Description
private static ObjID[]
createObjIDArray(Set<DGCClient.EndpointEntry.RefEntry> refEntries)

Create an array of ObjIDs (needed for the DGC remote calls) from the ids in the given set of refs.

public static DGCClient.EndpointEntry
lookup(Endpoint ep)

Look up the EndpointEntry for the given Endpoint.

private void
makeCleanCalls()

Make all of the clean calls described by the clean requests in this entry's set of "pending cleans".

private void
makeDirtyCall(Set<DGCClient.EndpointEntry.RefEntry> refEntries, long sequenceNum)

Make a DGC dirty call to this entry's endpoint, for the ObjIDs corresponding to the given set of refs and with the given sequence number.

private void
processPhantomRefs(DGCClient.EndpointEntry.RefEntry.PhantomLiveRef phantom)

Process the notification of the given phantom reference and any others that are on this entry's reference queue.

public boolean
registerRefs(List<LiveRef> refs)

Register the LiveRef instances in the supplied list to participate in distributed garbage collection.

private void
removeRefEntry(DGCClient.EndpointEntry.RefEntry refEntry)

Remove the given RefEntry from the ref table.

private void
setRenewTime(long newRenewTime)

Set the absolute time at which the lease for this entry should be renewed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dgcback to summary
private DGC dgc

synthesized reference to the remote server-side DGC

dirtyFailureDurationback to summary
private long dirtyFailureDuration

(average) elapsed time for recent failed dirty calls

dirtyFailuresback to summary
private int dirtyFailures

count of recent dirty calls that have failed

dirtyFailureStartTimeback to summary
private long dirtyFailureStartTime

absolute time of first recent failed dirty call

endpointback to summary
private Endpoint endpoint

the endpoint that this entry is for

endpointTableback to summary
private static Map<Endpoint, DGCClient.EndpointEntry> endpointTable

global endpoint table: maps Endpoint to EndpointEntry

expirationTimeback to summary
private long expirationTime

absolute time current lease to this endpoint will expire

gcLatencyRequestback to summary
private static GC.LatencyRequest gcLatencyRequest

handle for GC latency request (for future cancellation)

interruptibleback to summary
private boolean interruptible

true if renew/clean thread may be interrupted

invalidRefsback to summary
private Set<DGCClient.EndpointEntry.RefEntry> invalidRefs

set of RefEntry instances from last (failed) dirty call

pendingCleansback to summary
private Set<DGCClient.EndpointEntry.CleanRequest> pendingCleans

set of clean calls that need to be made

refQueueback to summary
private ReferenceQueue<LiveRef> refQueue

reference queue for phantom references

refTableback to summary
private Map<LiveRef, DGCClient.EndpointEntry.RefEntry> refTable

table of refs held for endpoint: maps LiveRef to RefEntry

removedback to summary
private boolean removed

true if this entry has been removed from the global table

renewCleanThreadback to summary
private Thread renewCleanThread

renew/clean thread for handling lease renewals and clean calls

renewTimeback to summary
private long renewTime

absolute time to renew current lease to this endpoint

Constructor Detail

EndpointEntryback to summary
private EndpointEntry(final Endpoint endpoint)

Method Detail

createObjIDArrayback to summary
private static ObjID[] createObjIDArray(Set<DGCClient.EndpointEntry.RefEntry> refEntries)

Create an array of ObjIDs (needed for the DGC remote calls) from the ids in the given set of refs.

lookupback to summary
public static DGCClient.EndpointEntry lookup(Endpoint ep)

Look up the EndpointEntry for the given Endpoint. An entry is created if one does not already exist.

makeCleanCallsback to summary
private void makeCleanCalls()

Make all of the clean calls described by the clean requests in this entry's set of "pending cleans". Clean requests for clean calls that succeed are removed from the "pending cleans" set. This method must NOT be called while synchronized on this entry.

makeDirtyCallback to summary
private void makeDirtyCall(Set<DGCClient.EndpointEntry.RefEntry> refEntries, long sequenceNum)

Make a DGC dirty call to this entry's endpoint, for the ObjIDs corresponding to the given set of refs and with the given sequence number. This method must NOT be called while synchronized on this entry.

processPhantomRefsback to summary
private void processPhantomRefs(DGCClient.EndpointEntry.RefEntry.PhantomLiveRef phantom)

Process the notification of the given phantom reference and any others that are on this entry's reference queue. Each phantom reference is removed from its RefEntry's ref set. All ref entries that have no more registered instances are collected into up to two batched clean call requests: one for refs requiring a "strong" clean call, and one for the rest. This method must ONLY be called while synchronized on this entry.

registerRefsback to summary
public boolean registerRefs(List<LiveRef> refs)

Register the LiveRef instances in the supplied list to participate in distributed garbage collection. This method returns false if this entry was removed from the global endpoint table (because it was empty) before these refs could be registered. In that case, a new EndpointEntry needs to be looked up. This method must NOT be called while synchronized on this entry.

removeRefEntryback to summary
private void removeRefEntry(DGCClient.EndpointEntry.RefEntry refEntry)

Remove the given RefEntry from the ref table. If that makes the ref table empty, remove this entry from the global endpoint table. This method must ONLY be called while synchronized on this entry.

setRenewTimeback to summary
private void setRenewTime(long newRenewTime)

Set the absolute time at which the lease for this entry should be renewed. This method must ONLY be called while synchronized on this entry.

sun.rmi.transport back to summary

private Class DGCClient.EndpointEntry.CleanRequest

extends Object
Class Inheritance

CleanRequest holds the data for the parameters of a clean call that needs to be made.

Field Summary

Modifier and TypeField and Description
pack-priv int
failures

how many times this request has failed

pack-priv final ObjID[]
pack-priv final long
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
CleanRequest(ObjID[] objIDs, long sequenceNum, boolean strong)

Field Detail

failuresback to summary
pack-priv int failures

how many times this request has failed

objIDsback to summary
pack-priv final ObjID[] objIDs
sequenceNumback to summary
pack-priv final long sequenceNum
strongback to summary
pack-priv final boolean strong

Constructor Detail

CleanRequestback to summary
pack-priv CleanRequest(ObjID[] objIDs, long sequenceNum, boolean strong)
sun.rmi.transport back to summary

private Class DGCClient.EndpointEntry.RefEntry

extends Object
Class Inheritance

RefEntry encapsulates the client-side DGC information specific to a particular LiveRef value. In particular, it contains a set of phantom references to all of the instances of the LiveRef value registered in the system (but not garbage collected locally).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
DGCClient.EndpointEntry.RefEntry.PhantomLiveRef

PhantomLiveRef is a PhantomReference to a LiveRef instance, used to detect when the LiveRef becomes permanently unreachable in this VM.

Field Summary

Modifier and TypeField and Description
private boolean
dirtyFailed

true if a dirty call containing this ref has failed

private LiveRef
ref

LiveRef value for this entry (not a registered instance)

private Set<DGCClient.EndpointEntry.RefEntry.PhantomLiveRef>
refSet

set of phantom references to registered instances

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addInstanceToRefSet(LiveRef ref)

Add a LiveRef to the set of registered instances for this entry.

public LiveRef
getRef()

Return the LiveRef value for this entry (not a registered instance).

public boolean
hasDirtyFailed()

Return true if a dirty call that explicitly contained this entry's ref has failed (and therefore a clean call for this ref needs to be marked "strong").

public boolean
isRefSetEmpty()

Return true if there are no registered LiveRef instances for this entry still reachable in this VM.

public void
markDirtyFailed()

Record that a dirty call that explicitly contained this entry's ref has failed.

public void
removeInstanceFromRefSet(DGCClient.EndpointEntry.RefEntry.PhantomLiveRef phantom)

Remove a PhantomLiveRef from the set of registered instances.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dirtyFailedback to summary
private boolean dirtyFailed

true if a dirty call containing this ref has failed

refback to summary
private LiveRef ref

LiveRef value for this entry (not a registered instance)

refSetback to summary
private Set<DGCClient.EndpointEntry.RefEntry.PhantomLiveRef> refSet

set of phantom references to registered instances

Constructor Detail

RefEntryback to summary
public RefEntry(LiveRef ref)

Method Detail

addInstanceToRefSetback to summary
public void addInstanceToRefSet(LiveRef ref)

Add a LiveRef to the set of registered instances for this entry. This method must ONLY be invoked while synchronized on this RefEntry's EndpointEntry.

getRefback to summary
public LiveRef getRef()

Return the LiveRef value for this entry (not a registered instance).

hasDirtyFailedback to summary
public boolean hasDirtyFailed()

Return true if a dirty call that explicitly contained this entry's ref has failed (and therefore a clean call for this ref needs to be marked "strong"). This method must ONLY be invoked while synchronized on this RefEntry's EndpointEntry.

isRefSetEmptyback to summary
public boolean isRefSetEmpty()

Return true if there are no registered LiveRef instances for this entry still reachable in this VM. This method must ONLY be invoked while synchronized on this RefEntry's EndpointEntry.

markDirtyFailedback to summary
public void markDirtyFailed()

Record that a dirty call that explicitly contained this entry's ref has failed. This method must ONLY be invoked while synchronized on this RefEntry's EndpointEntry.

removeInstanceFromRefSetback to summary
public void removeInstanceFromRefSet(DGCClient.EndpointEntry.RefEntry.PhantomLiveRef phantom)

Remove a PhantomLiveRef from the set of registered instances. This method must ONLY be invoked while synchronized on this RefEntry's EndpointEntry.

sun.rmi.transport back to summary

private Class DGCClient.EndpointEntry.RefEntry.PhantomLiveRef

extends PhantomReference<LiveRef>
Class Inheritance

PhantomLiveRef is a PhantomReference to a LiveRef instance, used to detect when the LiveRef becomes permanently unreachable in this VM.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public DGCClient.EndpointEntry.RefEntry
Inherited from java.lang.ref.PhantomReference:
get

Constructor Detail

PhantomLiveRefback to summary
public PhantomLiveRef(LiveRef ref)

Method Detail

getRefEntryback to summary
public DGCClient.EndpointEntry.RefEntry getRefEntry()
sun.rmi.transport back to summary

private Class DGCClient.EndpointEntry.RenewCleanThread

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

RenewCleanThread handles the asynchronous client-side DGC activity for this entry: renewing the leases and making clean calls.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RenewCleanThreadback to summary
private RenewCleanThread()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.