Package net.jini.core.lease

Examples of net.jini.core.lease.Lease


    public void run() throws Exception {
        specifyServices(new Class[] {
            TransactionManager.class, JavaSpace.class});
        space = (JavaSpace) services[1];
        txnMgr = (TransactionManager) services[0];
        final Lease el = space.write(entry, null, 1000 * 60 * 60);
        logger.log(Level.INFO, "Wrote entry");
        addOutriggerLease(el, true);
        final Transaction.Created txnHolder =
                TransactionFactory.create(txnMgr, 1000 * 60 * 60);
        final Transaction txn = txnHolder.transaction;
View Full Code Here


                logger.log(Level.FINE, "registering test service "
                                              +i+" with lookup service "+loc);
                ServiceRegistration srvcReg =
                 lookupProxy.register(new ServiceItem(srvcID,testService,null),
                                      Long.MAX_VALUE);
    Lease srvcLease = null;
    try {
        srvcReg = (ServiceRegistration) getConfig().prepare(
           "test.reggieServiceRegistrationPreparer",
           srvcReg);
        srvcLease = (Lease) getConfig().prepare(
View Full Code Here

  rstUtil.waitForLeaseExpiration(lease[5],
       "for the remaining client leases to expire.");

  // assert that all leases have expired
  for (int i = 0; i < 6; ++i) {
      Lease managedLease = set.remove(lease[i]);
      if (managedLease != null) {
    String message = "Lease #" + i + " did not expire as " +
        "expect.";
    throw new TestException(message);
      }
View Full Code Here

  // wait the lease to expire
  rstUtil.waitForLeaseExpiration(testLease,
               "for client lease to expire.");

  // assert that the lease is no longer in the renewal set
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "The lease that expired due to a definite";
      message += " exception was never removed from the\n";
      message += "renewal set.";
      return message;
View Full Code Here

  /* we need to sleep a bit longer because the LRS implementation
     might still be busy re-trying the renew operation */
  rstUtil.sleepAndTell(renewGrant/2, "to allow for lease removal.");

  // assert that the lease is no longer in the renewal set
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "The lease that expired due to a indefinite";
      message += " exception was never removed from the\n";
      message += "renewal set.";
      return message;
View Full Code Here

    public synchronized void notify(RemoteEvent theEvent)
           throws UnknownEventException, RemoteException {
  super.notify(theEvent);
  if (theEvent.getClass() == ExpirationWarningEvent.class) {
      LeaseRenewalSet set = (LeaseRenewalSet) theEvent.getSource();
      Lease lease = null;
      try {
    set = (LeaseRenewalSet)
          QAConfig.getConfig().prepare("test.normRenewalSetPreparer",
              set);
    lease = set.getRenewalSetLease();
    lease =  (Lease)
       QAConfig.getConfig().prepare("test.normLeasePreparer",
                 lease);
      } catch (TestException e) {
    renewalException = e;
    logger.log(Level.INFO,"Configuration error", e);
    return;
      }
      // try to renew until lease is expired.
      boolean canBeRenewed = true;
      while (canBeRenewed) {
    try {
        lease.renew(duration);
        renewalException = null;
        canBeRenewed = false;
        lastLeaseRenewed = lease;
        logger.log(Level.FINE, "Successfully renewed for " + duration +
                   " milliseconds.");
    } catch (Exception ex) {
        // assign the exception for later retrieval
        renewalException = ex;
        canBeRenewed =
      (lease.getExpiration() >= System.currentTimeMillis());
        if (canBeRenewed) {
      logger.log(Level.FINE, "Failed to renew lease, trying again.");
        } else {
      logger.log(Level.FINE, "Failed to renew lease, quitting.");
        }
View Full Code Here

     */
    protected void shortenLeases(long newLeaseDur) throws Exception {
        leaseRenewalMgr.clear();//remove the leases from the lease renewal mgr
        /* Shorten each service lease duration for quick expiration */
        for(int i=0;i<leaseList.size();i++) {
            Lease srvcLease = (Lease)(leaseList.get(i));
            logger.log(Level.FINE, "service lease["+i+"] changed to expire "
                              +"within "+(newLeaseDur/1000)+" second(s) -- "
                              +"simulates a down service");
            srvcLease.renew(newLeaseDur);
        }//end loop
        /* Remove all leases so we don't try to cancel them during shutdown. */
        leaseList.clear();
    }//end shortenLeases
View Full Code Here

      throw new TestException(message);
  }

  // assert it's the set that failed
  RenewalFailureEvent rfe = (RenewalFailureEvent) events[0];
  Lease failedLease = rfe.getLease();
  if (failedLease.equals(lease03) == false) {
      String message = "The source of the event was not the set" +
    " that caused the RenewalFailureEvent.";
      throw new TestException(message);
  }
View Full Code Here

  logger.log(Level.FINE, "Adding lease with membership of " +
        "Lease.FOREVER");
  set.renewFor(testLease, Lease.FOREVER);

  // remove the lease
  Lease managedLease = set.remove(testLease);
  if (managedLease.equals(testLease) == false) {
      String message = "Lease removed does not match the lease\n" +
           "originally added to the set.";
      throw new TestException(message);
  }
View Full Code Here

  set.renewFor(testLease2, Lease.FOREVER);
  set.renewFor(testLease3, Lease.FOREVER);
 
  // allow the lease of the renewal set to expire
  logger.log(Level.FINE, "Getting the renewal set lease.");
  Lease setLease = prepareLease(set.getRenewalSetLease());
  boolean success = expireRenewalSetLease(setLease);
  if (success == false) {
      String message = "Lease did not expire as expected.\n";
      throw new TestException(message);
  }

  // assert that any attempt to use the set results in an exception
  try {
      Lease managedLease = set.remove(testLease1);
      String message = "Performed successful remove operation on\n";
      message += " renewal set after its lease had expired.";
      throw new TestException(message);
  } catch (NoSuchObjectException ex) {
      // we passed so just keep on going ...
  }

  try {
      Lease managedLease = leaseProvider.createNewLease(owner,
                    renewGrant);
      set.renewFor(managedLease, Lease.FOREVER);
      managedLease.cancel();
      String message = "Performed successful add operation on\n";
      message += " renewal set after its lease had expired.";
      throw new TestException(message);
  } catch (NoSuchObjectException ex) {
      // we passed so just keep on going ...
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.