Module org.apache.derby.server
Package org.apache.derby.mbeans.drda

# Interface NetworkServerMBean

public interface NetworkServerMBean

This is an MBean defining a JMX management and monitoring interface of Derby's Network Server.

This MBean is created and registered automatically at Network Server startup if all requirements are met (J2SE 5.0 or better).

Key properties for the registered MBean:

- `type=NetworkServer`
- `system=`runtime system identifier (see description of package org.apache.derby.mbeans)

If a security manager is installed, accessing attributes and operations of this MBean may require a `SystemPermission`; see individual method documentation for details.

For more information on Managed Beans, refer to the JMX specification.

See Also:
  - `NetworkServerControl`
  - `SystemPermission`
  - `org.apache.derby.mbeans`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getAccumulatedConnectionCount()`
  Gets the accumulated number of connections.
  `int`
  `getActiveConnectionCount()`
  Gets the number of currently active connections.
  `long`
  `getBytesReceived()`
  Gets the total number of bytes read by the server since it was started.
  `int`
  `getBytesReceivedPerSecond()`
  Gets the number of bytes received per second by the Network Server.
  `long`
  `getBytesSent()`
  Gets the total number of bytes written by the server since it was started.
  `int`
  `getBytesSentPerSecond()`
  Gets the number of bytes sent per second by the Network Server.
  `int`
  `getConnectionCount()`
  Gets the total number of current connections (waiting or active) to the Network Server.
  `int`
  `getConnectionThreadPoolSize()`
  Get the size of the connection thread pool.
  `String`
  `getDrdaHost()`
  Gets the network interface address on which the Network Server is listening.
  `boolean`
  `getDrdaKeepAlive()`
  Reports whether or not the Derby Network Server will send keep-alive probes and attempt to clean up connections for disconnected clients (the value of the `derby.drda.keepAlive` property).
  `int`
  `getDrdaMaxThreads()`
  Reports the maximum number of client connection threads the Network Server will allocate at any given time.
  `int`
  `getDrdaPortNumber()`
  Gets the port number on which the Network Server is listening for client connections.
  `String`
  `getDrdaSecurityMechanism()`
  The Derby security mechanism required by the Network Server for all client connections.
  `String`
  `getDrdaSslMode()`
  Reports whether client connections must be encrypted using Secure Sockets Layer (SSL), and whether certificate based peer authentication is enabled.
  `int`
  `getDrdaStreamOutBufferSize()`
  The size of the buffer used for streaming BLOB and CLOB from server to client.
  `int`
  `getDrdaTimeSlice()`
  If the server property `derby.drda.maxThreads` is set to a non-zero value, this is the number of milliseconds that each client connection will actively use in the Network Server before yielding to another connection.
  `boolean`
  `getDrdaTraceAll()`
  Whether server-side tracing is enabled for all client connections (sessions).
  `String`
  `getDrdaTraceDirectory()`
  Indicates the location of tracing files on the server host, if server tracing has been enabled.
  `long`
  `getStartTime()`
  Gets the start time of the network server.
  `long`
  `getUptime()`
  Gets the time (in milliseconds) the Network Server has been running.
  `int`
  `getWaitingConnectionCount()`
  Gets the number of currently waiting connections.
  `void`
  `ping()`
  Executes the network server's `ping` command.

- ## Method Details

  - ### getDrdaHost

    String getDrdaHost()

    Gets the network interface address on which the Network Server is listening. This corresponds to the value of the `derby.drda.host` property.

    For example, the value "`localhost`" means that the Network Server is listening on the local loopback interface only.

    The special value "`0.0.0.0`" (IPv4 environments only) represents the "unspecified address" - also known as the anylocal or wildcard address. In this context this means that the server is listening on all network interfaces (and may thus be able to see connections from both the local host as well as remote hosts, depending on which network interfaces are available).

    Requires `SystemPermission("server", "control")` if a security manager is installed.

    Returns:
      the the network interface address on which the Network Server is listening (`derby.drda.host`)

  - ### getDrdaKeepAlive

    boolean getDrdaKeepAlive()

    Reports whether or not the Derby Network Server will send keep-alive probes and attempt to clean up connections for disconnected clients (the value of the `derby.drda.keepAlive` property).

    If `true`, a keep-alive probe is sent to the client if a "long time" (by default, more than two hours) passes with no other data being sent or received. This will detect and clean up connections for clients on powered-off machines or clients that have disconnected unexpectedly.

    If `false`, Derby will not attempt to clean up connections from disconnected clients, and will not send keep-alive probes.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    See also the documentation for the property `derby.drda.keepAlive` in the Derby Server and Administration Guide, section Managing the Derby Network Server, subsection Setting Network Server Properties, subsubsection derby.drda.keepAlive property.

    Returns:
      `true` if Derby Network Server will send keep-alive probes and attempt to clean up connections for disconnected clients (`derby.drda.keepAlive`)

  - ### getDrdaMaxThreads

    int getDrdaMaxThreads()

    Reports the maximum number of client connection threads the Network Server will allocate at any given time. This corresponds to the `derby.drda.maxThreads` property.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the maximum number of client connection threads the Network Server will allocate at any given time (`derby.drda.maxThreads`)

  - ### getDrdaPortNumber

    int getDrdaPortNumber()

    Gets the port number on which the Network Server is listening for client connections. This corresponds to the value of the `derby.drda.portNumber` Network Server setting.

    Requires `SystemPermission("server", "control")` if a security manager is installed.

    Returns:
      the port number on which the Network Server is listening for client connections.

  - ### getDrdaSecurityMechanism

    String getDrdaSecurityMechanism()

    The Derby security mechanism required by the Network Server for all client connections. This corresponds to the value of the `derby.drda.securityMechanism` property on the server.

    If not set, the empty String will be returned, which means that the Network Server accepts any connection which uses a valid security mechanism.

    For a list of valid security mechanisms, refer to the documentation for the `derby.drda.securityMechanism` property in the Derby Server and Administration Guide.

    Requires `SystemPermission("server", "control")` if a security manager is installed.

    Returns:
      the security mechanism required by the Network Server for all client connections (`derby.drda.securityMechanism`)

  - ### getDrdaSslMode

    String getDrdaSslMode()

    Reports whether client connections must be encrypted using Secure Sockets Layer (SSL), and whether certificate based peer authentication is enabled. Refers to the `derby.drda.sslMode` property.

    Peer authentication means that the other side of the SSL connection is authenticated based on a trusted certificate installed locally.

    The value returned is one of "`off`" (no SSL encryption), "`basic`" (SSL encryption, no peer authentication) and "`peerAuthentication`" (SSL encryption and peer authentication). Refer to the Derby Server and Administration Guide for more details.

    Requires `SystemPermission("server", "control")` if a security manager is installed.

    Returns:
      whether client connections must be encrypted using Secure Sockets Layer (SSL), and whether certificate based peer authentication is enabled (`derby.drda.sslMode`)

  - ### getDrdaStreamOutBufferSize

    int getDrdaStreamOutBufferSize()

    The size of the buffer used for streaming BLOB and CLOB from server to client. Refers to the `derby.drda.streamOutBufferSize` property.

    This setting may improve streaming performance when the default sizes of packets being sent are significantly smaller than the maximum allowed packet size in the network.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the size of the buffer used for streaming blob/clob from server to client (`derby.drda.streamOutBufferSize`)

  - ### getDrdaTimeSlice

    int getDrdaTimeSlice()

    If the server property `derby.drda.maxThreads` is set to a non-zero value, this is the number of milliseconds that each client connection will actively use in the Network Server before yielding to another connection. If this value is 0, a waiting connection will become active once a currently active connection is closed.

    Refers to the `derby.drda.timeSlice` server property.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of milliseconds that each client connection will actively use in the Network Server before yielding to another connection (`derby.drda.timeSlice`)
    See Also:
      - `getDrdaMaxThreads()`

  - ### getDrdaTraceAll

    boolean getDrdaTraceAll()

    Whether server-side tracing is enabled for all client connections (sessions). Refers to the `derby.drda.traceAll` server property.

    Tracing may for example be useful when providing technical support information. The Network Server also supports tracing for individual connections (sessions), see the Derby Server and Administration Guide ("Controlling tracing by using the trace facility") for details.

    When tracing is enabled, tracing information from each client connection will be written to a separate trace file.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      whether tracing for all client connections is enabled (`derby.drda.traceAll`)
    See Also:
      - `getDrdaTraceDirectory()`

  - ### getDrdaTraceDirectory

    String getDrdaTraceDirectory()

    Indicates the location of tracing files on the server host, if server tracing has been enabled.

    If the server setting `derby.drda.traceDirectory` is set, its value will be returned. Otherwise, the Network Server's default values will be taken into account when producing the result.

    Requires `SystemPermission("server", "control")` if a security manager is installed.

    Returns:
      the potential location of tracing files on the server host
    See Also:
      - `getDrdaTraceAll()`

  - ### getConnectionCount

    int getConnectionCount()

    Gets the total number of current connections (waiting or active) to the Network Server.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of current connections
    See Also:
      - `getActiveConnectionCount()`
      - `getWaitingConnectionCount()`

  - ### getActiveConnectionCount

    int getActiveConnectionCount()

    Gets the number of currently active connections. All connections are active if the DrdaMaxThreads attribute (`derby.drda.maxThreads` property) is 0.

    If DrdaMaxThreads is > 0 and DrdaTimeSlice is 0, connections remain active until they are closed. If there are more than DrdaMaxThreads connections, inactive connections will be waiting for some active connection to close. The connection request will return when the connection becomes active.

    If DrdaMaxThreads is > 0 and DrdaTimeSlice > 0, connections will be alternating beetween active and waiting according to Derby's time slicing algorithm.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of active connections
    See Also:
      - `getDrdaMaxThreads()`
      - `getDrdaTimeSlice()`
      - `getWaitingConnectionCount()`

  - ### getWaitingConnectionCount

    int getWaitingConnectionCount()

    Gets the number of currently waiting connections. This number will always be 0 if DrdaMaxThreads is 0. Otherwise, if the total number of connections is less than or equal to DrdaMaxThreads, then no connections are waiting.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of waiting connections
    See Also:
      - `getActiveConnectionCount()`
      - `getDrdaMaxThreads()`
      - `getDrdaTimeSlice()`

  - ### getConnectionThreadPoolSize

    int getConnectionThreadPoolSize()

    Get the size of the connection thread pool. If DrdaMaxThreads (`derby.drda.maxThreads`) is set to a non-zero value, the size of the thread pool will not exceed this value.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the size of the Network Server's connection thread pool
    See Also:
      - `getDrdaMaxThreads()`

  - ### getAccumulatedConnectionCount

    int getAccumulatedConnectionCount()

    Gets the accumulated number of connections. This includes all active and waiting connections since the Network Server was started. This number will not decrease as long as the Network Server is running.

    Require `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the accumulated number of connections made since server startup

  - ### getBytesReceived

    long getBytesReceived()

    Gets the total number of bytes read by the server since it was started.

    Require `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the total number of bytes received by the server

  - ### getBytesSent

    long getBytesSent()

    Gets the total number of bytes written by the server since it was started.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the total number of bytes sent by the server

  - ### getBytesReceivedPerSecond

    int getBytesReceivedPerSecond()

    Gets the number of bytes received per second by the Network Server. This number is calculated by taking into account the number of bytes received since the last calculation (or since MBean startup if it is the first time this attibute is being read).

    The shortest interval measured is 1 second. This means that a new value will not be calculated unless there has been at least 1 second since the last calculation.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of bytes received per second

  - ### getBytesSentPerSecond

    int getBytesSentPerSecond()

    Gets the number of bytes sent per second by the Network Server. This number is calculated by taking into account the number of bytes sent since the last calculation (or since MBean startup if it is the first time this attibute is being read).

    The shortest interval measured is 1 second. This means that a new value will not be calculated unless there has been at least 1 second since the last calculation.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the number of bytes sent per millisecond

  - ### getStartTime

    long getStartTime()

    Gets the start time of the network server. The time is reported as the number of milliseconds (ms) since Unix epoch (1970-01-01 00:00:00 UTC), and corresponds to the value of `java.lang.System#currentTimeMillis()` at the time the Network Server was started.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the difference, measured in milliseconds, between the time the Network Server was started and Unix epoch (1970-01-01T00:00:00Z)
    See Also:
      - `System.currentTimeMillis()`

  - ### getUptime

    long getUptime()

    Gets the time (in milliseconds) the Network Server has been running. In other words, the time passed since the server was started.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Returns:
      the difference, measured in milliseconds, between the current time and the time the Network Server was started
    See Also:
      - `getStartTime()`

  - ### ping

    void ping() throws Exception

    Executes the network server's `ping` command. Returns without errors if the server was successfully pinged.

    Note that the `ping` command itself will be executed from the network server instance that is actually running the server, and that the result will be transferred via JMX to the JMX client invoking this operation. This means that this operation will test network server connectivity from the same host (machine) as the network server, as opposed to when the `ping` command (or method) of `NetworkServerControl` is executed from a remote machine.

    This operation requires the following permission to be granted to the network server code base if a Java security manager is installed in the server JVM:

    `permission java.net.SocketPermission "*", "connect,resolve";`

    The value `"*"` will allow connections from the network server to any host and any port, and may be replaced with a more specific value if so desired. The required value will depend on the value of the `-h` (or `derby.drda.host`) (host) and `-p` (or `derby.drda.portNumber`) (port) settings of the Network Server.

    Requires `SystemPermission("server", "monitor")` if a security manager is installed.

    Throws:
      `Exception` - if the ping attempt fails (an indication that the network server is not running properly)
    See Also:
      - `NetworkServerControl.ping()`
      - `SocketPermission`