com.jcraft.jsch.Channel.isClosed()方法的使用及代码示例

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

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

Channel.isClosed介绍

[英]returns true if this channel is already closed (or another thread is in progress of closing the channel).
[中]

代码示例

代码示例来源:origin: alibaba/jstorm

System.out.print(new String(tmp, 0, i));
if (channel.isClosed()) {
  if (in.available() > 0) continue;
  System.out.println("exit-status: " + channel.getExitStatus());

代码示例来源:origin: alibaba/jstorm

if (channel.isClosed()) {
  if (in.available() > 0) continue;
  if (channel.getExitStatus() != 0)

代码示例来源:origin: apache/kylin

if (channel.isClosed()) {
  if (in.available() > 0)
    continue;

代码示例来源:origin: KylinOLAP/Kylin

if (channel.isClosed()) {
  if (in.available() > 0)
    continue;

代码示例来源:origin: com.axway.ats.expectj/ats-expectj

public boolean isClosed() {
  if( m_channel != null ) {
    if( m_channel.isClosed() ) {
      // We've been disconnected, shut down
      stop();
    }
  }
  return m_channel == null;
}

代码示例来源:origin: net.sourceforge.expectj/expectj

public boolean isClosed() {
  if (m_channel != null) {
    if (m_channel.isClosed()) {
      // We've been disconnected, shut down
      stop();
    }
  }
  return m_channel == null;
}

代码示例来源:origin: com.redhat.rhevm.api/rhevm-api-powershell-expectj

public boolean isClosed() {
  if (m_channel != null) {
    if (m_channel.isClosed()) {
      // We've been disconnected, shut down
      stop();
    }
  }
  return m_channel == null;
}

代码示例来源:origin: sonyxperiadev/gerrit-events

/**
 * Blocks until the given channel is close or the timout is reached
 *
 * @param channel the channel to wait for
 * @param timoutInMs the timeout
 */
private static void waitForChannelClosure(Channel channel, long timoutInMs) {
  final long start = System.currentTimeMillis();
  final long until = start + timoutInMs;
  try {
    while (!channel.isClosed() && System.currentTimeMillis() < until) {
      Thread.sleep(CLOSURE_WAIT_INTERVAL);
    }
    logger.trace("Time waited for channel closure: " + (System.currentTimeMillis() - start));
  } catch (InterruptedException e) {
    logger.trace("Interrupted", e);
  }
  if (!channel.isClosed()) {
    logger.trace("Channel not closed in timely manner!");
  }
};

代码示例来源:origin: Impetus/jumbune

private static String logJsch(Channel channel, InputStream in) 
{
  StringBuilder builder = new StringBuilder();
  try {
    byte[] tmp = new byte[1024];
    while (true) {
      while (in.available() > 0) {
        int i = in.read(tmp, 0, 1024);
        if (i < 0)
          break;
        builder.append((new String(tmp, 0, i)));
      }
      if (channel.isClosed()) {
      //	LOGGER.debug("exit-status: " + channel.getExitStatus());
        break;
      }
    }
  } catch (Exception ex) {
    LOGGER.error(ex);
  }
  return builder.toString();
}

代码示例来源:origin: Impetus/jumbune

private static String logJsch(Channel channel, InputStream in) 
{
  StringBuilder builder = new StringBuilder();
  try {
    byte[] tmp = new byte[1024];
    while (true) {
      while (in.available() > 0) {
        int i = in.read(tmp, 0, 1024);
        if (i < 0)
          break;
        builder.append((new String(tmp, 0, i)));
      }
      if (channel.isClosed()) {
      //	LOGGER.debug("exit-status: " + channel.getExitStatus());
        break;
      }
    }
  } catch (Exception ex) {
    LOGGER.error(ex);
  }
  return builder.toString();
}

代码示例来源:origin: Impetus/jumbune

private static String logJsch(Channel channel, InputStream in) 
{
  StringBuilder builder = new StringBuilder();
  try {
    byte[] tmp = new byte[1024];
    while (true) {
      while (in.available() > 0) {
        int i = in.read(tmp, 0, 1024);
        if (i < 0)
          break;
        builder.append((new String(tmp, 0, i)));
      }
      if (channel.isClosed()) {
      //	LOGGER.debug("exit-status: " + channel.getExitStatus());
        break;
      }
    }
  } catch (Exception ex) {
    LOGGER.error(ex);
  }
  return builder.toString();
}

代码示例来源:origin: Impetus/jumbune

private static String logJsch(Channel channel, InputStream in) 
{
  StringBuilder builder = new StringBuilder();
  try {
    byte[] tmp = new byte[1024];
    while (true) {
      while (in.available() > 0) {
        int i = in.read(tmp, 0, 1024);
        if (i < 0)
          break;
        builder.append((new String(tmp, 0, i)));
      }
      if (channel.isClosed()) {
      //	LOGGER.debug("exit-status: " + channel.getExitStatus());
        break;
      }
    }
  } catch (Exception ex) {
    LOGGER.error(ex);
  }
  return builder.toString();
}

代码示例来源:origin: Impetus/jumbune

private static void logJsch(Channel channel, InputStream in) 
  {
    try {
      byte[] tmp = new byte[1024];
      while (true) {
/*                while (in.available() > 0) {
          int i = in.read(tmp, 0, 1024);
          if (i < 0)
            break;
          LOGGER.debug(new String(tmp, 0, i));
        }
*/	            if (channel.isClosed()) {
          LOGGER.debug("exit-status: " + channel.getExitStatus());
          break;
        }
      }
    } catch (Exception ex) {
      LOGGER.error(ex);
    }
  }

代码示例来源:origin: com.cerner.ftp/jsch-util

public void close() {
  closed = true;
  for (final Channel channel : channels)
    if (!channel.isClosed())
      channel.disconnect();
  channels.clear();
  librarian.checkIn(this);
}

代码示例来源:origin: org.apache.airavata/gsissh

public void onOutput(Channel channel) {
  try {
    StringBuffer pbsOutput = new StringBuffer("");
    InputStream inputStream =  channel.getInputStream();
    byte[] tmp = new byte[1024];
    do {
      while (inputStream.available() > 0) {
        int i = inputStream.read(tmp, 0, 1024);
        if (i < 0) break;
        pbsOutput.append(new String(tmp, 0, i));
      }
    } while (!channel.isClosed()) ;
    String output = pbsOutput.toString();
    this.setStdOutputString(output);
  } catch (IOException e) {
    logger.error(e.getMessage(), e);
  }
}

代码示例来源:origin: org.apache.airavata/gsissh

public void onOutput(Channel channel) {
  try {
    InputStream inputStream = channel.getInputStream();
    byte[] tmp = new byte[1024];
    while (true) {
      while (inputStream.available() > 0) {
        int i = inputStream.read(tmp, 0, 1024);
        if (i < 0) break;
        System.out.print(new String(tmp, 0, i));
      }
      if (channel.isClosed()) {
        System.out.println("exit-status: " + channel.getExitStatus());
        break;
      }
      try {
        Thread.sleep(1000);
      } catch (Exception ignored) {
      }
    }
  } catch (IOException e) {
    logger.error(e.getMessage(), e);
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@Override
public long getLength() throws IOException {
  try {
    URI uri = new URI(encodeUriParts(getSourcePath()));
    if (channel == null || channel.isClosed()) {
      channel = getSessionForHost(uri).openChannel("sftp");
      channel.connect();
    }
    ChannelSftp sftpChannel = (ChannelSftp) channel;
    SftpATTRS stats = sftpChannel.lstat(decodeUriParts(uri.getRawPath()));
    return stats.getSize();
  } catch (URISyntaxException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Error parsing URL", ex);
  } catch (SftpException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Error getting file stats", ex);
  } catch (JSchException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Error opening SFTP channel", ex);
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@Override
public InputStream getStream() throws IOException {
  try {
    URI uri = new URI(encodeUriParts(getSourcePath()));
    if (channel == null || channel.isClosed()) {
      channel = getSessionForHost(uri).openChannel("sftp");
      channel.connect();
    }
    ChannelSftp sftpChannel = (ChannelSftp) channel;
    currentStream = sftpChannel.get(decodeUriParts(uri.getRawPath()));
    return currentStream;
  } catch (URISyntaxException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Bad URI format", ex);
  } catch (JSchException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Error with connection", ex);
  } catch (SftpException ex) {
    Logger.getLogger(FileOrRendition.class.getName()).log(Level.SEVERE, null, ex);
    throw new IOException("Error retrieving file", ex);
  }
}

代码示例来源:origin: org.onap.appc/appc-netconf-adapter-bundle

@Override
public void disconnect() {
  try {
    if((channel != null) && !channel.isClosed()) {
      netconfAdapter.sendMessage(NetconfConstMessages.CLOSE_SESSION);
      isOk(netconfAdapter.receiveMessage());
    }
  } catch(IOException e) {
    throw new RuntimeException("Error closing netconf device", e);
  } finally {
    netconfAdapter = null;
    if(channel != null) {
      channel.disconnect();
      channel = null;
    }
    if(session != null) {
      session.disconnect();
      session = null;
    }
  }
}

代码示例来源:origin: io.vertx/vertx-shell

private void testClose(TestContext context, Consumer<Term> closer) throws Exception {
 Async async = context.async();
 termHandler = term -> {
  term.closeHandler(v -> {
   async.complete();
  });
  closer.accept(term);
 };
 startShell();
 Session session = createSession("paulo", "secret", false);
 session.connect();
 Channel channel = session.openChannel("shell");
 channel.connect();
 while (channel.isClosed()) {
  Thread.sleep(10);
 }
}

相关文章