Tuesday, March 10, 2015

CommunicationException

com.sun.jmx.snmp.daemon.CommunicationException

CommunicationException is described in the javadoc comments as:

Represents exceptions raised due to communications problems, for example when a managed object server is out of reach.

This API is a Sun Microsystems internal API and is subject to change without notice.


version: 1.19 12/19/03 author: Sun Microsystems, Inc

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

com.sun.jmx.snmp.daemon.SnmpAdaptorServer.doBind()

/**
     * Creates the datagram socket.
     */
protected void doBind() throws CommunicationException, InterruptedException {
    try {
        synchronized (this) {
            socket = new DatagramSocket(port, address);
        }
        dbgTag = makeDebugTag();
    } catch (SocketException e) {
        if (e.getMessage().equals(InterruptSysCallMsg)) throw new InterruptedException(e.toString()); else {
            if (isDebugOn()) {
                debug('doBind', 'cannot bind on port ' + port);
            }
            throw new CommunicationException(e);
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.jmx.snmp.daemon.SnmpAdaptorServer.doReceive()

/**
     * Reads a packet from the datagram socket and creates a request 
     * handler which decodes and processes the request.
     */
protected void doReceive() throws CommunicationException, InterruptedException {
    try {
        packet = new DatagramPacket(new byte[bufferSize], bufferSize);
        socket.receive(packet);
        int state = getState();
        if (state != ONLINE) {
            if (isTraceOn()) {
                trace('doReceive', 'received a message but state not online, returning.');
            }
            return;
        }
        createSnmpRequestHandler(this, servedClientCount, socket, packet, root, mibs, ipacl, pduFactory, userDataFactory, topMBS, objectName);
    } catch (SocketException e) {
        if (e.getMessage().equals(InterruptSysCallMsg)) throw new InterruptedException(e.toString()); else throw new CommunicationException(e);
    } catch (InterruptedIOException e) {
        throw new InterruptedException(e.toString());
    } catch (CommunicationException e) {
        throw e;
    } catch (Exception e) {
        throw new CommunicationException(e);
    }
    if (isTraceOn()) {
        trace('doReceive', 'received a message');
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.jmx.snmp.daemon.CommunicatorServer.waitForStart(long)

/**
     * Waits until the communicator is started or timeout expires.
     * @param timeout Time in ms to wait for the connector to start.
     *        If <code>timeout</code> is positive, wait for at most
     *        the specified time. An infinite timeout can be specified
     *        by passing a <code>timeout</code> value equals 
     *        <code>Long.MAX_VALUE</code>. In that case the method
     *        will wait until the connector starts or fails to start. 
     *        If timeout is negative or zero, returns as soon as possible 
     *        without waiting.
     * @exception CommunicationException if the connectors fails to start.
     * @exception InterruptedException if the thread is interrupted or the
     *            timeout expires.
     */
private void waitForStart(long timeout) throws CommunicationException, InterruptedException {
    if (isTraceOn()) trace('waitForStart', 'Timeout=' + timeout + ' ; current state = ' + getStateString());
    final long startTime = System.currentTimeMillis();
    synchronized (stateLock) {
        while (state == STARTING) {
            final long elapsed = System.currentTimeMillis() - startTime;
            final long remainingTime = timeout - elapsed;
            if (remainingTime < 0) {
                if (isTraceOn()) trace('waitForStart', 'timeout < 0, return without wait');
                throw new InterruptedException('Timeout expired');
            }
            try {
                stateLock.wait(remainingTime);
            } catch (InterruptedException e) {
                if (isTraceOn()) trace('waitForStart', 'wait interrupted');
                if (state != ONLINE) throw e;
            }
        }
        if (state == ONLINE) {
            if (isTraceOn()) trace('waitForStart', 'started');
            return;
        } else if (startException instanceof CommunicationException) {
            throw (CommunicationException) startException;
        } else if (startException instanceof InterruptedException) {
            throw (InterruptedException) startException;
        } else if (startException != null) {
            throw new CommunicationException(startException, 'Failed to start: ' + startException);
        } else {
            throw new CommunicationException('Failed to start: state is ' + getStringForState(state));
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

No comments:

Post a Comment