Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/rmi/transport/DGCImpl.java
          +++ new/src/share/classes/sun/rmi/transport/DGCImpl.java
↓ open down ↓ 76 lines elided ↑ open up ↑
  77   77              new GetLongAction("sun.rmi.dgc.checkInterval", leaseValue / 2));
  78   78  
  79   79      /** thread pool for scheduling delayed tasks */
  80   80      private static final ScheduledExecutorService scheduler =
  81   81          AccessController.doPrivileged(
  82   82              new RuntimeUtil.GetInstanceAction()).getScheduler();
  83   83  
  84   84      /** remote implementation of DGC interface for this VM */
  85   85      private static DGCImpl dgc;
  86   86      /** table that maps VMID to LeaseInfo */
  87      -    private Map<VMID,LeaseInfo> leaseTable = new HashMap<VMID,LeaseInfo>();
       87 +    private Map<VMID,LeaseInfo> leaseTable = new HashMap<>();
  88   88      /** checks for lease expiration */
  89   89      private Future<?> checker = null;
  90   90  
  91   91      /**
  92   92       * Return the remote implementation of the DGC interface for
  93   93       * this VM.
  94   94       */
  95   95      static DGCImpl getDGCImpl() {
  96   96          return dgc;
  97   97      }
↓ open down ↓ 131 lines elided ↑ open up ↑
 229  229       * it from the table and notify all interested parties that the
 230  230       * VMID is essentially "dead".
 231  231       *
 232  232       * @return if true, there are leases outstanding; otherwise leases
 233  233       * no longer need to be checked
 234  234       */
 235  235      private void checkLeases() {
 236  236          long time = System.currentTimeMillis();
 237  237  
 238  238          /* List of vmids that need to be removed from the leaseTable */
 239      -        List<LeaseInfo> toUnregister = new ArrayList<LeaseInfo>();
      239 +        List<LeaseInfo> toUnregister = new ArrayList<>();
 240  240  
 241  241          /* Build a list of leaseInfo objects that need to have
 242  242           * targets removed from their notifySet.  Remove expired
 243  243           * leases from leaseTable.
 244  244           */
 245  245          synchronized (leaseTable) {
 246  246              Iterator<LeaseInfo> iter = leaseTable.values().iterator();
 247  247              while (iter.hasNext()) {
 248  248                  LeaseInfo info = iter.next();
 249  249                  if (info.expired(time)) {
↓ open down ↓ 56 lines elided ↑ open up ↑
 306  306                      Thread.currentThread().setContextClassLoader(savedCcl);
 307  307                  }
 308  308                  return null;
 309  309              }
 310  310          });
 311  311      }
 312  312  
 313  313      private static class LeaseInfo {
 314  314          VMID vmid;
 315  315          long expiration;
 316      -        Set<Target> notifySet = new HashSet<Target>();
      316 +        Set<Target> notifySet = new HashSet<>();
 317  317  
 318  318          LeaseInfo(VMID vmid, long lease) {
 319  319              this.vmid = vmid;
 320  320              expiration = System.currentTimeMillis() + lease;
 321  321          }
 322  322  
 323  323          synchronized void renew(long lease) {
 324  324              long newExpiration = System.currentTimeMillis() + lease;
 325  325              if (newExpiration > expiration)
 326  326                  expiration = newExpiration;
↓ open down ↓ 14 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX