mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8329138: Convert JFR FileForceEvent to static mirror event
Reviewed-by: alanb, egahlin
This commit is contained in:
parent
2cc8eccb36
commit
f4caac8dea
12 changed files with 252 additions and 42 deletions
|
@ -50,6 +50,7 @@ import java.util.Objects;
|
|||
|
||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.event.FileForceEvent;
|
||||
import jdk.internal.foreign.MemorySessionImpl;
|
||||
import jdk.internal.foreign.SegmentFactories;
|
||||
import jdk.internal.misc.Blocker;
|
||||
|
@ -486,8 +487,7 @@ public class FileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void force(boolean metaData) throws IOException {
|
||||
private void implForce(boolean metaData) throws IOException {
|
||||
ensureOpen();
|
||||
int rv = -1;
|
||||
int ti = -1;
|
||||
|
@ -511,6 +511,17 @@ public class FileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void force(boolean metaData) throws IOException {
|
||||
if (!FileForceEvent.enabled()) {
|
||||
implForce(metaData);
|
||||
return;
|
||||
}
|
||||
long start = FileForceEvent.timestamp();
|
||||
implForce(metaData);
|
||||
FileForceEvent.offer(start, path, metaData);
|
||||
}
|
||||
|
||||
// Assume at first that the underlying kernel supports sendfile/equivalent;
|
||||
// set this to true if we find out later that it doesn't
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,6 +25,8 @@
|
|||
|
||||
package sun.nio.ch;
|
||||
|
||||
import jdk.internal.event.FileForceEvent;
|
||||
|
||||
import java.nio.channels.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -50,19 +52,25 @@ public class SimpleAsynchronousFileChannelImpl
|
|||
// Used to make native read and write calls
|
||||
private static final FileDispatcher nd = new FileDispatcherImpl();
|
||||
|
||||
// file path
|
||||
private final String path;
|
||||
|
||||
// Thread-safe set of IDs of native threads, for signalling
|
||||
private final NativeThreadSet threads = new NativeThreadSet(2);
|
||||
|
||||
|
||||
SimpleAsynchronousFileChannelImpl(FileDescriptor fdObj,
|
||||
String path,
|
||||
boolean reading,
|
||||
boolean writing,
|
||||
ExecutorService executor)
|
||||
{
|
||||
super(fdObj, reading, writing, executor);
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public static AsynchronousFileChannel open(FileDescriptor fdo,
|
||||
String path,
|
||||
boolean reading,
|
||||
boolean writing,
|
||||
ThreadPool pool)
|
||||
|
@ -70,7 +78,7 @@ public class SimpleAsynchronousFileChannelImpl
|
|||
// Executor is either default or based on pool parameters
|
||||
ExecutorService executor = (pool == null) ?
|
||||
DefaultExecutorHolder.defaultExecutor : pool.executor();
|
||||
return new SimpleAsynchronousFileChannelImpl(fdo, reading, writing, executor);
|
||||
return new SimpleAsynchronousFileChannelImpl(fdo, path, reading, writing, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,8 +159,7 @@ public class SimpleAsynchronousFileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void force(boolean metaData) throws IOException {
|
||||
private void implForce(boolean metaData) throws IOException {
|
||||
int ti = threads.add();
|
||||
try {
|
||||
int n = 0;
|
||||
|
@ -169,6 +176,17 @@ public class SimpleAsynchronousFileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void force(boolean metaData) throws IOException {
|
||||
if (!FileForceEvent.enabled()) {
|
||||
implForce(metaData);
|
||||
return;
|
||||
}
|
||||
long start = FileForceEvent.timestamp();
|
||||
implForce(metaData);
|
||||
FileForceEvent.offer(start, path, metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
<A> Future<FileLock> implLock(final long position,
|
||||
final long size,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue