本文整理匯總了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}