org.apache.jute.Record Java Examples
The following examples show how to use
org.apache.jute.Record.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientCnxnAspect.java From pulsar with Apache License 2.0 | 6 votes |
private Record getEventType(Object packet) { try { if (packet.getClass().getName().equals("org.apache.zookeeper.ClientCnxn$Packet")) { Field field = Class.forName("org.apache.zookeeper.ClientCnxn$Packet").getDeclaredField("request"); field.setAccessible(true); Record response = (Record) field.get(packet); return response; } } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to get event-type from zk-response", e); } } return null; }
Example #2
Source File: IndexBuilder.java From exhibitor with Apache License 2.0 | 6 votes |
public void add(InputStream stream) throws Exception { ZooKeeperLogParser logParser = new ZooKeeperLogParser(stream); if ( logParser.isValid() ) { logParser.parse ( new LogEntryReceiver() { @Override public void receiveEntry(TxnHeader header, Record record) throws Exception { indexRecord(header, record, count, from, to); } } ); } }
Example #3
Source File: ClientCnxnAspect.java From pulsar with Apache License 2.0 | 5 votes |
private void processEvent(ProceedingJoinPoint joinPoint) { long startTimeNano = getStartTime(joinPoint.getArgs()[0]); if (startTimeNano == -1) { // couldn't find start time return; } Record request = getEventType(joinPoint.getArgs()[0]); if (request != null) { long timeElapsed = (MathUtils.nowInNano() - startTimeNano); notifyListeners(checkType(request), TimeUnit.NANOSECONDS.toMicros(timeElapsed)); } }
Example #4
Source File: ClientCnxnAspect.java From pulsar with Apache License 2.0 | 5 votes |
private EventType checkType(Record response) { if (response == null) { return EventType.other; } else if (response instanceof ConnectRequest) { return EventType.write; } else if (response instanceof CreateRequest) { return EventType.write; } else if (response instanceof DeleteRequest) { return EventType.write; } else if (response instanceof SetDataRequest) { return EventType.write; } else if (response instanceof SetACLRequest) { return EventType.write; } else if (response instanceof SetMaxChildrenRequest) { return EventType.write; } else if (response instanceof SetSASLRequest) { return EventType.write; } else if (response instanceof SetWatches) { return EventType.write; } else if (response instanceof SyncRequest) { return EventType.write; } else if (response instanceof ExistsRequest) { return EventType.read; } else if (response instanceof GetDataRequest) { return EventType.read; } else if (response instanceof GetMaxChildrenRequest) { return EventType.read; } else if (response instanceof GetACLRequest) { return EventType.read; } else if (response instanceof GetChildrenRequest) { return EventType.read; } else if (response instanceof GetChildren2Request) { return EventType.read; } else if (response instanceof GetSASLRequest) { return EventType.read; } else { return EventType.other; } }
Example #5
Source File: ClientCnxnInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { String peer = (String) objInst.getSkyWalkingDynamicField(); RequestHeader header = (RequestHeader) allArguments[0]; String operationName = ZooOpt.getOperationName(header.getType()); AbstractSpan span = ContextManager.createExitSpan("Zookeeper/" + operationName, peer); span.setComponent(ComponentsDefine.ZOOKEEPER); Tags.DB_TYPE.set(span, "Zookeeper"); ZooOpt.setTags(span, (Record) allArguments[2]); SpanLayer.asCache(span); }
Example #6
Source File: ZKLogFormatter.java From helix with Apache License 2.0 | 5 votes |
private static String formatTransaction(TxnHeader header, Record txn) { StringBuilder sb = new StringBuilder(); sb.append("time").append(fieldDelim).append(header.getTime()); sb.append(fieldSep).append("session").append(fieldDelim).append("0x") .append(Long.toHexString(header.getClientId())); sb.append(fieldSep).append("cxid").append(fieldDelim).append("0x") .append(Long.toHexString(header.getCxid())); sb.append(fieldSep).append("zxid").append(fieldDelim).append("0x") .append(Long.toHexString(header.getZxid())); sb.append(fieldSep).append("type").append(fieldDelim).append(op2String(header.getType())); if (txn != null) { try { byte[] data = null; for (PropertyDescriptor pd : Introspector.getBeanInfo(txn.getClass()) .getPropertyDescriptors()) { if (pd.getName().equalsIgnoreCase("data")) { data = (byte[]) pd.getReadMethod().invoke(txn); continue; } if (pd.getReadMethod() != null && !"class".equals(pd.getName())) { sb.append(fieldSep).append(pd.getDisplayName()).append(fieldDelim) .append(pd.getReadMethod().invoke(txn).toString().replaceAll("[\\s]+", "")); } } if (data != null) { sb.append(fieldSep).append("data").append(fieldDelim) .append(new String(data).replaceAll("[\\s]+", "")); } } catch (Exception e) { LOG.error("Error while retrieving bean property values for " + txn.getClass(), e); } } return sb.toString(); }
Example #7
Source File: ZooLog.java From zooadmin with MIT License | 4 votes |
/** * 读取多行日志 * @param total 读取的行数 * @return * @throws IOException */ public String getLastLog(int total) throws IOException { StringBuilder sb=new StringBuilder(1024); FileInputStream fis = new FileInputStream(this.logFile); BinaryInputArchive logStream = BinaryInputArchive.getArchive(fis); FileHeader fhdr = new FileHeader(); fhdr.deserialize(logStream, "fileheader"); if (fhdr.getMagic() != FileTxnLog.TXNLOG_MAGIC) { return "Invalid magic number for " + logFile; } sb.append("ZooKeeper Transactional Log File with dbid " + fhdr.getDbid() + " txnlog format version " + fhdr.getVersion()+"\r\n"); int count=0; while (count<total) { long crcValue; byte[] bytes; try { crcValue = logStream.readLong("crcvalue"); bytes = logStream.readBuffer("txnEntry"); } catch (EOFException e) { sb.append("EOF reached after " + count + " txns.\r\n"); break; } if (bytes.length == 0) { // Since we preallocate, we define EOF to be an // empty transaction sb.append("EOF reached after " + count + " txns.\r\n"); break; } Checksum crc = new Adler32(); crc.update(bytes, 0, bytes.length); if (crcValue != crc.getValue()) { throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue()); } TxnHeader hdr = new TxnHeader(); Record txn = SerializeUtils.deserializeTxn(bytes, hdr); sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date(hdr.getTime())) + " session 0x" + Long.toHexString(hdr.getClientId()) + " cxid 0x" + Long.toHexString(hdr.getCxid()) + " zxid 0x" + Long.toHexString(hdr.getZxid()) + " " + ZooLog.op2String(hdr.getType()) + " " + txn+"\r\n"); if (logStream.readByte("EOR") != 'B') { sb.append("Last transaction was partial."); } count++; } return sb.toString(); }
Example #8
Source File: ZooLog.java From zooadmin with MIT License | 4 votes |
/** * 读取多行日志 * @param total 读取的行数 * @return * @throws IOException */ public String getLastLog(int total) throws IOException { StringBuilder sb=new StringBuilder(1024); FileInputStream fis = new FileInputStream(this.logFile); BinaryInputArchive logStream = BinaryInputArchive.getArchive(fis); FileHeader fhdr = new FileHeader(); fhdr.deserialize(logStream, "fileheader"); if (fhdr.getMagic() != FileTxnLog.TXNLOG_MAGIC) { return "Invalid magic number for " + logFile; } sb.append("ZooKeeper Transactional Log File with dbid " + fhdr.getDbid() + " txnlog format version " + fhdr.getVersion()+"\r\n"); int count=0; while (count<total) { long crcValue; byte[] bytes; try { crcValue = logStream.readLong("crcvalue"); bytes = logStream.readBuffer("txnEntry"); } catch (EOFException e) { sb.append("EOF reached after " + count + " txns.\r\n"); break; } if (bytes.length == 0) { // Since we preallocate, we define EOF to be an // empty transaction sb.append("EOF reached after " + count + " txns.\r\n"); break; } Checksum crc = new Adler32(); crc.update(bytes, 0, bytes.length); if (crcValue != crc.getValue()) { throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue()); } TxnHeader hdr = new TxnHeader(); Record txn = SerializeUtils.deserializeTxn(bytes, hdr); sb.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date(hdr.getTime())) + " session 0x" + Long.toHexString(hdr.getClientId()) + " cxid 0x" + Long.toHexString(hdr.getCxid()) + " zxid 0x" + Long.toHexString(hdr.getZxid()) + " " + ZooLog.op2String(hdr.getType()) + " " + txn+"\r\n"); if (logStream.readByte("EOR") != 'B') { sb.append("Last transaction was partial."); } count++; } return sb.toString(); }
Example #9
Source File: TestConfigSetsAPIZkFailure.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ProcessTxnResult processTxn(TxnHeader hdr, Record txn) { return zkdb.processTxn(hdr, txn); }
Example #10
Source File: ZooKeeperLogParser.java From exhibitor with Apache License 2.0 | 4 votes |
public void parse(LogEntryReceiver receiver) throws Exception { if ( !validHeader ) { throw new Exception("Invalid magic number for"); } while ( true ) { long crcValue; byte[] bytes; try { crcValue = logStream.readLong("crcvalue"); bytes = logStream.readBuffer("txnEntry"); } catch ( EOFException e ) { break; } if ( bytes.length == 0 ) { // Since we preallocate, we define EOF to be an // empty transaction break; } Checksum crc = new Adler32(); crc.update(bytes, 0, bytes.length); if ( crcValue != crc.getValue() ) { throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue()); } InputArchive iab = BinaryInputArchive.getArchive(new ByteArrayInputStream(bytes)); TxnHeader hdr = new TxnHeader(); Record record = useOldDeserializeMethod ? (Record)deserializeTxnMethod.invoke(null, iab, hdr) : (Record)deserializeTxnMethod.invoke(null, bytes, hdr); if ( logStream.readByte("EOR") != 'B' ) { break; // partial transaction } receiver.receiveEntry(hdr, record); } }
Example #11
Source File: ZKLogFormatter.java From helix with Apache License 2.0 | 4 votes |
private static void readTransactionLog(String logfilepath) throws FileNotFoundException, IOException, EOFException { FileInputStream fis = new FileInputStream(logfilepath); BinaryInputArchive logStream = BinaryInputArchive.getArchive(fis); FileHeader fhdr = new FileHeader(); fhdr.deserialize(logStream, "fileheader"); if (fhdr.getMagic() != FileTxnLog.TXNLOG_MAGIC) { System.err.println("Invalid magic number for " + logfilepath); System.exit(2); } if (bw != null) { bw.write("ZooKeeper Transactional Log File with dbid " + fhdr.getDbid() + " txnlog format version " + fhdr.getVersion()); bw.newLine(); } else { System.out.println("ZooKeeper Transactional Log File with dbid " + fhdr.getDbid() + " txnlog format version " + fhdr.getVersion()); } int count = 0; while (true) { long crcValue; byte[] bytes; try { crcValue = logStream.readLong("crcvalue"); bytes = logStream.readBuffer("txnEntry"); } catch (EOFException e) { if (bw != null) { bw.write("EOF reached after " + count + " txns."); bw.newLine(); } else { System.out.println("EOF reached after " + count + " txns."); } break; } if (bytes.length == 0) { // Since we preallocate, we define EOF to be an // empty transaction if (bw != null) { bw.write("EOF reached after " + count + " txns."); bw.newLine(); } else { System.out.println("EOF reached after " + count + " txns."); } return; } Checksum crc = new Adler32(); crc.update(bytes, 0, bytes.length); if (crcValue != crc.getValue()) { throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue()); } TxnHeader hdr = new TxnHeader(); Record txn = SerializeUtils.deserializeTxn(bytes, hdr); if (bw != null) { bw.write(formatTransaction(hdr, txn)); bw.newLine(); } else { System.out.println(formatTransaction(hdr, txn)); } if (logStream.readByte("EOR") != 'B') { LOG.error("Last transaction was partial."); throw new EOFException("Last transaction was partial."); } count++; } }
Example #12
Source File: LogEntryReceiver.java From exhibitor with Apache License 2.0 | votes |
public void receiveEntry(TxnHeader header, Record record) throws Exception;