static private boolean checkIfProxyIsOpen(Proxy proxy) { boolean connected = false; int tries = 0; int port = proxy.getPort(); while (!connected && tries < connectRetries) { tries++; try { log.info("Attempting to connect to localhost:" + port + "..."); Socket testSocket = new Socket("localhost", port); log.info("Connection opened"); connected = testSocket.isConnected(); testSocket.close(); } catch (IOException e) { DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5)); } } return connected; }
static URI openSshTunnel(AccountDeploymentDetails<GoogleAccount> details, String instanceName, ServiceSettings service) throws InterruptedException { int port = service.getPort(); String key = Proxy.buildKey(details.getDeploymentName(), instanceName, port); Proxy proxy = proxyMap.getOrDefault(key, new Proxy()); JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor(); if (proxy.getJobId() == null || !jobExecutor.jobExists(proxy.getJobId())) { String ip = getInstanceIp(details, instanceName); String keyFile = getSshKeyFile(); JobStatus status = jobExecutor.updateJob(proxy.getJobId()); throw new HalException(FATAL, "Unable to connect to instance " + instanceName + ": " + status.getStdErr()); .setScheme("http") .setHost("localhost") .setPort(proxy.getPort()) .build(); } catch (URISyntaxException e) {
static URI openSshTunnel(AccountDeploymentDetails<GoogleAccount> details, String instanceName, ServiceSettings service) throws InterruptedException { int port = service.getPort(); String key = Proxy.buildKey(details.getDeploymentName(), instanceName, port); Proxy proxy = proxyMap.getOrDefault(key, new Proxy()); JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor(); if (proxy.getJobId() == null || !jobExecutor.jobExists(proxy.getJobId())) { String ip = getInstanceIp(details, instanceName); String keyFile = getSshKeyFile(); JobStatus status = jobExecutor.updateJob(proxy.getJobId()); throw new HalException(FATAL, "Unable to connect to instance " + instanceName + ": " + status.getStdErr()); .setScheme("http") .setHost("localhost") .setPort(proxy.getPort()) .build(); } catch (URISyntaxException e) {
static private boolean checkIfProxyIsOpen(Proxy proxy) { boolean connected = false; int tries = 0; int port = proxy.getPort(); while (!connected && tries < connectRetries) { tries++; try { log.info("Attempting to connect to localhost:" + port + "..."); Socket testSocket = new Socket("localhost", port); log.info("Connection opened"); connected = testSocket.isConnected(); testSocket.close(); } catch (IOException e) { DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5)); } } return connected; }
static private void closeSshTunnel(Proxy proxy) { JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor(); jobExecutor.cancelJob(proxy.getJobId()); }
static private void closeSshTunnel(Proxy proxy) { JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor(); jobExecutor.cancelJob(proxy.getJobId()); }