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

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

本文整理了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

@Override
public long getClusterTime() {
 return hzInstance.getCluster().getClusterTime();
}

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

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

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

public static long nextTimestamp(final HazelcastInstance instance) {
  if (instance == null) {
    throw new RuntimeException("No Hazelcast instance!");
  } else if (instance.getCluster() == null) {
    throw new RuntimeException("Hazelcast instance has no cluster!");
  }
  // System time in ms.
  return instance.getCluster().getClusterTime();
}

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

public static long nextTimestamp(final HazelcastInstance instance) {
  if (instance == null) {
    throw new RuntimeException("No Hazelcast instance!");
  } else if (instance.getCluster() == null) {
    throw new RuntimeException("Hazelcast instance has no cluster!");
  }
  // System time in ms.
  return instance.getCluster().getClusterTime();
}

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

public static long nextTimestamp(HazelcastInstance instance) {
  if (instance == null) {
    throw new RuntimeException("No Hazelcast instance!");
  } else if (instance.getCluster() == null) {
    throw new RuntimeException("Hazelcast instance has no cluster!");
  }
  // System time in ms.
  return instance.getCluster().getClusterTime();
}

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

public static long nextTimestamp(final HazelcastInstance instance) {
  if (instance == null) {
    throw new RuntimeException("No Hazelcast instance!");
  } else if (instance.getCluster() == null) {
    throw new RuntimeException("Hazelcast instance has no cluster!");
  }
  // System time in ms.
  return instance.getCluster().getClusterTime();
}

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

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

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

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

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

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

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

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

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

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

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

@Override
public void rollbackTransaction(long txId) throws BagriException {
  logger.trace("rollbackTransaction.enter; got txId: {}", txId); 
  // TODO: do this via EntryProcessor?
  Transaction xTx = txCache.get(txId);
  if (xTx != null) {
    triggerManager.applyTrigger(xTx, Order.before, Scope.rollback); 
    xTx.finish(false, cluster.getClusterTime());
    txCache.set(txId, xTx);
  } else {
    throw new BagriException("No transaction found for TXID: " + txId, ecTransNotFound);
  }
  thTx.set(TX_NO);
  cntRolled.incrementAndGet();
  triggerManager.applyTrigger(xTx, Order.after, Scope.rollback); 
  publishCounters(false, xTx.getDocsCreated(), xTx.getDocsUpdated(), xTx.getDocsDeleted());
  cleanAffectedDocuments(xTx);
  logger.trace("rollbackTransaction.exit; tx: {}", xTx); 
}

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

@Override
public void commitTransaction(long txId) throws BagriException {
  logger.trace("commitTransaction.enter; got txId: {}", txId); 
  // TODO: do this via EntryProcessor?
  Transaction xTx = txCache.get(txId);
  if (xTx != null) {
    triggerManager.applyTrigger(xTx, Order.before, Scope.commit); 
    xTx.finish(true, cluster.getClusterTime());
    //txCache.delete(txId);
    txCache.set(txId, xTx);
  } else {
    throw new BagriException("no transaction found for TXID: " + txId, ecTransNotFound);
  }
  thTx.set(TX_NO);
  cntCommited.incrementAndGet();
  triggerManager.applyTrigger(xTx, Order.after, Scope.commit); 
  publishCounters(true, xTx.getDocsCreated(), xTx.getDocsUpdated(), xTx.getDocsDeleted());
  cleanAffectedDocuments(xTx);
  logger.trace("commitTransaction.exit; tx: {}", xTx); 
}

相关文章