001 /*
002 * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package java.rmi.dgc;
026
027 import java.rmi.*;
028 import java.rmi.server.ObjID;
029
030 /**
031 * The DGC abstraction is used for the server side of the distributed
032 * garbage collection algorithm. This interface contains the two
033 * methods: dirty and clean. A dirty call is made when a remote
034 * reference is unmarshaled in a client (the client is indicated by
035 * its VMID). A corresponding clean call is made when no more
036 * references to the remote reference exist in the client. A failed
037 * dirty call must schedule a strong clean call so that the call's
038 * sequence number can be retained in order to detect future calls
039 * received out of order by the distributed garbage collector.
040 *
041 * A reference to a remote object is leased for a period of time by
042 * the client holding the reference. The lease period starts when the
043 * dirty call is received. It is the client's responsibility to renew
044 * the leases, by making additional dirty calls, on the remote
045 * references it holds before such leases expire. If the client does
046 * not renew the lease before it expires, the distributed garbage
047 * collector assumes that the remote object is no longer referenced by
048 * that client.
049 *
050 * @author Ann Wollrath
051 */
052 public interface DGC extends Remote {
053
054 /**
055 * The dirty call requests leases for the remote object references
056 * associated with the object identifiers contained in the array
057 * 'ids'. The 'lease' contains a client's unique VM identifier (VMID)
058 * and a requested lease period. For each remote object exported
059 * in the local VM, the garbage collector maintains a reference
060 * list-a list of clients that hold references to it. If the lease
061 * is granted, the garbage collector adds the client's VMID to the
062 * reference list for each remote object indicated in 'ids'. The
063 * 'sequenceNum' parameter is a sequence number that is used to
064 * detect and discard late calls to the garbage collector. The
065 * sequence number should always increase for each subsequent call
066 * to the garbage collector.
067 *
068 * Some clients are unable to generate a VMID, since a VMID is a
069 * universally unique identifier that contains a host address
070 * which some clients are unable to obtain due to security
071 * restrictions. In this case, a client can use a VMID of null,
072 * and the distributed garbage collector will assign a VMID for
073 * the client.
074 *
075 * The dirty call returns a Lease object that contains the VMID
076 * used and the lease period granted for the remote references (a
077 * server may decide to grant a smaller lease period than the
078 * client requests). A client must use the VMID the garbage
079 * collector uses in order to make corresponding clean calls when
080 * the client drops remote object references.
081 *
082 * A client VM need only make one initial dirty call for each
083 * remote reference referenced in the VM (even if it has multiple
084 * references to the same remote object). The client must also
085 * make a dirty call to renew leases on remote references before
086 * such leases expire. When the client no longer has any
087 * references to a specific remote object, it must schedule a
088 * clean call for the object ID associated with the reference.
089 *
090 * @param ids IDs of objects to mark as referenced by calling client
091 * @param sequenceNum sequence number
092 * @param lease requested lease
093 * @return granted lease
094 * @throws RemoteException if dirty call fails
095 */
096 Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
097 throws RemoteException;
098
099 /**
100 * The clean call removes the 'vmid' from the reference list of
101 * each remote object indicated in 'id's. The sequence number is
102 * used to detect late clean calls. If the argument 'strong' is
103 * true, then the clean call is a result of a failed dirty call,
104 * thus the sequence number for the client 'vmid' needs to be
105 * remembered.
106 *
107 * @param ids IDs of objects to mark as unreferenced by calling client
108 * @param sequenceNum sequence number
109 * @param vmid client VMID
110 * @param strong make 'strong' clean call
111 * @throws RemoteException if clean call fails
112 */
113 void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
114 throws RemoteException;
115 }
|