本文整理汇总了Java中org.apache.zookeeper.server.ZooTrace类的典型用法代码示例。如果您正苦于以下问题:Java ZooTrace类的具体用法?Java ZooTrace怎么用?Java ZooTrace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZooTrace类属于org.apache.zookeeper.server包,在下文中一共展示了ZooTrace类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeSnapshot
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
/**
* deseriluize from an inputarchive
* @param oldTree the tree to be created
* @param ia the input archive to be read from
* @param sessions the sessions to be created
* @throws IOException
*/
private void deserializeSnapshot(DataTreeV1 oldTree, InputArchive ia,
Map<Long, Integer> sessions) throws IOException {
int count = ia.readInt("count");
while (count > 0) {
long id = ia.readLong("id");
int to = ia.readInt("timeout");
sessions.put(id, to);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"loadData --- session in archive: " + id
+ " with timeout: " + to);
}
count--;
}
oldTree.deserialize(ia, "tree");
}
示例2: validateSession
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
/**
* validate a session for a client
*
* @param clientId
* the client to be revalidated
* @param timeout
* the timeout for which the session is valid
* @return
* @throws IOException
*/
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
throws IOException {
LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeLong(clientId);
dos.writeInt(timeout);
dos.close();
QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
.toByteArray(), null);
pendingRevalidations.put(clientId, cnxn);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"To validate session 0x"
+ Long.toHexString(clientId));
}
writePacket(qp, true);
}
示例3: revalidate
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
protected void revalidate(QuorumPacket qp) throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(qp
.getData());
DataInputStream dis = new DataInputStream(bis);
long sessionId = dis.readLong();
boolean valid = dis.readBoolean();
ServerCnxn cnxn = pendingRevalidations
.remove(sessionId);
if (cnxn == null) {
LOG.warn("Missing session 0x"
+ Long.toHexString(sessionId)
+ " for validation");
} else {
zk.finishSessionInit(cnxn, valid);
}
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(sessionId)
+ " is valid: " + valid);
}
}
示例4: deserializeSnapshot
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
public static void deserializeSnapshot(DataTree dt,InputArchive ia,
Map<Long, Integer> sessions) throws IOException {
int count = ia.readInt("count");
while (count > 0) {
long id = ia.readLong("id");
int to = ia.readInt("timeout");
sessions.put(id, to);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"loadData --- session in archive: " + id
+ " with timeout: " + to);
}
count--;
}
dt.deserialize(ia, "tree");
}
示例5: getMask
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
private static long getMask(String mask) {
long retv = 0;
if (mask.equalsIgnoreCase("CLIENT_REQUEST_TRACE_MASK")) {
retv = ZooTrace.CLIENT_REQUEST_TRACE_MASK;
} else if (mask.equalsIgnoreCase("CLIENT_DATA_PACKET_TRACE_MASK")) {
retv = ZooTrace.CLIENT_DATA_PACKET_TRACE_MASK;
} else if (mask.equalsIgnoreCase("CLIENT_PING_TRACE_MASK")) {
retv = ZooTrace.CLIENT_PING_TRACE_MASK;
} else if (mask.equalsIgnoreCase("SERVER_PACKET_TRACE_MASK")) {
retv = ZooTrace.SERVER_PACKET_TRACE_MASK;
} else if (mask.equalsIgnoreCase("SESSION_TRACE_MASK")) {
retv = ZooTrace.SESSION_TRACE_MASK;
} else if (mask.equalsIgnoreCase("EVENT_DELIVERY_TRACE_MASK")) {
retv = ZooTrace.EVENT_DELIVERY_TRACE_MASK;
} else if (mask.equalsIgnoreCase("SERVER_PING_TRACE_MASK")) {
retv = ZooTrace.SERVER_PING_TRACE_MASK;
} else if (mask.equalsIgnoreCase("WARNING_TRACE_MASK")) {
retv = ZooTrace.WARNING_TRACE_MASK;
}
return retv;
}
示例6: revalidate
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
protected void revalidate(QuorumPacket qp) throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(qp
.getData());
DataInputStream dis = new DataInputStream(bis);
long sessionId = dis.readLong();
boolean valid = dis.readBoolean();
ServerCnxn cnxn = pendingRevalidations.remove(sessionId);
if (cnxn == null) {
LOG.warn("Missing session 0x"
+ Long.toHexString(sessionId)
+ " for validation");
} else {
zk.finishSessionInit(cnxn, valid);
}
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(sessionId)
+ " is valid: " + valid);
}
}
示例7: run
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
@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;
}
示例8: deserializeSnapshot
import org.apache.zookeeper.server.ZooTrace; //导入依赖的package包/类
public static void deserializeSnapshot(DataTree dt,InputArchive ia,
Map<Long, Integer> sessions) throws IOException {
// 读取session个数
int count = ia.readInt("count");
while (count > 0) {
// session id
long id = ia.readLong("id");
// session超时时间
int to = ia.readInt("timeout");
// 解析session集合
sessions.put(id, to);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"loadData --- session in archive: " + id
+ " with timeout: " + to);
}
count--;
}
// 反序列化tree
dt.deserialize(ia, "tree");
}