hudson.remoting.Channel.call()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中hudson.remoting.Channel.call()方法的一些代码示例,展示了Channel.call()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channel.call()方法的具体详情如下:
包路径:hudson.remoting.Channel
类名称:Channel
方法名:call

Channel.call介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Shows {@link Channel#classLoadingTime}.
 * @since 1.495
 */
public long getClassLoadingTime() throws IOException, InterruptedException {
  return channel.call(new LoadingTime(false));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Shows {@link Channel#resourceLoadingTime}.
 * @since 1.495
 */
public long getResourceLoadingTime() throws IOException, InterruptedException {
  return channel.call(new LoadingTime(true));
}

代码示例来源:origin: jenkinsci/jenkins

public List<LogRecord> getLogRecords() throws IOException, InterruptedException {
  if(channel==null)
    return Collections.emptyList();
  else
    return channel.call(new SlaveLogFetcher());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Get the OS description.
 */
public String getOSDescription() throws IOException, InterruptedException {
  return channel.call(new DetectOS()) ? "Unix" : "Windows";
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Shows {@link Channel#classLoadingCount}.
 * @since 1.495
 */
public int getClassLoadingCount() throws IOException, InterruptedException {
  return channel.call(new LoadingCount(false));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Shows {@link Channel#resourceLoadingCount}.
 * @since 1.495
 */
public int getResourceLoadingCount() throws IOException, InterruptedException {
  return channel.call(new LoadingCount(true));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Get the agent version
 */
public String getSlaveVersion() throws IOException, InterruptedException {
  return channel.call(new SlaveVersion());
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void preOnline(Computer c, Channel channel, FilePath root, TaskListener listener)  {
  if (disabled)   return;
  try {
    if (channel.call(new ChannelSwapper()))
      listener.getLogger().println("Evacuated stdout");
  } catch (Throwable e) {
    LOGGER.fine("Fatal problem swapping file descriptors " + c.getName());
  }
}

代码示例来源:origin: jenkinsci/jenkins

protected @Nonnull Charset getClientCharset() throws IOException, InterruptedException {
  if (encoding != null) {
    return encoding;
  }
  if (channel==null)
    // for SSH, assume the platform default encoding
    // this is in-line with the standard SSH behavior
    return Charset.defaultCharset();
  String charsetName = checkChannel().call(new GetCharset());
  try {
    return Charset.forName(charsetName);
  } catch (UnsupportedCharsetException e) {
    LOGGER.log(Level.FINE,"Server doesn't have charset "+charsetName);
    return Charset.defaultCharset();
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Convenience method for subtypes to obtain environment variables of the client.
 * @deprecated Specific to Remoting-based protocol.
 */
@Deprecated
protected String getClientEnvironmentVariable(String name) throws IOException, InterruptedException {
  return checkChannel().call(new GetEnvironmentVariable(name));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Convenience method for subtypes to obtain the system property of the client.
 * @deprecated Specific to Remoting-based protocol.
 */
@Deprecated
protected String getClientSystemProperty(String name) throws IOException, InterruptedException {
  return checkChannel().call(new GetSystemProperty(name));
}

代码示例来源:origin: jenkinsci/jenkins

/**
   * Loads the script from the argument.
   */
  private String loadScript() throws CmdLineException, IOException, InterruptedException {
    if(script==null)
      throw new CmdLineException(null, "No script is specified");
    if (script.equals("="))
      return IOUtils.toString(stdin);

    return checkChannel().call(new ScriptLoader(script));
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * 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());
}

代码示例来源:origin: jenkinsci/jenkins

@VisibleForTesting
/*package*/ void install(Channel channel, @CheckForNull SlaveComputer c) {
  if (pingTimeoutSeconds < 1 || pingIntervalSeconds < 1) {
    LOGGER.warning("Agent ping is disabled");
    return;
  }
  // set up ping from both directions, so that in case of a router dropping a connection,
  // both sides can notice it and take compensation actions.
  try {
    channel.call(new SetUpRemotePing(pingTimeoutSeconds, pingIntervalSeconds));
    LOGGER.fine("Set up a remote ping for " + channel.getName());
  } catch (Exception e) {
    LOGGER.log(Level.SEVERE, "Failed to set up a ping for " + channel.getName(), e);
  }
  setUpPingForChannel(channel, c, pingTimeoutSeconds, pingIntervalSeconds, true);
}

代码示例来源:origin: jenkinsci/jenkins

@Override public void preOnline(Computer c, Channel channel, FilePath root, TaskListener listener) throws IOException, InterruptedException {
    for (LogRecorder recorder : Jenkins.getInstance().getLog().logRecorders.values()) {
      for (Target t : recorder.targets) {
        channel.call(new SetLevel(t.name, t.getLevel()));
      }
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

public static void applyConfiguration(SAXReader reader, Object context) throws IOException, InterruptedException {
  Collection<ParserConfigurator> all = Collections.emptyList();
  if (Jenkins.getInstanceOrNull()==null) {
    Channel ch = Channel.current();
    if (ch!=null)
      all = ch.call(new GetParserConfigurators());
  } else
    all = all();
  for (ParserConfigurator pc : all)
    pc.configure(reader,context);
}
private static class GetParserConfigurators extends SlaveToMasterCallable<Collection<ParserConfigurator>, IOException> {

代码示例来源:origin: jenkinsci/jenkins

/**
 * If the command is currently running inside a build, return it. Otherwise null.
 */
protected Run optCurrentlyBuilding() throws CmdLineException {
  try {
    CLICommand c = CLICommand.getCurrent();
    if (c==null)
      throw new IllegalStateException("Not executing a CLI command");
    String[] envs = c.checkChannel().call(new GetCharacteristicEnvironmentVariables());
    if (envs[0]==null || envs[1]==null)
      return null;
    Job j = Jenkins.getActiveInstance().getItemByFullName(envs[0],Job.class);
    if (j==null)
      throw new IllegalArgumentException("No such job: "+envs[0]);
    try {
      Run r = j.getBuildByNumber(Integer.parseInt(envs[1]));
      if (r==null)
        throw new IllegalArgumentException("No such build #"+envs[1]+" in "+envs[0]);
      if (!r.isBuilding()) {
        throw new IllegalStateException(r + " is not currently being built");
      }
      return r;
    } catch (NumberFormatException e) {
      throw new IllegalArgumentException("Invalid build number: "+envs[1]);
    }
  } catch (IOException | InterruptedException e) {
    throw new IllegalArgumentException("Failed to identify the build being executed",e);
  }
}

代码示例来源:origin: jenkinsci/jenkins

channel.addListener(listener);
String slaveVersion = channel.call(new SlaveVersion());
log.println("Remoting version: " + slaveVersion);
VersionNumber agentVersion = new VersionNumber(slaveVersion);
boolean _isUnix = channel.call(new DetectOS());
log.println(_isUnix? hudson.model.Messages.Slave_UnixSlave():hudson.model.Messages.Slave_WindowsSlave());
String defaultCharsetName = channel.call(new DetectDefaultCharset());
  remoteFS = channel.call(new AbsolutePath(remoteFS));
  log.println("NOTE: Relative remote path resolved to: "+remoteFS);
channel.call(new SlaveInitializer(DEFAULT_RING_BUFFER_SIZE));
SecurityContext old = ACL.impersonate(ACL.SYSTEM);
try {

代码示例来源:origin: jenkinsci/jenkins

protected int run() throws Exception {
  Jenkins h = Jenkins.getActiveInstance();
  h.checkPermission(Jenkins.READ);
  // where is this build running?
  BuildIDs id = checkChannel().call(new BuildIDs());
  if (!id.isComplete())
    throw new IllegalStateException("This command can be only invoked from a build executing inside Hudson");
  AbstractProject p = h.getItemByFullName(id.job, AbstractProject.class);
  if (p==null)
    throw new IllegalStateException("No such job found: "+id.job);
  p.checkPermission(Item.CONFIGURE);
  List<String> toolTypes = new ArrayList<>();
  for (ToolDescriptor<?> d : ToolInstallation.all()) {
    toolTypes.add(d.getDisplayName());
    if (d.getDisplayName().equals(toolType)) {
      List<String> toolNames = new ArrayList<>();
      for (ToolInstallation t : d.getInstallations()) {
        toolNames.add(t.getName());
        if (t.getName().equals(toolName))
          return install(t, id, p);
      }
      // didn't find the right tool name
      error(toolNames, toolName, "name");
    }
  }
  // didn't find the tool type
  error(toolTypes, toolType, "type");
  // will never be here
  throw new AssertionError();
}

代码示例来源:origin: jenkinsci/jenkins

public Authentication authenticate() throws AuthenticationException, IOException, InterruptedException {
    if (userName==null)
      return command.getTransportAuthentication();    // no authentication parameter. fallback to the transport
    if (passwordFile!=null)
      try {
        password = new FilePath(command.checkChannel(), passwordFile).readToString().trim();
      } catch (IOException e) {
        throw new BadCredentialsException("Failed to read "+passwordFile,e);
      }
    if (password==null)
      password = command.checkChannel().call(new InteractivelyAskForPassword());
    if (password==null)
      throw new BadCredentialsException("No password specified");
    UserDetails d = doAuthenticate(userName, password);
    return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities());
  }
};

相关文章