• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OpenFuture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.sshd.client.future.OpenFuture的典型用法代码示例。如果您正苦于以下问题:Java OpenFuture类的具体用法?Java OpenFuture怎么用?Java OpenFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OpenFuture类属于org.apache.sshd.client.future包,在下文中一共展示了OpenFuture类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sessionCreated

import org.apache.sshd.client.future.OpenFuture; //导入依赖的package包/类
@Override
public void sessionCreated(final IoSession session) throws Exception {
    final TcpipClientChannel channel;
    int localPort = ((InetSocketAddress) session.getLocalAddress()).getPort();
    if (localToRemote.containsKey(localPort)) {
        SshdSocketAddress remote = localToRemote.get(localPort);
        channel = new TcpipClientChannel(TcpipClientChannel.Type.Direct, session, remote);
    } else {
        channel = new TcpipClientChannel(TcpipClientChannel.Type.Forwarded, session, null);
    }
    session.setAttribute(TcpipClientChannel.class, channel);
    this.session.registerChannel(channel);
    channel.open().addListener(new SshFutureListener<OpenFuture>() {
        @Override
        public void operationComplete(OpenFuture future) {
            Throwable t = future.getException();
            if (t != null) {
                DefaultTcpipForwarder.this.session.unregisterChannel(channel);
                channel.close(false);
            }
        }
    });
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:24,代码来源:DefaultTcpipForwarder.java


示例2: 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();
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:17,代码来源:NetconfSessionMinaImpl.java


示例3: 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();
    }
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:8,代码来源:CloseListener.java


示例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 --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);
        }
    }
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:54,代码来源:SshAgentConnectionFactory.java


示例5: 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);
        }
    }
}
 
开发者ID:ibuildthecloud,项目名称:dstack,代码行数:54,代码来源:SshAgentConnectionFactory.java



注:本文中的org.apache.sshd.client.future.OpenFuture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GerritApi类代码示例发布时间:2022-05-22
下一篇:
Java JwtAuthenticator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap