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


Java Stat.getMtime方法代码示例

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


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

示例1: checkTask

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * 检查任务
 * <p>
 * 获取任务的信息
 *
 * @param path
 */
public Epoch checkTask(String path) {
    Epoch res = null;
    try {
        String taskName = new File(path).getName();
        Stat stat = new Stat();
        byte[] data = client.getData()
                .storingStatIn(stat)
                .forPath(path);
        TaskData taskData = new TaskData(data);
        res = new Epoch(taskName, stat.getMtime(), stat.getVersion(), taskData);
    } catch (Exception e) {
        logger.warn("Check task: " + path + " failed.", e);
    }
    return res;
}
 
开发者ID:xiongbeer,项目名称:Cobweb,代码行数:23,代码来源:Task.java

示例2: 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

示例3: getOriginalId

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * Get original snapshot and return id.
 *
 * @param path
 * @param cluster
 * @param creator
 * @param stat
 * @param action
 * @param createIfNotExists
 * @return snapshotId
 * @throws ShepherException
 */
public long getOriginalId(String path, String cluster, String creator, Stat stat, Action action, boolean createIfNotExists)
        throws ShepherException {
    if (StringUtils.isBlank(cluster) || StringUtils.isBlank(path) || stat == null) {
        throw ShepherException.createIllegalParameterException();
    }
    boolean exists = nodeDAO.exists(cluster, path);
    if (!exists) {
        throw ShepherException.createNoSuchNodeException();
    }

    long mtime = stat.getMtime();
    if (mtime == 0) {
        mtime = ReviewUtil.DEFAULT_MTIME;
    }

    Snapshot snapshot = this.getByPathAndZk(path, cluster, mtime, stat.getVersion());
    long snapshotId = 0L;
    if (snapshot != null) {
        snapshotId = snapshot.getId();
    } else {
        if (createIfNotExists) {
            String oldData = nodeDAO.getData(cluster, path);
            snapshotId = this.create(cluster, path, oldData, creator, action, mtime, ReviewStatus.ACCEPTED, stat.getVersion(),
                    ReviewUtil.DEFAULT_REVIEWER).getId();
        }
    }
    return snapshotId;
}
 
开发者ID:XiaoMi,项目名称:shepher,代码行数:41,代码来源:SnapshotBiz.java

示例4: isExistZombieServ

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
/**
 * 判断某个任务对应的线程组是否处于僵尸状态。
 * true 表示有线程组处于僵尸状态。需要告警。
 *
 * @param type
 * @param statMap
 * @return
 * @throws Exception
 */
private boolean isExistZombieServ(String type, Map<String, Stat> statMap) throws Exception {
    boolean exist = false;
    for (String key : statMap.keySet()) {
        Stat s = statMap.get(key);
        if (this.scheduleCenter.getSystemTime() - s.getMtime() > this.taskTypeInfo.getHeartBeatRate() * 40) {
            log.error("zombie serverList exists! serv=" + key + " ,type=" + type + "超过40次心跳周期未更新");
            exist = true;
        }
    }
    return exist;

}
 
开发者ID:hungki,项目名称:tbschedule-wed,代码行数:22,代码来源:TBScheduleManagerStatic.java

示例5: clearExpireTaskTypeRunningInfo

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
public void clearExpireTaskTypeRunningInfo(String baseTaskType,String serverUUID, double expireDateInternal) throws Exception {
	for (String name : this.getZooKeeper().getChildren(this.PATH_BaseTaskType + "/" + baseTaskType, false)) {
		String zkPath = this.PATH_BaseTaskType+"/"+ baseTaskType +"/" + name +"/" + this.PATH_TaskItem;
		Stat stat = this.getZooKeeper().exists(zkPath, false);
		if (stat == null || getSystemTime() - stat.getMtime() > (long) (expireDateInternal * 24 * 3600 * 1000)) {
			ZKTools.deleteTree(this.getZooKeeper(),this.PATH_BaseTaskType +"/" + baseTaskType + "/" + name);
		}
	}
}
 
开发者ID:hungki,项目名称:tbschedule-wed,代码行数:10,代码来源:ScheduleDataManager4ZK.java

示例6: clearExpireScheduleServer

import org.apache.zookeeper.data.Stat; //导入方法依赖的package包/类
@Override
public int clearExpireScheduleServer(String taskType,long expireTime) throws Exception {
	 int result =0;
	 String baseTaskType = ScheduleUtil.splitBaseTaskTypeFromTaskType(taskType);
	 String zkPath = this.PATH_BaseTaskType + "/" + baseTaskType 
	        + "/" + taskType + "/" + this.PATH_Server;
	 if(this.getZooKeeper().exists(zkPath,false)== null){
		 String tempPath =this.PATH_BaseTaskType + "/" + baseTaskType   + "/" + taskType;
		 if(this.getZooKeeper().exists(tempPath,false)== null){
			 this.getZooKeeper().create(tempPath, null, this.zkManager.getAcl(), CreateMode.PERSISTENT);
		 }
		 this.getZooKeeper().create(zkPath, null, this.zkManager.getAcl(), CreateMode.PERSISTENT);
	 }
	for (String name : this.getZooKeeper().getChildren(zkPath, false)) {
		try {
			Stat stat = this.getZooKeeper().exists(zkPath + "/" + name,false);
			if (getSystemTime() - stat.getMtime() > expireTime) {
				ZKTools.deleteTree(this.getZooKeeper(), zkPath + "/" + name);
				result++;
			}
		} catch (Exception e) {
			// 当有多台服务器时,存在并发清理的可能,忽略异常
			result++;
		}
	}
	return result;
}
 
开发者ID:hungki,项目名称:tbschedule-wed,代码行数:28,代码来源:ScheduleDataManager4ZK.java


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