Package net.jini.core.lease

Examples of net.jini.core.lease.UnknownLeaseException


      throw new IllegalArgumentException("negative lease duration");
  EventReg reg = (EventReg)eventByID.get(new Long(eventID));
  if (reg == null ||
      !reg.leaseID.equals(leaseID) ||
      reg.leaseExpiration <= now)
      throw new UnknownLeaseException();
  if (renewDuration > maxEventLease &&
      renewDuration > reg.leaseExpiration - now)
      renewDuration = Math.max(reg.leaseExpiration - now, maxEventLease);
  long renewExpiration = now + renewDuration;
  /* force a re-sort: must remove before changing, then reinsert */
 
View Full Code Here


  if (e != null &&
      (e.renew < e.endTime || System.currentTimeMillis() < e.endTime))
  {
      return e;
  }
  throw new UnknownLeaseException();
    }
View Full Code Here

        concurrentObj.priorityWriteLock();
        try {
            RegistrationInfo regInfo
                   = (RegistrationInfo)(registrationByID.get(registrationID));
            if(regInfo == null) {
                throw new UnknownLeaseException
                                 ("\n    Invalid registration ID on call to "
                                  +"cancelLease() method"
                                  +"\n    The lease may have expired or been "
                                  +"cancelled");
            }//endif
View Full Code Here

        concurrentObj.writeLock();
        try {
            RegistrationInfo regInfo
                   = (RegistrationInfo)(registrationByID.get(registrationID));
            if(regInfo == null) {
                throw new UnknownLeaseException
                                 ("\n    Invalid registration ID on call to "
                                  +"cancelLease() method"
                                  +"\n    The lease may have expired or been "
                                  +"cancelled");
            }//endif
View Full Code Here

            throw new IllegalArgumentException("non-positive lease duration");
        }//endif
        if (    (regInfo == null)
             || ( !(regInfo.leaseID).equals(leaseID) )
             || (regInfo.leaseExpiration <= curTime) ) {
            throw new UnknownLeaseException();
        }//endif
        if(    (duration > leaseBound)
      && (duration > (regInfo.leaseExpiration - curTime)) ) {
            duration = Math.max( (regInfo.leaseExpiration - curTime),
                                 leaseBound );
View Full Code Here

    private void cancelLeaseDo(RegistrationInfo regInfo, Uuid leaseID)
                                     throws UnknownLeaseException, IOException
    {
        long curTime = System.currentTimeMillis();
        if ( (regInfo == null) || (regInfo.leaseExpiration <= curTime) ) {
            throw new UnknownLeaseException();
        }//endif
        removeRegistration(regInfo);
        /* wake up thread if this might be the (only) earliest time */
        if (regInfo.leaseExpiration == minExpiration) {
            concurrentObj.waiterNotify(leaseExpireThreadSyncObj);
View Full Code Here

  addGoodLeaseDEL(leases, +5000, 60000, ++id, id, -10000);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLease(leases, 60000, ++id, id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because of an indefinie
  // exception
  addBadLease(leases, 60000, ++id, id, 2 * 60000, new RemoteException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, ++id, id, -10000, null);

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, ++id, id, +60000, null);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLeaseDEL(leases, 60000, ++id, id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because of an indefinie
  // exception
  addBadLeaseDEL(leases, 60000, ++id, id, 2 * 60000,
           new RemoteException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLeaseDEL(leases, -20000, ++id, id, -10000, null);

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLeaseDEL(leases, -20000, ++id, id, +60000, null);

  // Do it all again (twicw) but with batching

  // Lease that should not get any events
  addGoodLeaseDEL(leases, 60000, 60000, 0, ++id, Long.MAX_VALUE);

  // Lease that should get a DER event
  addGoodLeaseDEL(leases, 60000, 60000, 0, ++id, 2*60000);

  // Lease that has already reached its desired expiration
  // and should get a DER event
  addGoodLeaseDEL(leases, -5000, 60000, 0, ++id, -10000);

  // Lease that has already reached its desired expiration
  // and should get a DER event
  addGoodLeaseDEL(leases, +5000, 60000, 0, ++id, -10000);

  // Lease that should get no events
  addGoodLease(leases, 60000, 60000, 0, ++id, Long.MAX_VALUE);

  // Lease that would  get a DER event but only registers a LeaesListener
  addGoodLease(leases, 60000, 60000, 0, ++id, 2*60000);

  // Lease that has already reached its desired expiration
  // and would get a DER event but only registers a LeaesListener
  addGoodLeaseDEL(leases, -5000, 60000, 0, ++id, -10000);

  // Lease that has already reached its desired expiration
  // and would get a DER event but only registers a LeaesListener
  addGoodLeaseDEL(leases, +5000, 60000, 0, ++id, -10000);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLease(leases, 60000, 0, ++id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, 0, ++id, -10000, null);

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, 0, ++id, +60000, null);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLeaseDEL(leases, 60000, 0, ++id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLeaseDEL(leases, -20000, 0, ++id, -10000, null);

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLeaseDEL(leases, -20000, 0, ++id, +60000, null);

  // Lease that should not get any events
  addGoodLeaseDEL(leases, 60000, 60000, 1, ++id, Long.MAX_VALUE);

  // Lease that should get a DER event
  addGoodLeaseDEL(leases, 60000, 60000, 1, ++id, 2*60000);

  // Lease that has already reached its desired expiration
  // and should get a DER event
  addGoodLeaseDEL(leases, -5000, 60000, 1, ++id, -10000);

  // Lease that has already reached its desired expiration
  // and should get a DER event
  addGoodLeaseDEL(leases, +5000, 60000, 1, ++id, -10000);

  // Lease that should get no events
  addGoodLease(leases, 60000, 60000, 1, ++id, Long.MAX_VALUE);

  // Lease that would  get a DER event but only registers a LeaesListener
  addGoodLease(leases, 60000, 60000, 1, ++id, 2*60000);

  // Lease that has already reached its desired expiration
  // and would get a DER event but only registers a LeaesListener
  addGoodLeaseDEL(leases, -5000, 60000, 1, ++id, -10000);

  // Lease that has already reached its desired expiration
  // and would get a DER event but only registers a LeaesListener
  addGoodLeaseDEL(leases, +5000, 60000, 1, ++id, -10000);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLease(leases, 60000, 1, ++id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, 1, ++id, -10000, null);

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLease(leases, -20000, 1, ++id, +60000, null);

  // Lease that will generate a renewal failure because of a definie
  // exception
  addBadLeaseDEL(leases, 60000, 1, ++id, 2 * 60000,
        new UnknownLeaseException());

  // Lease that will generate a renewal failure because it has already
  // expired and it has not reached its desired expiration
  addBadLeaseDEL(leases, -20000, 1, ++id, -10000, null);

View Full Code Here

  // Has the lease expired?
  if (!ensureCurrent(now)) {
      setRsltIfNeeded("Renwal service let lease expire, " +
          (now - expiration) + " ms late");
      throw new UnknownLeaseException("Lease expired");
  }

  // Have the asked for the right renewal?
  if (!isValidExtension(extension))
      throw new LeaseDeniedException("Did not ask for right extension");
View Full Code Here

  // Has the lease expired?
  if (expiration < now) {
      if (!ensureCurrent(now))
    setRsltIfNeeded("Renwal service let lease expire");
      throw new UnknownLeaseException("Lease expired");
  }

  // Have the asked for the right renewal?
 
  // Are they supposted to ask for Lease.ANY, and if they
View Full Code Here

        ServiceResource[] svcResources = selector.getServiceResources();
        if(svcResources.length == 0) {
            logger.warn("{} is updating resource information, but we don't have any registered Cybernodes. " +
                        "Force removal of all Leases", resource.getName());
            landlord.removeAll();
            throw new UnknownLeaseException("Update failed, there are no known leases.");
        }
        boolean updated = false;
        ServiceResource couldNotEnsureLease = null;
        for(ServiceResource svcResource : svcResources) {
            InstantiatorResource ir = (InstantiatorResource) svcResource.getResource();
            logger.trace("Checking for InstantiatorResource match");
            if(ir.getInstantiator().equals(preparedResource)) {
                logger.trace("Update from {}, current serviceCount {}, serviceLimit {}",
                             ir.getName(),
                             deployedServices.size(),
                             serviceLimit);
                logger.trace("Matched InstantiatorResource");
                if(!landlord.ensure(svcResource)) {
                    couldNotEnsureLease = svcResource;
                    break;
                }
                updated = true;
                logger.trace("Set updated resource capabilities");
                ir.setResourceCapability(updatedCapabilities);
                logger.trace("Set serviceLimit to {}", serviceLimit);
                ir.setServiceLimit(serviceLimit);
                try {
                    logger.trace("Set deployedServices, was: {}, updated count is now: {}",
                                  ir.getServiceCount(), deployedServices.size());
                    ir.setDeployedServices(deployedServices);
                } catch (Throwable t) {
                    logger.warn("Getting ServiceRecords from {}", ir.getName(), t);
                }
                /* Process all provision types of Fixed first */
                fixedServiceManager.process(svcResource);
                /* See if any dynamic provision types are pending */
                pendingMgr.process();
                break;
            } else {
                logger.trace("Did not match InstantiatorResource");
            }
        }

        if(couldNotEnsureLease!=null) {
            selector.dropServiceResource(couldNotEnsureLease);
            throw new UnknownLeaseException("Could not ensure lease. Lease expiration: "+couldNotEnsureLease.getExpiration()+", " +
                                            "current time: "+System.currentTimeMillis());
        }
        if(!updated) {
            logger.warn("Update failed, no matching registration found for {}", resource.getName());
            throw new UnknownLeaseException("Update failed, no matching registration found");
        }
    }
View Full Code Here

TOP

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

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.