Package net.jini.lease

Examples of net.jini.lease.LeaseRenewalSet


  // grab the ever popular LRS
  LeaseRenewalService lrs = getLRS();

  // create a renewal set
  long renewSetDur = Lease.FOREVER;
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  logger.log(Level.FINE, "Created Set 01 with lease duration of " +
        "Lease.FOREVER.");

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  /* assert that using a membership duration of 0
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, 0);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += " with a 0 membership duration has failed.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of -99 (negative test)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, -99);
      // success, keep on trucking ... 
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a negative membership duration has ";
      message += "failed.";
      throw new TestException(message, ex);
  }     

  // trying to remove the lease should result in null value
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "Lease was added to renewal set in error\n";
      message += "from a call to renewFor with 0 membership.";
      throw new TestException(message);
  }
 
  /* assert that using a membership duration of Lease.ANY
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Lease.ANY);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Lease.ANY membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of Lease.FOREVER
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Lease.FOREVER);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Lease.FOREVER membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of Long.MAX_VALUE
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, Long.MAX_VALUE);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a Long.MAX_VALUE membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of 1 (edge case)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, 1);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a 1 millisecond membership duration\n";
      message += "has failed with an IllegalArgumentException.";
      throw new TestException(message, ex);
  }     

  /* assert that using a membership duration of 30000 (normal case)
     does NOT generate an IllegalArgumentException */
  try {
      set.renewFor(testLease, 30000L);
      set.remove(testLease);
      // success, keep on trucking ...
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += "with a 30000 millisecond membership duration\n";
      message += "has failed with an IllegalArgumentException.";
View Full Code Here


  // get a lease renewal set w/ duration for as long as we can
  logger.log(Level.FINE, "Creating the lease renewal set with duration" +
        " of Lease.FOREVER");
  LeaseRenewalService lrs = getLRS();
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(Lease.FOREVER);
  set = prepareSet(set);
  lrm.renewFor(prepareLease(set.getRenewalSetLease()), Lease.FOREVER, null);

  // register listener to receive events
  logger.log(Level.FINE, "Registering listener for renewal failure" +
        " events.");
  set.setRenewalFailureListener(rrl  , null);

  // create the lease to be managed
  logger.log(Level.FINE, "Creating lease with duration of " +
        renewGrant + " milliseconds.");
  Lease testLease =
      leaseProvider.createNewLease(owner,
           rstUtil.durToExp(renewGrant));

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

  /* this should trigger an immediate renewal failure event.
     (implementation dependent? I think so.) */
  set.renewFor(testLease, Lease.FOREVER);

  // wait for an event to arrive
  rstUtil.waitForRemoteEvents(rrl, 1, 30000L);

  // assert we received exactly one event
View Full Code Here

  // grab the ever popular LRS
  LeaseRenewalService lrs = getLRS();

  // create a renewal set
  long renewSetDur = Lease.FOREVER;
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  logger.log(Level.FINE, "Created renewal set with lease duration of " +
        "Lease.FOREVER.");

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // start managing the lease for the base membership time
  logger.log(Level.FINE, "Adding lease with membership of " +
        membershipDuration + " milliseconds");
  set.renewFor(testLease, membershipDuration);

  // wait for 1/2 the membership time
  long sleepTime = membershipDuration / 2;
  rstUtil.sleepAndTell(sleepTime, "1/2 lease membership duration.");

  // now add the lease again doubling the membership duration
  long doubleDuration = membershipDuration * 2;
  logger.log(Level.FINE, "Adding lease with membership of " +
        doubleDuration + " milliseconds");
  set.renewFor(testLease, doubleDuration);

  // sleep for 3/4 of the doubled membershipDuration
  sleepTime = doubleDuration * 3 / 4;
  rstUtil.sleepAndTell(sleepTime, "3/4 lease membership duration.");

  /* if the membership duration was honored we should be able
     to remove the lease */
  Lease managedLease = set.remove(testLease);
  if (managedLease == null) { // new membership was not honored
      String message = "The membership duration was apparently ";
      message += "not updated to the longer value\n";
      message += "when the lease was re-added to the set.";
      throw new TestException(message);
  }

  /* now assert that a shorter time will also be honored.
     start managing the lease for the base membership time
     again */
  logger.log(Level.FINE, "Adding lease with membership of " +
        doubleDuration + " milliseconds");
  set.renewFor(testLease, doubleDuration);
  logger.log(Level.FINE, "Re-adding lease with membership of " +
        membershipDuration + " milliseconds");
  set.renewFor(testLease, membershipDuration);
 
  // sleep 1.5 times the membership to ensure expiration
  sleepTime = membershipDuration + (membershipDuration / 2);
  rstUtil.sleepAndTell(sleepTime, "1.5 X membership duration.");

  /* if the membership duration was honored we should NOT be able
     to remove the lease because its membership has expired */
  managedLease = set.remove(testLease);
  if (managedLease != null) { // new membership was not honored
      String message = "The membership duration was apparently\n";
      message += "updated to a value that was longer than\n";
      message += "the base membership duration when the lease\n";
      message += "was re-added to the set.";
View Full Code Here

  LeaseRenewalService lrs = getLRS();

  // create a renewal set for the requested duration
  logger.log(Level.FINE, "Creating renewal set w/ duration = " +
        renewSetDur + " milliseconds.");
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);

  // register listener #1 to receive events
  logger.log(Level.FINE, "Registering listener for warning events.");
  logger.log(Level.FINE, "minWarning = " + minWarning + ".");
  set.setExpirationWarningListener(rrl, minWarning, null);

  // sleep the length of the lease duration
  rstUtil.waitForLeaseExpiration(prepareLease(set.getRenewalSetLease()),
               "for renewal set to be renewed.");
 
  /* by now it should have been renewed exactly once.
     clear the listener multiple times to ensure no ill effect. */
  try {
      for (int i = 0; i < 10; ++i) {
    set.clearExpirationWarningListener();
      }
  } catch (Exception ex) {
      String message = "Multiple calls to " +
    "clearExpirationWarningListener raises an exception.";
      throw new TestException(message, ex);
  }

  RemoteEvent[] events = rrl.getEvents();
  if (events.length < 1) {
      String message = "Listener did not receive any events.\n" +
    "Should have received exactly one.";
      throw new TestException(message);
  } else if (events.length > 1) {
      String message = "Listener received " + events.length +
    "events.\n" + "Should have received exactly one.";
      throw new TestException(message);
  }

  // There is only one event received, now allow lease to expire
  Lease setLease = rrl.getLastLeaseRenewed();
  rstUtil.waitForLeaseExpiration(setLease,
               "for renewal set to expire.");
 
  // lease should now be expired, prove it ...
  try {
      set.setExpirationWarningListener(rrl, minWarning, null);
      String message = "The set's lease did not expire as expected.";
      throw new TestException(message);
      // we should not get to this place
  } catch (NoSuchObjectException ex) {
      // we are golden if we get to here so just keep on trucking ...
View Full Code Here

  LeaseRenewalService lrs = getLRS();

  // capture times for roundTrip calculations
        // expand round-trip time to tolerate gc-delays, etc.
  long time01 = System.currentTimeMillis();
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  long time02 = System.currentTimeMillis();
  long roundTrip = (time02 - time01) * 10;
  warnLease = prepareLease(set.getRenewalSetLease());
  long warnLeaseExpiration = warnLease.getExpiration();
 
  // create the lease to be managed
  logger.log(Level.FINE, "Creating lease with duration of " +
        renewGrant + " milliseconds.");
  failLease =
      leaseProvider.createNewLease(owner,
           rstUtil.durToExp(renewGrant));
  long failLeaseLocalExpiration = failLease.getExpiration();
  set.renewFor(failLease, Lease.FOREVER);
  long nextFailExpiration = failLeaseLocalExpiration + renewGrant;

  // register listener to receive expiration warning events
  long minWarning = renewSetDur / 2;
  logger.log(Level.FINE, "Registering listener for expiration" +
        " warning events.");
  logger.log(Level.FINE, "minWarning = " + minWarning + " milliseconds.");
  set.setExpirationWarningListener(warnListener, minWarning, null);

  // register listener to receive renewal failure events
  logger.log(Level.FINE, "Registering listener for renewal" +
        " failure events.");
  set.setRenewalFailureListener(failListener, null);

  /* wait for the events to get arrive. We do this by creating
     two threads that wait for the events to arrive and then
     join with both. */
  Thread warnWaitThread =
      rstUtil.createRemoteEventWaitThread(warnListener, 1);
  Thread failWaitThread =
      rstUtil.createRemoteEventWaitThread(failListener, 1);

  long maxWaitTime = Math.max(renewSetDur, renewGrant);

  // wait for expiration warning event
  warnWaitThread.join(maxWaitTime);

  if (warnWaitThread.isAlive() == true) {
      String message = "ExpirationWarningEvent was never received.";
      throw new TestException(message);
  }
 
  // capture the expiration time of the warning event
  ExpirationWarningEvent warnEvent =
      (ExpirationWarningEvent) warnListener.getEvents()[0];
  long warnEventExpiration =
      prepareLease(warnEvent.getRenewalSetLease()).getExpiration();

  // wait for renewal failure event
  failWaitThread.join(maxWaitTime);

  // if the thread is still alive then the event was never received.
  if (failWaitThread.isAlive() == true) {
      String message = "RenewalFailureEvent was never received.";
      throw new TestException(message);
  }

  // capture the expiration time of the renewal failure event
  RenewalFailureEvent failEvent =
      (RenewalFailureEvent) failListener.getEvents()[0];
  long failEventExpiration = failEvent.getLease().getExpiration();

  logger.log(Level.FINE, "Number of failure events = " +
        warnListener.getEvents().length);
  logger.log(Level.FINE, "Number of warning events = " +
        failListener.getEvents().length);


  /* ASSERTION #1 :
     assert that the leases are the ones we expect */
  if (warnLease.equals(prepareLease(warnEvent.getRenewalSetLease())) == false) {
      String message = "Assertion #1 failed.\n" +
    "Expiration warning lease does not match\n" +
    "the lease encapsulated in the ExpirationWarningEvent " +
    "object.";
      throw new TestException(message);
  }

  if (failLease.equals(failEvent.getLease()) == false) {
      String message = "Assertion #1 has failed.\n" +
    "Renewal failure lease does not match the " +
    "lease encapsulated in the RenewalFailureEvent object.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #1 passed.");

  /* ASSERTION #2 :
     the expiration will reflect the expiration of the lease
     when the event occurred. */

  long delta = warnLeaseExpiration - warnEventExpiration;
  if (Math.abs(delta) > roundTrip) {
      logger.log(Level.FINE, "Assertion #2 failed, delta = " + delta
          + "  10*roundTrip = " + roundTrip);
      String message = "Assertion #2 has failed.\n" +
    "Expiration time of lease in warning event does not\n" +
    "reflect the expiration of the lease when the event " +
    "occurred.";
      throw new TestException(message);
  } else {
      logger.log(Level.FINE, "Assertion #2 passed, delta = " + delta
          + "  10*roundTrip = " + roundTrip);
  }

  /*
   * This portion of the assertion is pretty weak. All it says
   * is that the expiration time on the lease is at least
   * within one renewGrant times worth of the original lease.
   * That's pretty broad and may not be particularly useful.
   * The problem is that there is no real way of determining
   * exactly what the lease expiration was at the time the renewal
   * failure event occurred and there is a significant (5 second)
   * time interval between the delivery of the marshalling of the
   * lease object and the delivery of the event.
   */
  if (failEventExpiration > nextFailExpiration) {
      String message = "Assertion #2 has failed.\n" +
    "Expiration time of lease in failure event does not\n" +
    "reflect the expiration of the lease when the event " +
    "occurred.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #2 passed.");

  /* ASSERTION #3 :
     The Throwable Object is the one expected. */        
  Throwable failException = failEvent.getThrowable();
  Throwable targetException = getExpectedException();

  if (! (failException.getClass() == targetException.getClass())) {
      String message = "Assertion #3 has failed.\n" +
    "Throwable encapsulated by the RenewalFailureEvent is" +
    " of type " + failException.getClass() +
    "\nbut an exception of type " +
    targetException.getClass() + " is excepted.";
      throw new TestException(message);
  }

  if ((failException.getMessage().equals
       (targetException.getMessage())) == false) {
      String message = "Assertion #3 has failed.\n" +
    "Throwable encapsulated by the RenewalFailureEvent is" +
    " of type " + failException.getClass() +
    "\nas expected but the instances are different.";
      throw new TestException(message);
  }

  logger.log(Level.FINE, "Assertion #3 passed.");

  /* ASSERTION #4
     The lease whose renewal failed should have been removed
     from the renewal set. */
  Lease managedLease = set.remove(failLease);
  if (managedLease != null) {
      String message = "Assertion #4 failed.\n" +
    "Failed lease was never removed from renewal set.";
      throw new TestException(message);
  }
View Full Code Here

  // create a renewal set
  long renewSetDur = 30000L; // 30 second lease
  logger.log(Level.FINE, "Creating renewal set with lease duration of " +
        renewSetDur + " milliseconds.");
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  lrm.renewFor(prepareLease(set.getRenewalSetLease()), renewSetDur, null);

  // grab two instances of the renewal set lease
  Lease lease01 = prepareLease(set.getRenewalSetLease());
  Lease lease02 = prepareLease(set.getRenewalSetLease());

  // they should be the same
  if (lease01.equals(lease02) == false) {
      String message = "GetRenewalSetLease has returned an\n" +
           "invalid lease.";
      throw new TestException(message);
  }

  /* okay they are the same lease but are they the correct lease??
     well, we can't be sure but we can check to make sure that the
     lease will expire in at least setRenewDur time. */
  logger.log(Level.FINE, "Removing lease from the LRM.");
  lrm.remove(lease01);
  lease01 = prepareLease(set.getRenewalSetLease());
  rstUtil.sleepAndTell(renewSetDur, "for client lease to expire.");
  if (rstUtil.isExpired(lease01) == false) {
      String message = "getRenewalSetLease seems to have\n" +
           "returned an invalid lease based upon\n" +
           "the expiration time.";
View Full Code Here

  // get a lease renewal set w/ duration of setLeaseGrant
  logger.log(Level.FINE, "Creating the lease renewal set.");
  logger.log(Level.FINE, "Duration = " + setLeaseGrant +
        " milliseconds.");
  LeaseRenewalService lrs = getLRS();
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(setLeaseGrant);
  set = prepareSet(set);
 
  // get a lease for some time less than the renewal set
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration = " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(owner,
           rstUtil.durToExp(renewGrant));

  // start managing the lease for as long as we can
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
  set.renewFor(testLease, Long.MAX_VALUE);
 
  // Remove the lease. Removal should succeed.
  logger.log(Level.FINE, "Removing the managed lease from the set.");
  Lease managedLease = set.remove(testLease);
  if (managedLease == null) {
      String message = "Lease could not be removed from\n";
      message += "renewal set.";
      throw new TestException(message);
  }
View Full Code Here

  // create a renewal set
  logger.log(Level.FINE, "Creating renewal set with lease duration of " +
        "Lease.FOREVER.");
  long renewSetDur = Lease.FOREVER;
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  lrm.renewFor(prepareLease(set.getRenewalSetLease()), renewSetDur, null);

  // create a test lease to be managed
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // remove the lease
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "Removal of non-managed lease does NOT\n" +
           "return null as required.";
      throw new TestException(message);
  }
View Full Code Here

  LeaseRenewalService lrs = getLRS();

  // create a lease renewal set that hangs around a long time
  logger.log(Level.FINE, "Creating Set with lease duration of " +
        "Lease.FOREVER.");
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(Lease.FOREVER);
  set = prepareSet(set);
  lrm.renewFor(prepareLease(set.getRenewalSetLease()), Long.MAX_VALUE, null);

  // create a handback object
  MarshalledObject handback = new MarshalledObject(new Integer(99));

  // register listener to receive events
  EventRegistration evReg =
      set.setRenewalFailureListener(rrl, handback);
  evReg = prepareRegistration(evReg);

  // create a lease that will fail to renew
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(definiteOwner,
           rstUtil.durToExp(renewGrant));

  // start managing the lease for as long as we can
  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
  logger.log(Level.FINE, "Membership = Lease.FOREVER.");
  set.renewFor(testLease, Lease.FOREVER);
 
  // wait for the lease to expire
  rstUtil.waitForLeaseExpiration(testLease,
               "for client lease to expire.");

  /* Assert that the notification was received at approximately
     the lease expiration time */
  Long[] arrivalTimes = rrl.getArrivalTimes();

  // must at lease have received one event
  if (arrivalTimes.length == 0) {
      String message = "RenewalFailure event never received.";
      throw new TestException(message);
  }

  // must NOT have received more than one event
  if (arrivalTimes.length > 1) {
      String message = "Too many events received.";
      throw new TestException(message);
  }

  /* TESTING ASSERTION #1
     was the event received around the right time? */
  long leaseExpiration = testLease.getExpiration();
  long maxAllowed = leaseExpiration + latencySlop;

  long actualArrivalTime = arrivalTimes[0].longValue();

  // event must arrive within our assumed constraints
  if (actualArrivalTime < maxAllowed) {
      // we say event was received around the right time
      logger.log(Level.FINE, "Assertion #1 passes!");
  } else {
      /* There was a lag. This could be a network problem or an
         overloaded cpu but we will just have to assume that the
         specification was not met. */
      String message = "Assertion #1 failed ...\n" +
    "Event was not received within " + latencySlop +
    " milliseconds of client lease expiration.";
      throw new TestException(message);
  }

  /* TESTING ASSERTION #2
     the handback object is the one we expect. */
  RemoteEvent[] events = rrl.getEvents();
  MarshalledObject mObj = events[0].getRegistrationObject();
  if (handback.equals(mObj) == false) {
      String message = "Assertion #2 failed ...\n" +
    "Handback object does not match original.";
      throw new TestException(message);
  }
  logger.log(Level.FINE, "Assertion #2 passes!");
 
  /* TESTING ASSERTION #3
     The lease for the event registration is the same as the event's
     lease */
  if (rstUtil.isValidRenewFailEventReg(evReg, set) == false) {
      String message = "Assertion #3 failed ...\n" +
    "Event Registration is invalid." +
    rstUtil.getFailureReason();
      throw new TestException(message);
  }
  logger.log(Level.FINE, "Assertion #3 passes!");

  /* TESTING ASSERTION #4
     a null listener results in a NullPointException. */
  set = lrs.createLeaseRenewalSet(Lease.FOREVER);
  set = prepareSet(set);
  logger.log(Level.FINE, "Created Set with lease duration of " +
        "Lease.FOREVER.");
  try {
      evReg = set.setRenewalFailureListener(null, handback);
      evReg = prepareRegistration(evReg);
      if (rstUtil.isValidExpWarnEventReg(evReg, set) == false) {
    String message = "Assertion #4 failed ...\n" +
        "Event Registration is invalid.";
    throw new TestException(message);
View Full Code Here

  // grab the ever popular LRS
  LeaseRenewalService lrs = getLRS();

  // create 2 renewal sets
  long renewSetDur = Lease.FOREVER;
  LeaseRenewalSet set01 = lrs.createLeaseRenewalSet(renewSetDur);
  set01 = prepareSet(set01);
  logger.log(Level.FINE, "Created Set 01 with lease duration of " +
        "Lease.FOREVER.");
  LeaseRenewalSet set02 = lrs.createLeaseRenewalSet(renewSetDur);
  set02 = prepareSet(set02);
  logger.log(Level.FINE, "Created Set 02 with lease duration of " +
        "Lease.FOREVER.");

  /* assert that attempting to add the set's lease to itself
     generates an IllegalArgumentException */
  Lease setLease = prepareLease(set01.getRenewalSetLease());
  logger.log(Level.FINE, "Lease is " + setLease);
  try {
      set01.renewFor(setLease, renewGrant);
      String message = "An attempt to add a renewal set's lease\n";
      message += " to itself has succeeded.";
      throw new TestException(message);
  } catch (IllegalArgumentException ex) {
      // success, keep on trucking ...
  }     

  /* assert that attempting to add the set01's lease to set02
     generates an IllegalArgumentException */
  try {
      set02.renewFor(setLease, renewGrant);
      String message = "An attempt to add a renewal set's lease\n";
      message += " to another set has succeeded.";
      throw new TestException(message);
  } catch (IllegalArgumentException ex) {
      // success, keep on trucking ...
  }     

  // create a lease that renews normally
  logger.log(Level.FINE, "Creating the lease to be managed.");
  logger.log(Level.FINE, "Duration == " + renewGrant);
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner,
           rstUtil.durToExp(renewGrant));

  // add the lease to set01
  set01.renewFor(testLease, renewGrant);

  /* assert that attempting to add the test lease to set02
     succeeds. */
  try {
      set02.renewFor(testLease, renewGrant);
      // success
  } catch (IllegalArgumentException ex) {
      String message = "An attempt to add a client lease\n";
      message += " to two different sets has failed.";
      throw new TestException(message, ex);
  }     

  /*
   * Assert that adding set01's lease to set02 succeeds if set01's
   * lease has been cancelled.
   */
  setLease.cancel();
  try {
      set02.renewFor(setLease, renewGrant);
  } catch (IllegalArgumentException ex) {
    throw new TestException("Failed to add an expired set "
          + "lease to another set",
          ex);
  }
View Full Code Here

TOP

Related Classes of net.jini.lease.LeaseRenewalSet

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.