本文整理汇总了Java中org.apache.zookeeper.inspector.logger.LoggerFactory类的典型用法代码示例。如果您正苦于以下问题:Java LoggerFactory类的具体用法?Java LoggerFactory怎么用?Java LoggerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoggerFactory类属于org.apache.zookeeper.inspector.logger包,在下文中一共展示了LoggerFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: disconnect
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public boolean disconnect() {
try {
if (this.zooKeeper != null) {
this.zooKeeper.close();
this.zooKeeper = null;
connected = false;
removeWatchers(this.watchers.keySet());
return true;
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred while disconnecting from ZooKeeper server",
e);
}
return false;
}
示例2: getData
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public String getData(String nodePath) {
if (connected) {
try {
if (nodePath.length() == 0) {
nodePath = "/";
}
Stat s = zooKeeper.exists(nodePath, false);
if (s != null) {
return this.encryptionManager.decryptData(zooKeeper
.getData(nodePath, false, s));
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred getting data for node: " + nodePath, e);
}
}
return null;
}
示例3: getNodeChild
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public String getNodeChild(String nodePath, int childIndex) {
if (connected) {
try {
Stat s = zooKeeper.exists(nodePath, false);
if (s != null) {
return this.zooKeeper.getChildren(nodePath, false).get(
childIndex);
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred retrieving child " + childIndex
+ " of node: " + nodePath, e);
}
}
return null;
}
示例4: getSessionMeta
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public Map<String, String> getSessionMeta() {
Map<String, String> sessionMeta = new LinkedHashMap<String, String>();
try {
if (zooKeeper != null) {
sessionMeta.put(SESSION_ID, String.valueOf(zooKeeper
.getSessionId()));
sessionMeta.put(SESSION_STATE, String.valueOf(zooKeeper
.getState().toString()));
sessionMeta.put(CONNECT_STRING, this.connectString);
sessionMeta.put(SESSION_TIMEOUT, String
.valueOf(this.sessionTimeout));
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred retrieving session meta data.", e);
}
return sessionMeta;
}
示例5: createNode
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public boolean createNode(String parent, String nodeName) {
if (connected) {
try {
String[] nodeElements = nodeName.split("/");
for (String nodeElement : nodeElements) {
String node = parent + "/" + nodeElement;
Stat s = zooKeeper.exists(node, false);
if (s == null) {
zooKeeper.create(node, this.encryptionManager
.encryptData(null), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
parent = node;
}
}
return true;
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred creating node: " + parent + "/"
+ nodeName, e);
}
}
return false;
}
示例6: deleteNode
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public boolean deleteNode(String nodePath) {
if (connected) {
try {
Stat s = zooKeeper.exists(nodePath, false);
if (s != null) {
List<String> children = zooKeeper.getChildren(nodePath,
false);
for (String child : children) {
String node = nodePath + "/" + child;
deleteNode(node);
}
zooKeeper.delete(nodePath, -1);
}
return true;
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred deleting node: " + nodePath, e);
}
}
return false;
}
示例7: addWatchers
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public void addWatchers(Collection<String> selectedNodes,
NodeListener nodeListener) {
// add watcher for each node and add node to collection of
// watched nodes
if (connected) {
for (String node : selectedNodes) {
if (!watchers.containsKey(node)) {
try {
watchers.put(node, new NodeWatcher(node, nodeListener,
zooKeeper));
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occured adding node watcher for node: "
+ node, e);
}
}
}
}
}
示例8: process
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public void process(WatchedEvent event) {
if (!closed) {
try {
if (event.getType() != EventType.NodeDeleted) {
Stat s = zooKeeper.exists(nodePath, this);
if (s != null) {
zookeeper.getChildren(nodePath, this);
}
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occured re-adding node watcherfor node "
+ nodePath, e);
}
nodeListener.processEvent(event.getPath(), event.getType()
.name(), null);
}
}
示例9: setACL
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
@Override
public Stat setACL(String path, List<ACL> acl, int version)
throws KeeperException, InterruptedException {
int count = 0;
do {
try {
return super.setACL(path, acl, version);
} catch (KeeperException.ConnectionLossException e) {
LoggerFactory.getLogger().warn(
"ZooKeeper connection lost. Trying to reconnect.");
Stat s = exists(path, false);
if (s != null) {
if (getACL(path, s).equals(acl)) {
return s;
}
} else {
return null;
}
}
} while (!closed && (limit == -1 || count++ < limit));
return null;
}
示例10: setData
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
@Override
public Stat setData(String path, byte[] data, int version)
throws KeeperException, InterruptedException {
int count = 0;
do {
try {
return super.setData(path, data, version);
} catch (KeeperException.ConnectionLossException e) {
LoggerFactory.getLogger().warn(
"ZooKeeper connection lost. Trying to reconnect.");
Stat s = exists(path, false);
if (s != null) {
if (getData(path, false, s) == data) {
return s;
}
} else {
return null;
}
}
} while (!closed && (limit == -1 || count++ < limit));
return null;
}
示例11: addWatchers
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public void addWatchers(Collection<String> selectedNodes,
NodeListener nodeListener) {
// add watcher for each node and add node to collection of
// watched nodes
if (connected) {
for (String node : selectedNodes) {
if (!watchers.containsKey(node)) {
try {
watchers.put(node, new NodeWatcher(node, nodeListener,
zooKeeper));
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred adding node watcher for node: "
+ node, e);
}
}
}
}
}
示例12: process
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
public void process(WatchedEvent event) {
if (!closed) {
try {
if (event.getType() != EventType.NodeDeleted) {
Stat s = zooKeeper.exists(nodePath, this);
if (s != null) {
zookeeper.getChildren(nodePath, this);
}
}
} catch (Exception e) {
LoggerFactory.getLogger().error(
"Error occurred re-adding node watcherfor node "
+ nodePath, e);
}
nodeListener.processEvent(event.getPath(), event.getType()
.name(), null);
}
}
示例13: setACL
import org.apache.zookeeper.inspector.logger.LoggerFactory; //导入依赖的package包/类
@Override
public Stat setACL(String path, List<ACL> acl, int aclVersion)
throws KeeperException, InterruptedException {
int count = 0;
do {
try {
return super.setACL(path, acl, aclVersion);
} catch (KeeperException.ConnectionLossException e) {
LoggerFactory.getLogger().warn(
"ZooKeeper connection lost. Trying to reconnect.");
Stat s = exists(path, false);
if (s != null) {
if (getACL(path, s).equals(acl)) {
return s;
}
} else {
return null;
}
}
} while (!closed && (limit == -1 || count++ < limit));
return null;
}