Search in sources :

Example 6 with ObjID

use of java.rmi.server.ObjID in project jdk8u_jdk by JetBrains.

the class DGCImpl method dirty.

/**
     * The dirty call adds the VMID "vmid" to the set of clients
     * that hold references to the object associated with the ObjID
     * id.  The long "sequenceNum" is used to detect late dirty calls.  If
     * the VMID "vmid" is null, a VMID will be generated on the
     * server (for use by the client in subsequent calls) and
     * returned.
     *
     * The client must call the "dirty" method to renew the lease
     * before the "lease" time expires or all references to remote
     * objects in this VM that the client holds are considered
     * "unreferenced".
     */
public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease) {
    VMID vmid = lease.getVMID();
    /*
         * The server specifies the lease value; the client has
         * no say in the matter.
         */
    long duration = leaseValue;
    if (dgcLog.isLoggable(Log.VERBOSE)) {
        dgcLog.log(Log.VERBOSE, "vmid = " + vmid);
    }
    // create a VMID if one wasn't supplied
    if (vmid == null) {
        vmid = new VMID();
        if (dgcLog.isLoggable(Log.BRIEF)) {
            String clientHost;
            try {
                clientHost = RemoteServer.getClientHost();
            } catch (ServerNotActiveException e) {
                clientHost = "<unknown host>";
            }
            dgcLog.log(Log.BRIEF, " assigning vmid " + vmid + " to client " + clientHost);
        }
    }
    lease = new Lease(vmid, duration);
    // record lease information
    synchronized (leaseTable) {
        LeaseInfo info = leaseTable.get(vmid);
        if (info == null) {
            leaseTable.put(vmid, new LeaseInfo(vmid, duration));
            if (checker == null) {
                checker = scheduler.scheduleWithFixedDelay(new Runnable() {

                    public void run() {
                        checkLeases();
                    }
                }, leaseCheckInterval, leaseCheckInterval, TimeUnit.MILLISECONDS);
            }
        } else {
            info.renew(duration);
        }
    }
    for (ObjID id : ids) {
        if (dgcLog.isLoggable(Log.VERBOSE)) {
            dgcLog.log(Log.VERBOSE, "id = " + id + ", vmid = " + vmid + ", duration = " + duration);
        }
        ObjectTable.referenced(id, sequenceNum, vmid);
    }
    // return the VMID used
    return lease;
}
Also used : ServerNotActiveException(java.rmi.server.ServerNotActiveException) Lease(java.rmi.dgc.Lease) ObjID(java.rmi.server.ObjID) VMID(java.rmi.dgc.VMID)

Aggregations

ObjID (java.rmi.server.ObjID)6 TCPEndpoint (sun.rmi.transport.tcp.TCPEndpoint)3 IOException (java.io.IOException)2 Remote (java.rmi.Remote)2 RemoteException (java.rmi.RemoteException)2 RemoteRef (java.rmi.server.RemoteRef)2 ServerNotActiveException (java.rmi.server.ServerNotActiveException)2 UnicastRef (sun.rmi.server.UnicastRef)2 LiveRef (sun.rmi.transport.LiveRef)2 ObjectOutput (java.io.ObjectOutput)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 Constructor (java.lang.reflect.Constructor)1 Method (java.lang.reflect.Method)1 MarshalException (java.rmi.MarshalException)1 NoSuchObjectException (java.rmi.NoSuchObjectException)1 Lease (java.rmi.dgc.Lease)1 VMID (java.rmi.dgc.VMID)1 LocateRegistry (java.rmi.registry.LocateRegistry)1 Registry (java.rmi.registry.Registry)1