jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java
author rriggs
Wed, 12 Oct 2016 12:56:35 -0400
changeset 43211 f264afd5082c
parent 33288 ef7d99d1e531
permissions -rw-r--r--
8156802: Better constraint checking Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
     2
 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.rmi.transport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
    27
import java.io.ObjectInputFilter;
33288
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
    28
import java.net.SocketPermission;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.rmi.dgc.DGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.rmi.dgc.Lease;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.rmi.dgc.VMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.rmi.server.LogStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.rmi.server.ObjID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.rmi.server.RemoteServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.rmi.server.ServerNotActiveException;
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
    38
import java.rmi.server.UID;
33288
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
    39
import java.security.AccessControlContext;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.security.AccessController;
33288
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
    41
import java.security.Permissions;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.security.PrivilegedAction;
33288
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
    43
import java.security.ProtectionDomain;
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
    44
import java.security.Security;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.concurrent.Future;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.util.concurrent.ScheduledExecutorService;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.util.concurrent.TimeUnit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.rmi.runtime.Log;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import sun.rmi.runtime.RuntimeUtil;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import sun.rmi.server.UnicastRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.rmi.server.UnicastServerRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.rmi.server.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * This class implements the guts of the server-side distributed GC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @author Ann Wollrath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
19211
32a04c562026 8022440: suppress deprecation warnings in sun.rmi
smarks
parents: 14342
diff changeset
    67
@SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
final class DGCImpl implements DGC {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /* dgc system log */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    static final Log dgcLog = Log.getLog("sun.rmi.dgc", "dgc",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        LogStream.parseLevel(AccessController.doPrivileged(
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 19211
diff changeset
    73
            (PrivilegedAction<String>) () -> System.getProperty("sun.rmi.dgc.logLevel"))));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /** lease duration to grant to clients */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private static final long leaseValue =              // default 10 minutes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        AccessController.doPrivileged(
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 19211
diff changeset
    78
            (PrivilegedAction<Long>) () -> Long.getLong("java.rmi.dgc.leaseValue", 600000));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /** lease check interval; default is half of lease grant duration */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static final long leaseCheckInterval =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        AccessController.doPrivileged(
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 19211
diff changeset
    83
            (PrivilegedAction<Long>) () -> Long.getLong("sun.rmi.dgc.checkInterval", leaseValue / 2));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /** thread pool for scheduling delayed tasks */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private static final ScheduledExecutorService scheduler =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            new RuntimeUtil.GetInstanceAction()).getScheduler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /** remote implementation of DGC interface for this VM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static DGCImpl dgc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /** table that maps VMID to LeaseInfo */
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 5506
diff changeset
    93
    private Map<VMID,LeaseInfo> leaseTable = new HashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /** checks for lease expiration */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private Future<?> checker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Return the remote implementation of the DGC interface for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * this VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    static DGCImpl getDGCImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return dgc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   106
     * Property name of the DGC serial filter to augment
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   107
     * the built-in list of allowed types.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   108
     * Setting the property in the {@code conf/security/java.security} file
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   109
     * or system property will enable the augmented filter.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   110
     */
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   111
    private static final String DGC_FILTER_PROPNAME = "sun.rmi.transport.dgcFilter";
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   112
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   113
    /** Registry max depth of remote invocations. **/
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   114
    private static int DGC_MAX_DEPTH = 5;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   115
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   116
    /** Registry maximum array size in remote invocations. **/
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   117
    private static int DGC_MAX_ARRAY_SIZE = 10000;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   118
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   119
    /**
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   120
     * The dgcFilter created from the value of the {@code  "sun.rmi.transport.dgcFilter"}
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   121
     * property.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   122
     */
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   123
    private static final ObjectInputFilter dgcFilter =
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   124
            AccessController.doPrivileged((PrivilegedAction<ObjectInputFilter>)DGCImpl::initDgcFilter);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   125
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   126
    /**
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   127
     * Initialize the dgcFilter from the security properties or system property; if any
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   128
     * @return an ObjectInputFilter, or null
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   129
     */
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   130
    private static ObjectInputFilter initDgcFilter() {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   131
        ObjectInputFilter filter = null;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   132
        String props = System.getProperty(DGC_FILTER_PROPNAME);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   133
        if (props == null) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   134
            props = Security.getProperty(DGC_FILTER_PROPNAME);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   135
        }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   136
        if (props != null) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   137
            filter = ObjectInputFilter.Config.createFilter(props);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   138
            if (dgcLog.isLoggable(Log.BRIEF)) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   139
                dgcLog.log(Log.BRIEF, "dgcFilter = " + filter);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   140
            }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   141
        }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   142
        return filter;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   143
    }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   144
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   145
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Construct a new server-side remote object collector at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * a particular port. Disallow construction from outside.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    private DGCImpl() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * The dirty call adds the VMID "vmid" to the set of clients
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * that hold references to the object associated with the ObjID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * id.  The long "sequenceNum" is used to detect late dirty calls.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * the VMID "vmid" is null, a VMID will be generated on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * server (for use by the client in subsequent calls) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * The client must call the "dirty" method to renew the lease
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * before the "lease" time expires or all references to remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * objects in this VM that the client holds are considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * "unreferenced".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        VMID vmid = lease.getVMID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         * The server specifies the lease value; the client has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
         * no say in the matter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        long duration = leaseValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (dgcLog.isLoggable(Log.VERBOSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            dgcLog.log(Log.VERBOSE, "vmid = " + vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        // create a VMID if one wasn't supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (vmid == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            vmid = new VMID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            if (dgcLog.isLoggable(Log.BRIEF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                String clientHost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    clientHost = RemoteServer.getClientHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                } catch (ServerNotActiveException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    clientHost = "<unknown host>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                dgcLog.log(Log.BRIEF, " assigning vmid " + vmid +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                           " to client " + clientHost);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        lease = new Lease(vmid, duration);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        // record lease information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        synchronized (leaseTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            LeaseInfo info = leaseTable.get(vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            if (info == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                leaseTable.put(vmid, new LeaseInfo(vmid, duration));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                if (checker == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    checker = scheduler.scheduleWithFixedDelay(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                checkLeases();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        leaseCheckInterval,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                        leaseCheckInterval, TimeUnit.MILLISECONDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                info.renew(duration);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        for (ObjID id : ids) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            if (dgcLog.isLoggable(Log.VERBOSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                dgcLog.log(Log.VERBOSE, "id = " + id +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                           ", vmid = " + vmid + ", duration = " + duration);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            ObjectTable.referenced(id, sequenceNum, vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        // return the VMID used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return lease;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * The clean call removes the VMID from the set of clients
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * that hold references to the object associated with the LiveRef
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * ref.  The sequence number is used to detect late clean calls.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * argument "strong" is true, then the clean call is a result of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * failed "dirty" call, thus the sequence number for the VMID needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * to be remembered until the client goes away.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        for (ObjID id : ids) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            if (dgcLog.isLoggable(Log.VERBOSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                dgcLog.log(Log.VERBOSE, "id = " + id +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    ", vmid = " + vmid + ", strong = " + strong);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            ObjectTable.unreferenced(id, sequenceNum, vmid, strong);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Register interest in receiving a callback when this VMID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * becomes inaccessible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    void registerTarget(VMID vmid, Target target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        synchronized (leaseTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            LeaseInfo info = leaseTable.get(vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            if (info == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                target.vmidDead(vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                info.notifySet.add(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Remove notification request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    void unregisterTarget(VMID vmid, Target target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        synchronized (leaseTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            LeaseInfo info = leaseTable.get(vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if (info != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                info.notifySet.remove(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Check if leases have expired.  If a lease has expired, remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * it from the table and notify all interested parties that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * VMID is essentially "dead".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @return if true, there are leases outstanding; otherwise leases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * no longer need to be checked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    private void checkLeases() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        long time = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        /* List of vmids that need to be removed from the leaseTable */
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 5506
diff changeset
   285
        List<LeaseInfo> toUnregister = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        /* Build a list of leaseInfo objects that need to have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
         * targets removed from their notifySet.  Remove expired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
         * leases from leaseTable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        synchronized (leaseTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            Iterator<LeaseInfo> iter = leaseTable.values().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                LeaseInfo info = iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                if (info.expired(time)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    toUnregister.add(info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            if (leaseTable.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                checker.cancel(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                checker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        /* Notify and unegister targets without holding the lock on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
         * the leaseTable so we avoid deadlock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        for (LeaseInfo info : toUnregister) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            for (Target target : info.notifySet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                target.vmidDead(info.vmid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
         * "Export" the singleton DGCImpl in a context isolated from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
         * the arbitrary current thread context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            public Void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                ClassLoader savedCcl =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    Thread.currentThread().getContextClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    Thread.currentThread().setContextClassLoader(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                        ClassLoader.getSystemClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                     * Put remote collector object in table by hand to prevent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                     * listen on port.  (UnicastServerRef.exportObject would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                     * cause transport to listen.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                        dgc = new DGCImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                        ObjID dgcID = new ObjID(ObjID.DGC_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                        LiveRef ref = new LiveRef(dgcID, 0);
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   339
                        UnicastServerRef disp = new UnicastServerRef(ref,
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   340
                                DGCImpl::checkInput);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                        Remote stub =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                            Util.createProxy(DGCImpl.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                             new UnicastRef(ref), true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                        disp.setSkeleton(dgc);
33288
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   345
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   346
                        Permissions perms = new Permissions();
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   347
                        perms.add(new SocketPermission("*", "accept,resolve"));
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   348
                        ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   349
                        AccessControlContext acceptAcc = new AccessControlContext(pd);
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   350
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   351
                        Target target = AccessController.doPrivileged(
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   352
                            new PrivilegedAction<Target>() {
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   353
                                public Target run() {
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   354
                                    return new Target(dgc, disp, stub, dgcID, true);
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   355
                                }
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   356
                            }, acceptAcc);
ef7d99d1e531 8080688: Service for DGC services
smarks
parents: 25859
diff changeset
   357
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                        ObjectTable.putTarget(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                    } catch (RemoteException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                        throw new Error(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                            "exception initializing server-side DGC", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    Thread.currentThread().setContextClassLoader(savedCcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
43211
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   371
    /**
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   372
     * ObjectInputFilter to filter DGC input objects.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   373
     * The list of acceptable classes is very short and explicit.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   374
     * The depth and array sizes are limited.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   375
     *
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   376
     * @param filterInfo access to class, arrayLength, etc.
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   377
     * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   378
     *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   379
     *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   380
     */
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   381
    private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   382
        if (dgcFilter != null) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   383
            ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   384
            if (status != ObjectInputFilter.Status.UNDECIDED) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   385
                // The DGC filter can override the built-in white-list
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   386
                return status;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   387
            }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   388
        }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   389
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   390
        if (filterInfo.depth() > DGC_MAX_DEPTH) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   391
            return ObjectInputFilter.Status.REJECTED;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   392
        }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   393
        Class<?> clazz = filterInfo.serialClass();
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   394
        if (clazz != null) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   395
            while (clazz.isArray()) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   396
                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   397
                    return ObjectInputFilter.Status.REJECTED;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   398
                }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   399
                // Arrays are allowed depending on the component type
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   400
                clazz = clazz.getComponentType();
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   401
            }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   402
            if (clazz.isPrimitive()) {
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   403
                // Arrays of primitives are allowed
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   404
                return ObjectInputFilter.Status.ALLOWED;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   405
            }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   406
            return (clazz == ObjID.class ||
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   407
                    clazz == UID.class ||
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   408
                    clazz == VMID.class ||
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   409
                    clazz == Lease.class)
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   410
                    ? ObjectInputFilter.Status.ALLOWED
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   411
                    : ObjectInputFilter.Status.REJECTED;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   412
        }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   413
        // Not a class, not size limited
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   414
        return ObjectInputFilter.Status.UNDECIDED;
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   415
    }
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   416
f264afd5082c 8156802: Better constraint checking
rriggs
parents: 33288
diff changeset
   417
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    private static class LeaseInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        VMID vmid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        long expiration;
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 5506
diff changeset
   421
        Set<Target> notifySet = new HashSet<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        LeaseInfo(VMID vmid, long lease) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            this.vmid = vmid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            expiration = System.currentTimeMillis() + lease;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        synchronized void renew(long lease) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            long newExpiration = System.currentTimeMillis() + lease;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            if (newExpiration > expiration)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                expiration = newExpiration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        boolean expired(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            if (expiration < time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                if (dgcLog.isLoggable(Log.BRIEF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    dgcLog.log(Log.BRIEF, vmid.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
}