sun.rmi.runtime.Log Java Examples

The following examples show how to use sun.rmi.runtime.Log. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistryImpl.java    From jdk8u_jdk with GNU General Public License v2.0 7 votes vote down vote up
/**
 * Initialize the registryFilter from the security properties or system property; if any
 * @return an ObjectInputFilter, or null
 */
private static ObjectInputFilter initRegistryFilter() {
    ObjectInputFilter filter = null;
    String props = System.getProperty(REGISTRY_FILTER_PROPNAME);
    if (props == null) {
        props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
    }
    if (props != null) {
        filter = ObjectInputFilter.Config.createFilter2(props);
        Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
        if (regLog.isLoggable(Log.BRIEF)) {
            regLog.log(Log.BRIEF, "registryFilter = " + filter);
        }
    }
    return filter;
}
 
Example #2
Source File: ConnectionMultiplexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Acknowledge remote endpoint's closing of connection.
 * @param info connection information structure
 */
void sendCloseAck(MultiplexConnectionInfo info) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(CLOSEACK);
                dataOut.writeShort(info.id);
                dataOut.flush();
                info.closed = true;
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #3
Source File: StreamRemoteCall.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
 
Example #4
Source File: TCPEndpoint.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #5
Source File: StreamRemoteCall.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
 
Example #6
Source File: ConnectionMultiplexer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Send packet of requested data on connection to remote endpoint.
 * @param info connection information structure
 * @param buf array containing bytes to send
 * @param off offset of first array index of packet
 * @param len number of bytes in packet to send
 */
void sendTransmit(MultiplexConnectionInfo info,
                  byte buf[], int off, int len) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(TRANSMIT);
                dataOut.writeShort(info.id);
                dataOut.writeInt(len);
                dataOut.write(buf, off, len);
                dataOut.flush();
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #7
Source File: HttpSendSocket.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a stream socket and connect it to the specified port on
 * the specified host.
 * @param host the host
 * @param port the port
 */
public HttpSendSocket(String host, int port, URL url) throws IOException
{
    super((SocketImpl)null);        // no underlying SocketImpl for this object

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
            "host = " + host + ", port = " + port + ", url = " + url);
    }

    this.host = host;
    this.port = port;
    this.url = url;

    inNotifier = new HttpSendInputStream(null, this);
    outNotifier = new HttpSendOutputStream(writeNotify(), this);
}
 
Example #8
Source File: ObjectTable.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove target from object table.
 *
 * NOTE: This method must only be invoked while synchronized on
 * the "tableLock" object, because it does not do so itself.
 */
private static void removeTarget(Target target) {
    // assert Thread.holdsLock(tableLock);

    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove object " + oe);
    }

    objTable.remove(oe);
    implTable.remove(weakImpl);

    target.markRemoved();   // handles decrementing keep-alive count
}
 
Example #9
Source File: TCPEndpoint.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #10
Source File: TCPEndpoint.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #11
Source File: UnicastRef.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Done should only be called if the invoke returns successfully
 * (non-exceptionally) to the stub. It allows the remote reference to
 * clean up (or reuse) the connection.
 */
public void done(RemoteCall call) throws RemoteException {

    /* Done only uses the connection inside the call to obtain the
     * channel the connection uses.  Once all information is read
     * from the connection, the connection may be freed.
     */
    clientRefLog.log(Log.BRIEF, "free connection (reuse = true)");

    /* Free the call connection early. */
    free(call, true);

    try {
        call.done();
    } catch (IOException e) {
        /* WARNING: If the conn has been reused early, then it is
         * too late to recover from thrown IOExceptions caught
         * here. This code is relying on StreamRemoteCall.done()
         * not actually throwing IOExceptions.
         */
    }
}
 
Example #12
Source File: ConnectionMultiplexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Inform remote endpoint that connection has been closed.
 * @param info connection information structure
 */
void sendClose(MultiplexConnectionInfo info) throws IOException
{
    info.out.disconnect();
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(CLOSE);
                dataOut.writeShort(info.id);
                dataOut.flush();
                info.closed = true;
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #13
Source File: ConnectionMultiplexer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Send request for more data on connection to remote endpoint.
 * @param info connection information structure
 * @param len number of more bytes that can be received
 */
void sendRequest(MultiplexConnectionInfo info, int len) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(REQUEST);
                dataOut.writeShort(info.id);
                dataOut.writeInt(len);
                dataOut.flush();
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #14
Source File: HttpSendSocket.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a stream socket and connect it to the specified port on
 * the specified host.
 * @param host the host
 * @param port the port
 */
public HttpSendSocket(String host, int port, URL url) throws IOException
{
    super((SocketImpl)null);        // no underlying SocketImpl for this object

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
            "host = " + host + ", port = " + port + ", url = " + url);
    }

    this.host = host;
    this.port = port;
    this.url = url;

    inNotifier = new HttpSendInputStream(null, this);
    outNotifier = new HttpSendOutputStream(writeNotify(), this);
}
 
