org.apache.zookeeper.data.Stat.getMtime()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(132)

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

Stat.getMtime介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-pinot

@VisibleForTesting
protected boolean isTooSoonToCorrect(String tableNameWithType, String segmentId, long now) {
 Stat stat = new Stat();
 LLCRealtimeSegmentZKMetadata metadata = getRealtimeSegmentZKMetadata(tableNameWithType, segmentId, stat);
 long metadataUpdateTime = stat.getMtime();
 if (now < metadataUpdateTime + TimeUnit.MILLISECONDS.convert(MAX_SEGMENT_COMPLETION_TIME_MINS, TimeUnit.MINUTES)) {
  LOGGER.info("Too soon to correct segment:{} updateTime: {} now:{}", segmentId, metadataUpdateTime, now);
  return true;
 }
 return false;
}

代码示例来源:origin: elasticjob/elastic-job-lite

@Override
public long getRegistryCenterTime(final String key) {
  long result = 0L;
  try {
    persist(key, "");
    result = client.checkExists().forPath(key).getMtime();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
  Preconditions.checkState(0L != result, "Cannot get registry center time.");
  return result;
}

代码示例来源:origin: apache/zookeeper

public void print(Stat stat) {
    out.println("cZxid = 0x" + Long.toHexString(stat.getCzxid()));
    out.println("ctime = " + new Date(stat.getCtime()).toString());
    out.println("mZxid = 0x" + Long.toHexString(stat.getMzxid()));
    out.println("mtime = " + new Date(stat.getMtime()).toString());
    out.println("pZxid = 0x" + Long.toHexString(stat.getPzxid()));
    out.println("cversion = " + stat.getCversion());
    out.println("dataVersion = " + stat.getVersion());
    out.println("aclVersion = " + stat.getAversion());
    out.println("ephemeralOwner = 0x"
        + Long.toHexString(stat.getEphemeralOwner()));
    out.println("dataLength = " + stat.getDataLength());
    out.println("numChildren = " + stat.getNumChildren());
  }
}

代码示例来源:origin: apache/pulsar

ZKStat(org.apache.zookeeper.data.Stat stat) {
  this.version = stat.getVersion();
  this.creationTimestamp = stat.getCtime();
  this.modificationTimestamp = stat.getMtime();
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

private static void printStat(Stat stat) {
  System.err.println("cZxid = 0x" + Long.toHexString(stat.getCzxid()));
  System.err.println("ctime = " + new Date(stat.getCtime()).toString());
  System.err.println("mZxid = 0x" + Long.toHexString(stat.getMzxid()));
  System.err.println("mtime = " + new Date(stat.getMtime()).toString());
  System.err.println("pZxid = 0x" + Long.toHexString(stat.getPzxid()));
  System.err.println("cversion = " + stat.getCversion());
  System.err.println("dataVersion = " + stat.getVersion());
  System.err.println("aclVersion = " + stat.getAversion());
  System.err.println("ephemeralOwner = 0x"
      + Long.toHexString(stat.getEphemeralOwner()));
  System.err.println("dataLength = " + stat.getDataLength());
  System.err.println("numChildren = " + stat.getNumChildren());
}

代码示例来源:origin: apache/incubator-pinot

@Nullable
public static ZNRecord getZnRecord(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String path) {
 Stat stat = new Stat();
 ZNRecord znRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT);
 if (znRecord != null) {
  znRecord.setCreationTime(stat.getCtime());
  znRecord.setModifiedTime(stat.getMtime());
  znRecord.setVersion(stat.getVersion());
 }
 return znRecord;
}

代码示例来源:origin: apache/incubator-pinot

/**
 * Locate the controller leader so that we can send LLC segment completion requests to it.
 * Checks the {@link ControllerLeaderLocator::_cachedControllerLeaderInvalid} flag and fetches the leader from helix if cached value is invalid
 *
 * @return The host:port string of the current controller leader.
 */
public synchronized Pair<String, Integer> getControllerLeader() {
 if (!_cachedControllerLeaderInvalid) {
  return _controllerLeaderHostPort;
 }
 BaseDataAccessor<ZNRecord> dataAccessor = _helixManager.getHelixDataAccessor().getBaseDataAccessor();
 Stat stat = new Stat();
 try {
  ZNRecord znRecord =
    dataAccessor.get("/" + _clusterName + "/CONTROLLER/LEADER", stat, AccessOption.THROW_EXCEPTION_IFNOTEXIST);
  String leader = znRecord.getId();
  int index = leader.lastIndexOf('_');
  String leaderHost = leader.substring(0, index);
  int leaderPort = Integer.valueOf(leader.substring(index + 1));
  _controllerLeaderHostPort = new Pair<>(leaderHost, leaderPort);
  _cachedControllerLeaderInvalid = false;
  LOGGER.info("Setting controller leader to be {}:{} as per znode version {}, mtime {}", leaderHost, leaderPort,
    stat.getVersion(), stat.getMtime());
  return _controllerLeaderHostPort;
 } catch (Exception e) {
  LOGGER.warn("Could not locate controller leader, exception", e);
  _cachedControllerLeaderInvalid = true;
  return null;
 }
}

