< prev index next >

test/jdk/jdk/jfr/event/io/TestFileChannelEvents.java

Print this page
rev 51054 : imported patch 9000013-aixDisableJFR-requires.patch


  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.event.io;
  27 
  28 import static jdk.test.lib.Asserts.assertEquals;
  29 
  30 import java.io.File;
  31 import java.io.RandomAccessFile;
  32 import java.nio.ByteBuffer;
  33 import java.nio.channels.FileChannel;
  34 import java.time.Duration;
  35 import java.util.ArrayList;
  36 import java.util.List;
  37 
  38 import jdk.jfr.Recording;
  39 import jdk.jfr.consumer.RecordedEvent;
  40 import jdk.test.lib.jfr.Events;
  41 
  42 /*
  43  * @test
  44  * @key jfr

  45  * @library /test/lib /test/jdk
  46  * @run main/othervm jdk.jfr.event.io.TestFileChannelEvents
  47  */
  48 public class TestFileChannelEvents {
  49     public static void main(String[] args) throws Throwable {
  50         File tmp = File.createTempFile("TestFileChannelEvents", ".tmp", new File("."));
  51         tmp.deleteOnExit();
  52         Recording recording = new Recording();
  53         List<IOEvent> expectedEvents = new ArrayList<>();
  54 
  55         try (RandomAccessFile rf = new RandomAccessFile(tmp, "rw"); FileChannel ch = rf.getChannel();) {
  56             recording.enable(IOEvent.EVENT_FILE_FORCE).withThreshold(Duration.ofMillis(0));
  57             recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
  58             recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0));
  59             recording.start();
  60 
  61             ByteBuffer bufA = ByteBuffer.allocateDirect(10);
  62             ByteBuffer bufB = ByteBuffer.allocateDirect(20);
  63             bufA.put("1234567890".getBytes());
  64             bufB.put("1234567890".getBytes());




  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jfr.event.io;
  27 
  28 import static jdk.test.lib.Asserts.assertEquals;
  29 
  30 import java.io.File;
  31 import java.io.RandomAccessFile;
  32 import java.nio.ByteBuffer;
  33 import java.nio.channels.FileChannel;
  34 import java.time.Duration;
  35 import java.util.ArrayList;
  36 import java.util.List;
  37 
  38 import jdk.jfr.Recording;
  39 import jdk.jfr.consumer.RecordedEvent;
  40 import jdk.test.lib.jfr.Events;
  41 
  42 /**
  43  * @test
  44  * @key jfr
  45  * @requires vm.hasJFR
  46  * @library /test/lib /test/jdk
  47  * @run main/othervm jdk.jfr.event.io.TestFileChannelEvents
  48  */
  49 public class TestFileChannelEvents {
  50     public static void main(String[] args) throws Throwable {
  51         File tmp = File.createTempFile("TestFileChannelEvents", ".tmp", new File("."));
  52         tmp.deleteOnExit();
  53         Recording recording = new Recording();
  54         List<IOEvent> expectedEvents = new ArrayList<>();
  55 
  56         try (RandomAccessFile rf = new RandomAccessFile(tmp, "rw"); FileChannel ch = rf.getChannel();) {
  57             recording.enable(IOEvent.EVENT_FILE_FORCE).withThreshold(Duration.ofMillis(0));
  58             recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0));
  59             recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0));
  60             recording.start();
  61 
  62             ByteBuffer bufA = ByteBuffer.allocateDirect(10);
  63             ByteBuffer bufB = ByteBuffer.allocateDirect(20);
  64             bufA.put("1234567890".getBytes());
  65             bufB.put("1234567890".getBytes());


< prev index next >