本文整理汇总了Java中org.apache.sshd.client.future.OpenFuture.isOpened方法的典型用法代码示例。如果您正苦于以下问题:Java OpenFuture.isOpened方法的具体用法?Java OpenFuture.isOpened怎么用?Java OpenFuture.isOpened使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sshd.client.future.OpenFuture
的用法示例。
在下文中一共展示了OpenFuture.isOpened方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openChannel
import org.apache.sshd.client.future.OpenFuture; //导入方法依赖的package包/类
@Deprecated
private void openChannel() throws IOException {
channel = session.createSubsystemChannel("netconf");
OpenFuture channelFuture = channel.open();
if (channelFuture.await(connectTimeout, TimeUnit.SECONDS)) {
if (channelFuture.isOpened()) {
streamHandler = new NetconfStreamThread(channel.getInvertedOut(), channel.getInvertedIn(),
channel.getInvertedErr(), deviceInfo,
new NetconfSessionDelegateImpl(), replies);
} else {
throw new NetconfException("Failed to open channel with device " +
deviceInfo);
}
sendHello();
}
}
示例2: operationComplete
import org.apache.sshd.client.future.OpenFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(OpenFuture future) {
if ( ! future.isOpened() ) {
log.error("Failed to execute bootstrap command for agent [{}]", connection.getAgentId(), future.getException());
connection.close();
}
}
示例3: createConnection
import org.apache.sshd.client.future.OpenFuture; //导入方法依赖的package包/类
protected AgentConnection createConnection(Agent agent, SshConnectionOptions opts) throws IOException, InterruptedException {
SshClient client = getClient();
ClientSession session = null;
boolean success = false;
try {
session = connect(client, opts);
String hostIp = getIp(opts);
String script = copyBootStrap(session);
int port = setForwarding(session);
log.info("Allocated random port [{}] on [{}]", port, opts.getHost());
EofAwareChannelExec exec = callBootStrap(agent, session, String.format("%s --read-env --port %d --ip %s", script, port, hostIp));
final SshAgentConnection sshAgent = new SshAgentConnection(agent.getId(), agent.getUri(), eventService, this, session, exec, port);
success = true;
connections.add(sshAgent);
exec.onEof(new Runnable() {
@Override
public void run() {
sshAgent.close();
}
});
CloseListener listener = new CloseListener(sshAgent);
session.addListener(listener);
OpenFuture execOpen = exec.open();
execOpen.addListener(listener);
try {
execOpen.await(SSH_TIMEOUT.get(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new IllegalStateException("Interrupted waiting for script [" + script + "]", e);
}
if ( ! execOpen.isOpened() ) {
throw new IOException("Failed to start script [" + script + "]");
}
success = writeAuth(sshAgent);
if ( ! success ) {
sshAgent.close();
throw new IOException("Failed to write context info for agent [" + sshAgent.getAgentId() + "]");
}
return sshAgent;
} finally {
if ( ! success && session != null ) {
session.close(true);
}
}
}
示例4: createConnection
import org.apache.sshd.client.future.OpenFuture; //导入方法依赖的package包/类
protected AgentConnection createConnection(Agent agent, SshConnectionOptions opts) throws IOException, InterruptedException {
SshClient client = getClient();
ClientSession session = null;
boolean success = false;
try {
session = connect(client, opts);
String hostIp = getIp(opts);
String script = copyBootStrap(session);
int port = setForwarding(session);
log.info("Allocated random port [{}] on [{}]", port, opts.getHost());
EofAwareChannelExec exec = callBootStrap(agent, session, String.format("%s --port %d --ip %s", script, port, hostIp));
final SshAgentConnection sshAgent = new SshAgentConnection(agent.getId(), agent.getUri(), eventService, this, session, exec, port);
success = true;
connections.add(sshAgent);
exec.onEof(new Runnable() {
@Override
public void run() {
sshAgent.close();
}
});
CloseListener listener = new CloseListener(sshAgent);
session.addListener(listener);
OpenFuture execOpen = exec.open();
execOpen.addListener(listener);
try {
execOpen.await(SSH_TIMEOUT.get(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new IllegalStateException("Interrupted waiting for script [" + script + "]", e);
}
if ( ! execOpen.isOpened() ) {
throw new IOException("Failed to start script [" + script + "]");
}
success = writeAuth(sshAgent);
if ( ! success ) {
sshAgent.close();
throw new IOException("Failed to write context info for agent [" + sshAgent.getAgentId() + "]");
}
return sshAgent;
} finally {
if ( ! success && session != null ) {
session.close(true);
}
}
}