Package org.apache.derby.drda

Examples of org.apache.derby.drda.NetworkServerControl


        else {
            serverPort = 20000;
        }

        try {
            NetworkServerControl networkServer =
                     new NetworkServerControl(InetAddress.getByName(serverName),
                                              serverPort);
            networkServer.start(null);

            // Wait for the network server to start
            boolean started = false;
            int retries = 10;         // Max retries = max seconds to wait
            while (!started && retries > 0) {
                try {
                    // Sleep 1 second and then ping the network server
          Thread.sleep(1000);
                    networkServer.ping();

                    // If ping does not throw an exception the server has started
                    started = true;
                } catch(Exception e) {
                    System.out.println("INFO: ping returned: " + e);
View Full Code Here


    /**
     * Stop the network server
     */
    private void stopNetworkServer() {
        try {
            NetworkServerControl networkServer = new NetworkServerControl();
            networkServer.shutdown();
        } catch(Exception e) {
            System.out.println("INFO: Network server shutdown returned: " + e);
        }
    }
View Full Code Here

        else {
            serverPort = 20000;
        }

        try {
            NetworkServerControl networkServer =
                     new NetworkServerControl(InetAddress.getByName(serverName),
                                              serverPort);
            networkServer.start(null);

            // Wait for the network server to start
            boolean started = false;
            int retries = 10;         // Max retries = max seconds to wait
            while (!started && retries > 0) {
                try {
                    // Sleep 1 second and then ping the network server
          Thread.sleep(1000);
                    networkServer.ping();

                    // If ping does not throw an exception the server has started
                    started = true;
                } catch(Exception e) {
                    System.out.println("INFO: ping returned: " + e);
View Full Code Here

    // Copied from org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.Pinger
    private  void  pingServer( int iterations )
    throws Exception
    {
        DEBUG("+++ pingServer");
        ping( new NetworkServerControl(), iterations );
        DEBUG("--- pingServer");
    }
View Full Code Here

                getSystemProperty("derby.drda.startNetworkServer"));
       
        boolean serverShouldBeUp =
            nsAutoBoot && fullEngineAutoBoot();
       
        NetworkServerControl control = new NetworkServerControl();
       
        boolean isServerUp = NetworkServerTestSetup.pingForServerStart(control);
       
        assertEquals("Network Server state incorrect",
                serverShouldBeUp, isServerUp);
       
        if (isServerUp)
            control.shutdown();
    }
View Full Code Here

    private boolean setSecurityMechanism(String derby_security_mechanism)
    throws Exception {
        try {
        // getting a networkservercontrol to shutdown the currently running
        // server, before setting the next security mechanism
        NetworkServerControl server = new NetworkServerControl(
            InetAddress.getByName(
                TestConfiguration.getCurrent().getHostName()),
                TestConfiguration.getCurrent().getPort());

        // shut down the server
        server.shutdown();
        } catch (Exception e) {
            if (!(e.getMessage().substring(0,17).equals("DRDA_InvalidValue")))
            {
                fail("unexpected error");
            }
        }

        try {
            AccessController.doPrivileged
            (new java.security.PrivilegedAction(){
                public Object run(){
                    return System.setProperty(
                        "derby.drda.securityMechanism",
                        derby_drda_securityMechanism);
                }
            });
           
            // if the security mechanism isn't supported or invalid, getting a
            // networkservercontrol will fail.
            NetworkServerControl server2 = new NetworkServerControl(
                InetAddress.getByName(
                    TestConfiguration.getCurrent().getHostName()),
                    TestConfiguration.getCurrent().getPort());

            // For debugging, to make output come to console uncomment:
            //server2.start(new PrintWriter(System.out, true));
            // and comment out:
            server2.start(null);
            NetworkServerTestSetup.waitForServerStart(server2);
           
            if (derby_drda_securityMechanism.equals("") ||
                derby_drda_securityMechanism.equals("INVALID_VALUE"))
            {
View Full Code Here

   * other than 1527 in the same jvm
   * @throws Exception
   **/
  public void testShutdown() throws Exception {
    final int NETWORKSERVER_PORT = 20000; //port to start the server
    NetworkServerControl serverControl = null;
    try {
      serverControl = new NetworkServerControl(InetAddress
          .getByName("localhost"), NETWORKSERVER_PORT);//initialized for the shutdown.
      Connection connection = null;
      // Just connect, do something and close the connection
      connection = getConnection();
      Statement stmt = connection.createStatement();
      ResultSet rs = stmt.executeQuery("Select  tablename   from  sys.systables")
      JDBC.assertDrainResults(rs);
      serverControl.shutdown();
      Thread.sleep(5000);
    } catch (Exception e) {
      System.out.print("FAIL: Unexpected exception" + e.getMessage());
      e.printStackTrace();
    }
View Full Code Here

  private static void waitForStart(String portString, int timeToWait) throws Exception
  {
    int waitTime = 0;
    int port = Integer.parseInt(portString);
   
    NetworkServerControl derbyServer = new NetworkServerControl( InetAddress.getByName("localhost"),
                          port);
   
   

        while (waitTime < timeToWait) {
            try {
                derbyServer.ping();
                return;
            } catch (Exception e) {
        Thread currentThread = Thread.currentThread();
        synchronized (currentThread) {
                    try {
View Full Code Here

        }
  }

  private static void listProperties(String portString) throws Exception{
    int port = Integer.parseInt(portString);
    NetworkServerControl derbyServer = new NetworkServerControl( InetAddress.getByName("localhost"),
                          port);
    Properties p = derbyServer.getCurrentProperties();
    p.list(System.out);
  }
View Full Code Here

    public static NetworkServerControl getNetworkServerControl()
        throws Exception
    {
        TestConfiguration config = TestConfiguration.getCurrent();
        if (config.getSsl() == null) {
            return new NetworkServerControl
                (InetAddress.getByName(config.getHostName()),
                 config.getPort());
        } else {
            // This is a hack. A NetworkServerControl constructor with
            // the needed interface to control sslMode (and possibly
            // more) would be better.
            String oldValue =
                System.setProperty("derby.drda.sslMode", config.getSsl());
            NetworkServerControl control = new NetworkServerControl
                (InetAddress.getByName(config.getHostName()),
                 config.getPort());
            if (oldValue == null) {
                // JDK 1.4 does not have clearProperty....
                System.getProperties().remove("derby.drda.sslMode");
View Full Code Here

TOP

Related Classes of org.apache.derby.drda.NetworkServerControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.