1. /*
  2. * @(#)DGC.java 1.9 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.dgc;
  8. import java.rmi.*;
  9. import java.rmi.server.ObjID;
  10. /**
  11. * The DGC abstraction is used for the server side of the distributed
  12. * garbage collection algorithm. This interface contains the two
  13. * methods: dirty and clean. A dirty call is made when a remote
  14. * reference is unmarshaled in a client (the client is indicated by
  15. * its VMID). A corresponding clean call is made when no more
  16. * references to the remote reference exist in the client. A failed
  17. * dirty call must schedule a strong clean call so that the call's
  18. * sequence number can be retained in order to detect future calls
  19. * received out of order by the distributed garbage collector.
  20. *
  21. * A reference to a remote object is leased for a period of time by
  22. * the client holding the reference. The lease period starts when the
  23. * dirty call is received. It is the client's responsibility to renew
  24. * the leases, by making additional dirty calls, on the remote
  25. * references it holds before such leases expire. If the client does
  26. * not renew the lease before it expires, the distributed garbage
  27. * collector assumes that the remote object is no longer referenced by
  28. * that client.
  29. *
  30. * @author Ann Wollrath
  31. */
  32. public interface DGC extends Remote {
  33. /**
  34. * The dirty call requests leases for the remote object references
  35. * associated with the object identifiers contained in the array
  36. * 'ids'. The 'lease' contains a client's unique VM identifier (VMID)
  37. * and a requested lease period. For each remote object exported
  38. * in the local VM, the garbage collector maintains a reference
  39. * list-a list of clients that hold references to it. If the lease
  40. * is granted, the garbage collector adds the client's VMID to the
  41. * reference list for each remote object indicated in 'ids'. The
  42. * 'sequenceNum' parameter is a sequence number that is used to
  43. * detect and discard late calls to the garbage collector. The
  44. * sequence number should always increase for each subsequent call
  45. * to the garbage collector.
  46. *
  47. * Some clients are unable to generate a VMID, since a VMID is a
  48. * universally unique identifier that contains a host address
  49. * which some clients are unable to obtain due to security
  50. * restrictions. In this case, a client can use a VMID of null,
  51. * and the distributed garbage collector will assign a VMID for
  52. * the client.
  53. *
  54. * The dirty call returns a Lease object that contains the VMID
  55. * used and the lease period granted for the remote references (a
  56. * server may decide to grant a smaller lease period than the
  57. * client requests). A client must use the VMID the garbage
  58. * collector uses in order to make corresponding clean calls when
  59. * the client drops remote object references.
  60. *
  61. * A client VM need only make one initial dirty call for each
  62. * remote reference referenced in the VM (even if it has multiple
  63. * references to the same remote object). The client must also
  64. * make a dirty call to renew leases on remote references before
  65. * such leases expire. When the client no longer has any
  66. * references to a specific remote object, it must schedule a
  67. * clean call for the object ID associated with the reference.
  68. */
  69. Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
  70. throws RemoteException;
  71. /**
  72. * The clean call removes the 'vmid' from the reference list of
  73. * each remote object indicated in 'id's. The sequence number is
  74. * used to detect late clean calls. If the argument 'strong' is
  75. * true, then the clean call is a result of a failed dirty call,
  76. * thus the sequence number for the client 'vmid' needs to be
  77. * remembered.
  78. */
  79. void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
  80. throws RemoteException;
  81. }