Package com.sun.jini.landlord

Examples of com.sun.jini.landlord.LeasedResource


    public long renew(Uuid cookie, long extension)
        throws UnknownLeaseException, LeaseDeniedException
    {
  leaseLogger.entering("OutriggerServerImpl","renew");

  LeasedResource    resource;
  LeasePeriodPolicy policy;
 
  if (null != (resource = contents.getLeasedResource(cookie)))
      policy = entryLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)eventRegistrations.get(cookie)))
      policy = eventLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)contentsQueries.get(cookie)))
      policy = contentsLeasePolicy;
  else
      throw throwNewUnknownLeaseException(cookie);

  synchronized (resource) {
      if (resource.getExpiration() <= System.currentTimeMillis()) {
    // Lease has expired, don't renew
    throw throwNewUnknownLeaseException(cookie);
      }

      // No one can expire the lease, so it is safe to update.
      final LeasePeriodPolicy.Result r =
    policy.renew(resource, extension);

      if (log != null)
    log.renewOp((Uuid)cookie, r.expiration);

      resource.setExpiration(r.expiration);

      if (leaseLogger.isLoggable(Level.FINER)) {
    leaseLogger.log(Level.FINER, "renew({0},{1}) returns {2}",
        new Object[]{cookie, new Long(extension),
         new Long(r.duration)});
View Full Code Here


    * current time, canceling the resource if its time has
   * passed.  Synchronize on the resource before checking the
   * expiration time.
   */
  public void run() {
      final LeasedResource resource = (LeasedResource)resourceRef.get();
      if (resource == null)
    // Already gone
    return;

      synchronized (resource) {
    if (resource.getExpiration() <= System.currentTimeMillis()) {
        try {
      ticketMap.remove(resource);
      landlord.cancel(resource.getCookie());
        } catch (UnknownLeaseException e) {
            // Don't care, probably already gone
        }
    }
    // else Someone must have just renewed the resource,
View Full Code Here

    public long renew(Uuid cookie, long extension)
        throws UnknownLeaseException, LeaseDeniedException
    {
  leaseLogger.entering("OutriggerServerImpl","renew");

  LeasedResource    resource;
  LeasePeriodPolicy policy;
 
  if (null != (resource = contents.getLeasedResource(cookie)))
      policy = entryLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)eventRegistrations.get(cookie)))
      policy = eventLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)contentsQueries.get(cookie)))
      policy = contentsLeasePolicy;
  else
      throw throwNewUnknownLeaseException(cookie);

  synchronized (resource) {
      if (resource.getExpiration() <= System.currentTimeMillis()) {
    // Lease has expired, don't renew
    throw throwNewUnknownLeaseException(cookie);
      }

      // No one can expire the lease, so it is safe to update.
      final LeasePeriodPolicy.Result r =
    policy.renew(resource, extension);

      if (log != null)
    log.renewOp((Uuid)cookie, r.expiration);

      resource.setExpiration(r.expiration);

      if (leaseLogger.isLoggable(Level.FINER)) {
    leaseLogger.log(Level.FINER, "renew({0},{1}) returns {2}",
        new Object[]{cookie, new Long(extension),
         new Long(r.duration)});
View Full Code Here

    * current time, canceling the resource if its time has
   * passed.  Synchronize on the resource before checking the
   * expiration time.
   */
  public void run() {
      final LeasedResource resource = (LeasedResource)resourceRef.get();
      if (resource == null)
    // Already gone
    return;

      synchronized (resource) {
    if (resource.getExpiration() <= System.currentTimeMillis()) {
        try {
      ticketMap.remove(resource);
      landlord.cancel(resource.getCookie());
        } catch (UnknownLeaseException e) {
            // Don't care, probably already gone
        }
    }
    // else Someone must have just renewed the resource,
View Full Code Here

    public long renew(Uuid cookie, long extension)
        throws UnknownLeaseException, LeaseDeniedException
    {
  leaseLogger.entering("OutriggerServerImpl","renew");

  LeasedResource    resource;
  LeasePeriodPolicy policy;
 
  if (null != (resource = contents.getLeasedResource(cookie)))
      policy = entryLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)eventRegistrations.get(cookie)))
      policy = eventLeasePolicy;
  else if (null !=
     (resource = (LeasedResource)contentsQueries.get(cookie)))
      policy = contentsLeasePolicy;
  else
      throw throwNewUnknownLeaseException(cookie);

  synchronized (resource) {
      if (resource.getExpiration() <= System.currentTimeMillis()) {
    // Lease has expired, don't renew
    throw throwNewUnknownLeaseException(cookie);
      }

      // No one can expire the lease, so it is safe to update.
      final LeasePeriodPolicy.Result r =
    policy.renew(resource, extension);

      if (log != null)
    log.renewOp((Uuid)cookie, r.expiration);

      resource.setExpiration(r.expiration);

      if (leaseLogger.isLoggable(Level.FINER)) {
    leaseLogger.log(Level.FINER, "renew({0},{1}) returns {2}",
        new Object[]{cookie, new Long(extension),
         new Long(r.duration)});
View Full Code Here

     * @param cookie Object to remove
     *
     * @return boolean True if removed false if not removed
     */
    public boolean remove(final Uuid cookie) {
        LeasedResource resource;
        boolean removed = false;
        synchronized(resources) {
            resource = resources.remove(cookie);
        }
        if(resource != null) {
View Full Code Here

     * @throws IllegalArgumentException if the cookie is null
     */
    public LeasedResource getLeasedResource(final Uuid cookie) {
        if(cookie == null)
            throw new IllegalArgumentException("cookie is null");
        LeasedResource resource;
        synchronized(resources) {
            resource = resources.get(cookie);
        }
        return(resource);
    }
View Full Code Here

                Set<Entry<Uuid,LeasedResource>> mapEntries;
                synchronized(resources) {
                    mapEntries = resources.entrySet();
                }
                for (Entry<Uuid, LeasedResource> entry : mapEntries) {
                    LeasedResource lr = entry.getValue();
                    if (!ensure(lr)) {
                        if (logger.isDebugEnabled())
                            logger.debug("Lease expired for resource {}, cookie {}",
                                         ((ServiceResource) lr).getResource().toString(), lr.getCookie());
                        remove(lr.getCookie());
                        notifyLeaseExpiration(lr);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.sun.jini.landlord.LeasedResource

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.