src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java
changeset 50194 2ae4cd9d809d
parent 50113 caf115bb98ad
child 50197 f4735ff8d17d
equal deleted inserted replaced
50193:49c3e91c424f 50194:2ae4cd9d809d
   243         }
   243         }
   244 
   244 
   245         RequestEngine.doChunkBegin();
   245         RequestEngine.doChunkBegin();
   246     }
   246     }
   247 
   247 
   248     synchronized void stop(PlatformRecording recording) {
   248     synchronized void stop(PlatformRecording recording, WriteableUserPath alternativePath) {
   249         RecordingState state = recording.getState();
   249         RecordingState state = recording.getState();
   250 
   250 
   251         if (Utils.isAfter(state, RecordingState.RUNNING)) {
   251         if (Utils.isAfter(state, RecordingState.RUNNING)) {
   252             throw new IllegalStateException("Can't stop an already stopped recording.");
   252             throw new IllegalStateException("Can't stop an already stopped recording.");
   253         }
   253         }
   276                     finishChunk(currentChunk, now, null);
   276                     finishChunk(currentChunk, now, null);
   277                     currentChunk = null;
   277                     currentChunk = null;
   278                 }
   278                 }
   279             } else {
   279             } else {
   280                 // last memory
   280                 // last memory
   281                 dumpMemoryToDestination(recording);
   281                 dumpMemoryToDestination(recording, alternativePath);
   282             }
   282             }
   283             jvm.endRecording_();
   283             jvm.endRecording_();
   284             disableEvents();
   284             disableEvents();
   285         } else {
   285         } else {
   286             RepositoryChunk newChunk = null;
   286             RepositoryChunk newChunk = null;
   312             long ticks = Utils.nanosToTicks(nanos);
   312             long ticks = Utils.nanosToTicks(nanos);
   313             JVM.getJVM().emitOldObjectSamples(ticks, WhiteBox.getWriteAllObjectSamples());
   313             JVM.getJVM().emitOldObjectSamples(ticks, WhiteBox.getWriteAllObjectSamples());
   314         }
   314         }
   315     }
   315     }
   316 
   316 
   317     private void dumpMemoryToDestination(PlatformRecording recording) {
   317     private void dumpMemoryToDestination(PlatformRecording recording, WriteableUserPath alternativePath) {
   318         WriteableUserPath dest = recording.getDestination();
   318         WriteableUserPath dest = alternativePath != null ? alternativePath : recording.getDestination();
   319         if (dest != null) {
   319         if (dest != null) {
   320             MetadataRepository.getInstance().setOutput(dest.getText());
   320             MetadataRepository.getInstance().setOutput(dest.getText());
   321             recording.clearDestination();
   321             recording.clearDestination();
   322         }
   322         }
   323     }
   323     }