private void check(int threshold) throws InterruptedException { i++; if (i==threshold) { notifyAll(); } else { while (i<threshold && interrupted==null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted!=null) throw (InterruptedException)new InterruptedException().initCause(interrupted); }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if(channel!=null) { // run this on a remote system try { DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<T>(callable, cl); for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) { wrapper = factory.wrap(wrapper); } return channel.call(wrapper); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException(e.getMessage()).initCause(e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), localChannel); } }
/** * Performs monitoring across the board. * * @return * For all the computers, report the monitored values. */ protected Map<Computer,T> monitor() throws InterruptedException { Map<Computer,T> data = new HashMap<Computer,T>(); for( Computer c : Jenkins.getInstance().getComputers() ) { try { Thread.currentThread().setName("Monitoring "+c.getDisplayName()+" for "+getDisplayName()); if(c.getChannel()==null) data.put(c,null); else data.put(c,monitor(c)); } catch (RuntimeException e) { LOGGER.log(Level.WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to monitor "+c.getDisplayName()+" for "+getDisplayName(), e); } catch (InterruptedException e) { throw (InterruptedException)new InterruptedException("Node monitoring "+c.getDisplayName()+" for "+getDisplayName()+" aborted.").initCause(e); } } return data; }
@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { try { return closeFuture.await(timeout, unit); } catch (IOException e) { throw (InterruptedException) new InterruptedException().initCause(e); } }
private void check(int threshold) throws InterruptedException { i++; if (i==threshold) { notifyAll(); } else { while (i<threshold && interrupted==null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted!=null) throw (InterruptedException)new InterruptedException().initCause(interrupted); }
private void check(int threshold) throws InterruptedException { i++; if (i==threshold) { notifyAll(); } else { while (i<threshold && interrupted==null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted!=null) throw (InterruptedException)new InterruptedException().initCause(interrupted); }
private void check(int threshold) throws InterruptedException { i++; if (i==threshold) { notifyAll(); } else { while (i<threshold && interrupted==null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted!=null) throw (InterruptedException)new InterruptedException().initCause(interrupted); }
@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { try { return closeFuture.await(timeout, unit); } catch (IOException e) { throw (InterruptedException) new InterruptedException().initCause(e); } }
private void check(int threshold) throws InterruptedException { i++; if (i==threshold) { notifyAll(); } else { while (i<threshold && interrupted==null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted!=null) throw (InterruptedException)new InterruptedException().initCause(interrupted); }
private void check(int threshold) throws InterruptedException { i++; if (i == threshold) { notifyAll(); } else { while (i < threshold && interrupted == null) { try { wait(); } catch (InterruptedException e) { interrupted = e; notifyAll(); throw e; } } } // all of us either leave normally or get interrupted if (interrupted != null) { throw (InterruptedException) new InterruptedException().initCause(interrupted); } }
private <T> void checkResult(Future<T> result) throws InterruptedException { try { result.get(); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof InterruptedException) { throw (InterruptedException) new InterruptedException().initCause(cause); } else { throw new GitException(cause); } } } }
/** * Returns the current active ZK connection or establishes a new one if none has yet been * established or a previous connection was disconnected or had its session time out. This method * will attempt to re-use sessions when possible. Equivalent to: * <pre>get(Amount.of(0L, ...)</pre>. * * @return a connected ZooKeeper client * @throws ZooKeeperConnectionException if there was a problem connecting to the ZK cluster * @throws InterruptedException if interrupted while waiting for a connection to be established */ public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } }
/** * Returns the current active ZK connection or establishes a new one if none has yet been * established or a previous connection was disconnected or had its session time out. This method * will attempt to re-use sessions when possible. Equivalent to: * <pre>get(Amount.of(0L, ...)</pre>. * * @return a connected ZooKeeper client * @throws ZooKeeperConnectionException if there was a problem connecting to the ZK cluster * @throws InterruptedException if interrupted while waiting for a connection to be established */ public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } }
@Override protected String nextEvent() throws IOException, InterruptedException { WatchKey key; try { key = watcher.take(); } catch (ClosedWatchServiceException cwse) { // #238261 @SuppressWarnings({"ThrowableInstanceNotThrown"}) InterruptedException ie = new InterruptedException(); throw (InterruptedException) ie.initCause(cwse); } Path dir = (Path)key.watchable(); String res = dir.toAbsolutePath().toString(); for (WatchEvent<?> event: key.pollEvents()) { if (event.kind() == OVERFLOW) { // full rescan res = null; } } key.reset(); return res; }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if (channel != null) { // run this on a remote system try { return channel.call(new FileCallableWrapper<T>(callable, cl)); } catch (TunneledInterruptedException e) { throw (InterruptedException) new InterruptedException().initCause(e); } catch (AbortException e) { throw e; // pass through so that the caller can catch it as AbortException } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. throw new IOException2("remote file operation failed: " + remote + " at " + channel, e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), Hudson.MasterComputer.localChannel); } }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if(channel!=null) { // run this on a remote system try { return channel.call(new FileCallableWrapper<T>(callable,cl)); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException().initCause(e); } catch (AbortException e) { throw e; // pass through so that the caller can catch it as AbortException } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. throw new IOException2("remote file operation failed: "+remote+" at "+channel,e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), Hudson.MasterComputer.localChannel); } }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if(channel!=null) { // run this on a remote system try { return channel.call(new FileCallableWrapper<T>(callable,cl)); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException().initCause(e); } catch (AbortException e) { throw e; // pass through so that the caller can catch it as AbortException } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. throw new IOException2("remote file operation failed: "+remote+" at "+channel,e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), Hudson.MasterComputer.localChannel); } }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if(channel!=null) { // run this on a remote system try { return channel.call(new FileCallableWrapper<T>(callable,cl)); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException().initCause(e); } catch (AbortException e) { throw e; // pass through so that the caller can catch it as AbortException } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. throw new IOException2("remote file operation failed: "+remote+" at "+channel,e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), Hudson.MasterComputer.localChannel); } }
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(value); if (lockable) { try { if (!latch.await(1, TimeUnit.MINUTES)) throw new RuntimeException("Cannot serialize!!"); } catch (InterruptedException e) { InterruptedIOException exception = new InterruptedIOException(); e.initCause(e); throw exception; } latch.close(); } }
private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOException, InterruptedException { if(channel!=null) { // run this on a remote system try { DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<T>(callable, cl); for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) { wrapper = factory.wrap(wrapper); } return channel.call(wrapper); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException(e.getMessage()).initCause(e); } catch (AbortException e) { throw e; // pass through so that the caller can catch it as AbortException } catch (IOException e) { // wrap it into a new IOException so that we get the caller's stack trace as well. throw new IOException("remote file operation failed: " + remote + " at " + channel + ": " + e, e); } } else { // the file is on the local machine. return callable.invoke(new File(remote), localChannel); } }