本文整理汇总了Java中com.trilead.ssh2.ChannelCondition类的典型用法代码示例。如果您正苦于以下问题:Java ChannelCondition类的具体用法?Java ChannelCondition怎么用?Java ChannelCondition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelCondition类属于com.trilead.ssh2包,在下文中一共展示了ChannelCondition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: canEndTheSshConnectionTest
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void canEndTheSshConnectionTest() throws Exception {
PowerMockito.spy(SshHelper.class);
final Session mockedSession = Mockito.mock(Session.class);
PowerMockito.doReturn(true).when(SshHelper.class, "isChannelConditionEof", Mockito.anyInt());
Mockito.when(mockedSession.waitForCondition(ChannelCondition.EXIT_STATUS, 1l)).thenReturn(0);
PowerMockito.doNothing().when(SshHelper.class, "throwSshExceptionIfConditionsTimeout", Mockito.anyInt());
SshHelper.canEndTheSshConnection(1, mockedSession, 0);
PowerMockito.verifyStatic();
SshHelper.isChannelConditionEof(Mockito.anyInt());
SshHelper.throwSshExceptionIfConditionsTimeout(Mockito.anyInt());
Mockito.verify(mockedSession).waitForCondition(ChannelCondition.EXIT_STATUS, 1l);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:SshHelperTest.java
示例2: getSessionOutcomeMessage
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* Find the exit code or exit status, which are differentiated in SSH protocol.
*/
private String getSessionOutcomeMessage(Session session, boolean isConnectionLost) throws InterruptedException {
session.waitForCondition(ChannelCondition.EXIT_STATUS | ChannelCondition.EXIT_SIGNAL, 3000);
Integer exitCode = session.getExitStatus();
if (exitCode != null)
return "Slave JVM has terminated. Exit code=" + exitCode;
String sig = session.getExitSignal();
if (sig != null)
return "Slave JVM has terminated. Exit signal=" + sig;
if (isConnectionLost)
return "Slave JVM has not reported exit code before the socket was lost";
return "Slave JVM has not reported exit code. Is it still running?";
}
开发者ID:thescouser89,项目名称:ovirt-slaves-plugin,代码行数:20,代码来源:OVirtSshLauncher.java
示例3: canEndTheSshConnectionTest
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void canEndTheSshConnectionTest() throws Exception {
PowerMockito.spy(SshHelper.class);
Session mockedSession = Mockito.mock(Session.class);
PowerMockito.doReturn(true).when(SshHelper.class, "isChannelConditionEof", Mockito.anyInt());
Mockito.when(mockedSession.waitForCondition(ChannelCondition.EXIT_STATUS, 1l)).thenReturn(0);
PowerMockito.doNothing().when(SshHelper.class, "throwSshExceptionIfConditionsTimeout", Mockito.anyInt());
SshHelper.canEndTheSshConnection(1, mockedSession, 0);
PowerMockito.verifyStatic();
SshHelper.isChannelConditionEof(Mockito.anyInt());
SshHelper.throwSshExceptionIfConditionsTimeout(Mockito.anyInt());
Mockito.verify(mockedSession).waitForCondition(ChannelCondition.EXIT_STATUS, 1l);
}
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:SshHelperTest.java
示例4: read
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Override
public int read(byte[] buffer, int start, int len) throws IOException {
int bytesRead = 0;
if (session == null)
return 0;
int newConditions = session.waitForCondition(conditions, 0);
if ((newConditions & ChannelCondition.STDOUT_DATA) != 0) {
bytesRead = stdout.read(buffer, start, len);
}
if ((newConditions & ChannelCondition.STDERR_DATA) != 0) {
byte discard[] = new byte[256];
while (stderr.available() > 0) {
stderr.read(discard);
}
}
if ((newConditions & ChannelCondition.EOF) != 0) {
close();
onDisconnect();
throw new IOException("Remote end closed connection");
}
return bytesRead;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SSH.java
示例5: throwSshExceptionIfConditionsTimeout
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* It throws a {@link SshException} if the channel condition is {@link ChannelCondition#TIMEOUT}
*/
protected static void throwSshExceptionIfConditionsTimeout(final int conditions) throws SshException {
if ((conditions & ChannelCondition.TIMEOUT) != 0) {
final String msg = "Timed out in waiting for SSH execution exit status";
s_logger.error(msg);
throw new SshException(msg);
}
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:11,代码来源:SshHelper.java
示例6: canEndTheSshConnection
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* Handles the SSH connection in case of timeout or exit. If the session ends with a timeout
* condition, it throws an exception; if the channel reaches an end of file condition, but it
* does not have an exit status, it returns true to break the loop; otherwise, it returns
* false.
*/
protected static boolean canEndTheSshConnection(final int waitResultTimeoutInMs, final com.trilead.ssh2.Session sess, final int conditions) throws SshException {
if (isChannelConditionEof(conditions)) {
final int newConditions = sess.waitForCondition(ChannelCondition.EXIT_STATUS, waitResultTimeoutInMs);
throwSshExceptionIfConditionsTimeout(newConditions);
if ((newConditions & ChannelCondition.EXIT_STATUS) != 0) {
return true;
}
}
return false;
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:SshHelper.java
示例7: isChannelConditionEof
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* Checks if the channel condition mask is of {@link ChannelCondition#EOF} and not
* {@link ChannelCondition#STDERR_DATA} or {@link ChannelCondition#STDOUT_DATA}.
*/
protected static boolean isChannelConditionEof(final int conditions) {
if ((conditions & ChannelCondition.EOF) != 0) {
return true;
}
return false;
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:11,代码来源:SshHelper.java
示例8: read
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Override
public int read(byte[] buffer, int start, int len) throws IOException {
int bytesRead = 0;
if (session == null)
return 0;
int newConditions = session.waitForCondition(conditions, 0);
if ((newConditions & ChannelCondition.STDOUT_DATA) != 0) {
bytesRead = stdout.read(buffer, start, len);
}
if ((newConditions & ChannelCondition.STDERR_DATA) != 0) {
byte discard[] = new byte[256];
while (stderr.available() > 0) {
stderr.read(discard);
}
}
if ((newConditions & ChannelCondition.EOF) != 0) {
onDisconnect();
throw new IOException("Remote end closed connection");
}
return bytesRead;
}
开发者ID:dragonlinux,项目名称:connectbot,代码行数:28,代码来源:SSH.java
示例9: communicate
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
public static CommunicateResult communicate(Connection connection, Duration timeout, String... command) throws IOException {
checkNotNull(connection);
checkNotNull(timeout);
checkNotNull(command);
String commandString = quoteCommand(asList(command));
Session session = connection.openSession();
try {
session.execCommand(commandString);
StreamGobbler stderr = new StreamGobbler(session.getStderr());
StreamGobbler stdout = new StreamGobbler(session.getStdout());
try {
session.waitForCondition(ChannelCondition.EXIT_STATUS, timeout.getMillis());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return new CommunicateResult(
commandString,
readAll(stdout, Charsets.UTF_8),
readAll(stderr, Charsets.UTF_8),
firstNonNull(session.getExitStatus(), -1000)
);
} finally {
session.close();
}
}
开发者ID:dump247,项目名称:jenkins-docker-build-plugin,代码行数:31,代码来源:Ssh.java
示例10: canEndTheSshConnection
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* Handles the SSH connection in case of timeout or exit. If the session ends with a timeout
* condition, it throws an exception; if the channel reaches an end of file condition, but it
* does not have an exit status, it returns true to break the loop; otherwise, it returns
* false.
*/
protected static boolean canEndTheSshConnection(int waitResultTimeoutInMs, com.trilead.ssh2.Session sess, int conditions) throws SshException {
if (isChannelConditionEof(conditions)) {
int newConditions = sess.waitForCondition(ChannelCondition.EXIT_STATUS, waitResultTimeoutInMs);
throwSshExceptionIfConditionsTimeout(newConditions);
if ((newConditions & ChannelCondition.EXIT_STATUS) != 0) {
return true;
}
}
return false;
}
开发者ID:apache,项目名称:cloudstack,代码行数:17,代码来源:SshHelper.java
示例11: throwSshExceptionIfConditionsTimeout
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* It throws a {@link SshException} if the channel condition is {@link ChannelCondition#TIMEOUT}
*/
protected static void throwSshExceptionIfConditionsTimeout(int conditions) throws SshException {
if ((conditions & ChannelCondition.TIMEOUT) != 0) {
String msg = "Timed out in waiting for SSH execution exit status";
s_logger.error(msg);
throw new SshException(msg);
}
}
开发者ID:apache,项目名称:cloudstack,代码行数:11,代码来源:SshHelper.java
示例12: isChannelConditionEof
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
/**
* Checks if the channel condition mask is of {@link ChannelCondition#EOF} and not
* {@link ChannelCondition#STDERR_DATA} or {@link ChannelCondition#STDOUT_DATA}.
*/
protected static boolean isChannelConditionEof(int conditions) {
if ((conditions & ChannelCondition.EOF) != 0) {
return true;
}
return false;
}
开发者ID:apache,项目名称:cloudstack,代码行数:11,代码来源:SshHelper.java
示例13: close
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
public void close() throws IOException {
this.flush();
this.session.waitForCondition(ChannelCondition.EOF, 1);
/* Now its hopefully safe to close the session */
this.session.close();
// Socket::close()
this.unused = true;
}
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:9,代码来源:SshProxySession.java
示例14: throwSshExceptionIfConditionsTimeout
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test(expected = SshException.class)
public void throwSshExceptionIfConditionsTimeout() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.TIMEOUT);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例15: doNotThrowSshExceptionIfConditionsClosed
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsClosed() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.CLOSED);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例16: doNotThrowSshExceptionIfConditionsStdout
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsStdout() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.STDOUT_DATA);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例17: doNotThrowSshExceptionIfConditionsStderr
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsStderr() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.STDERR_DATA);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例18: doNotThrowSshExceptionIfConditionsEof
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsEof() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.EOF);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例19: doNotThrowSshExceptionIfConditionsExitStatus
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsExitStatus() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.EXIT_STATUS);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
示例20: doNotThrowSshExceptionIfConditionsExitSignal
import com.trilead.ssh2.ChannelCondition; //导入依赖的package包/类
@Test
public void doNotThrowSshExceptionIfConditionsExitSignal() throws SshException {
SshHelper.throwSshExceptionIfConditionsTimeout(ChannelCondition.EXIT_SIGNAL);
}
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:5,代码来源:SshHelperTest.java
注:本文中的com.trilead.ssh2.ChannelCondition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论