代码示例来源:origin: spotify/helios

final Stat hostInfoStat = client.stat(hostInfoPath);
if (hostInfoStat != null) {
 final long mtime = hostInfoStat.getMtime();
 final long diff = clock.now().getMillis() - mtime;
 if (diff < zooKeeperRegistrationTtlMillis) {

代码示例来源:origin: spotify/helios

private boolean isRolloutTimedOut(final ZooKeeperClient client,
                 final DeploymentGroup deploymentGroup) {
 final String groupName = deploymentGroup.getName();
 final RolloutOptions defaultOptions = RolloutOptions.getDefault();
 final long groupTimeoutSetting =
   deploymentGroup.getRolloutOptions() == null
   ? defaultOptions.getTimeout()
   : deploymentGroup.getRolloutOptions().withFallback(defaultOptions).getTimeout();
 final long secondsSinceDeploy;
 try {
  final String statusPath = Paths.statusDeploymentGroupTasks(groupName);
  secondsSinceDeploy = MILLISECONDS.toSeconds(
    System.currentTimeMillis() - client.getNode(statusPath).getStat().getMtime());
 } catch (KeeperException e) {
  // statusPath doesn't exist or some other ZK issue. probably this deployment group
  // was removed.
  log.warn("error determining deployment group modification time: name={}", groupName, e);
  return false;
 }
 if (secondsSinceDeploy > groupTimeoutSetting) {
  log.info("rolling-update on deployment-group name={} has timed out after "
       + "{} seconds (rolloutOptions.timeout={})",
    groupName, secondsSinceDeploy, groupTimeoutSetting);
  return true;
 }
 return false;
}

代码示例来源:origin: apache/zookeeper

Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(i + 1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());

代码示例来源:origin: apache/zookeeper

@Test
public void testChildren()
  throws IOException, KeeperException, InterruptedException
{
  String name = "/foo";
  zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  for(int i = 0; i < 10; i++) {
    String childname = name + "/bar" + i;
    zk.create(childname, childname.getBytes(), Ids.OPEN_ACL_UNSAFE,
        CreateMode.EPHEMERAL);
    Stat stat;
    stat = newStat();
    zk.getData(name, false, stat);
    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid() + i + 1, stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(i + 1, stat.getCversion());
    Assert.assertEquals(0, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length(), stat.getDataLength());
    Assert.assertEquals(i + 1, stat.getNumChildren());
  }
}

代码示例来源:origin: apache/zookeeper

Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());

代码示例来源:origin: apache/zookeeper

@Test
public void testBasic()
  throws IOException, KeeperException, InterruptedException
{
  String name = "/foo";
  zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  Stat stat;
  stat = newStat();
  zk.getData(name, false, stat);
  Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
  Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
  Assert.assertEquals(stat.getCtime(), stat.getMtime());
  Assert.assertEquals(0, stat.getCversion());
  Assert.assertEquals(0, stat.getVersion());
  Assert.assertEquals(0, stat.getAversion());
  Assert.assertEquals(0, stat.getEphemeralOwner());
  Assert.assertEquals(name.length(), stat.getDataLength());
  Assert.assertEquals(0, stat.getNumChildren());
}

代码示例来源:origin: apache/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: apache/zookeeper

Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(1, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());

代码示例来源:origin: apache/zookeeper

private void validateCreateStat(Stat stat, String name) {
  Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
  Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
  Assert.assertEquals(stat.getCtime(), stat.getMtime());
  Assert.assertEquals(0, stat.getCversion());
  Assert.assertEquals(0, stat.getVersion());
  Assert.assertEquals(0, stat.getAversion());
  Assert.assertEquals(0, stat.getEphemeralOwner());
  Assert.assertEquals(name.length(), stat.getDataLength());
  Assert.assertEquals(0, stat.getNumChildren());
 }
}

代码示例来源:origin: apache/zookeeper

Assert.assertEquals(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(0, stat.getVersion());
Assert.assertNotSame(stat.getCtime(), stat.getMtime());
Assert.assertEquals(0, stat.getCversion());
Assert.assertEquals(1, stat.getVersion());

代码示例来源:origin: apache/zookeeper

private void validateCreateStat(Stat stat, String name) {
    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(0, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length(), stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

相关文章