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

Java LatencyAwarePolicy类代码示例

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

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



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

示例1: buildCluster

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
static Cluster buildCluster(Cassandra3Storage cassandra) {
  Cluster.Builder builder = Cluster.builder();
  List<InetSocketAddress> contactPoints = parseContactPoints(cassandra);
  int defaultPort = findConnectPort(contactPoints);
  builder.addContactPointsWithPorts(contactPoints);
  builder.withPort(defaultPort); // This ends up protocolOptions.port
  if (cassandra.username != null && cassandra.password != null) {
    builder.withCredentials(cassandra.username, cassandra.password);
  }
  builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE);
  builder.withLoadBalancingPolicy(new TokenAwarePolicy(new LatencyAwarePolicy.Builder(
      cassandra.localDc != null
          ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc).build()
          : new RoundRobinPolicy()
      // This can select remote, but LatencyAwarePolicy will prefer local
  ).build()));
  builder.withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost(
      HostDistance.LOCAL, cassandra.maxConnections
  ));
  return builder.build();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:22,代码来源:DefaultSessionFactory.java


示例2: buildCluster

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
static Cluster buildCluster(CassandraStorage cassandra) {
  Cluster.Builder builder = Cluster.builder();
  List<InetSocketAddress> contactPoints = parseContactPoints(cassandra);
  int defaultPort = findConnectPort(contactPoints);
  builder.addContactPointsWithPorts(contactPoints);
  builder.withPort(defaultPort); // This ends up protocolOptions.port
  if (cassandra.username != null && cassandra.password != null) {
    builder.withCredentials(cassandra.username, cassandra.password);
  }
  builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE);
  builder.withLoadBalancingPolicy(new TokenAwarePolicy(new LatencyAwarePolicy.Builder(
      cassandra.localDc != null
          ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc).build()
          : new RoundRobinPolicy()
      // This can select remote, but LatencyAwarePolicy will prefer local
  ).build()));
  builder.withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost(
      HostDistance.LOCAL, cassandra.maxConnections
  ));
  return builder.build();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:22,代码来源:SessionFactory.java


示例3: build

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
@Override
public LoadBalancingPolicy build() {
    LatencyAwarePolicy.Builder builder = LatencyAwarePolicy.builder(subPolicy.build());

    if (exclusionThreshold != null) {
        builder.withExclusionThreshold(exclusionThreshold);
    }

    if (minimumMeasurements != null) {
        builder.withMininumMeasurements(minimumMeasurements);
    }

    if (retryPeriod != null) {
        builder.withRetryPeriod(retryPeriod.getQuantity(), retryPeriod.getUnit());
    }

    if (scale != null) {
        builder.withScale(scale.getQuantity(), scale.getUnit());
    }

    if (updateRate != null) {
        builder.withUpdateRate(updateRate.getQuantity(), updateRate.getUnit());
    }

    return builder.build();
}
 
开发者ID:composable-systems,项目名称:dropwizard-cassandra,代码行数:27,代码来源:LatencyAwarePolicyFactory.java


