com.hazelcast.core.Cluster.getClusterTime()方法的使用及代码示例

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

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

Cluster.getClusterTime介绍

[英]Returns the cluster-wide time in milliseconds.

Cluster tries to keep a cluster-wide time which might be different than the member's own system time. Cluster-wide time is -almost- the same on all members of the cluster.
[中]返回群集范围内的时间(毫秒)。
群集尝试保留群集范围内的时间,该时间可能不同于成员自己的系统时间。集群范围内的时间在集群的所有成员上几乎相同。

代码示例

代码示例来源:origin: SonarSource/sonarqube

  1. @Override
  2. public long getClusterTime() {
  3. return hzInstance.getCluster().getClusterTime();
  4. }

代码示例来源:origin: lumongo/lumongo

  1. public long getClusterTime() {
  2. return hazelcastInstance.getCluster().getClusterTime();
  3. }

代码示例来源:origin: com.hazelcast/hazelcast-hibernate5

  1. public static long nextTimestamp(final HazelcastInstance instance) {
  2. if (instance == null) {
  3. throw new RuntimeException("No Hazelcast instance!");
  4. } else if (instance.getCluster() == null) {
  5. throw new RuntimeException("Hazelcast instance has no cluster!");
  6. }
  7. // System time in ms.
  8. return instance.getCluster().getClusterTime();
  9. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. public static long nextTimestamp(final HazelcastInstance instance) {
  2. if (instance == null) {
  3. throw new RuntimeException("No Hazelcast instance!");
  4. } else if (instance.getCluster() == null) {
  5. throw new RuntimeException("Hazelcast instance has no cluster!");
  6. }
  7. // System time in ms.
  8. return instance.getCluster().getClusterTime();
  9. }

代码示例来源:origin: com.hazelcast/hazelcast-hibernate4

  1. public static long nextTimestamp(HazelcastInstance instance) {
  2. if (instance == null) {
  3. throw new RuntimeException("No Hazelcast instance!");
  4. } else if (instance.getCluster() == null) {
  5. throw new RuntimeException("Hazelcast instance has no cluster!");
  6. }
  7. // System time in ms.
  8. return instance.getCluster().getClusterTime();
  9. }

代码示例来源:origin: com.hazelcast/hazelcast-hibernate52

  1. public static long nextTimestamp(final HazelcastInstance instance) {
  2. if (instance == null) {
  3. throw new RuntimeException("No Hazelcast instance!");
  4. } else if (instance.getCluster() == null) {
  5. throw new RuntimeException("Hazelcast instance has no cluster!");
  6. }
  7. // System time in ms.
  8. return instance.getCluster().getClusterTime();
  9. }

代码示例来源:origin: com.hazelcast/hazelcast-all

  1. @ManagedAnnotation("clusterTime")
  2. @ManagedDescription("Cluster-wide Time")
  3. public long getClusterTime() {
  4. return cluster.getClusterTime();
  5. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. @ManagedAnnotation("clusterTime")
  2. @ManagedDescription("Cluster-wide Time")
  3. public long getClusterTime() {
  4. return cluster.getClusterTime();
  5. }

代码示例来源:origin: dsukhoroslov/bagri

  1. private void addClient(final ClientContainer cc, final String clientId, Properties props) {
  2. HazelcastInstance hzClient = cc.hzInstance;
  3. if (cc.addClient(clientId)) {
  4. ReplicatedMap<String, Properties> clientProps = hzClient.getReplicatedMap(CN_XDM_CLIENT);
  5. HazelcastClientProxy proxy = (HazelcastClientProxy) hzClient;
  6. props.setProperty(pn_client_memberId, proxy.client.getClientClusterService().getLocalClient().getUuid());
  7. props.setProperty(pn_client_connectedAt, new java.util.Date(proxy.getCluster().getClusterTime()).toString());
  8. clientProps.put(clientId, props);
  9. logger.debug("addClient; got new connection for clientId: {}", clientId);
  10. } else {
  11. logger.trace("addClient; got existing connection for clientId: {}", clientId);
  12. }
  13. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. public ClusterMetadata(String name, Cluster cluster) {
  2. this.name = name;
  3. this.version = BuildInfoProvider.getBuildInfo().getJetBuildInfo().getVersion();
  4. this.state = cluster.getClusterState();
  5. this.clusterTime = cluster.getClusterTime();
  6. }

代码示例来源:origin: dsukhoroslov/bagri

  1. @Override
  2. public long beginTransaction(TransactionIsolation txIsolation) throws BagriException {
  3. logger.trace("beginTransaction.enter; txIsolation: {}", txIsolation);
  4. long txId = thTx.get();
  5. if (txId > TX_NO && txCache.containsKey(txId)) {
  6. throw new BagriException("nested transactions are not supported; current txId: " + txId, ecTransNoNested);
  7. }
  8. txId = txGen.next();
  9. // TODO: do this via EntryProcessor?
  10. Transaction xTx = new Transaction(txId, cluster.getClusterTime(), 0, repo.getUserName(), txIsolation, TransactionState.started);
  11. triggerManager.applyTrigger(xTx, Order.before, Scope.begin);
  12. txCache.set(txId, xTx);
  13. thTx.set(txId);
  14. cntStarted.incrementAndGet();
  15. triggerManager.applyTrigger(xTx, Order.after, Scope.begin);
  16. logger.trace("beginTransaction.exit; started tx: {}; returning: {}", xTx, txId);
  17. return txId;
  18. }

代码示例来源:origin: dsukhoroslov/bagri

  1. @Override
  2. public void rollbackTransaction(long txId) throws BagriException {
  3. logger.trace("rollbackTransaction.enter; got txId: {}", txId);
  4. // TODO: do this via EntryProcessor?
  5. Transaction xTx = txCache.get(txId);
  6. if (xTx != null) {
  7. triggerManager.applyTrigger(xTx, Order.before, Scope.rollback);
  8. xTx.finish(false, cluster.getClusterTime());
  9. txCache.set(txId, xTx);
  10. } else {
  11. throw new BagriException("No transaction found for TXID: " + txId, ecTransNotFound);
  12. }
  13. thTx.set(TX_NO);
  14. cntRolled.incrementAndGet();
  15. triggerManager.applyTrigger(xTx, Order.after, Scope.rollback);
  16. publishCounters(false, xTx.getDocsCreated(), xTx.getDocsUpdated(), xTx.getDocsDeleted());
  17. cleanAffectedDocuments(xTx);
  18. logger.trace("rollbackTransaction.exit; tx: {}", xTx);
  19. }

代码示例来源:origin: dsukhoroslov/bagri

  1. @Override
  2. public void commitTransaction(long txId) throws BagriException {
  3. logger.trace("commitTransaction.enter; got txId: {}", txId);
  4. // TODO: do this via EntryProcessor?
  5. Transaction xTx = txCache.get(txId);
  6. if (xTx != null) {
  7. triggerManager.applyTrigger(xTx, Order.before, Scope.commit);
  8. xTx.finish(true, cluster.getClusterTime());
  9. //txCache.delete(txId);
  10. txCache.set(txId, xTx);
  11. } else {
  12. throw new BagriException("no transaction found for TXID: " + txId, ecTransNotFound);
  13. }
  14. thTx.set(TX_NO);
  15. cntCommited.incrementAndGet();
  16. triggerManager.applyTrigger(xTx, Order.after, Scope.commit);
  17. publishCounters(true, xTx.getDocsCreated(), xTx.getDocsUpdated(), xTx.getDocsDeleted());
  18. cleanAffectedDocuments(xTx);
  19. logger.trace("commitTransaction.exit; tx: {}", xTx);
  20. }

相关文章