servertableentry.java
来自「JAVA 所有包」· Java 代码 · 共 527 行 · 第 1/2 页
JAVA
527 行
Process localProcess = null; synchronized (this) { localServerObj = serverObj; localProcess = process; if (state == RUNNING) { deActivate(); } else { throw wrapper.serverNotRunning() ; } } try { if (localServerObj != null) { localServerObj.shutdown(); // shutdown the server localServerObj.uninstall() ; // call the uninstall } if (localProcess != null) { localProcess.destroy(); } } catch (Exception ex) { // what kind of exception should be thrown } } synchronized void holdDown() { state = HELD_DOWN; if (debug) printDebug( "holdDown", "server held down" ) ; notifyAll(); } synchronized void deActivate() { state = DE_ACTIVATED; if (debug) printDebug( "deActivate", "server deactivated" ) ; notifyAll(); } synchronized void checkProcessHealth( ) { // If the State in the ServerTableEntry is RUNNING and the // Process was shut down abnormally, The method will change the // server state as De-Activated. if( state == RUNNING ) { try { int exitVal = process.exitValue(); } catch (IllegalThreadStateException e1) { return; } synchronized ( this ) { // Clear the PortInformation as it is old orbAndPortInfo.clear(); // Move the state to De-Activated, So that the next // call to this server will re-activate. deActivate(); } } } synchronized boolean isValid() { if ((state == ACTIVATING) || (state == HELD_DOWN)) { if (debug) printDebug( "isValid", "returns true" ) ; return true; } try { int exitVal = process.exitValue(); } catch (IllegalThreadStateException e1) { return true; } if (state == ACTIVATED) { if (activateRetryCount < ActivationRetryMax) { if (debug) printDebug("isValid", "reactivating server"); activateRetryCount++; activate(); return true; } if (debug) printDebug("isValid", "holding server down"); holdDown(); return true; } deActivate(); return false; } synchronized ORBPortInfo[] lookup(String endpointType) throws ServerHeldDown { while ((state == ACTIVATING) || (state == ACTIVATED)) { try { wait(waitTime); if (!isValid()) break; } catch(Exception e) {} } ORBPortInfo[] orbAndPortList = null; if (state == RUNNING) { orbAndPortList = new ORBPortInfo[orbAndPortInfo.size()]; Iterator setORBids = orbAndPortInfo.keySet().iterator(); try { int numElements = 0; int i; int port; while (setORBids.hasNext()) { String orbId = (String) setORBids.next(); // get an entry corresponding to orbId EndPointInfo [] serverListenerPorts = (EndPointInfo []) orbAndPortInfo.get(orbId); port = -1; // return the port corresponding to the endpointType for (i = 0; i < serverListenerPorts.length; i++) { if (debug) System.out.println("lookup num-ports " + serverListenerPorts.length + " " + serverListenerPorts[i].endpointType + " " + serverListenerPorts[i].port ); if ((serverListenerPorts[i].endpointType).equals(endpointType)) { port = serverListenerPorts[i].port; break; } } orbAndPortList[numElements] = new ORBPortInfo(orbId, port); numElements++; } } catch (NoSuchElementException e) { // have everything in the table } return orbAndPortList; } if (debug) printDebug("lookup", "throwing server held down error"); throw new ServerHeldDown( serverId ) ; } synchronized EndPointInfo[] lookupForORB(String orbId) throws ServerHeldDown, InvalidORBid { while ((state == ACTIVATING) || (state == ACTIVATED)) { try { wait(waitTime); if (!isValid()) break; } catch(Exception e) {} } EndPointInfo[] portList = null; if (state == RUNNING) { try { // get an entry corresponding to orbId EndPointInfo [] serverListenerPorts = (EndPointInfo []) orbAndPortInfo.get(orbId); portList = new EndPointInfo[serverListenerPorts.length]; // return the port corresponding to the endpointType for (int i = 0; i < serverListenerPorts.length; i++) { if (debug) System.out.println("lookup num-ports " + serverListenerPorts.length + " " + serverListenerPorts[i].endpointType + " " + serverListenerPorts[i].port ); portList[i] = new EndPointInfo(serverListenerPorts[i].endpointType, serverListenerPorts[i].port); } } catch (NoSuchElementException e) { // no element in HashMap corresponding to ORBid found throw new InvalidORBid(); } return portList; } if (debug) printDebug("lookup", "throwing server held down error"); throw new ServerHeldDown( serverId ) ; } synchronized String[] getORBList() { String [] orbList = new String[orbAndPortInfo.size()]; Iterator setORBids = orbAndPortInfo.keySet().iterator(); try { int numElements = 0; while (setORBids.hasNext()) { String orbId = (String) setORBids.next(); orbList[numElements++] = orbId ; } } catch (NoSuchElementException e) { // have everything in the table } return orbList; } int getServerId() { return serverId; } boolean isActive() { return (state == RUNNING) || (state == ACTIVATED); } synchronized void destroy() { Server localServerObj = null; Process localProcess = null; synchronized (this) { localServerObj = serverObj; localProcess = process; deActivate(); } try { if (localServerObj != null) localServerObj.shutdown(); if (debug) printDebug( "destroy", "server shutdown successfully" ) ; } catch (Exception ex) { if (debug) printDebug( "destroy", "server shutdown threw exception" + ex ) ; // ex.printStackTrace(); } try { if (localProcess != null) localProcess.destroy(); if (debug) printDebug( "destroy", "process destroyed successfully" ) ; } catch (Exception ex) { if (debug) printDebug( "destroy", "process destroy threw exception" + ex ) ; // ex.printStackTrace(); } } private boolean debug = false;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?