本文整理了Java中org.apache.zookeeper.server.ZooTrace
类的一些代码示例,展示了ZooTrace
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooTrace
类的具体详情如下:
包路径:org.apache.zookeeper.server.ZooTrace
类名称:ZooTrace
[英]This class encapsulates and centralizes tracing for the ZooKeeper server. Trace messages go to the log with TRACE level.
Log4j must be correctly configured to capture the TRACE messages.
[中]此类封装并集中ZooKeeper服务器的跟踪。跟踪消息以跟踪级别进入日志。
必须正确配置Log4j以捕获跟踪消息。
代码示例来源:origin: apache/zookeeper
public void shutdown() {
LOG.info("Shutting down");
running = false;
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.getTextTraceLevel(),
"Shutdown SessionTrackerImpl!");
}
}
代码示例来源:origin: apache/zookeeper
static public void logQuorumPacket(Logger log, long mask,
char direction, QuorumPacket qp)
{
if (isTraceEnabled(log, mask)) {
logTraceMessage(log, mask, direction +
" " + LearnerHandler.packetToString(qp));
}
}
代码示例来源:origin: apache/zookeeper
/**
* read a packet from the leader
*
* @param pp
* the packet to be instantiated
* @throws IOException
*/
void readPacket(QuorumPacket pp) throws IOException {
synchronized (leaderIs) {
leaderIs.readRecord(pp, "packet");
}
long traceMask = ZooTrace.SERVER_PACKET_TRACE_MASK;
if (pp.getType() == Leader.PING) {
traceMask = ZooTrace.SERVER_PING_TRACE_MASK;
}
if (LOG.isTraceEnabled()) {
ZooTrace.logQuorumPacket(LOG, traceMask, 'i', pp);
}
}
代码示例来源:origin: apache/zookeeper
private void logTraceTouchSession(long sessionId, int timeout, String sessionStatus){
if (!LOG.isTraceEnabled())
return;
String msg = MessageFormat.format(
"SessionTrackerImpl --- Touch {0}session: 0x{1} with timeout {2}",
sessionStatus, Long.toHexString(sessionId), Integer.toString(timeout));
ZooTrace.logTraceMessage(LOG, ZooTrace.CLIENT_PING_TRACE_MASK, msg);
}
代码示例来源:origin: apache/zookeeper
@Override
public void run() {
try {
while (true) {
Request request = submittedRequests.take();
long traceMask = ZooTrace.CLIENT_REQUEST_TRACE_MASK;
if (request.type == OpCode.ping) {
traceMask = ZooTrace.CLIENT_PING_TRACE_MASK;
}
if (LOG.isTraceEnabled()) {
ZooTrace.logRequest(LOG, traceMask, 'P', request, "");
}
if (Request.requestOfDeath == request) {
break;
}
pRequest(request);
}
} catch (RequestProcessorException e) {
if (e.getCause() instanceof XidRolloverException) {
LOG.info(e.getCause().getMessage());
}
handleException(this.getName(), e);
} catch (Exception e) {
handleException(this.getName(), e);
}
LOG.info("PrepRequestProcessor exited loop!");
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
ZooTrace.logQuorumPacket(LOG, traceMask, 'i', qp);
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(id)
代码示例来源:origin: apache/zookeeper
public static void logTraceMessage(Logger log, long mask, String msg) {
if (isTraceEnabled(log, mask)) {
log.trace(msg);
}
}
代码示例来源:origin: apache/zookeeper
@Override
public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
CommandResponse response = initializeResponse();
long traceMask;
if (!kwargs.containsKey("traceMask")) {
response.put("error", "setTraceMask requires long traceMask argument");
return response;
}
try {
traceMask = Long.parseLong(kwargs.get("traceMask"));
} catch (NumberFormatException e) {
response.put("error", "setTraceMask requires long traceMask argument, got "
+ kwargs.get("traceMask"));
return response;
}
ZooTrace.setTextTraceLevel(traceMask);
response.put("tracemask", traceMask);
return response;
}
}
代码示例来源:origin: apache/zookeeper
@Override
public void commandRun() {
long traceMask = ZooTrace.getTextTraceLevel();
pw.print(traceMask);
}
}
代码示例来源:origin: apache/zookeeper
synchronized public void removeSession(long sessionId) {
LOG.debug("Removing session 0x" + Long.toHexString(sessionId));
SessionImpl s = sessionsById.remove(sessionId);
sessionsWithTimeout.remove(sessionId);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"SessionTrackerImpl --- Removing session 0x"
+ Long.toHexString(sessionId));
}
if (s != null) {
sessionExpiryQueue.remove(s);
}
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
@Override
public void run() {
try {
while (true) {
Request request = submittedRequests.take();
long traceMask = ZooTrace.CLIENT_REQUEST_TRACE_MASK;
if (request.type == OpCode.ping) {
traceMask = ZooTrace.CLIENT_PING_TRACE_MASK;
}
if (LOG.isTraceEnabled()) {
ZooTrace.logRequest(LOG, traceMask, 'P', request, "");
}
if (Request.requestOfDeath == request) {
break;
}
pRequest(request);
}
} catch (RequestProcessorException e) {
if (e.getCause() instanceof XidRolloverException) {
LOG.info(e.getCause().getMessage());
}
handleException(this.getName(), e);
} catch (Exception e) {
handleException(this.getName(), e);
}
LOG.info("PrepRequestProcessor exited loop!");
}
代码示例来源:origin: org.apache.hadoop/zookeeper
ZooTrace.logQuorumPacket(LOG, traceMask, 'i', qp);
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(id)
代码示例来源:origin: org.apache.zookeeper/zookeeper
public static void logTraceMessage(Logger log, long mask, String msg) {
if (isTraceEnabled(log, mask)) {
log.trace(msg);
}
}
代码示例来源:origin: apache/zookeeper
ZooTrace.setTextTraceLevel(traceMask);
SetTraceMaskCommand setMask = new SetTraceMaskCommand(pwriter, this, traceMask);
setMask.start();
代码示例来源:origin: org.apache.zookeeper/zookeeper
@Override
public void commandRun() {
long traceMask = ZooTrace.getTextTraceLevel();
pw.print(traceMask);
}
}
代码示例来源:origin: apache/zookeeper
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
int sessionTimeout) throws IOException {
boolean rc = sessionTracker.touchSession(sessionId, sessionTimeout);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(sessionId) +
" is valid: " + rc);
}
finishSessionInit(cnxn, rc);
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
public void shutdown() {
LOG.info("Shutting down");
running = false;
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.getTextTraceLevel(),
"Shutdown SessionTrackerImpl!");
}
}
代码示例来源:origin: apache/zookeeper
ZooTrace.logRequest(LOG, traceMask, 'R', request, "");
代码示例来源:origin: org.apache.zookeeper/zookeeper
static public void logQuorumPacket(Logger log, long mask,
char direction, QuorumPacket qp)
{
if (isTraceEnabled(log, mask)) {
logTraceMessage(log, mask, direction +
" " + LearnerHandler.packetToString(qp));
}
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
/**
* read a packet from the leader
*
* @param pp
* the packet to be instantiated
* @throws IOException
*/
void readPacket(QuorumPacket pp) throws IOException {
synchronized (leaderIs) {
leaderIs.readRecord(pp, "packet");
}
long traceMask = ZooTrace.SERVER_PACKET_TRACE_MASK;
if (pp.getType() == Leader.PING) {
traceMask = ZooTrace.SERVER_PING_TRACE_MASK;
}
if (LOG.isTraceEnabled()) {
ZooTrace.logQuorumPacket(LOG, traceMask, 'i', pp);
}
}
内容来源于网络,如有侵权,请联系作者删除!