< prev index next >

src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java

Print this page




 298             updateSettingsButIgnoreRecording(recording);
 299             if (toDisk) {
 300                 newChunk = repository.newChunk(now);
 301                 MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString());
 302             } else {
 303                 MetadataRepository.getInstance().setOutput(null);
 304             }
 305             writeMetaEvents();
 306             if (currentChunk != null) {
 307                 finishChunk(currentChunk, now, null);
 308             }
 309             currentChunk = newChunk;
 310             RequestEngine.doChunkBegin();
 311         }
 312         recording.setState(RecordingState.STOPPED);
 313     }
 314 
 315     private void dumpMemoryToDestination(PlatformRecording recording)  {
 316         WriteableUserPath dest = recording.getDestination();
 317         if (dest != null) {
 318             MetadataRepository.getInstance().setOutput(dest.getRealPathText());
 319             recording.clearDestination();
 320         }
 321     }
 322     private void disableEvents() {
 323         MetadataRepository.getInstance().disableEvents();
 324     }
 325 
 326     void updateSettings() {
 327         updateSettingsButIgnoreRecording(null);
 328     }
 329 
 330     void updateSettingsButIgnoreRecording(PlatformRecording ignoreMe) {
 331         List<PlatformRecording> recordings = getRunningRecordings();
 332         List<Map<String, String>> list = new ArrayList<>(recordings.size());
 333         for (PlatformRecording r : recordings) {
 334             if (r != ignoreMe) {
 335                 list.add(r.getSettings());
 336             }
 337         }
 338         MetadataRepository.getInstance().setSettings(list);


 389     }
 390 
 391     private void finishChunk(RepositoryChunk chunk, Instant time, PlatformRecording ignoreMe) {
 392         chunk.finish(time);
 393         for (PlatformRecording r : getRecordings()) {
 394             if (r != ignoreMe && r.getState() == RecordingState.RUNNING) {
 395                 r.appendChunk(chunk);
 396             }
 397         }
 398     }
 399 
 400     private void writeMetaEvents() {
 401 
 402         if (activeRecordingEvent.isEnabled()) {
 403             for (PlatformRecording r : getRecordings()) {
 404                 if (r.getState() == RecordingState.RUNNING && r.shouldWriteMetadataEvent()) {
 405                     ActiveRecordingEvent event = new ActiveRecordingEvent();
 406                     event.id = r.getId();
 407                     event.name = r.getName();
 408                     WriteableUserPath p = r.getDestination();
 409                     event.destination = p == null ? null : p.getRealPathText();
 410                     Duration d = r.getDuration();
 411                     event.recordingDuration = d == null ? Long.MAX_VALUE : d.toMillis();
 412                     Duration age = r.getMaxAge();
 413                     event.maxAge = age == null ? Long.MAX_VALUE : age.toMillis();
 414                     Long size = r.getMaxSize();
 415                     event.maxSize = size == null ? Long.MAX_VALUE : size;
 416                     Instant start = r.getStartTime();
 417                     event.recordingStart = start == null ? Long.MAX_VALUE : start.toEpochMilli();
 418                     event.commit();
 419                 }
 420             }
 421         }
 422         if (activeSettingEvent.isEnabled()) {
 423             for (EventControl ec : MetadataRepository.getInstance().getEventControls()) {
 424                 ec.writeActiveSettingEvent();
 425             }
 426         }
 427     }
 428 
 429     private void periodicTask() {




 298             updateSettingsButIgnoreRecording(recording);
 299             if (toDisk) {
 300                 newChunk = repository.newChunk(now);
 301                 MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString());
 302             } else {
 303                 MetadataRepository.getInstance().setOutput(null);
 304             }
 305             writeMetaEvents();
 306             if (currentChunk != null) {
 307                 finishChunk(currentChunk, now, null);
 308             }
 309             currentChunk = newChunk;
 310             RequestEngine.doChunkBegin();
 311         }
 312         recording.setState(RecordingState.STOPPED);
 313     }
 314 
 315     private void dumpMemoryToDestination(PlatformRecording recording)  {
 316         WriteableUserPath dest = recording.getDestination();
 317         if (dest != null) {
 318             MetadataRepository.getInstance().setOutput(dest.getText());
 319             recording.clearDestination();
 320         }
 321     }
 322     private void disableEvents() {
 323         MetadataRepository.getInstance().disableEvents();
 324     }
 325 
 326     void updateSettings() {
 327         updateSettingsButIgnoreRecording(null);
 328     }
 329 
 330     void updateSettingsButIgnoreRecording(PlatformRecording ignoreMe) {
 331         List<PlatformRecording> recordings = getRunningRecordings();
 332         List<Map<String, String>> list = new ArrayList<>(recordings.size());
 333         for (PlatformRecording r : recordings) {
 334             if (r != ignoreMe) {
 335                 list.add(r.getSettings());
 336             }
 337         }
 338         MetadataRepository.getInstance().setSettings(list);


 389     }
 390 
 391     private void finishChunk(RepositoryChunk chunk, Instant time, PlatformRecording ignoreMe) {
 392         chunk.finish(time);
 393         for (PlatformRecording r : getRecordings()) {
 394             if (r != ignoreMe && r.getState() == RecordingState.RUNNING) {
 395                 r.appendChunk(chunk);
 396             }
 397         }
 398     }
 399 
 400     private void writeMetaEvents() {
 401 
 402         if (activeRecordingEvent.isEnabled()) {
 403             for (PlatformRecording r : getRecordings()) {
 404                 if (r.getState() == RecordingState.RUNNING && r.shouldWriteMetadataEvent()) {
 405                     ActiveRecordingEvent event = new ActiveRecordingEvent();
 406                     event.id = r.getId();
 407                     event.name = r.getName();
 408                     WriteableUserPath p = r.getDestination();
 409                     event.destination = p == null ? null : p.getText();
 410                     Duration d = r.getDuration();
 411                     event.recordingDuration = d == null ? Long.MAX_VALUE : d.toMillis();
 412                     Duration age = r.getMaxAge();
 413                     event.maxAge = age == null ? Long.MAX_VALUE : age.toMillis();
 414                     Long size = r.getMaxSize();
 415                     event.maxSize = size == null ? Long.MAX_VALUE : size;
 416                     Instant start = r.getStartTime();
 417                     event.recordingStart = start == null ? Long.MAX_VALUE : start.toEpochMilli();
 418                     event.commit();
 419                 }
 420             }
 421         }
 422         if (activeSettingEvent.isEnabled()) {
 423             for (EventControl ec : MetadataRepository.getInstance().getEventControls()) {
 424                 ec.writeActiveSettingEvent();
 425             }
 426         }
 427     }
 428 
 429     private void periodicTask() {


< prev index next >