db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r540809 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Date Wed, 23 May 2007 02:36:48 GMT
Author: kmarsden
Date: Tue May 22 19:36:47 2007
New Revision: 540809

URL: http://svn.apache.org/viewvc?view=rev&rev=540809
Log:
DERBY-1465 NetworkServerControl.start() should throw an exception and not just print exceptions
if the server fails to start

Backout change until changes from review comments from Dan can be incorporated.


Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/NSinSameJVM.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?view=diff&rev=540809&r1=540808&r2=540809
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Tue May 22 19:36:47 2007
@@ -161,7 +161,6 @@
     
 	private static String buildNumber;
 	private static String versionString;
-	
 	// we will use single or mixed, not double byte to reduce traffic on the
 	// wire, this is in keeping with JCC
 	// Note we specify UTF8 for the single byte encoding even though it can
@@ -213,12 +212,6 @@
 	private InetAddress hostAddress;
 	private int sessionArg;
 	private boolean unsecureArg;
-	
-	/** Any exception that occurs during 
-	 *  start up will be saved in this variable and
-	 *  thrown by the start method.
-	 */
-	private Exception runtimeException = null;
 
 	// Used to debug memory in SanityManager.DEBUG mode
 	private memCheck mc;
@@ -240,10 +233,6 @@
 	private boolean traceAll;			// trace all sessions
 	private Object traceAllSync = new Object();	// object to use for syncing reading
 										// and changing trace all
-	/**
-	 * Object to sync the start of network server and wait until server startup is 
-	 * complete
-	 */
 	private Object serverStartSync = new Object();	// for syncing start of server.
 	private boolean logConnections;		// log connects
 	private Object logConnectionsSync = new Object(); // object to use for syncing 
@@ -321,7 +310,6 @@
 	private static final int SSL_PEER_AUTHENTICATION = 2;
 
 	private int sslMode = SSL_OFF;
-	private Object  serverStartComplete = new Object();
 
     /**
      * Can EUSRIDPWD security mechanism be used with 
@@ -578,46 +566,19 @@
 	 *
 	 * @param consoleWriter   PrintWriter to which server console will be 
 	 *                        output. Null will disable console output.
-	 *                        
-	 * 
+	 *
 	 *		   
 	 * @exception Exception	throws an exception if an error occurs
 	 */
-	public void start(final PrintWriter consoleWriter)
+	public void start(PrintWriter consoleWriter)
 		throws Exception
-	{		
-		 
-		   Thread t = new Thread("NetworkServerControl") {
-			   
-		        public void run() {
-		          try {
-		        	  blockingStart(consoleWriter);
-		            } catch (Exception e) {
-		            	runtimeException = e;
-		            }
-		          }
-		        };
-		    // if there was an immediate error like
-		    // another server already running, throw it here.
-		    // ping is still required to verify the server is
-		    // up.     
-		   
-		    t.start();
-		    // We wait on the serverStartComplete object until
-		    // blocking_start sends a notify to tell us the 
-		    // server is up. Then we throw any exception that 
-		    // occurred on startup. blocking_start will remain
-		    // blocked on shutdownSync until it gets a shutdown
-		    // command.
-		    synchronized(serverStartComplete){
-		    	serverStartComplete.wait();
-		    }
-		    
-		    if (runtimeException != null)
-		    	throw runtimeException;		   
+	{
+		DRDAServerStarter starter = new DRDAServerStarter();
+		starter.setStartInfo(hostAddress,portNumber,consoleWriter);
+        this.setLogWriter(consoleWriter);
+		startNetworkServer();
+		starter.boot(false,null);
 	}
-	
-	
 
 	/**
 	 * Create the right kind of server socket
@@ -673,8 +634,8 @@
 	public void blockingStart(PrintWriter consoleWriter)
 		throws Exception
 	{
-		setLogWriter(consoleWriter);
 		startNetworkServer();
+		setLogWriter(consoleWriter);
 		cloudscapeLogWriter = Monitor.getStream().getPrintWriter();
 		if (SanityManager.DEBUG && debugOutput)
 		{
@@ -682,7 +643,7 @@
 			mc = new memCheck(200000);
 			mc.start();
 		}
-		// Open a server socket listener
+		// Open a server socket listener	  
 		try{
 			serverSocket = 
 				(ServerSocket) 
@@ -715,15 +676,10 @@
 			} else {
 				throw e1;
 			}
-		
 		} catch (Exception e) {
 		// If we find other (unexpected) errors, we ultimately exit--so make
 		// sure we print the error message before doing so (Beetle 5033).
 			throwUnexpectedException(e);
-		} finally {
-			synchronized (serverStartComplete) {
-				serverStartComplete.notifyAll();
-			}
 		}
 
 		switch (getSSLMode()) {
@@ -744,7 +700,7 @@
 				 getFormattedTimestamp()});
 			break;
 		}
-
+		
 		// We accept clients on a separate thread so we don't run into a problem
 		// blocking on the accept when trying to process a shutdown
 		ClientThread clientThread =	 
@@ -758,9 +714,7 @@
 								}
 							);
 		clientThread.start();
-		
-
-		
+			
 		// wait until we are told to shutdown or someone sends an InterruptedException
         synchronized(shutdownSync) {
             try {
@@ -836,7 +790,7 @@
 				}
 			}
 		}
-		 
+
 		consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
 						        {att_srvclsnm, versionString, 
 								getFormattedTimestamp()});

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/NSinSameJVM.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/NSinSameJVM.out?view=diff&rev=540809&r1=540808&r2=540809
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/NSinSameJVM.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/NSinSameJVM.out
Tue May 22 19:36:47 2007
@@ -3,3 +3,4 @@
 main-NSinSameJVM: NetworkServer started
 main-NSinSameJVM: Connected to database NSinSameJVMTestDB;create=true
 getting ready to shutdown
+Apache Derby Network Server - 10.3.0.0 alpha -(EXPECTED SUBVERSION INFO)  shutdown at xxxxxxFILTERED-TIMESTAMPxxxxxGMT

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM.java?view=diff&rev=540809&r1=540808&r2=540809
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM.java
Tue May 22 19:36:47 2007
@@ -100,13 +100,6 @@
 			// sure the thread closes down.
 			// connection.close();
 			
-            // DERBY-1465 Make sure attempt to start another
-            // server on the same port fails.
-            try {
-            	serverControl.start(null);
-            	System.out.println("FAIL: Should have gotten exception");
-            } catch (Exception e) {// expecting exception 
-            	}
 			System.out.println("getting ready to shutdown");
 			serverControl.shutdown();
 			Thread.sleep(5000);



Mime
View raw message