Package net.jini.core.lease

Examples of net.jini.core.lease.Lease


    }


    // Inherit java doc from super type
    public long getExpiration() {
  final Lease cl = getClientLease();
  if (cl == null) {
      // $$$ Why is this synchronized?
      synchronized (this) {   
    return clientLeaseExpiration;
      }
  } else {
      return cl.getExpiration();
  }
    }
View Full Code Here


  }
 
  // Do we have the real lease in unmarshalled form?
  if (clientLease == null) {
      // try to unmarshal client lease
      Lease unmarshalledLease;
      try {
    unmarshalledLease = (Lease) marshalledClientLease.get(false);
      } catch (IOException e) {
    UnmarshalException t = new UnmarshalException(
        "ClientLeaseWrapper.renew:Could not unmarshal client " +
View Full Code Here

      return false;

  if (isDeformed() || clw.isDeformed())
      return false;

  Lease clientLease = getClientLease();
  Lease otherClientLease = clw.getClientLease();
  return sameConstraints(clientLease, otherClientLease) &&
      clientLease.canBatch(otherClientLease);
    }
View Full Code Here

  leaseToRemove = (Lease) leasePreparer.prepareProxy(leaseToRemove);
  logger.log(Level.FINE, "Removing lease {0}", leaseToRemove);

  // The most up-to-date ref to the lease we have
  Lease rslt = null;
  try {
      store.acquireMutatorLock();     
      synchronized (set) {
    ensureCurrent(set);
   
    final ClientLeaseWrapper clw
        = set.getClientLeaseWrapper(leaseToRemove);

    if (clw == null) {
        // Lease must have been removed already
        return null;
    }

    try {
        lrm.remove(clw);
    } catch (UnknownLeaseException e) {
        // This can happen if there was some problem
        // renewing the lease or its LRM expiration just
        // ran out. Since we are removing the lease anyway
        // ignore.
    }

    final boolean present = set.remove(clw)

    // Only return a non-null result if the removed lease
    // had not be removed already
    if (present) {
        // At this point we can assume clw is no
        // longer deformed
        rslt = clw.getClientLease();
    }
      }
  } finally {
      store.releaseMutatorLock();
  }   

  if (rslt == null)
      return null;

  // Whenever we serialize a lease we have to make sure that
  // its serial form will stay the same during the
  // serialization.  Since we have removed it from the set we
  // don't have to worry about this lease being serialized to disk
  // any more so changing the serial format here should be safe.
  rslt.setSerialFormat(Lease.DURATION);
  return rslt;
    }
View Full Code Here

           "this should not happen!",
           e);
      throw new InternalNormException("Error creating lease", e);
  }

  Lease newLease = leaseFactory.newLease(newID, leasePeriod.expiration);
  newSet.setExpiration(leasePeriod.expiration);
  try {
      store.acquireMutatorLock();
      final Object u = new CreateLeaseSet(newSet);
      store.update(u);
View Full Code Here

     * Method used by <code>LeaseSet</code> when it needs to cons up
     * a SetProxy with an up-to-date Lease.  Assumes the appropriate
     * locks have been obtained.
     */
    SetProxy newSetProxy(LeaseSet set) {
  Lease l = leaseFactory.newLease(set.getUuid(), set.getExpiration());
  return SetProxy.create(serverProxy, set.getUuid(), l);
    }
View Full Code Here

     * @param wrapper a wrapper for the lease that wants to be renewed
     * @param duration the duration to associate with wrapper
     * @throws IllegalArgumentException if wrapper is deformed
     */
    ClientLeaseMapWrapper(ClientLeaseWrapper wrapper, long duration) {
  final Lease clientLease = wrapper.getClientLease();
  if (clientLease == null) {
      throw new IllegalArgumentException("Wrapper cannot be deformed");
  }
  LeaseMap leaseMap = clientLease.createLeaseMap(duration);
  if (clientLease instanceof RemoteMethodControl &&
      leaseMap instanceof RemoteMethodControl)
  {
      leaseMap = (LeaseMap)
    ((RemoteMethodControl) leaseMap).setConstraints(
View Full Code Here

      throw e;
  }

  // For each Lease still in the map we need to update the wrapper
  for (Iterator i=clientLeaseMap.keySet().iterator(); i.hasNext(); ) {
      final Lease cl = (Lease) i.next();
      final ClientLeaseWrapper clw =
    (ClientLeaseWrapper) wrapperMap.get(cl);

      clw.successfulRenewal();
  }

  // If there were no errors just return
  if (lme == null && newExceptionMap == null)
      return;

  // If the renewAll() threw a LeaseMapException we have to
  // remove the problem leases from the wrapper and place
  // them in newExceptionMap

  if (lme != null) {
      final Map exceptionMap = lme.exceptionMap;

      // Create the newExceptionMap if we don't have one
      if (newExceptionMap == null)
    newExceptionMap = new HashMap(exceptionMap.size());

      // Copy each lease out of the exception's map into newExceptionMap,
      // also remove these leases from the wrapper and get the
      // failure logged
      for (Iterator i = exceptionMap.entrySet().iterator();
     i.hasNext(); )
      {
    final Map.Entry e = (Map.Entry) i.next();
    final Lease cl = (Lease) e.getKey();
    final Throwable t = (Throwable) e.getValue();
    final ClientLeaseWrapper clw =
        (ClientLeaseWrapper) wrapperMap.remove(cl);
    i.remove();
View Full Code Here

      throw new IllegalArgumentException("value is not a Long");
    }

    // inherit javadoc
    public boolean containsKey(Object key) {
  final Lease cl = checkKey(key)
  return clientLeaseMap.containsKey(cl);
    }
View Full Code Here

  return clientLeaseMap.containsValue(value);
    }

    // inherit javadoc
    public Object get(Object key) {
  final Lease cl = checkKey(key)
  return clientLeaseMap.get(cl);
    }
View Full Code Here

TOP

Related Classes of net.jini.core.lease.Lease

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.