src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java
branchJEP-349-branch
changeset 57452 6fabe73e5d9a
parent 57433 83e4343a6984
child 57454 703fb247dc4e
equal deleted inserted replaced
57449:099789ceff7d 57452:6fabe73e5d9a
    62     private boolean chunkFinished;
    62     private boolean chunkFinished;
    63     private InternalEventFilter eventFilter = InternalEventFilter.ACCEPT_ALL;
    63     private InternalEventFilter eventFilter = InternalEventFilter.ACCEPT_ALL;
    64     private boolean reuse;
    64     private boolean reuse;
    65     private boolean ordered;
    65     private boolean ordered;
    66     private boolean resetEventCache;
    66     private boolean resetEventCache;
       
    67     private long firstNanos;
    67 
    68 
    68     public ChunkParser(RecordingInput input, boolean reuse) throws IOException {
    69     public ChunkParser(RecordingInput input, boolean reuse) throws IOException {
    69        this(new ChunkHeader(input), null, 500);
    70        this(new ChunkHeader(input), null, 500);
    70        this.reuse = reuse;
    71        this.reuse = reuse;
    71     }
    72     }
   357         this.ordered = ordered;
   358         this.ordered = ordered;
   358     }
   359     }
   359 
   360 
   360     // Need to call updateEventParsers() for
   361     // Need to call updateEventParsers() for
   361     // change to take effect
   362     // change to take effect
       
   363     public void setFirstNanos(long firstNanos) {
       
   364         long chunkStart = chunkHeader.getStartNanos();
       
   365         // Optimization.
       
   366         if (firstNanos < chunkStart - 1_000_000_000L) {
       
   367             firstNanos = 0;
       
   368         }
       
   369         this.firstNanos = firstNanos;
       
   370     }
       
   371 
       
   372     // Need to call updateEventParsers() for
       
   373     // change to take effect
   362     public void resetEventCache() {
   374     public void resetEventCache() {
   363         this.resetEventCache = true;
   375         this.resetEventCache = true;
   364     }
   376     }
   365 
   377 
   366     public void updateEventParsers() {
   378     public void updateEventParsers() {
   368             if (p instanceof EventParser) {
   380             if (p instanceof EventParser) {
   369                 EventParser ep = (EventParser) p;
   381                 EventParser ep = (EventParser) p;
   370                 String name = ep.getEventType().getName();
   382                 String name = ep.getEventType().getName();
   371                 ep.setOrdered(ordered);
   383                 ep.setOrdered(ordered);
   372                 ep.setReuse(reuse);
   384                 ep.setReuse(reuse);
       
   385                 ep.setFirstNanos(firstNanos);
   373                 if (resetEventCache) {
   386                 if (resetEventCache) {
   374                     ep.resetCache();
   387                     ep.resetCache();
   375                 }
   388                 }
   376                 long threshold = eventFilter.getThreshold(name);
   389                 long threshold = eventFilter.getThreshold(name);
   377                 if (threshold >= 0) {
   390                 if (threshold >= 0) {
   378                     ep.setEnabled(true);
   391                     ep.setEnabled(true);
   379                     ep.setThreshold(timeConverter.convertDurationNanos(threshold));
   392                     ep.setThresholdNanos(threshold);
   380                 } else {
   393                 } else {
   381                     ep.setEnabled(false);
   394                     ep.setEnabled(false);
   382                     ep.setThreshold(Long.MAX_VALUE);
   395                     ep.setThresholdNanos(Long.MAX_VALUE);
   383                 }
   396                 }
   384             }
   397             }
   385         });
   398         });
   386         resetEventCache = false;
   399         resetEventCache = false;
   387     }
   400     }