Example #15
Source File: HttpInputStream.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Read a byte of data from the stream.  Make sure that one is available
 * from the proper content of the message, else -1 is returned to
 * indicate to the user that the end of the stream has been reached.
 */
public int read() throws IOException
{
    if (bytesLeft > 0) {
        int data = in.read();
        if (data != -1)
            -- bytesLeft;

        if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
            RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
               "received byte: '" +
                ((data & 0x7F) < ' ' ? " " : String.valueOf((char) data)) +
                "' " + data);
        }

        return data;
    }
    else {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
                                            "read past content length");

        return -1;
    }
}
 
Example #16
Source File: RegistryImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the registryFilter from the security properties or system property; if any
 * @return an ObjectInputFilter, or null
 */
private static ObjectInputFilter initRegistryFilter() {
    ObjectInputFilter filter = null;
    String props = System.getProperty(REGISTRY_FILTER_PROPNAME);
    if (props == null) {
        props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
    }
    if (props != null) {
        filter = ObjectInputFilter.Config.createFilter(props);
        Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
        if (regLog.isLoggable(Log.BRIEF)) {
            regLog.log(Log.BRIEF, "registryFilter = " + filter);
        }
    }
    return filter;
}
 
Example #17
Source File: ConnectionMultiplexer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Send packet of requested data on connection to remote endpoint.
 * @param info connection information structure
 * @param buf array containing bytes to send
 * @param off offset of first array index of packet
 * @param len number of bytes in packet to send
 */
void sendTransmit(MultiplexConnectionInfo info,
                  byte buf[], int off, int len) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(TRANSMIT);
                dataOut.writeShort(info.id);
                dataOut.writeInt(len);
                dataOut.write(buf, off, len);
                dataOut.flush();
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #18
Source File: Target.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #19
Source File: ObjectTable.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove target from object table.
 *
 * NOTE: This method must only be invoked while synchronized on
 * the "tableLock" object, because it does not do so itself.
 */
private static void removeTarget(Target target) {
    // assert Thread.holdsLock(tableLock);

    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove object " + oe);
    }

    objTable.remove(oe);
    implTable.remove(weakImpl);

    target.markRemoved();   // handles decrementing keep-alive count
}
 
Example #20
Source File: HttpSendSocket.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a stream socket and connect it to the specified port on
 * the specified host.
 * @param host the host
 * @param port the port
 */
public HttpSendSocket(String host, int port, URL url) throws IOException
{
    super((SocketImpl)null);        // no underlying SocketImpl for this object

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
            "host = " + host + ", port = " + port + ", url = " + url);
    }

    this.host = host;
    this.port = port;
    this.url = url;

    inNotifier = new HttpSendInputStream(null, this);
    outNotifier = new HttpSendOutputStream(writeNotify(), this);
}
 
Example #21
Source File: HttpInputStream.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public int read(byte b[], int off, int len) throws IOException
{
    if (bytesLeft == 0 && len > 0) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
                                            "read past content length");

        return -1;
    }
    if (len > bytesLeft)
        len = bytesLeft;
    int bytesRead = in.read(b, off, len);
    bytesLeft -= bytesRead;

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
            "read " + bytesRead + " bytes, " + bytesLeft + " remaining");
    }

    return bytesRead;
}
 
Example #22
Source File: HttpInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public int read(byte b[], int off, int len) throws IOException
{
    if (bytesLeft == 0 && len > 0) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
                                            "read past content length");

        return -1;
    }
    if (len > bytesLeft)
        len = bytesLeft;
    int bytesRead = in.read(b, off, len);
    bytesLeft -= bytesRead;

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
        RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
            "read " + bytesRead + " bytes, " + bytesLeft + " remaining");
    }

    return bytesRead;
}
 
Example #23
Source File: ConnectionMultiplexer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Send request for more data on connection to remote endpoint.
 * @param info connection information structure
 * @param len number of more bytes that can be received
 */
