当前位置: 首页>>代码示例>>Java>>正文


Java Stat.getCtime方法代码示例

本文整理汇总了Java中org.apache.zookeeper.data.Stat.getCtime方法的典型用法代码示例。如果您正苦于以下问题:Java Stat.getCtime方法的具体用法?Java Stat.getCtime怎么用?Java Stat.getCtime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.data.Stat的用法示例。


在下文中一共展示了Stat.getCtime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ScheduleDataManager4ZK

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public ScheduleDataManager4ZK(ZKManager aZkManager) throws Exception {
   	this.zkManager = aZkManager;
   	gson = new GsonBuilder().registerTypeAdapter(Timestamp.class,new TimestampTypeAdapter()).setDateFormat("yyyy-MM-dd HH:mm:ss").create();

    this.PATH_BaseTaskType = this.zkManager.getRootPath() +"/baseTaskType";
    
    if (this.getZooKeeper().exists(this.PATH_BaseTaskType, false) == null) {
        ZKTools.createPath(getZooKeeper(),this.PATH_BaseTaskType, CreateMode.PERSISTENT, this.zkManager.getAcl());
    }
    loclaBaseTime = System.currentTimeMillis();
       String tempPath = this.zkManager.getZooKeeper().create(this.zkManager.getRootPath() + "/systime",null, this.zkManager.getAcl(), CreateMode.EPHEMERAL_SEQUENTIAL);
       Stat tempStat = this.zkManager.getZooKeeper().exists(tempPath, false);
       zkBaseTime = tempStat.getCtime();
       ZKTools.deleteTree(getZooKeeper(), tempPath);
       if(Math.abs(this.zkBaseTime - this.loclaBaseTime) > 5000){
       	log.error("请注意,Zookeeper服务器时间与本地时间相差 : " + Math.abs(this.zkBaseTime - this.loclaBaseTime) +" ms");
       }	
}
 
开发者ID:hungki,项目名称:tbschedule-wed,代码行数:19,代码来源:ScheduleDataManager4ZK.java

示例2: SchedulerServerForZookeeper

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public SchedulerServerForZookeeper(ZKManager zkManager, String pathServer, String pathTask) {
    this.zkManager = zkManager;
    this.pathTask = pathTask;
    this.pathServer = pathServer;
    try {
        long timeApart = 5000;
        // zookeeper时间与服务端时间差距判断
        String tempPath = this.zkManager.getZooKeeper().create(this.zkManager.getRootPath() + "/systime", null, this.zkManager.getAcl(), CreateMode.EPHEMERAL_SEQUENTIAL);
        Stat tempStat = this.zkManager.getZooKeeper().exists(tempPath, false);
        zkBaseTime = tempStat.getCtime();
        ZKTools.deleteTree(this.zkManager.getZooKeeper(), tempPath);
        loclaBaseTime = System.currentTimeMillis();
        if (Math.abs(this.zkBaseTime - this.loclaBaseTime) > timeApart) {
            LOG.error("请注意,Zookeeper服务器时间与本地时间相差 : " + Math.abs(this.zkBaseTime - this.loclaBaseTime) + " ms");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:liuht777,项目名称:uncode-scheduler,代码行数:20,代码来源:SchedulerServerForZookeeper.java

示例3: getCreateTime

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public long getCreateTime(String path) throws KeeperException, InterruptedException {
    Stat stat = _zk.exists(path, false);
    if (stat != null) {
        return stat.getCtime();
    }
    return -1;
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:8,代码来源:ZkConnection.java

示例4: setZNode

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:41,代码来源:ZNodeResource.java

示例5: reapExpiredLocks

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Will delete all lock znodes of this type (either read or write) which are "expired"
 * according to timeout. Assumption is that the clock skew between zookeeper and this servers
 * is negligible.
 * Referred in zk recipe as "Revocable Shared Locks with Freaking Laser Beams".
 * (http://zookeeper.apache.org/doc/trunk/recipes.html).
 */
public void reapExpiredLocks(long timeout) throws IOException {
  List<String> children;
  try {
    children = ZKUtil.listChildrenNoWatch(zkWatcher, parentLockNode);
  } catch (KeeperException e) {
    LOG.error("Unexpected ZooKeeper error when listing children", e);
    throw new IOException("Unexpected ZooKeeper exception", e);
  }
  if (children == null) return;

  KeeperException deferred = null;
  Stat stat = new Stat();
  long expireDate = System.currentTimeMillis() - timeout; //we are using cTime in zookeeper
  for (String child : children) {
    if (isChildOfSameType(child)) {
      String znode = ZKUtil.joinZNode(parentLockNode, child);
      try {
        ZKUtil.getDataNoWatch(zkWatcher, znode, stat);
        if (stat.getCtime() < expireDate) {
          LOG.info("Reaping lock for znode:" + znode);
          ZKUtil.deleteNodeFailSilent(zkWatcher, znode);
        }
      } catch (KeeperException ex) {
        LOG.warn("Error reaping the znode for write lock :" + znode);
        deferred = ex;
      }
    }
  }
  if (deferred != null) {
    throw new IOException("ZK exception while reaping locks:", deferred);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:ZKInterProcessLockBase.java


注:本文中的org.apache.zookeeper.data.Stat.getCtime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。