< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 301         }
 302         RecordingState state = getState();
 303         if (state == RecordingState.CLOSED) {
 304             throw new IOException("Recording \"" + name + "\" (id=" + id + ") has been closed, no contents to write");
 305         }
 306         if (state == RecordingState.DELAYED || state == RecordingState.NEW) {
 307             throw new IOException("Recording \"" + name + "\" (id=" + id + ") has not started, no contents to write");
 308         }
 309         if (state == RecordingState.STOPPED) {
 310             PlatformRecording clone = recorder.newTemporaryRecording();
 311             for (RepositoryChunk r : chunks) {
 312                 clone.add(r);
 313             }
 314             return clone;
 315         }
 316 
 317         // Recording is RUNNING, create a clone
 318         PlatformRecording clone = recorder.newTemporaryRecording();
 319         clone.setShouldWriteActiveRecordingEvent(false);
 320         clone.setName(getName());
 321         clone.setDestination(this.destination);
 322         clone.setToDisk(true);
 323         // We purposely don't clone settings here, since
 324         // a union a == a
 325         if (!isToDisk()) {
 326             // force memory contents to disk
 327             clone.start();
 328         } else {
 329             // using existing chunks on disk
 330             for (RepositoryChunk c : chunks) {
 331                 clone.add(c);
 332             }
 333             clone.setState(RecordingState.RUNNING);
 334             clone.setStartTime(getStartTime());
 335         }
 336         if (pathToGcRoots == null) {
 337             clone.setSettings(getSettings()); // needed for old object sample
 338             clone.stop(reason); // dumps to destination path here
 339         } else {
 340             // Risk of violating lock order here, since
 341             // clone.stop() will take recorder lock inside


   1 /*
   2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 301         }
 302         RecordingState state = getState();
 303         if (state == RecordingState.CLOSED) {
 304             throw new IOException("Recording \"" + name + "\" (id=" + id + ") has been closed, no contents to write");
 305         }
 306         if (state == RecordingState.DELAYED || state == RecordingState.NEW) {
 307             throw new IOException("Recording \"" + name + "\" (id=" + id + ") has not started, no contents to write");
 308         }
 309         if (state == RecordingState.STOPPED) {
 310             PlatformRecording clone = recorder.newTemporaryRecording();
 311             for (RepositoryChunk r : chunks) {
 312                 clone.add(r);
 313             }
 314             return clone;
 315         }
 316 
 317         // Recording is RUNNING, create a clone
 318         PlatformRecording clone = recorder.newTemporaryRecording();
 319         clone.setShouldWriteActiveRecordingEvent(false);
 320         clone.setName(getName());

 321         clone.setToDisk(true);
 322         // We purposely don't clone settings here, since
 323         // a union a == a
 324         if (!isToDisk()) {
 325             // force memory contents to disk
 326             clone.start();
 327         } else {
 328             // using existing chunks on disk
 329             for (RepositoryChunk c : chunks) {
 330                 clone.add(c);
 331             }
 332             clone.setState(RecordingState.RUNNING);
 333             clone.setStartTime(getStartTime());
 334         }
 335         if (pathToGcRoots == null) {
 336             clone.setSettings(getSettings()); // needed for old object sample
 337             clone.stop(reason); // dumps to destination path here
 338         } else {
 339             // Risk of violating lock order here, since
 340             // clone.stop() will take recorder lock inside


< prev index next >