db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Al Eridani <al.erid...@gmail.com>
Subject NetworkServerControl.ping() does not return when port is blocked
Date Tue, 09 Apr 2013 17:38:02 GMT
At the start of our application, we use a call to
NetworkServerControl.ping() to verify that Derby is up.

We expect an exception to be thrown if the ping call fails and we try 40
times every half second before giving up.

It has reported to me that when port 1527 is blocked by packet filters,
that call never returns or it takes a long time, maybe.

Is there something I can do to get ping to return normally or throw an
exception quickly?

We are using Derby 10.9.1.0 with the following non-default configuration

datasource.className=org.apache.derby.jdbc.ClientDataSource
datasource.createDatabase=create
datasource.databaseName=/some/directory
datasource.portNumber=1527
datasource.serverName=some.server.name
datasource.user=someuser

The basic code is

    ClientDataSource cds = (ClientDataSource) dataSource;
    String serverName = cds.getServerName();
    int serverPort = cds.getPortNumber();

    InetAddress inetAddr = InetAddress.getByName(serverName);
    networkServerControl = new NetworkServerControl(inetAddr, serverPort);
    networkServerControl.start(null);

    for (int i = 0; i < 40; i++) {
      try {
    networkServerControl.ping();
      } catch (Exception e) {
    try {
      // Sleep for 1/2 second.
    } catch (InterruptedException ie) {
      break;
    }
      }
    }

Mime
View raw message