1 /* |
1 /* |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package jdk.jfr.consumer; |
26 package jdk.jfr.consumer; |
27 |
27 |
|
28 import java.io.IOException; |
28 import java.io.PrintWriter; |
29 import java.io.PrintWriter; |
29 import java.io.StringWriter; |
30 import java.io.StringWriter; |
30 import java.time.Duration; |
31 import java.time.Duration; |
31 import java.time.Instant; |
32 import java.time.Instant; |
32 import java.time.OffsetDateTime; |
33 import java.time.OffsetDateTime; |
|
34 import java.util.Collections; |
33 import java.util.List; |
35 import java.util.List; |
34 import java.util.Objects; |
36 import java.util.Objects; |
35 |
37 |
36 import jdk.jfr.Timespan; |
38 import jdk.jfr.Timespan; |
37 import jdk.jfr.Timestamp; |
39 import jdk.jfr.Timestamp; |
38 import jdk.jfr.ValueDescriptor; |
40 import jdk.jfr.ValueDescriptor; |
39 import jdk.jfr.internal.PrivateAccess; |
41 import jdk.jfr.internal.PrivateAccess; |
|
42 import jdk.jfr.internal.Type; |
|
43 import jdk.jfr.internal.consumer.Parser; |
|
44 import jdk.jfr.internal.consumer.RecordingInternals; |
40 import jdk.jfr.internal.tool.PrettyWriter; |
45 import jdk.jfr.internal.tool.PrettyWriter; |
41 |
46 |
42 /** |
47 /** |
43 * A complex data type that consists of one or more fields. |
48 * A complex data type that consists of one or more fields. |
44 * <p> |
49 * <p> |
48 * and if a part is {@code null}, it throws {@code NullPointerException}. |
53 * and if a part is {@code null}, it throws {@code NullPointerException}. |
49 * |
54 * |
50 * @since 9 |
55 * @since 9 |
51 */ |
56 */ |
52 public class RecordedObject { |
57 public class RecordedObject { |
|
58 |
|
59 static{ |
|
60 RecordingInternals.INSTANCE = new RecordingInternals() { |
|
61 public List<Type> readTypes(RecordingFile file) throws IOException { |
|
62 return file.readTypes(); |
|
63 } |
|
64 |
|
65 public boolean isLastEventInChunk(RecordingFile file) { |
|
66 return file.isLastEventInChunk; |
|
67 } |
|
68 |
|
69 @Override |
|
70 public Object getOffsetDataTime(RecordedObject event, String name) { |
|
71 return event.getOffsetDateTime(name); |
|
72 } |
|
73 |
|
74 @Override |
|
75 public void sort(List<RecordedEvent> events) { |
|
76 Collections.sort(events, (e1, e2) -> Long.compare(e1.endTime, e2.endTime)); |
|
77 } |
|
78 |
|
79 @Override |
|
80 public Parser newStringParser() { |
|
81 return new StringParser(null, false); |
|
82 } |
|
83 }; |
|
84 } |
53 |
85 |
54 private final static class UnsignedValue { |
86 private final static class UnsignedValue { |
55 private final Object o; |
87 private final Object o; |
56 |
88 |
57 UnsignedValue(Object o) { |
89 UnsignedValue(Object o) { |