use of com.chinaunicom.etcd.v2.model.ResoponseAtom in project mesosFramework by zhizuqiu.
the class EtcdService method getNodes.
/**
* 从请求队列中获取请求
*
* @param logTime 任务标识
* @param queuePath 队列路径
* @return 返回请求节点,如果不存在第一个请求,返回null
*/
public List<Node> getNodes(Long logTime, String queuePath) {
try {
ResoponseAtom result = etcd.getInOdrderKeys(queuePath);
logger.debug("[" + logTime + "]" + "getNodes");
List<Node> nodes = result.getNode().getNodes();
if (nodes != null && nodes.size() > 0) {
logger.info("[" + logTime + "]" + "getNodes size:" + nodes.size());
return nodes;
}
} catch (ClientException e) {
logger.error("[" + logTime + "]" + "getNodes->ClientException->" + e.getDetail().getMessage());
return null;
} catch (ServerException e) {
logger.error("[" + logTime + "]" + "getNodes->ServerException->" + e.getDetail().getMessage());
return null;
} catch (Exception e) {
logger.error("[" + logTime + "]" + "getNodes->Exception->" + e.getMessage());
return null;
}
return new ArrayList<>();
}
use of com.chinaunicom.etcd.v2.model.ResoponseAtom in project mesosFramework by zhizuqiu.
the class EtcdService method getFirstNode.
/**
* 从请求队列中获取第一个请求
*
* @param logTime 任务标识
* @param queuePath 队列路径
* @return 返回请求节点,如果不存在第一个请求,返回null
*/
public Node getFirstNode(Long logTime, String queuePath) {
Node requestNode = null;
try {
ResoponseAtom result = etcd.getInOdrderKeys(queuePath);
logger.debug("[" + logTime + "]" + "从请求队列中获取请求成功");
List<Node> nodes = result.getNode().getNodes();
if (nodes != null && nodes.size() > 0) {
requestNode = nodes.get(0);
logger.info("[" + logTime + "]" + "当前队列中请求数:" + nodes.size());
}
} catch (ClientException e) {
logger.error("[" + logTime + "]" + "从请求队列中获取请求失败->请求无效->" + e.getDetail().getMessage());
} catch (ServerException e) {
logger.error("[" + logTime + "]" + "从请求队列中获取请求失败->服务器异常->" + e.getMessage());
} catch (Exception e) {
logger.error("[" + logTime + "]" + "从请求队列中获取请求失败->其他异常->" + e.getMessage());
}
return requestNode;
}
Aggregations