示例4: toRoundRobinPolicy

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
RoundRobinPolicy toRoundRobinPolicy(Cassandra3Storage storage) {
  return (RoundRobinPolicy) ((LatencyAwarePolicy) ((TokenAwarePolicy) buildCluster(storage)
      .getConfiguration()
      .getPolicies()
      .getLoadBalancingPolicy())
      .getChildPolicy()).getChildPolicy();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:8,代码来源:SessionFactoryTest.java


示例5: toDCAwareRoundRobinPolicy

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
DCAwareRoundRobinPolicy toDCAwareRoundRobinPolicy(Cassandra3Storage storage) {
  return (DCAwareRoundRobinPolicy) ((LatencyAwarePolicy) ((TokenAwarePolicy) buildCluster(storage)
      .getConfiguration()
      .getPolicies()
      .getLoadBalancingPolicy())
      .getChildPolicy()).getChildPolicy();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:8,代码来源:SessionFactoryTest.java


示例6: toRoundRobinPolicy

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
RoundRobinPolicy toRoundRobinPolicy(CassandraStorage storage) {
  return (RoundRobinPolicy) ((LatencyAwarePolicy) ((TokenAwarePolicy) buildCluster(storage)
      .getConfiguration()
      .getPolicies()
      .getLoadBalancingPolicy())
      .getChildPolicy()).getChildPolicy();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:8,代码来源:SessionFactoryTest.java


示例7: toDCAwareRoundRobinPolicy

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
DCAwareRoundRobinPolicy toDCAwareRoundRobinPolicy(CassandraStorage storage) {
  return (DCAwareRoundRobinPolicy) ((LatencyAwarePolicy) ((TokenAwarePolicy) buildCluster(storage)
      .getConfiguration()
      .getPolicies()
      .getLoadBalancingPolicy())
      .getChildPolicy()).getChildPolicy();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:8,代码来源:SessionFactoryTest.java


示例8: testLoadBalancingPolicyParsing

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
@Test
public void testLoadBalancingPolicyParsing() throws Exception
{
	String lbPolicyStr = "RoundRobinPolicy()";
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr) instanceof RoundRobinPolicy);
	System.out.println("====================");
	lbPolicyStr = "TokenAwarePolicy(RoundRobinPolicy())";
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr) instanceof TokenAwarePolicy);
	System.out.println("====================");
	lbPolicyStr = "DCAwareRoundRobinPolicy(\"dc1\")";
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr) instanceof DCAwareRoundRobinPolicy);
	System.out.println("====================");
	lbPolicyStr = "TokenAwarePolicy(DCAwareRoundRobinPolicy(\"dc1\"))";
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr) instanceof TokenAwarePolicy);    	
	System.out.println("====================");
	lbPolicyStr = "TokenAwarePolicy";
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr)==null);
	System.out.println("====================");
	lbPolicyStr = "LatencyAwarePolicy(TokenAwarePolicy(RoundRobinPolicy()),(double) 10.5,(long) 1,(long) 10,(long)1,10)";    	
	System.out.println(lbPolicyStr);
	assertTrue(Utils.parseLbPolicy(lbPolicyStr) instanceof LatencyAwarePolicy);
	System.out.println("====================");    	    	
	
}
 
开发者ID:adejanovski,项目名称:cassandra-jdbc-wrapper,代码行数:30,代码来源:UtilsUnitTest.java


示例9: setUp

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    when(subPolicyFactory.build()).thenReturn(subPolicy);
    mockStatic(LatencyAwarePolicy.class);
    when(LatencyAwarePolicy.builder(subPolicy)).thenReturn(policyBuilder);
    when(policyBuilder.build()).thenReturn(resultingPolicy);
}
 
开发者ID:composable-systems,项目名称:dropwizard-cassandra,代码行数:8,代码来源:LatencyAwarePolicyFactoryTest.java


示例10: build

import com.datastax.driver.core.policies.LatencyAwarePolicy; //导入依赖的package包/类
private static Cluster build(List<String> addresses, int port) {
  Cluster.Builder builder = Cluster.builder();
  for (String address : addresses) {
    builder.addContactPoint(address);
  }
  builder
    .withPort(port)
    .withCompression(Compression.LZ4)
    .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
    .withLoadBalancingPolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
  
  Cluster cluster = builder.build();
  
  try {
    // Attempt to init the cluster to make sure it's usable. I'd prefer to remove this and leave it on the
    // client to retry when the connect method throws an exception.
    cluster.init();
    return cluster;
  } catch(NoHostAvailableException e) {
    LOGGER.warn("Unable to connect to Cassandra, will retry contact points next time",
        cluster, e);
    cluster = builder.build();
    cluster.init();
  }
  
  return cluster;
  
}
 
开发者ID:brndnmtthws,项目名称:metrics-cassandra,代码行数:29,代码来源:Cassandra.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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