@Override protected void onDead(Throwable cause) { if (analysis) { analyze(cause); } boolean inClosed = isInClosed.get(); // Disassociate computer channel before closing it if (computer != null) { Exception exception = cause instanceof Exception ? (Exception) cause: new IOException(cause); computer.disconnect(new OfflineCause.ChannelTermination(exception)); } if (inClosed) { LOGGER.log(Level.FINE,"Ping failed after the channel "+channel.getName()+" is already partially closed.",cause); } else { LOGGER.log(Level.INFO,"Ping failed. Terminating the channel "+channel.getName()+".",cause); } } /** Keep in a separate method so we do not even try to do class loading on {@link PingFailureAnalyzer} from an agent JVM. */
@Override public void run() { if (c.isIdle()) { LOGGER.log(INFO, "Disconnecting computer {0} as it has finished all jobs running when " + "it completed its scheduled uptime", new Object[]{c.getName()}); c.disconnect(OfflineCause .create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime())); } } });
@Override public void run() { if (c.isIdle()) { LOGGER.log(INFO, "Disconnecting computer {0} as it has finished its scheduled uptime", new Object[]{c.getName()}); c.disconnect(OfflineCause .create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime())); } else { c.setAcceptingTasks(false); } } });
@RequirePOST public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(DISCONNECT); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(new OfflineCause.UserCause(User.current(), offlineMessage)); } return new HttpRedirect("."); }
c.disconnect(new OfflineCause.IdleOfflineCause()); } else {
computer.disconnect(new ConnectionFromCurrentPeer()).get(15, TimeUnit.SECONDS); } catch (ExecutionException | TimeoutException | InterruptedException e) { event.reject(new ConnectionRefusalException("Failed to disconnect the current client", e));
c.disconnect(OfflineCause.create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime()));
public void disconnectSlave(DumbSlave slave) throws Exception { slave.getComputer().disconnect(new OfflineCause.ChannelTermination(new Exception("terminate"))); long start = System.currentTimeMillis(); while (slave.getChannel() != null) { if (System.currentTimeMillis() > (start + 10000)) { throw new IllegalStateException("Timed out waiting on DumbSlave channel to disconnect."); } Thread.sleep(200); } }
@Override protected void onDead(Throwable cause) { if (analysis) { analyze(cause); } boolean inClosed = isInClosed.get(); // Disassociate computer channel before closing it if (computer != null) { Exception exception = cause instanceof Exception ? (Exception) cause: new IOException(cause); computer.disconnect(new OfflineCause.ChannelTermination(exception)); } if (inClosed) { LOGGER.log(Level.FINE,"Ping failed after the channel "+channel.getName()+" is already partially closed.",cause); } else { LOGGER.log(Level.INFO,"Ping failed. Terminating the channel "+channel.getName()+".",cause); } } /** Keep in a separate method so we do not even try to do class loading on {@link PingFailureAnalyzer} from an agent JVM. */
@Override public void run() { if (c.isIdle()) { LOGGER.log(INFO, "Disconnecting computer {0} as it has finished all jobs running when " + "it completed its scheduled uptime", new Object[]{c.getName()}); c.disconnect(OfflineCause .create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime())); } } });
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel != null) { //does nothing in case computer is already disconnected checkPermission(CONFIGURE); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( HudsonSecurityManager.getAuthentication().getName(), offlineMessage != null ? " : " + offlineMessage : ""))); } return new HttpRedirect("."); }
@Override public void run() { if (c.isIdle()) { LOGGER.log(INFO, "Disconnecting computer {0} as it has finished its scheduled uptime", new Object[]{c.getName()}); c.disconnect(OfflineCause .create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime())); } else { c.setAcceptingTasks(false); } } });
@RequirePOST public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(DISCONNECT); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(new OfflineCause.UserCause(User.current(), offlineMessage)); } return new HttpRedirect("."); }
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(Hudson.ADMINISTER); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( Hudson.getAuthentication().getName(), offlineMessage!=null ? " : " + offlineMessage : "") )); } return new HttpRedirect("."); }
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(Hudson.ADMINISTER); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( Hudson.getAuthentication().getName(), offlineMessage!=null ? " : " + offlineMessage : "") )); } return new HttpRedirect("."); }
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(Hudson.ADMINISTER); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( Hudson.getAuthentication().getName(), offlineMessage!=null ? " : " + offlineMessage : "") )); } return new HttpRedirect("."); }
public synchronized long check(SlaveComputer c) { if (c.isOffline()) { final long demandMilliseconds = System.currentTimeMillis() - c.getDemandStartMilliseconds(); if (demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/ && c.isLaunchSupported()) { // we've been in demand for long enough logger.log(Level.INFO, "Launching computer {0} as it has been in demand for {1}", new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)}); c.connect(false); } } else if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > idleDelay * 1000 * 60 /*MINS->MILLIS*/) { // we've been idle for long enough logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}", new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)}); c.disconnect(OfflineCause.create(Messages._RetentionStrategy_Demand_OfflineIdle())); } } return 1; }
public synchronized void shutdown(Localizable reason) { if (isEligibleForReuse()) { LOGGER.log(Level.INFO, "AzureVMAgent: shutdown: agent {0} is always shut down", this. getDisplayName()); return; } LOGGER.log(Level.INFO, "AzureVMAgent: shutdown: Add suspended status for node {0}", this.getNodeName()); this.getComputer().setAcceptingTasks(false); this.getComputer().disconnect(OfflineCause.create(reason)); LOGGER.log(Level.INFO, "AzureVMAgent: shutdown: shutting down agent {0}", this. getDisplayName()); AzureVMManagementServiceDelegate serviceDelegate = getServiceDelegate(); if (serviceDelegate != null) { serviceDelegate.shutdownVirtualMachine(this); } // After shutting down successfully, set the node as eligible for // reuse. setEligibleForReuse(true); final Map<String, String> properties = new HashMap<>(); properties.put("Reason", reason == null ? "Unknown reason" : reason.toString()); AzureVMAgentPlugin.sendEvent(Constants.AI_VM_AGENT, "ShutDown", properties); }
public synchronized long check(SlaveComputer c) { if (c.isOffline()) { final long demandMilliseconds = System.currentTimeMillis() - c.getDemandStartMilliseconds(); if (demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/ && c.isLaunchSupported()) { // we've been in demand for long enough logger.log(Level.INFO, "Launching computer {0} as it has been in demand for {1}", new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)}); c.connect(false); } } else if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > idleDelay * 1000 * 60 /*MINS->MILLIS*/) { // we've been idle for long enough logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}", new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)}); c.disconnect(OfflineCause.create(Messages._RetentionStrategy_Demand_OfflineIdle())); } } return 1; }
public synchronized long check(SlaveComputer c) { if (c.isOffline()) { final long demandMilliseconds = System.currentTimeMillis() - c.getDemandStartMilliseconds(); if (demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/ && c.isLaunchSupported()) { // we've been in demand for long enough logger.log(Level.INFO, "Launching computer {0} as it has been in demand for {1}", new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)}); c.connect(false); } } else if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > idleDelay * 1000 * 60 /*MINS->MILLIS*/) { // we've been idle for long enough logger.log(Level.INFO, "Disconnecting computer {0} as it has been idle for {1}", new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)}); c.disconnect(OfflineCause.create(Messages._RetentionStrategy_Demand_OfflineIdle())); } } return 1; }