Package net.jini.core.lease

Examples of net.jini.core.lease.LeaseMapException


                emap.put(e.getKey(), results.exceptions[j++]);
                iter.remove();
            }
        }
        if (emap != null) {
            throw new LeaseMapException("lease renewal failures", emap);
        }
    }
View Full Code Here


            if (ex != null) {
                emap.put(ls, ex);
                iter.remove();
            }
        }
        throw new LeaseMapException("lease cancellation failures", emap);
    }
View Full Code Here

    // inherit javadoc
    // This method assumes that none of the leases in the map are
    // also being renewed by some other thread.
    public void renewAll() throws LeaseMapException, RemoteException {
  LeaseMapException lme = null;
  Map newExceptionMap = null;

  // Iterate over the wrappers, causing the appropriate exceptions
  // for the ones who's sets have expired.
  final long now = System.currentTimeMillis();
  for (Iterator i=wrapperMap.values().iterator(); i.hasNext(); ) {
      final ClientLeaseWrapper clw = (ClientLeaseWrapper) i.next();
      if (!clw.ensureCurrent(now)) {
    // Map an exception to this lease and drop from the map

    // If necessary create newExceptionMap
    if (newExceptionMap == null)
        newExceptionMap = new HashMap(wrapperMap.size());

    // Add to the newExceptionMap
    newExceptionMap.put(clw,
            LRMEventListener.EXPIRED_SET_EXCEPTION);

    // Drop from both the wrapper and inner map
    i.remove();
    clientLeaseMap.remove(clw.getClientLease());

    // Note, we don't call failedRenewal() because the set is
    // dead so logging changes is pointless.  Besides, there
    // is no change to log.
      }
  }

  // If the map is now empty don't bother calling renewAll()
  if (clientLeaseMap.isEmpty()) {
      if (newExceptionMap == null)
    return;

      throw new LeaseMapException("Expired Sets", newExceptionMap);
  }

  try {
      clientLeaseMap.renewAll();
  } catch (LeaseMapException e) {
      lme = e;
  } catch (RemoteException e) {
      applyException(e);
      throw e;
  } catch (Error e) {
      applyException(e);
      throw e;
  } catch (RuntimeException e) {
      applyException(e);
      throw e;
  }

  // For each Lease still in the map we need to update the wrapper
  for (Iterator i=clientLeaseMap.keySet().iterator(); i.hasNext(); ) {
      final Lease cl = (Lease) i.next();
      final ClientLeaseWrapper clw =
    (ClientLeaseWrapper) wrapperMap.get(cl);

      clw.successfulRenewal();
  }

  // If there were no errors just return
  if (lme == null && newExceptionMap == null)
      return;

  // If the renewAll() threw a LeaseMapException we have to
  // remove the problem leases from the wrapper and place
  // them in newExceptionMap

  if (lme != null) {
      final Map exceptionMap = lme.exceptionMap;

      // Create the newExceptionMap if we don't have one
      if (newExceptionMap == null)
    newExceptionMap = new HashMap(exceptionMap.size());

      // Copy each lease out of the exception's map into newExceptionMap,
      // also remove these leases from the wrapper and get the
      // failure logged
      for (Iterator i = exceptionMap.entrySet().iterator();
     i.hasNext(); )
      {
    final Map.Entry e = (Map.Entry) i.next();
    final Lease cl = (Lease) e.getKey();
    final Throwable t = (Throwable) e.getValue();
    final ClientLeaseWrapper clw =
        (ClientLeaseWrapper) wrapperMap.remove(cl);
    i.remove();

    clw.failedRenewal(t);
    newExceptionMap.put(clw, t);
      }
  }

  // If necessary throw a LeaseMapException
  if (newExceptionMap != null) {
      throw new LeaseMapException(
          (lme == null) ? "Expired Sets" : lme.getMessage(),
    newExceptionMap);
  }

  return;
    }
View Full Code Here

  try {
      l.renew(d);
  } catch (LeaseException e) {
      final Map m = new HashMap(1);
      m.put(l, e);
      throw new LeaseMapException(e.getMessage(), m);
  }
    }
View Full Code Here

    map.put(new Integer(ids[i]), e);
      }
  }

  if (map != null)
      throw new LeaseMapException("cancelling", map);
  return null;
    }
View Full Code Here

    map.put(new Integer(ids[i]), e);
      }
  }

  if (map != null)
      throw new LeaseMapException("cancelling", map);
  return null;
    }
View Full Code Here

                emap.put(e.getKey(), results.exceptions[j++]);
                iter.remove();
            }
        }
        if (emap != null) {
            throw new LeaseMapException("lease renewal failures", emap);
        }
    }
View Full Code Here

            if (ex != null) {
                emap.put(ls, ex);
                iter.remove();
            }
        }
        throw new LeaseMapException("lease cancellation failures", emap);
    }
View Full Code Here

      }

      if (origSize != rslt.size())  // some cookie wasn't found
    throw new ConcurrentModificationException();
     
      throw new LeaseMapException(
          "Failure canceling one or more leases", rslt);
  }
    }
View Full Code Here

    bad.put(leases[i], results.denied[d++]);// add to "bad" map
      }
  }

  if (bad != null)
      throw new LeaseMapException("renewing", bad);
    }
View Full Code Here

TOP

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

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.