/** * Executes some program on the machine that this {@link FilePath} exists, * so that one can perform local file operations. */ public <V,E extends Throwable> V act(Callable<V,E> callable) throws IOException, InterruptedException, E { if(channel!=null) { // run this on a remote system return channel.call(callable); } else { // the file is on the local machine return callable.call(); } }
@Override public void checkRoles(RoleChecker checker) throws SecurityException { delegate.checkRoles(checker); } }
/** * A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067 * on BugParade for more details. */ private void _syncIO() throws InterruptedException { channel.syncLocalIO(); }
public int execute(List<String> args, InputStream stdin, OutputStream stdout, OutputStream stderr) { return entryPoint.main(args, Locale.getDefault(), new RemoteInputStream(stdin), new RemoteOutputStream(stdout), new RemoteOutputStream(stderr)); }
@Override public Channel getChannelOrFail() throws ChannelClosedException { final Channel ch = Channel.current(); if (ch == null) { throw new ChannelClosedException(new IllegalStateException("No channel associated with the thread")); } return ch; }
/** * Shows {@link Channel#classLoadingPrefetchCacheCount}. * @return -1 in case that capability is not supported * @since 1.519 */ public int getClassLoadingPrefetchCacheCount() throws IOException, InterruptedException { if (!channel.remoteCapability.supportsPrefetch()) { return -1; } return channel.call(new LoadingPrefetchCacheCount()); }
protected <V, T extends Throwable> V _withLock(hudson.remoting.Callable<V,T> callable) throws T { synchronized (this) { return callable.call(); } } }
public static Future<Map<String,String>> getThreadDumpAsync(VirtualChannel channel) throws IOException, InterruptedException { if(channel==null) return new AsyncFutureImpl<Map<String, String>>(Collections.singletonMap("N/A","offline")); return channel.callAsync(new GetThreadDump()); }
@Override public Channel getOpenChannelOrFail() throws ChannelClosedException { final Channel ch = getChannelOrFail(); if (ch.isClosingOrClosed()) { // TODO: Since Remoting 2.33, we still need to explicitly declare minimum Remoting version throw new ChannelClosedException(new IllegalStateException("The associated channel " + ch + " is closing down or has closed down", ch.getCloseRequestCause())); } return ch; } }
public URL getWhereServletIsLoaded() throws IOException { return Which.jarURL(servletClass); } }
@Override public final ClassLoader getClassLoader() { return callable.getClassLoader(); }
public CliManagerImpl(Channel channel) { this.channel = channel; channel.addLocalExecutionInterceptor(authenticationFilter); }
@Override public synchronized void setAsCancelled() { super.setAsCancelled(); if (!start.isDone()) { start.setAsCancelled(); } }
/** * Undo {@link #register}. */ public static void unregister() { ClassFilter.setDefault(ClassFilter.STANDARD); }
public IOTriplet getIOtriplet() { IOTriplet r = new IOTriplet(); if (reverseStdout) r.stdout = new RemoteInputStream(p.getStdout()); if (reverseStderr) r.stderr = new RemoteInputStream(p.getStderr()); if (reverseStdin) r.stdin = new RemoteOutputStream(p.getStdin()); return r; } });
/** * Does some calculations in batch. * For a remote file, this can be much faster than doing the corresponding operations one by one as separate requests. * The default implementation just calls the block directly. * @param <V> a value type * @param callable something to run all at once (only helpful if any mentioned files are on the same system) * @return the callable result * @throws IOException if remote communication failed * @since 1.554 */ public <V> V run(Callable<V,IOException> callable) throws IOException { return callable.call(); }
public URL getWhereAntIsLoaded() throws IOException { return Which.jarURL(antClass); } }