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

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

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

Channel.isClosingOrClosed介绍

[英]Returns true if the channel is either in the process of closing down or has closed down. If the result is true, it means that the channel will be closed at some point by Remoting, and that it makes no sense to send any new UserRequests to the remote side. Invocations like #call(hudson.remoting.Callable) and #callAsync(hudson.remoting.Callable) will just fail as well.
[中]如果通道正在关闭或已关闭,则返回true。如果结果为真,则意味着该通道将在某个时间点通过远程处理关闭,并且向远程端发送任何新的userrequest是没有意义的。调用#call(hudson.remoting.Callable)和#callAsync(hudson.remoting.Callable)也会失败。

代码示例

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

@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;
  }
}

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

return new Launcher.DummyLauncher(listener);
if (channel.isClosingOrClosed()) {
  reportLauncherCreateError("The agent is being disconnected",
               "Remoting channel is either in the process of closing down or has closed down", listener);

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

@Override
  public void run() {
    if (!channel.isClosingOrClosed()) {
      event.fireAfterChannel(channel);
    }
  }
});

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

@Override
  public void run() {
    if (!channel.isClosingOrClosed()) {
      event.fireAfterChannel(channel);
    }
  }
});

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

@Override
  public void checkIfCanBeExecutedOnChannel(Channel channel) throws IOException {
    // Default check for all requests
    super.checkIfCanBeExecutedOnChannel(channel);
    // We also do not want to run UserRequests when the channel is being closed
    if (channel.isClosingOrClosed()) {
      throw new ChannelClosedException("The request cannot be executed on channel " + channel + ". "
          + "The channel is closing down or has closed down", channel.getCloseRequestCause());
    }
  }
}

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

@Override
public void checkIfCanBeExecutedOnChannel(Channel channel) throws IOException {
  // Default check for all requests
  super.checkIfCanBeExecutedOnChannel(channel);
  
  // We also do not want to run UserRequests when the channel is being closed
  if (channel.isClosingOrClosed()) {
    throw new ChannelClosedException("The request cannot be executed on channel " + channel + ". "
        + "The channel is closing down or has closed down", channel.getCloseRequestCause());
  }
}

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

/**
   * Gets an open channel, which is ready to accept commands.
   *
   * It is a convenience method for cases, when a callable needs to invoke call backs on the master.
   * In such case the requests will be likely failed by {@linkplain UserRequest} logic anyway, but it is better to fail fast.
   * 
   * @return Channel instance
   * @throws ChannelStateException The channel is closing down or has been closed.
   *          Also happens if the channel is not associated with the thread at all.
   * @since TODO
   */
  @Nonnull
  default Channel getOpenChannelOrFail() throws ChannelStateException {
    final Channel ch = getChannelOrFail();
    if (ch.isClosingOrClosed()) {
      throw new ChannelClosedException(ch, "The associated channel " + ch + " is closing down or has closed down", ch.getCloseRequestCause());
    }
    return ch;
  }
}

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

/**
   * Sends the {@link UnexportCommand} for the specified {@link #oid} if the {@link Channel} is still open.
   * @throws IOException if the {@link UnexportCommand} could not be sent.
   */
  private void cleanup() throws IOException {
    if (this.channel == null) {
      return;
    }
    Channel channel = this.channel.channel();
    if (channel != null && !channel.isClosingOrClosed()) {
      try {
        channel.send(new UnexportCommand(oid, origin));
      } finally {
        // clear out references to simplify GC
        this.origin = null;
        this.channel = null;
      }
    }
  }
}

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

if (isClosingOrClosed()) {

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

if (local.isClosingOrClosed()) {
  Throwable createdAtValue = createdAt;
  if (createdAtValue == null) {

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

assertTrue("Channel should be closing", channel.isClosingOrClosed());
assertFalse("Channel should not be closed due to the lock", channel.isOutClosed());

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

/**
 * {@inheritDoc}
 */
public <V,T extends Throwable>
Future<V> callAsync(final Callable<V,T> callable) throws IOException {
  if (isClosingOrClosed()) {
    // No reason to even try performing a user request
    throw new ChannelClosedException("Remote call on " + name + " failed. "
        + "The channel is closing down or has closed down", getCloseRequestCause());
  }
  
  final Future<UserRequest.ResponseToUserRequest<V, T>> f = new UserRequest<V, T>(this, callable).callAsync(this);
  return new FutureAdapter<V, UserRequest.ResponseToUserRequest<V, T>>(f) {
    @Override
    protected V adapt(UserRequest.ResponseToUserRequest<V, T> r) throws ExecutionException {
      try {
        return r.retrieve(Channel.this, UserRequest.getClassLoader(callable));
      } catch (Throwable t) {// really means catch(T t)
        throw new ExecutionException(t);
      }
    }
  };
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

return new Launcher.DummyLauncher(listener);
if (channel.isClosingOrClosed()) {
  reportLauncerCreateError("The agent is being disconnected",
               "Remoting channel is either in the process of closing down or has closed down", listener);

相关文章