< prev index next >

src/jdk.management.jfr/share/classes/jdk/management/jfr/RecordingInfo.java

Print this page




   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
  23  * questions.
  24  */
  25 
  26 package jdk.management.jfr;
  27 

  28 import java.time.Duration;
  29 import java.time.Instant;
  30 import java.util.LinkedHashMap;
  31 import java.util.List;
  32 import java.util.Map;
  33 
  34 import javax.management.openmbean.CompositeData;
  35 import javax.management.openmbean.TabularData;
  36 
  37 import jdk.jfr.Recording;
  38 import jdk.jfr.RecordingState;
  39 import jdk.jfr.internal.management.ManagementSupport;
  40 
  41 /**
  42  * Management representation of a {@code Recording}.
  43  *
  44  * @see Recording
  45  *
  46  * @since 9
  47  */
  48 public final class RecordingInfo {
  49     private final long id;
  50     private final String name;
  51     private final String state;
  52     private final boolean dumpOnExit;
  53     private final long size;
  54     private final boolean disk;
  55     private final long maxAge;
  56     private final long maxSize;
  57     private final long startTime;
  58     private final long stopTime;
  59     private final String destination;


  63     // package private
  64     RecordingInfo(Recording recording) {
  65         id = recording.getId();
  66         name = recording.getName();
  67         state = recording.getState().toString();
  68         dumpOnExit = recording.getDumpOnExit();
  69         size = recording.getSize();
  70         disk = recording.isToDisk();
  71 
  72         Duration d = recording.getMaxAge();
  73         if (d == null) {
  74             maxAge = 0;
  75         } else {
  76             maxAge = d.getSeconds();
  77         }
  78         maxSize = recording.getMaxSize();
  79         Instant s = recording.getStartTime();
  80         startTime = s == null ? 0L : s.toEpochMilli();
  81         Instant st = recording.getStopTime();
  82         stopTime = st == null ? 0L : st.toEpochMilli();
  83         destination = ManagementSupport.getDestinationOriginalText(recording);

  84         Duration duration = recording.getDuration();
  85         durationInSeconds = duration == null ? 0 : duration.getSeconds();
  86         settings = recording.getSettings();
  87     }
  88 
  89     private RecordingInfo(CompositeData cd) {
  90         id = (int) cd.get("id");
  91         name = (String) cd.get("name");
  92         state = (String) cd.get("state");
  93         dumpOnExit = (boolean) cd.get("dumpOnExit");
  94         size = (long) cd.get("size");
  95         disk = (boolean) cd.get("disk");
  96         maxAge = (Long) cd.get("maxAge");
  97         maxSize = (Long) cd.get("maxSize");
  98         startTime = (Long) cd.get("startTime");
  99         stopTime = (Long) cd.get("stopTime");
 100         destination = (String) cd.get("destination");
 101         durationInSeconds = (long) cd.get("duration");
 102         settings = new LinkedHashMap<>();
 103         Object map = cd.get("settings");




   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
  23  * questions.
  24  */
  25 
  26 package jdk.management.jfr;
  27 
  28 import java.nio.file.Path;
  29 import java.time.Duration;
  30 import java.time.Instant;
  31 import java.util.LinkedHashMap;
  32 import java.util.List;
  33 import java.util.Map;
  34 
  35 import javax.management.openmbean.CompositeData;
  36 import javax.management.openmbean.TabularData;
  37 
  38 import jdk.jfr.Recording;
  39 import jdk.jfr.RecordingState;

  40 
  41 /**
  42  * Management representation of a {@code Recording}.
  43  *
  44  * @see Recording
  45  *
  46  * @since 9
  47  */
  48 public final class RecordingInfo {
  49     private final long id;
  50     private final String name;
  51     private final String state;
  52     private final boolean dumpOnExit;
  53     private final long size;
  54     private final boolean disk;
  55     private final long maxAge;
  56     private final long maxSize;
  57     private final long startTime;
  58     private final long stopTime;
  59     private final String destination;


  63     // package private
  64     RecordingInfo(Recording recording) {
  65         id = recording.getId();
  66         name = recording.getName();
  67         state = recording.getState().toString();
  68         dumpOnExit = recording.getDumpOnExit();
  69         size = recording.getSize();
  70         disk = recording.isToDisk();
  71 
  72         Duration d = recording.getMaxAge();
  73         if (d == null) {
  74             maxAge = 0;
  75         } else {
  76             maxAge = d.getSeconds();
  77         }
  78         maxSize = recording.getMaxSize();
  79         Instant s = recording.getStartTime();
  80         startTime = s == null ? 0L : s.toEpochMilli();
  81         Instant st = recording.getStopTime();
  82         stopTime = st == null ? 0L : st.toEpochMilli();
  83         Path p = recording.getDestination();
  84         destination = p == null ? null : p.toString();
  85         Duration duration = recording.getDuration();
  86         durationInSeconds = duration == null ? 0 : duration.getSeconds();
  87         settings = recording.getSettings();
  88     }
  89 
  90     private RecordingInfo(CompositeData cd) {
  91         id = (int) cd.get("id");
  92         name = (String) cd.get("name");
  93         state = (String) cd.get("state");
  94         dumpOnExit = (boolean) cd.get("dumpOnExit");
  95         size = (long) cd.get("size");
  96         disk = (boolean) cd.get("disk");
  97         maxAge = (Long) cd.get("maxAge");
  98         maxSize = (Long) cd.get("maxSize");
  99         startTime = (Long) cd.get("startTime");
 100         stopTime = (Long) cd.get("stopTime");
 101         destination = (String) cd.get("destination");
 102         durationInSeconds = (long) cd.get("duration");
 103         settings = new LinkedHashMap<>();
 104         Object map = cd.get("settings");


< prev index next >