@Override protected void launch(EC2Computer computer, TaskListener listener, Instance inst) throws AmazonClientException, IOException, InterruptedException { int processedTime = 0; JIException exception = null; // TODO 自動生成されたメソッド・スタブ this.host = getHostName(computer); while (TIMEOUT > processedTime) { try { wmiLaunch(computer, listener); return; } catch (JIException e) { listener.getLogger().println("Waiting for DCOM to come up. Sleeping " + WAIT); Thread.sleep(WAIT * 1000); processedTime += WAIT * 1000; exception = e; } } // if not return, then print error. if (exception.getErrorCode() == 5) { // access denied error exception.printStackTrace( listener.error(Messages.ManagedWindowsServiceLauncher_AccessDenied())); } else { exception.printStackTrace(listener.error(exception.getMessage())); } }
@Override public void afterDisconnect(SlaveComputer computer, TaskListener listener) { try { JIDefaultAuthInfoImpl auth = createAuth(); JISession session = JISession.createSession(auth); session.setGlobalSocketTimeout(60000); SWbemServices services = WMI.connect(session, computer.getName()); Win32Service slaveService = services.getService("jenkinsslave"); if (slaveService != null) { listener.getLogger().println(Messages.ManagedWindowsServiceLauncher_StoppingService()); slaveService.StopService(); } // destroy session to free the socket JISession.destroySession(session); } catch (UnknownHostException e) { e.printStackTrace(listener.error(e.getMessage())); } catch (JIException e) { e.printStackTrace(listener.error(e.getMessage())); } }