7.1. Leases on Entries
When we call write, we supply a lease parameter that specifies the amount of time we'd like the space to store the entry. Recall the signature of the write method, which we discussed in Chapter 2:
Lease write(Entry e, Transaction txn, long lease) throws RemoteException, TransactionException;
The write method returns a Lease object that contains the actual lease time the entry was granted—the space may grant the full time requested, or a reduced time. In either case, when the lease time expires, the space will remove the entry from the space. If the space is unable to grant a lease at all, the write method will throw a RemoteException.
So far in this book, we've been supplying Lease.FOREVER as the lease time, which requests ...
Get JavaSpaces™ Principles, Patterns, and Practice now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.