RMI specification (9)

zhaozj2021-02-11  202

Chapter 9

The interfaces in this chapter are used in the distributed garbage collector (DGC) of RMI.

Topic: Interface DGC Lease class OBJID class UID class VMID class 9.1 Interface DGC DGC Abstract server side for distributed garbage collection algorithm. This interface contains two methods: Dirty and Clean. DIRTY is called when the remote reference is on the client (the client is represented by VMID). When there is no longer there is a reference to the remote reference, the corresponding cleanup call is performed. Failed D Irty calls must be scheduled to be a Strong (Strong) Clean call to retain the call sequence number, from the detection, after the disorderly call received by the distributed garbage collector.

References to remote objects will have this reference to client rental (Leased) for a while. The rental period begins when the Dirty is received. The client must call DIRTY again on the remote reference before lease expires for renewal. If you don't renew until the expiration, the distributed garbage collector believes that the client will no longer reference the remote object.

Package java.rmi.dgc; import java.rmi.server.objid;

Public Interface DGC Extends Java.rmi.Remote {

Lease Dirty (Objid [] iDS, long seat lese) throws java.rmi.remoteexception;

Void Clean (Objid [] iDS, Long Seqnum, VMID VMID, Boolean Strong) THROWS JAVA.RMI.RemoteException;}

Method DIRTY requests the rental object reference associated with an object identifier contained in array parameter IDs. Lease contains the client unique virtual machine identifier (VMID) and the rented rent period. The garbage collector will preserve a Reference List (Reference List)-Save the referenced client list for the remote objects exported in each local virtual machine. If you are giving, the garbage collector will add the client VMID into the reference list of each remote object indicated in the I DS. SequenceNum is used to detect and discard the sequence number of the post-lateral garbage collector call. Each time you call the garbage collector, the sequence number will increase.

Some clients cannot generate unique VMIDs. This is because only the unique unique identifier when the VMID contains the True host address. Some clients will not be able to get the address due to security restrictions. In this case, the client can use empty VMID. Distributed garbage collectors will assign VMIDs to clients.

Dirty calls will return the Lease object, which contains the VMID and permitted rents used by remote references (the server can decide to grant a breech period than the client requests). The client must use the VMID used in the garbage collector to perform the corresponding Clean calls when the client releases the remote object reference.

Customer virtual machines only need initial Dirty calls for remote references referenced in each virtual machine (even if it is a multiple reference to the same remote object). In addition, the client must also call DIR TY to renew the rental of remote references before lease expire. When the client does not have any references to a specific remote object, the object IDs associated with this reference must be scheduled for a Clean call.

The Clean call removes the VMID from the reference list of the remote object specified by the IDS. The sequence number is used to detect the following cleanup operation. If the parameter strong is true, the CLEAN call is the result of a failed DI RTY call. At this point, you should remember the sequence number of the client VMID.

9.2 Lease class lease contains a unique virtual machine identifier and a rent period. Lease objects are used to request and grant rental of remote object references.

Package Java.rmi.dgc; Public Final Class Lease IMPLEments Java.io.serializable {

Public Lease (VMID ID, long duration);

Public vmid getVmid ();

Public long getValue ();

The Lease constructor creates rental with specific VMID and rent period. VMID can be NULL.

GetVMID method Returns the client VMID associated with the lease.

GetValue method Returns the rental period.

9.3 Objid class OBJID is used as a unique identifier for remote objects as a virtual machine. Each identifier contains an object number and a unique address space identifier on a particular host. The object identifier will assign the object when exporting the remote object.

Objid consists of a unique identifier (UID) of the object number (long) and address space.

Package java.rmi.server;

Public Final Class Objid Implements Java.io.Serializable {

Public Objid ();

Public Objid (int Num);

Public void write (ObjectOutput out) throws java.io.ioException;

Public Static Objid Read (ObjectInput in) THROWS JAVA.IO.IEXCEPTION;

Public int hashcode ()

Public Boolean Equals (Object Obj)

Public String Tostring ()}

The first form of the OBJID constructor will generate a unique object identifier. The second constructor generates a known object identifier (eg, the identifier used by the registration service program and distributed garbage collector), and uses the known object number as a parameter. The known object ID generated by the second constructor does not conflict with the object ID generated by the default constructor; for forced implementation, the object number of the Objid will be set to "known" in the constructor. At the same time all UID domains will be set to zero.

Method WRITE groups the representation of the object ID into the output stream.

Method Read constructs an object ID whose content reads from the specified input stream.

Methods HashCode returns the object number as a HashCode.

If the OBJ is the same as the OBJID content, the equals method returns True.

The TOSTRING method returns a string containing the object ID representation. The address space identifier will be in a string representation only when the object ID comes from a non-local address space.

.4 UID class UID is an abstract class that creates a unique identifier for generating its host. It will be in the form of address space identifiers in Objid. The UID is consisting of a unique number (int), time (long), and counting on the host.

Package java.rmi.server;

Public Final Class Uid Implements Java.io.Serializable {

Public UID ();

Public UID (Short Num);

Public int hashcode ();

Public Boolean Equals (Object Obj);

Public String Tostring ();

Public void write (DataOutput out) throws java.io.ioException;

Public Static Uid Read (DataInput in) THROWS JAVA.IO.IEXCEPTION;

The first form of the constructor will create a unique pure identifier generating its host. This UID has uniqueness under the following conditions: a) The computer takes a second or more time to restart, b) The computer's clock will never be adjusted forward. In order to construct the global unique UID, simply pair the UID and INetAddress respectively. The second form of constructor will create a known UID. IDs are known to have 216 -1 possible. The ID generated by this constructor does not conflict with the ID conflicts generated by the default UID constructor. The default constructor generates a true unique identifier on the host.

Methods HashCode, Equals and Tostring are defined for UID. If the two UIDs are the same, they are considered equivalent.

Method Write will write the UID to the output stream.

Method Read constructs a UID whose content will be read from the specified input stream.

转载请注明原文地址:https://www.9cbs.com/read-4720.html

New Post(0)