com.datastax.driver.core.Cluster.timeSince()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中com.datastax.driver.core.Cluster.timeSince()方法的一些代码示例,展示了Cluster.timeSince()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.timeSince()方法的具体详情如下:
包路径:com.datastax.driver.core.Cluster
类名称:Cluster
方法名:timeSince

Cluster.timeSince介绍

暂无

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. static boolean waitForSchemaAgreement(Connection connection, Cluster.Manager cluster)
  2. throws ConnectionException, BusyConnectionException, ExecutionException,
  3. InterruptedException {
  4. long start = System.nanoTime();
  5. long elapsed = 0;
  6. int maxSchemaAgreementWaitSeconds =
  7. cluster.configuration.getProtocolOptions().getMaxSchemaAgreementWaitSeconds();
  8. while (elapsed < maxSchemaAgreementWaitSeconds * 1000) {
  9. if (checkSchemaAgreement(connection, cluster)) return true;
  10. // let's not flood the node too much
  11. Thread.sleep(200);
  12. elapsed = Cluster.timeSince(start, TimeUnit.MILLISECONDS);
  13. }
  14. return false;
  15. }

代码示例来源:origin: com.yugabyte/cassandra-driver-core

  1. static boolean waitForSchemaAgreement(Connection connection, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
  2. long start = System.nanoTime();
  3. long elapsed = 0;
  4. int maxSchemaAgreementWaitSeconds = cluster.configuration.getProtocolOptions().getMaxSchemaAgreementWaitSeconds();
  5. while (elapsed < maxSchemaAgreementWaitSeconds * 1000) {
  6. if (checkSchemaAgreement(connection, cluster))
  7. return true;
  8. // let's not flood the node too much
  9. Thread.sleep(200);
  10. elapsed = Cluster.timeSince(start, TimeUnit.MILLISECONDS);
  11. }
  12. return false;
  13. }

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

  1. static boolean waitForSchemaAgreement(Connection connection, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
  2. long start = System.nanoTime();
  3. long elapsed = 0;
  4. int maxSchemaAgreementWaitSeconds = cluster.configuration.getProtocolOptions().getMaxSchemaAgreementWaitSeconds();
  5. while (elapsed < maxSchemaAgreementWaitSeconds * 1000) {
  6. if (checkSchemaAgreement(connection, cluster))
  7. return true;
  8. // let's not flood the node too much
  9. Thread.sleep(200);
  10. elapsed = Cluster.timeSince(start, TimeUnit.MILLISECONDS);
  11. }
  12. return false;
  13. }

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

  1. static boolean waitForSchemaAgreement(Connection connection, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
  2. long start = System.nanoTime();
  3. long elapsed = 0;
  4. int maxSchemaAgreementWaitSeconds = cluster.configuration.getProtocolOptions().getMaxSchemaAgreementWaitSeconds();
  5. while (elapsed < maxSchemaAgreementWaitSeconds * 1000) {
  6. if (checkSchemaAgreement(connection, cluster))
  7. return true;
  8. // let's not flood the node too much
  9. Thread.sleep(200);
  10. elapsed = Cluster.timeSince(start, TimeUnit.MILLISECONDS);
  11. }
  12. return false;
  13. }

代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core

  1. remaining = timeout - Cluster.timeSince(start, unit);
  2. } while (remaining > 0);

代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core

  1. static boolean waitForSchemaAgreement(Connection connection, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
  2. long start = System.nanoTime();
  3. long elapsed = 0;
  4. while (elapsed < MAX_SCHEMA_AGREEMENT_WAIT_MS) {
  5. DefaultResultSetFuture peersFuture = new DefaultResultSetFuture(null, new Requests.Query(SELECT_SCHEMA_PEERS));
  6. DefaultResultSetFuture localFuture = new DefaultResultSetFuture(null, new Requests.Query(SELECT_SCHEMA_LOCAL));
  7. connection.write(peersFuture);
  8. connection.write(localFuture);
  9. Set<UUID> versions = new HashSet<UUID>();
  10. Row localRow = localFuture.get().one();
  11. if (localRow != null && !localRow.isNull("schema_version"))
  12. versions.add(localRow.getUUID("schema_version"));
  13. for (Row row : peersFuture.get()) {
  14. InetSocketAddress addr = addressToUseForPeerHost(row, connection.address, cluster);
  15. if (addr == null || row.isNull("schema_version"))
  16. continue;
  17. Host peer = cluster.metadata.getHost(addr);
  18. if (peer != null && peer.isUp())
  19. versions.add(row.getUUID("schema_version"));
  20. }
  21. logger.debug("Checking for schema agreement: versions are {}", versions);
  22. if (versions.size() <= 1)
  23. return true;
  24. // let's not flood the node too much
  25. Thread.sleep(200);
  26. elapsed = Cluster.timeSince(start, TimeUnit.MILLISECONDS);
  27. }
  28. return false;
  29. }

相关文章