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

Java OutboundTcpConnectionPool类代码示例

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

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



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

示例1: createConnection

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Connect to peer and start exchanging message.
 * When connect attempt fails, this retries for maximum of MAX_CONNECT_ATTEMPTS times.
 *
 * @param peer the peer to connect to.
 * @return the created socket.
 *
 * @throws IOException when connection failed.
 */
public Socket createConnection(InetAddress peer) throws IOException
{
    int attempts = 0;
    while (true)
    {
        try
        {
            Socket socket = OutboundTcpConnectionPool.newSocket(peer);
            socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
            socket.setKeepAlive(true);
            return socket;
        }
        catch (IOException e)
        {
            if (++attempts >= MAX_CONNECT_ATTEMPTS)
                throw e;

            long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
            logger.warn("Failed attempt " + attempts + " to connect to " + peer + ". Retrying in " + waitms + " ms. (" + e + ")");
            try
            {
                Thread.sleep(waitms);
            }
            catch (InterruptedException wtf)
            {
                throw new IOException("interrupted", wtf);
            }
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:40,代码来源:DefaultConnectionFactory.java


示例2: testEc2MRSnitch

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
@Test
public void testEc2MRSnitch() throws UnknownHostException
{
    InetAddress me = InetAddress.getByName("127.0.0.2");
    InetAddress com_ip = InetAddress.getByName("127.0.0.3");

    OutboundTcpConnectionPool pool = MessagingService.instance().getConnectionPool(me);
    Assert.assertEquals(me, pool.endPoint());
    pool.reset(com_ip);
    Assert.assertEquals(com_ip, pool.endPoint());

    MessagingService.instance().destroyConnectionPool(me);
    pool = MessagingService.instance().getConnectionPool(me);
    Assert.assertEquals(com_ip, pool.endPoint());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:EC2SnitchTest.java


示例3: connect

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Connect to peer and start exchanging message.
 * When connect attempt fails, this retries for maximum of MAX_CONNECT_ATTEMPTS times.
 *
 * @param peer the peer to connect to.
 * @return the created socket.
 *
 * @throws IOException when connection failed.
 */
private static Socket connect(InetAddress peer) throws IOException
{
    int attempts = 0;
    while (true)
    {
        try
        {
            Socket socket = OutboundTcpConnectionPool.newSocket(peer);
            socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
            return socket;
        }
        catch (IOException e)
        {
            if (++attempts >= MAX_CONNECT_ATTEMPTS)
                throw e;

            long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
            logger.warn("Failed attempt " + attempts + " to connect to " + peer + ". Retrying in " + waitms + " ms. (" + e + ")");
            try
            {
                Thread.sleep(waitms);
            }
            catch (InterruptedException wtf)
            {
                throw new IOException("interrupted", wtf);
            }
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:39,代码来源:ConnectionHandler.java


示例4: createConnection

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Connect to peer and start exchanging message.
 * When connect attempt fails, this retries for maximum of MAX_CONNECT_ATTEMPTS times.
 *
 * @param peer the peer to connect to.
 * @return the created socket.
 *
 * @throws IOException when connection failed.
 */
public Socket createConnection(InetAddress peer) throws IOException
{
    int attempts = 0;
    while (true)
    {
        try
        {
            Socket socket = OutboundTcpConnectionPool.newSocket(peer);
            socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
            socket.setKeepAlive(true);
            return socket;
        }
        catch (IOException e)
        {
            if (++attempts >= MAX_CONNECT_ATTEMPTS)
                throw e;

            long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
            logger.warn("Failed attempt {} to connect to {}. Retrying in {} ms. ({})", attempts, peer, waitms, e);
            try
            {
                Thread.sleep(waitms);
            }
            catch (InterruptedException wtf)
            {
                throw new IOException("interrupted", wtf);
            }
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:40,代码来源:DefaultConnectionFactory.java


示例5: connect

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Connect to peer and start exchanging message.
 * When connect attempt fails, this retries for maximum of MAX_CONNECT_ATTEMPTS times.
 *
 * @param peer the peer to connect to.
 * @return the created socket.
 *
 * @throws IOException when connection failed.
 */
private static Socket connect(InetAddress peer) throws IOException
{
    int attempts = 0;
    while (true)
    {
        try
        {
            Socket socket = OutboundTcpConnectionPool.newSocket(peer);
            socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
            return socket;
        }
        catch (IOException e)
        {
            if (++attempts >= MAX_CONNECT_ATTEMPTS)
                throw e;

            long waitms = DatabaseDescriptor.getRpcTimeout() * (long)Math.pow(2, attempts);
            logger.warn("Failed attempt {} to connect to {}. Retrying in {} ms. ({})", attempts, peer, waitms, e);
            try
            {
                Thread.sleep(waitms);
            }
            catch (InterruptedException wtf)
            {
                throw new IOException("interrupted", wtf);
            }
        }
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:39,代码来源:ConnectionHandler.java


示例6: ConnectionMetrics

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Create metrics for given connection pool.
 *
 * @param ip IP address to use for metrics label
 * @param connectionPool Connection pool
 */
public ConnectionMetrics(InetAddress ip, final OutboundTcpConnectionPool connectionPool)
{
    // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
    address = ip.getHostAddress().replace(':', '.');

    factory = new DefaultNameFactory("Connection", address);

    commandPendingTasks = Metrics.newGauge(factory.createMetricName("CommandPendingTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.cmdCon.getPendingMessages();
        }
    });
    commandCompletedTasks = Metrics.newGauge(factory.createMetricName("CommandCompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getCompletedMesssages();
        }
    });
    commandDroppedTasks = Metrics.newGauge(factory.createMetricName("CommandDroppedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getDroppedMessages();
        }
    });
    responsePendingTasks = Metrics.newGauge(factory.createMetricName("ResponsePendingTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.ackCon.getPendingMessages();
        }
    });
    responseCompletedTasks = Metrics.newGauge(factory.createMetricName("ResponseCompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.ackCon.getCompletedMesssages();
        }
    });
    timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:51,代码来源:ConnectionMetrics.java


示例7: ConnectionMetrics

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Create metrics for given connection pool.
 *
 * @param ip IP address to use for metrics label
 * @param connectionPool Connection pool
 */
public ConnectionMetrics(InetAddress ip, final OutboundTcpConnectionPool connectionPool)
{
    // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
    address = ip.getHostAddress().replaceAll(":", ".");

    factory = new DefaultNameFactory("Connection", address);

    commandPendingTasks = Metrics.newGauge(factory.createMetricName("CommandPendingTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.cmdCon.getPendingMessages();
        }
    });
    commandCompletedTasks = Metrics.newGauge(factory.createMetricName("CommandCompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getCompletedMesssages();
        }
    });
    commandDroppedTasks = Metrics.newGauge(factory.createMetricName("CommandDroppedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getDroppedMessages();
        }
    });
    responsePendingTasks = Metrics.newGauge(factory.createMetricName("ResponsePendingTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.ackCon.getPendingMessages();
        }
    });
    responseCompletedTasks = Metrics.newGauge(factory.createMetricName("ResponseCompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.ackCon.getCompletedMesssages();
        }
    });
    timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:51,代码来源:ConnectionMetrics.java


示例8: ConnectionMetrics

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Create metrics for given connection pool.
 *
 * @param ip IP address to use for metrics label
 * @param connectionPool Connection pool
 */
public ConnectionMetrics(InetAddress ip, final OutboundTcpConnectionPool connectionPool)
{
    // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
    address = ip.getHostAddress().replace(':', '.');

    factory = new DefaultNameFactory("Connection", address);

    largeMessagePendingTasks = Metrics.register(factory.createMetricName("LargeMessagePendingTasks"), new Gauge<Integer>()
    {
        public Integer getValue()
        {
            return connectionPool.largeMessages.getPendingMessages();
        }
    });
    largeMessageCompletedTasks = Metrics.register(factory.createMetricName("LargeMessageCompletedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.largeMessages.getCompletedMesssages();
        }
    });
    largeMessageDroppedTasks = Metrics.register(factory.createMetricName("LargeMessageDroppedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.largeMessages.getDroppedMessages();
        }
    });
    smallMessagePendingTasks = Metrics.register(factory.createMetricName("SmallMessagePendingTasks"), new Gauge<Integer>()
    {
        public Integer getValue()
        {
            return connectionPool.smallMessages.getPendingMessages();
        }
    });
    smallMessageCompletedTasks = Metrics.register(factory.createMetricName("SmallMessageCompletedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.smallMessages.getCompletedMesssages();
        }
    });
    smallMessageDroppedTasks = Metrics.register(factory.createMetricName("SmallMessageDroppedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.smallMessages.getDroppedMessages();
        }
    });
    gossipMessagePendingTasks = Metrics.register(factory.createMetricName("GossipMessagePendingTasks"), new Gauge<Integer>()
    {
        public Integer getValue()
        {
            return connectionPool.gossipMessages.getPendingMessages();
        }
    });
    gossipMessageCompletedTasks = Metrics.register(factory.createMetricName("GossipMessageCompletedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.gossipMessages.getCompletedMesssages();
        }
    });
    gossipMessageDroppedTasks = Metrics.register(factory.createMetricName("GossipMessageDroppedTasks"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return connectionPool.gossipMessages.getDroppedMessages();
        }
    });
    timeouts = Metrics.meter(factory.createMetricName("Timeouts"));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:79,代码来源:ConnectionMetrics.java


