public Entry(Lease lease, long expiration, long renewDuration, long renewalRTT, LeaseListener listener) { this.endTime = lease.getExpiration(); this.lease = lease; this.expiration = expiration; this.renewDuration = renewDuration; this.listener = listener; this.renewalRTT = renewalRTT; id = cnt++; }
public Entry(Lease lease, long expiration, long renewDuration, LeaseListener listener, long renewalRTT) { this.endTime = lease.getExpiration(); this.lease = lease; this.expiration = expiration; this.renewDuration = renewDuration; this.listener = listener; this.renewalRTT = renewalRTT; id = cnt++; }
public long getExpiration() { final Lease cl = getClientLease(); if (cl == null) { // $$$ Why is this synchronized? synchronized (this) { return clientLeaseExpiration; } } else { return cl.getExpiration(); } }
/** * Called by the LeaseRenewalManager when it cannot renew a lease that it is managing, and the * lease's desired expiration time has not yet been reached. * * @param leaseManagerEvent Instance of LeaseRenewalEvent containing information about the lease * that the <code>LeaseRenewalManager</code> was unable to renew. **/ public void notify(LeaseRenewalEvent leaseManagerEvent) { if (_logger.isLoggable(Level.FINE)) { Throwable error = leaseManagerEvent.getException(); _logger.fine("LeaseRenewalManager cannot renew this lease <" + leaseManagerEvent.getLease().getExpiration() + ">" + (error != null ? " - " + error.toString() : "")); } }
clientLeaseExpiration = clientLease.getExpiration();
/** Calculate the renew time for the lease entry */ public void calcRenew(long now) { endTime = lease.getExpiration(); if (renewalsDone()) { if (null == desiredExpirationListener()) { // Nothing urgent needs to be done with this lease renew = Long.MAX_VALUE; } else { /* * Tell listener about dropping this lease in a * timely fashion */ renew = expiration; } return; } long delta = endTime - now; if (delta <= renewalRTT * 2) { delta = renewalRTT; } else if (delta <= renewalRTT * 8) { delta /= 2; } else if (delta <= 1000 * 60 * 60 * 24 * 7) { delta /= 8; } else if (delta <= 1000 * 60 * 60 * 24 * 14) { delta = 1000 * 60 * 60 * 24; } else { delta = 1000 * 60 * 60 * 24 * 3; } renew = endTime - delta; }
endTime = lease.getExpiration(); if (renewalsDone()) { if (null == desiredExpirationListener()) {
/** * 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); }
public ServiceRegistration register(Item nitem, long leaseDuration) throws NoSuchObjectException { long startTime = 0; if (loggerStats.isLoggable(Level.FINEST)) { startTime = SystemTime.timeMillis(); } concurrentObj.writeLock(); try { ready.check(); ServiceRegistration reg = registerDo(nitem, leaseDuration); if (logger.isLoggable(Level.FINE)) { logger.log( Level.FINE, "registered instance of {0} as {1} with lease of {2} ms", new Object[]{ nitem.serviceType.getName(), reg.getServiceID(), (reg.getLease().getExpiration() - SystemTime.timeMillis())}); } return reg; } finally { concurrentObj.writeUnlock(); if (loggerStats.isLoggable(Level.FINEST)) { long duration = SystemTime.timeMillis() - startTime; if (duration > registerMaxDuration) { registerMaxDuration = duration; } loggerStats.finest("DURATION [" + duration + "]\t\tMAX [" + registerMaxDuration + "]"); } } }
public EventRegistration addListener(Object template, long lease, NotifyInfo notifyInfo, boolean isMultiplex) throws RemoteException { try { _spaceProxy.beforeSpaceAction(); final ITemplatePacket templatePacket = createTemplatePacket(template); if (!notifyInfo.isFifo()) { if (_spaceProxy.isFifo() || (templatePacket.getTypeDescriptor() != null && templatePacket.getTypeDescriptor().isFifoDefault())) notifyInfo.setFifo(true); } wrapAndExportListener(notifyInfo, isMultiplex); final RegisterEntriesListenerSpaceOperationRequest request = new RegisterEntriesListenerSpaceOperationRequest( templatePacket, notifyInfo, lease); _spaceProxy.getProxyRouter().execute(request); RegisterEntriesListenerSpaceOperationResult result = request.getFinalResult(); result.processExecutionException(); final GSEventRegistration eventRegistration = result.getEventRegistration(); eventRegistration.setLease(new SpaceNotifyLease( _spaceProxy, templatePacket.getTypeName(), ((LeaseContext) eventRegistration.getLease()).getUID(), templatePacket.getRoutingFieldValue(), eventRegistration.getLease().getExpiration(), (ManagedRemoteEventListener) notifyInfo.getListener(), eventRegistration)); return eventRegistration; } catch (InterruptedException e) { throw new InterruptedSpaceException(e); } }