Package net.jini.core.lease

Examples of net.jini.core.lease.LeaseMap


    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


    "Unsupported mailbox type requested" + mbType);
  }
 

  logger.log(Level.INFO, "Generating LeaseMap to manage all leases");
  LeaseMap lm = leases[0].createLeaseMap(DURATION);
  for (i = 1; i < numRegs; i++) {
      if (lm.canContainKey(leases[i])) {
    lm.put(leases[i], new Long(DURATION));
      } else {
          throw new TestException("Could not add valid lease to Map");
      }
  }

  logger.log(Level.INFO, "Renewing all leases");
  lm.renewAll();

  logger.log(Level.INFO, "Cancelling even numbered leases");
  int cancelCount = 0;
  for (i = 0; i < numRegs; i++) {
      if ((i % 2) == 0) {
    leases[i].cancel();
    cancelCount++;
      }
  }

  logger.log(Level.INFO, "Renewing all leases");
  try {
      lm.renewAll();
      throw new TestException("Successfully renewed non-existent lease");
  } catch (LeaseMapException lme) {
      if (lme.exceptionMap.size() != cancelCount) {
    dumpLeaseMapException(lme);
    throw new TestException("Received unexpected number "
              + "of exceptions upon renewal");
      } else  {
    logger.log(Level.INFO,
         "Received expected number of renewal exceptions");
      }
  }

  // Note that the LeaseMap will REMOVE the Leases that failed to
  // to renew from the Map. We are working with a subset now.

  logger.log(Level.INFO, "Cancelling another lease");
  leases[1].cancel();
  cancelCount = 1;

  logger.log(Level.INFO, "Cancelling remaining leases");
  try {
      logger.log(Level.INFO,
           "Note: Expect cancelAll() to produce an exception trace"
         + "for the generated LeaseMapException");
      lm.cancelAll();
      throw new TestException("Successfully cancelled "
          + "non-existent lease");
  } catch (LeaseMapException lme) {
      if (lme.exceptionMap.size() != cancelCount) {
    dumpLeaseMapException(lme);
View Full Code Here

         * Wrapper around <code>Lease.leaseMap()</code>
         *
         * @see net.jini.core.lease.Lease#leaseMap
         */
        public LeaseMap createLeaseMap(long renew) {
            LeaseMap map = lease.createLeaseMap(renew);
      return map;
        }
View Full Code Here

      if (bList.size() == 1) {
    Entry e = (Entry) bList.get(0);
    logger.log(Level.FINE, "Renewing lease {0}", e.lease);
    e.lease.renew(e.getRenewDuration(now));
      } else {
    LeaseMap batchLeaseMap = createBatchLeaseMap(bList, now);
    logger.log(Level.FINE, "Renewing leases {0}", batchLeaseMap);
    batchLeaseMap.renewAll();
      }
  } catch (LeaseMapException ex) {
      lmeMap = ex.exceptionMap;
      bad = new ArrayList(lmeMap.size());
  } catch (Throwable ex) {
View Full Code Here

    /** Create a LeaseMap for batch renewal */
    private static LeaseMap createBatchLeaseMap(List bList, long now) {
  Iterator iter = bList.iterator();
  Entry e = (Entry) iter.next();
  LeaseMap batchLeaseMap =
      e.lease.createLeaseMap(e.getRenewDuration(now));
  if (e.lease instanceof RemoteMethodControl &&
      batchLeaseMap instanceof RemoteMethodControl)
  {
      batchLeaseMap = (LeaseMap)
    ((RemoteMethodControl) batchLeaseMap).setConstraints(
        ConstrainableProxyUtil.translateConstraints(
      ((RemoteMethodControl) e.lease).getConstraints(),
      leaseToLeaseMapMethods));
  }
  while (iter.hasNext()) {
      e = (Entry) iter.next();
      batchLeaseMap.put(e.lease, new Long(e.getRenewDuration(now)));
  }
  return batchLeaseMap;
    }
View Full Code Here

      leases[i] = getTransactionManagerLease(mbrs[i]);
      checkLease(leases[i], DURATION);
  }

  logger.log(Level.INFO, "Generating LeaseMap to manage all leases");
  LeaseMap lm = leases[0].createLeaseMap(DURATION);
  for (i = 1; i < numRegs; i++) {
      if (lm.canContainKey(leases[i])) {
    lm.put(leases[i], new Long(DURATION));
      } else {
    throw new TestException( "Could not add valid lease to LeaseMap");
      }
  }

  logger.log(Level.INFO, "Renewing all leases");
  try {
      lm.renewAll();
  } catch (Exception e) {
      throw new TestException( "Caught unexpected exception: " + e);
  }

  logger.log(Level.INFO, "Cancelling even numbered leases");
  int cancelCount = 0;
  for (i = 0; i < numRegs; i++) {
      try {
    if ((i % 2) == 0) {
        leases[i].cancel();
        cancelCount++;
    }
      } catch (Exception e) {
    throw new TestException( "Caught unexpected excetion: " + e);
      }
  }

  logger.log(Level.INFO, "Renewing all leases");
  try {
      lm.renewAll();
      throw new TestException( "Successfully renewed non-existent lease");
  } catch (LeaseMapException lme) {
      if (lme.exceptionMap.size() != cancelCount) {
    dumpLeaseMapException(lme);
    throw new TestException( "Received unexpected number of "
               + "exceptions upon renewal");
      } else  {
    logger.log(Level.INFO, "Received expected number of "
                   + "renewal exceptions");
      }
  }

  // Note that the LeaseMap will REMOVE the Leases that failed to
  // to renew from the Map. We are working with a subset now.

  logger.log(Level.INFO, "Cancelling another lease");
  leases[1].cancel();
  cancelCount = 1;

  logger.log(Level.INFO, "Cancelling remaining leases");
  try {
      logger.log(Level.INFO,
           "Note: Expect cancelAll() to produce an exception trace "
         + "for the generated LeaseMapException");
      lm.cancelAll();
      throw new TestException("Successfully cancelled non-existent"
          + "lease");
  } catch (LeaseMapException lme) {
      if (lme.exceptionMap.size() != cancelCount) {
    dumpLeaseMapException(lme);
View Full Code Here

TOP

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

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.