示例9: ConnectionMetrics

import org.apache.cassandra.net.OutboundTcpConnectionPool; //导入依赖的package包/类
/**
 * Create metrics for given connection pool.
 *
 * @param ip IP address to use for metrics label
 * @param connectionPool Connection pool
 */
public ConnectionMetrics(InetAddress ip, final OutboundTcpConnectionPool connectionPool)
{
    // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName
    address = ip.getHostAddress().replaceAll(":", ".");

    commandPendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandPendingTasks", address), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.cmdCon.getPendingMessages();
        }
    });
    commandCompletedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandCompletedTasks", address), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getCompletedMesssages();
        }
    });
    commandDroppedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CommandDroppedTasks", address), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.cmdCon.getDroppedMessages();
        }
    });
    responsePendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "ResponsePendingTasks", address), new Gauge<Integer>()
    {
        public Integer value()
        {
            return connectionPool.ackCon.getPendingMessages();
        }
    });
    responseCompletedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "ResponseCompletedTasks", address), new Gauge<Long>()
    {
        public Long value()
        {
            return connectionPool.ackCon.getCompletedMesssages();
        }
    });
    timeouts = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "Timeouts", address), "timeouts", TimeUnit.SECONDS);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:49,代码来源:ConnectionMetrics.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SessionInputBufferImpl类代码示例发布时间:2022-05-22
下一篇:
Java HintedHandOffManagerMBean类代码示例发布时间: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