author | egahlin |
Mon, 16 Sep 2019 15:16:59 +0200 | |
branch | JEP-349-branch |
changeset 58153 | 0f7562601338 |
parent 58145 | bc54ed8d908a |
child 58180 | 0a8943b4d0dd |
permissions | -rw-r--r-- |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
1 |
/* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
4 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
10 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
15 |
* accompanied this code). |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
16 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
20 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
23 |
* questions. |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
24 |
*/ |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
25 |
|
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
26 |
package jdk.jfr.internal.consumer; |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
27 |
|
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
28 |
import java.io.IOException; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
29 |
import java.security.AccessControlContext; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
30 |
import java.security.AccessController; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
31 |
import java.security.PrivilegedAction; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
32 |
import java.time.Duration; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
33 |
import java.time.Instant; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
34 |
import java.util.Objects; |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
35 |
import java.util.concurrent.atomic.AtomicLong; |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
36 |
import java.util.function.Consumer; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
37 |
|
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
38 |
import jdk.jfr.consumer.EventStream; |
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
39 |
import jdk.jfr.consumer.RecordedEvent; |
57614 | 40 |
import jdk.jfr.internal.JVM; |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
41 |
import jdk.jfr.internal.LogLevel; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
42 |
import jdk.jfr.internal.LogTag; |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
43 |
import jdk.jfr.internal.Logger; |
57985 | 44 |
import jdk.jfr.internal.SecuritySupport; |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
45 |
|
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
46 |
/* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
47 |
* Purpose of this class is to simplify the implementation of |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
48 |
* an event stream. In particular, it handles: |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
49 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
50 |
* - configuration storage |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
51 |
* - atomic updates to a configuration |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
52 |
* - dispatch mechanism |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
53 |
* - error handling |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
54 |
* - security |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
55 |
* |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
56 |
*/ |
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
57 |
public abstract class AbstractEventStream implements EventStream { |
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
58 |
private final static AtomicLong counter = new AtomicLong(1); |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
59 |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
60 |
private final Object terminated = new Object(); |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57628
diff
changeset
|
61 |
private final boolean active; |
58129 | 62 |
private final Runnable flushOperation = () -> dispatcher().runFlushActions(); |
57985 | 63 |
private final AccessControlContext accessControllerContext; |
58129 | 64 |
private final StreamConfiguration configuration = new StreamConfiguration(); |
57861 | 65 |
|
58129 | 66 |
private volatile Thread thread; |
67 |
private Dispatcher dispatcher; |
|
68 |
||
69 |
private volatile boolean closed; |
|
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
70 |
|
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57628
diff
changeset
|
71 |
public AbstractEventStream(AccessControlContext acc, boolean active) throws IOException { |
57985 | 72 |
this.accessControllerContext = Objects.requireNonNull(acc); |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
57628
diff
changeset
|
73 |
this.active = active; |
57985 | 74 |
} |
75 |
||
76 |
@Override |
|
77 |
abstract public void start(); |
|
78 |
||
79 |
@Override |
|
80 |
abstract public void startAsync(); |
|
81 |
||
82 |
@Override |
|
83 |
abstract public void close(); |
|
84 |
||
58129 | 85 |
protected final Dispatcher dispatcher() { |
86 |
if (configuration.hasChanged()) { |
|
87 |
synchronized (configuration) { |
|
88 |
dispatcher = new Dispatcher(configuration); |
|
89 |
} |
|
90 |
} |
|
91 |
return dispatcher; |
|
92 |
} |
|
93 |
||
57985 | 94 |
@Override |
95 |
public final void setOrdered(boolean ordered) { |
|
58129 | 96 |
configuration.setOrdered(ordered); |
57985 | 97 |
} |
98 |
||
99 |
@Override |
|
100 |
public final void setReuse(boolean reuse) { |
|
58129 | 101 |
configuration.setReuse(reuse); |
57985 | 102 |
} |
103 |
||
104 |
@Override |
|
105 |
public final void setStartTime(Instant startTime) { |
|
106 |
Objects.nonNull(startTime); |
|
58129 | 107 |
synchronized (configuration) { |
108 |
if (configuration.started) { |
|
57985 | 109 |
throw new IllegalStateException("Stream is already started"); |
110 |
} |
|
111 |
if (startTime.isBefore(Instant.EPOCH)) { |
|
112 |
startTime = Instant.EPOCH; |
|
113 |
} |
|
58129 | 114 |
configuration.setStartTime(startTime); |
57985 | 115 |
} |
116 |
} |
|
117 |
||
118 |
@Override |
|
119 |
public final void setEndTime(Instant endTime) { |
|
120 |
Objects.requireNonNull(endTime); |
|
58129 | 121 |
synchronized (configuration) { |
122 |
if (configuration.started) { |
|
57985 | 123 |
throw new IllegalStateException("Stream is already started"); |
124 |
} |
|
58129 | 125 |
configuration.setEndTime(endTime); |
57985 | 126 |
} |
127 |
} |
|
128 |
||
129 |
@Override |
|
130 |
public final void onEvent(Consumer<RecordedEvent> action) { |
|
131 |
Objects.requireNonNull(action); |
|
58129 | 132 |
configuration.addEventAction(action); |
57985 | 133 |
} |
134 |
||
135 |
@Override |
|
136 |
public final void onEvent(String eventName, Consumer<RecordedEvent> action) { |
|
137 |
Objects.requireNonNull(eventName); |
|
138 |
Objects.requireNonNull(action); |
|
58129 | 139 |
configuration.addEventAction(eventName, action); |
57985 | 140 |
} |
141 |
||
142 |
@Override |
|
143 |
public final void onFlush(Runnable action) { |
|
144 |
Objects.requireNonNull(action); |
|
58129 | 145 |
configuration.addFlushAction(action); |
57985 | 146 |
} |
147 |
||
148 |
@Override |
|
149 |
public final void onClose(Runnable action) { |
|
150 |
Objects.requireNonNull(action); |
|
58129 | 151 |
configuration.addCloseAction(action); |
57985 | 152 |
} |
153 |
||
154 |
@Override |
|
155 |
public final void onError(Consumer<Throwable> action) { |
|
156 |
Objects.requireNonNull(action); |
|
58129 | 157 |
configuration.addErrorAction(action); |
57985 | 158 |
} |
159 |
||
160 |
@Override |
|
161 |
public final boolean remove(Object action) { |
|
162 |
Objects.requireNonNull(action); |
|
58129 | 163 |
return configuration.remove(action); |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
164 |
} |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
165 |
|
57985 | 166 |
@Override |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
167 |
public final void awaitTermination() throws InterruptedException { |
57985 | 168 |
awaitTermination(Duration.ofMillis(0)); |
169 |
} |
|
170 |
||
171 |
@Override |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
172 |
public final void awaitTermination(Duration timeout) throws InterruptedException { |
57985 | 173 |
Objects.requireNonNull(timeout); |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
174 |
if (timeout.isNegative()) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
175 |
throw new IllegalArgumentException("timeout value is negative"); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
176 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
177 |
|
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
178 |
long base = System.currentTimeMillis(); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
179 |
long now = 0; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
180 |
|
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
181 |
long millis; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
182 |
try { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
183 |
millis = Math.multiplyExact(timeout.getSeconds(), 1000); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
184 |
} catch (ArithmeticException a) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
185 |
millis = Long.MAX_VALUE; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
186 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
187 |
int nanos = timeout.toNanosPart(); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
188 |
if (nanos == 0 && millis == 0) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
189 |
synchronized (terminated) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
190 |
while (!isClosed()) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
191 |
terminated.wait(0); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
192 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
193 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
194 |
} else { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
195 |
while (!isClosed()) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
196 |
long delay = millis - now; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
197 |
if (delay <= 0) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
198 |
break; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
199 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
200 |
synchronized (terminated) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
201 |
terminated.wait(delay, nanos); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
202 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
203 |
now = System.currentTimeMillis() - base; |
57985 | 204 |
} |
205 |
} |
|
206 |
} |
|
207 |
||
58153 | 208 |
protected abstract void process() throws IOException; |
57985 | 209 |
|
210 |
protected final void setClosed(boolean closed) { |
|
58129 | 211 |
this.closed = closed; |
57985 | 212 |
} |
213 |
||
214 |
protected final boolean isClosed() { |
|
58129 | 215 |
return closed; |
57985 | 216 |
} |
217 |
||
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
218 |
public final void startAsync(long startNanos) { |
57985 | 219 |
startInternal(startNanos); |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
220 |
Runnable r = () -> run(accessControllerContext); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
221 |
thread = SecuritySupport.createThreadWitNoPermissions(nextThreadName(), r); |
57985 | 222 |
thread.start(); |
223 |
} |
|
224 |
||
58145
bc54ed8d908a
Move implementation into jdk.jfr.internal.consumer
egahlin
parents:
58129
diff
changeset
|
225 |
public final void start(long startNanos) { |
57985 | 226 |
startInternal(startNanos); |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
227 |
thread = Thread.currentThread(); |
57985 | 228 |
run(accessControllerContext); |
229 |
} |
|
230 |
||
231 |
protected final Runnable getFlushOperation() { |
|
232 |
return flushOperation; |
|
233 |
} |
|
234 |
||
235 |
private void startInternal(long startNanos) { |
|
58129 | 236 |
synchronized (configuration) { |
237 |
if (configuration.started) { |
|
57985 | 238 |
throw new IllegalStateException("Event stream can only be started once"); |
239 |
} |
|
240 |
if (active) { |
|
58129 | 241 |
configuration.setStartNanos(startNanos); |
57985 | 242 |
} |
58129 | 243 |
configuration.setStarted(true); |
57985 | 244 |
} |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
245 |
} |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
246 |
|
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
247 |
private void execute() { |
57614 | 248 |
JVM.getJVM().exclude(Thread.currentThread()); |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
249 |
try { |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
250 |
process(); |
58129 | 251 |
} catch (IOException ioe) { |
252 |
// This can happen if a chunk file is removed, or |
|
253 |
// a file is access that has been closed |
|
254 |
// This is "normal" behavior for streaming and the |
|
58153 | 255 |
// stream will be closed when this happens. |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
256 |
} finally { |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
257 |
Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.DEBUG, "Execution of stream ended."); |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
258 |
try { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
259 |
close(); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
260 |
} finally { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
261 |
synchronized (terminated) { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
262 |
terminated.notifyAll(); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
263 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
264 |
} |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
265 |
} |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
266 |
} |
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
267 |
|
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
268 |
private void run(AccessControlContext accessControlContext) { |
57985 | 269 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
270 |
@Override |
|
271 |
public Void run() { |
|
272 |
execute(); |
|
273 |
return null; |
|
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
274 |
} |
58020
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
275 |
}, accessControlContext); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
276 |
} |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
277 |
|
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
278 |
private String nextThreadName() { |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
279 |
counter.incrementAndGet(); |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
280 |
return "JFR Event Stream " + counter; |
f082177c5023
Improved handling of Thread.interrupt() + cleanup
egahlin
parents:
57985
diff
changeset
|
281 |
} |
57604
838f9a7635b6
Cleaner stream reconfiguration + reduced allocation in JFR framework
egahlin
parents:
diff
changeset
|
282 |
} |