Java Code Examples for org.wso2.carbon.automation.extensions.servers.utils.ClientConnectionUtil#isPortOpen()
The following examples show how to use
org.wso2.carbon.automation.extensions.servers.utils.ClientConnectionUtil#isPortOpen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CarbonServerManager.java From product-ei with Apache License 2.0 | 6 votes |
private int checkPortAvailability(Map<String, String> commandMap) throws AutomationFrameworkException { final int portOffset = getPortOffsetFromCommandMap(commandMap); //check whether http port is already occupied if (ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) { throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpPort + portOffset) + " : Port already in use"); } //check whether https port is already occupied if (ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) { throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpsPort + portOffset) + " : Port already in use"); } return portOffset; }
Example 2
Source File: CarbonServerManagerExtension.java From product-iots with Apache License 2.0 | 5 votes |
private int checkPortAvailability(Map<String, String> commandMap) throws AutomationFrameworkException { int portOffset = this.getPortOffsetFromCommandMap(commandMap); if(ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) { throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpPort + portOffset) + " : Port already in use"); } else if(ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) { throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpsPort + portOffset) + " : Port already in use"); } else { return portOffset; } }
Example 3
Source File: StratosTestServerManager.java From attic-stratos with Apache License 2.0 | 5 votes |
private int checkPortAvailability(Map<String, String> commandMap) throws AutomationFrameworkException { int portOffset = this.getPortOffsetFromCommandMap(commandMap); if (ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) { throw new AutomationFrameworkException( "Unable to start carbon server on port " + (defaultHttpPort + portOffset) + " : Port already in use"); } else if (ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) { throw new AutomationFrameworkException( "Unable to start carbon server on port " + (defaultHttpsPort + portOffset) + " : Port already in use"); } else { return portOffset; } }
Example 4
Source File: CarbonServerManagerExtension.java From product-iots with Apache License 2.0 | 4 votes |
public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException { if(this.process != null) { log.info("Shutting down server.."); if(ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) { int httpsPort = defaultHttpsPort + portOffset; String url = null; try { url = this.automationContext.getContextUrls().getBackEndUrl(); } catch (XPathExpressionException var10) { throw new AutomationFrameworkException("Get context failed", var10); } String backendURL = url.replaceAll("(:\\d+)", ":" + httpsPort); try { ClientConnectionUtil.sendForcefulShutDownRequest(backendURL, this.automationContext.getSuperTenant().getContextUser().getUserName(), this.automationContext.getSuperTenant().getContextUser().getPassword()); } catch (AutomationFrameworkException var8) { throw new AutomationFrameworkException("Get context failed", var8); } catch (XPathExpressionException var9) { throw new AutomationFrameworkException("Get context failed", var9); } long time = System.currentTimeMillis() + 300000L; // while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { // ; // } log.info("Server stopped successfully..."); } this.inputStreamHandler.stop(); this.errorStreamHandler.stop(); this.process.destroy(); this.process = null; if(this.isCoverageEnable) { try { log.info("Generating Jacoco code coverage..."); this.generateCoverageReport(new File(this.carbonHome + File.separator + "wso2" + File.separator + "components" + File.separator + "plugins" + File.separator)); } catch (IOException var7) { log.error("Failed to generate code coverage ", var7); throw new AutomationFrameworkException("Failed to generate code coverage ", var7); } } if(portOffset == 0) { System.clearProperty("carbon.home"); } } }
Example 5
Source File: StratosTestServerManager.java From attic-stratos with Apache License 2.0 | 4 votes |
public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException { if (this.process != null) { log.info("Shutting down server.."); if (ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) { int e = defaultHttpsPort + portOffset; String url = null; try { url = this.automationContext.getContextUrls().getBackEndUrl(); } catch (XPathExpressionException var10) { throw new AutomationFrameworkException("Get context failed", var10); } String backendURL = url.replaceAll("(:\\d+)", ":" + e); try { ClientConnectionUtil.sendForcefulShutDownRequest(backendURL, this.automationContext.getSuperTenant().getContextUser().getUserName(), this.automationContext.getSuperTenant().getContextUser().getPassword()); } catch (AutomationFrameworkException var8) { throw new AutomationFrameworkException("Get context failed", var8); } catch (XPathExpressionException var9) { throw new AutomationFrameworkException("Get context failed", var9); } long time = System.currentTimeMillis() + 300000L; while (!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { ; } log.info("Server stopped successfully..."); } this.inputStreamHandler.stop(); this.errorStreamHandler.stop(); this.process.destroy(); this.process = null; if (this.isCoverageEnable) { try { log.info("Generating Jacoco code coverage..."); this.generateCoverageReport( new File(this.carbonHome + File.separator + "repository" + File.separator + "components" + File.separator + "plugins" + File.separator)); } catch (IOException var7) { log.error("Failed to generate code coverage ", var7); throw new AutomationFrameworkException("Failed to generate code coverage ", var7); } } if (portOffset == 0) { System.clearProperty("carbon.home"); } } }