Path: blob/master/src/java.rmi/share/classes/java/rmi/dgc/DGC.java
41159 views
/*1* Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package java.rmi.dgc;2526import java.rmi.*;27import java.rmi.server.ObjID;2829/**30* The DGC abstraction is used for the server side of the distributed31* garbage collection algorithm. This interface contains the two32* methods: dirty and clean. A dirty call is made when a remote33* reference is unmarshaled in a client (the client is indicated by34* its VMID). A corresponding clean call is made when no more35* references to the remote reference exist in the client. A failed36* dirty call must schedule a strong clean call so that the call's37* sequence number can be retained in order to detect future calls38* received out of order by the distributed garbage collector.39*40* A reference to a remote object is leased for a period of time by41* the client holding the reference. The lease period starts when the42* dirty call is received. It is the client's responsibility to renew43* the leases, by making additional dirty calls, on the remote44* references it holds before such leases expire. If the client does45* not renew the lease before it expires, the distributed garbage46* collector assumes that the remote object is no longer referenced by47* that client.48*49* @author Ann Wollrath50*/51public interface DGC extends Remote {5253/**54* The dirty call requests leases for the remote object references55* associated with the object identifiers contained in the array56* 'ids'. The 'lease' contains a client's unique VM identifier (VMID)57* and a requested lease period. For each remote object exported58* in the local VM, the garbage collector maintains a reference59* list-a list of clients that hold references to it. If the lease60* is granted, the garbage collector adds the client's VMID to the61* reference list for each remote object indicated in 'ids'. The62* 'sequenceNum' parameter is a sequence number that is used to63* detect and discard late calls to the garbage collector. The64* sequence number should always increase for each subsequent call65* to the garbage collector.66*67* Some clients are unable to generate a VMID, since a VMID is a68* universally unique identifier that contains a host address69* which some clients are unable to obtain due to security70* restrictions. In this case, a client can use a VMID of null,71* and the distributed garbage collector will assign a VMID for72* the client.73*74* The dirty call returns a Lease object that contains the VMID75* used and the lease period granted for the remote references (a76* server may decide to grant a smaller lease period than the77* client requests). A client must use the VMID the garbage78* collector uses in order to make corresponding clean calls when79* the client drops remote object references.80*81* A client VM need only make one initial dirty call for each82* remote reference referenced in the VM (even if it has multiple83* references to the same remote object). The client must also84* make a dirty call to renew leases on remote references before85* such leases expire. When the client no longer has any86* references to a specific remote object, it must schedule a87* clean call for the object ID associated with the reference.88*89* @param ids IDs of objects to mark as referenced by calling client90* @param sequenceNum sequence number91* @param lease requested lease92* @return granted lease93* @throws RemoteException if dirty call fails94*/95Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)96throws RemoteException;9798/**99* The clean call removes the 'vmid' from the reference list of100* each remote object indicated in 'id's. The sequence number is101* used to detect late clean calls. If the argument 'strong' is102* true, then the clean call is a result of a failed dirty call,103* thus the sequence number for the client 'vmid' needs to be104* remembered.105*106* @param ids IDs of objects to mark as unreferenced by calling client107* @param sequenceNum sequence number108* @param vmid client VMID109* @param strong make 'strong' clean call110* @throws RemoteException if clean call fails111*/112void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)113throws RemoteException;114}115116117