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