/** * Return the client lease in marshalled form. If possible * marshal using the Lease.DURATION serialization format. * <p> * Assumes that no one else will be serializing the lease * during this call. */ MarshalledInstance getMarshalledClientLease() { final Lease cl = getClientLease(); if (cl == null) { // We are deformed, best we can do is return the (possibly // stale) pre-marshalled lease we already have return marshalledClientLease; } else { try { cl.setSerialFormat(Lease.DURATION); return new MarshalledInstance(cl); } catch (IOException e) { // Can't create a new MarshalledInstance, return the old one return marshalledClientLease; } finally { cl.setSerialFormat(Lease.ABSOLUTE); } } }
/** * Simple constructor * @param clientLease lease from client that is to be renewed * @param UID ID number for this wrapper unique for all wrappers in a given * server * @param renewedList list that wrapper should go on after renewing their * client lease is renewed * @param leaseSet the <code>LeaseSet</code> this lease is in * @param membershipDuration * initial membership duration for this lease * @param renewDuration * initial membership expiration for the lease * @param now the current time */ ClientLeaseWrapper(Lease clientLease, long UID, List renewedList, LeaseSet leaseSet, long membershipDuration, long renewDuration, long now) throws IOException { this.renewedList = renewedList; this.UID = UID; this.clientLease = clientLease; set = leaseSet; clientLeaseExpiration = clientLease.getExpiration(); clientLease.setSerialFormat(Lease.ABSOLUTE); marshalledClientLease = new AtomicMarshalledInstance(clientLease); this.renewDuration = renewDuration; membershipExpiration = calcMembershipExpiration(membershipDuration, now); }
rslt.setSerialFormat(Lease.DURATION); return rslt;