src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java
branchJEP-349-branch
changeset 57376 8e8a06a3059c
parent 57373 400db63e4937
child 57377 528d85d2fce5
equal deleted inserted replaced
57375:3efa9b992c4d 57376:8e8a06a3059c
    59 
    59 
    60     private LongMap<Type> typeMap;
    60     private LongMap<Type> typeMap;
    61     private LongMap<Parser> parsers;
    61     private LongMap<Parser> parsers;
    62     private boolean chunkFinished;
    62     private boolean chunkFinished;
    63     private InternalEventFilter eventFilter = InternalEventFilter.ACCEPT_ALL;
    63     private InternalEventFilter eventFilter = InternalEventFilter.ACCEPT_ALL;
    64 
    64     private boolean reuse;
    65     public ChunkParser(RecordingInput input) throws IOException {
    65 
       
    66     public ChunkParser(RecordingInput input, boolean reuse) throws IOException {
    66         this(new ChunkHeader(input), null, 500);
    67         this(new ChunkHeader(input), null, 500);
       
    68        this.reuse = reuse;
       
    69     }
       
    70 
       
    71     public void setReuse(boolean resue) {
       
    72         this.reuse = resue;
    67     }
    73     }
    68 
    74 
    69     private ChunkParser(ChunkHeader header, ChunkParser previous, long pollInterval) throws IOException {
    75     private ChunkParser(ChunkHeader header, ChunkParser previous, long pollInterval) throws IOException {
    70         this.input = header.getInput();
    76         this.input = header.getInput();
    71         this.chunkHeader = header;
    77         this.chunkHeader = header;
   106 
   112 
   107     public InternalEventFilter getEventFilter() {
   113     public InternalEventFilter getEventFilter() {
   108         return this.eventFilter;
   114         return this.eventFilter;
   109     }
   115     }
   110 
   116 
   111     private void updateParserFilters() {
   117     private void updateParsers() {
   112         parsers.forEach(p -> {
   118         parsers.forEach(p -> {
   113             if (p instanceof EventParser) {
   119             if (p instanceof EventParser) {
   114                 EventParser ep = (EventParser) p;
   120                 EventParser ep = (EventParser) p;
       
   121                 if (reuse) {
       
   122                     ep.setReuse(true);
       
   123                 }
   115                 long threshold = eventFilter.getThreshold(ep.getEventType().getName());
   124                 long threshold = eventFilter.getThreshold(ep.getEventType().getName());
   116                 if (threshold >= 0) {
   125                 if (threshold >= 0) {
   117                     ep.setEnabled(true);
   126                     ep.setEnabled(true);
   118                     ep.setThreshold(timeConverter.convertDurationNanos(threshold));
   127                     ep.setThreshold(timeConverter.convertDurationNanos(threshold));
   119                 } else {
   128                 } else {
   150                 Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Found new metadata in chunk. Rebuilding types and parsers");
   159                 Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Found new metadata in chunk. Rebuilding types and parsers");
   151                 MetadataDescriptor metadata = chunkHeader.readMetadata(previousMetadata);
   160                 MetadataDescriptor metadata = chunkHeader.readMetadata(previousMetadata);
   152                 ParserFactory factory = new ParserFactory(metadata, constantLookups, timeConverter);
   161                 ParserFactory factory = new ParserFactory(metadata, constantLookups, timeConverter);
   153                 parsers = factory.getParsers();
   162                 parsers = factory.getParsers();
   154                 typeMap = factory.getTypeMap();
   163                 typeMap = factory.getTypeMap();
   155                 updateParserFilters();
   164                 updateParsers();
   156             }
   165             }
   157             if (contantPosition != chunkHeader.getConstantPoolPosition()) {
   166             if (contantPosition != chunkHeader.getConstantPoolPosition()) {
   158                 Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Found new constant pool data. Filling up pools with new values");
   167                 Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Found new constant pool data. Filling up pools with new values");
   159                 constantLookups.forEach(c -> c.getLatestPool().setAllResolved(false));
   168                 constantLookups.forEach(c -> c.getLatestPool().setAllResolved(false));
   160                 fillConstantPools(contantPosition + chunkHeader.getAbsoluteChunkStart());
   169                 fillConstantPools(contantPosition + chunkHeader.getAbsoluteChunkStart());