void sendRequest(MultiplexConnectionInfo info, int len) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(REQUEST);
                dataOut.writeShort(info.id);
                dataOut.writeInt(len);
                dataOut.flush();
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #24
Source File: ObjectTable.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove target from object table.
 *
 * NOTE: This method must only be invoked while synchronized on
 * the "tableLock" object, because it does not do so itself.
 */
private static void removeTarget(Target target) {
    // assert Thread.holdsLock(tableLock);

    ObjectEndpoint oe = target.getObjectEndpoint();
    WeakRef weakImpl = target.getWeakImpl();

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove object " + oe);
    }

    objTable.remove(oe);
    implTable.remove(weakImpl);

    target.markRemoved();   // handles decrementing keep-alive count
}
 
Example #25
Source File: Target.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove endpoint from remembered set.  If set becomes empty,
 * remove server from Transport's object table.
 */
synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong)
{
    // check sequence number for vmid
    SequenceEntry entry = sequenceTable.get(vmid);
    if (entry == null || entry.sequenceNum > sequenceNum) {
        // late clean call; ignore
        return;
    } else if (strong) {
        // strong clean call; retain sequenceNum
        entry.retain(sequenceNum);
    } else if (entry.keep == false) {
        // get rid of sequence number
        sequenceTable.remove(vmid);
    }

    if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
        DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid);
    }

    refSetRemove(vmid);
}
 
Example #26
Source File: UnicastRef.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Done should only be called if the invoke returns successfully
 * (non-exceptionally) to the stub. It allows the remote reference to
 * clean up (or reuse) the connection.
 */
public void done(RemoteCall call) throws RemoteException {

    /* Done only uses the connection inside the call to obtain the
     * channel the connection uses.  Once all information is read
     * from the connection, the connection may be freed.
     */
    clientRefLog.log(Log.BRIEF, "free connection (reuse = true)");

    /* Free the call connection early. */
    free(call, true);

    try {
        call.done();
    } catch (IOException e) {
        /* WARNING: If the conn has been reused early, then it is
         * too late to recover from thrown IOExceptions caught
         * here. This code is relying on StreamRemoteCall.done()
         * not actually throwing IOExceptions.
         */
    }
}
 
Example #27
Source File: ConnectionMultiplexer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Send request for more data on connection to remote endpoint.
 * @param info connection information structure
 * @param len number of more bytes that can be received
 */
void sendRequest(MultiplexConnectionInfo info, int len) throws IOException
{
    synchronized (dataOut) {
        if (alive && !info.closed)
            try {
                dataOut.writeByte(REQUEST);
                dataOut.writeShort(info.id);
                dataOut.writeInt(len);
                dataOut.flush();
            } catch (IOException e) {
                multiplexLog.log(Log.BRIEF, "exception: ", e);

                shutDown();
                throw e;
            }
    }
}
 
Example #28
Source File: StreamRemoteCall.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the InputStream the stub/skeleton should get results/arguments
 * from.
 */
public ObjectInput getInputStream() throws IOException {
    if (in == null) {
        Transport.transportLog.log(Log.VERBOSE, "getting input stream");

        in = new ConnectionInputStream(conn.getInputStream());
    }
    return in;
}
 
Example #29
Source File: Target.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Remove endpoint from the reference set.
 */
synchronized private void refSetRemove(VMID vmid) {
    // remove notification request
    DGCImpl.getDGCImpl().unregisterTarget(vmid, this);

    if (refSet.removeElement(vmid) && refSet.isEmpty()) {
        // reference set is empty, so server can be garbage collected.
        // remove object from table.
        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE,
                "reference set is empty: target = " + this);
        }

        /*
         * If the remote object implements the Unreferenced interface,
         * invoke its unreferenced callback in a separate thread.
         */
        Remote obj = getImpl();
        if (obj instanceof Unreferenced) {
            final Unreferenced unrefObj = (Unreferenced) obj;
            AccessController.doPrivileged(
                new NewThreadAction(() -> {
                    Thread.currentThread().setContextClassLoader(ccl);
                    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
                        unrefObj.unreferenced();
                        return null;
                    }, acc);
                }, "Unreferenced-" + nextThreadNum++, false, true)).start();
                // REMIND: access to nextThreadNum not synchronized; you care?
        }

        unpinImpl();
    }
}
 
Example #30
Source File: WeakRef.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pin the contained reference (make this a strong reference).
 */
public synchronized void pin() {
    if (strongRef == null) {
        strongRef = get();

        if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) {
            DGCImpl.dgcLog.log(Log.VERBOSE,
                               "strongRef = " + strongRef);
        }
    }
}