< prev index next >

src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/RandomAccessFileInstrumentor.java

Print this page

 52         long bytesRead = 0;
 53         boolean endOfFile = false;
 54         long start = 0;
 55         try {
 56             start = EventHandler.timestamp();
 57             result = read();
 58             if (result < 0) {
 59                 endOfFile = true;
 60             } else {
 61                 bytesRead = 1;
 62             }
 63         } finally {
 64             long duration = EventHandler.timestamp() - start;
 65             if (handler.shouldCommit(duration)) {
 66                 handler.write(start, duration, path, bytesRead, endOfFile);
 67             }
 68         }
 69         return result;
 70     }
 71 
 72     @SuppressWarnings("deprecation")
 73     @JIInstrumentationMethod
 74     public int read(byte b[]) throws IOException {
 75         EventHandler handler = Handlers.FILE_READ;
 76         if (!handler.isEnabled()) {
 77             return read(b);
 78         }
 79         int bytesRead = 0;
 80         long start = 0;
 81         try {
 82             start = EventHandler.timestamp();
 83             bytesRead = read(b);
 84         } finally {
 85             long duration = EventHandler.timestamp() - start;
 86             if (handler.shouldCommit(duration)) {
 87                 if (bytesRead < 0) {
 88                     handler.write(start, duration, path, 0L, true);
 89                 } else {
 90                     handler.write(start, duration, path, bytesRead, false);
 91                 }
 92             }
 93         }
 94         return bytesRead;
 95     }
 96 
 97     @SuppressWarnings("deprecation")
 98     @JIInstrumentationMethod
 99     public int read(byte b[], int off, int len) throws IOException {
100         EventHandler handler = Handlers.FILE_READ;
101         if (!handler.isEnabled()) {
102             return read(b, off, len);
103         }
104         int bytesRead = 0;
105         long start = 0;
106         try {
107             start = EventHandler.timestamp();
108             bytesRead = read(b, off, len);
109         } finally {
110             long duration = EventHandler.timestamp() - start;
111             if (handler.shouldCommit(duration)) {
112                 if (bytesRead < 0) {
113                     handler.write(start, duration, path, 0L, true);
114                 } else {
115                     handler.write(start, duration, path, bytesRead, false);
116                 }

124     public void write(int b) throws IOException {
125         EventHandler handler = Handlers.FILE_WRITE;
126         if (!handler.isEnabled()) {
127             write(b);
128             return;
129         }
130         long bytesWritten = 0;
131         long start = 0;
132         try {
133             start = EventHandler.timestamp();
134             write(b);
135             bytesWritten = 1;
136         } finally {
137             long duration = EventHandler.timestamp() - start;
138             if (handler.shouldCommit(duration)) {
139                 handler.write(start, duration, path, bytesWritten);
140             }
141         }
142     }
143 
144     @SuppressWarnings("deprecation")
145     @JIInstrumentationMethod
146     public void write(byte b[]) throws IOException {
147         EventHandler handler = Handlers.FILE_WRITE;
148         if (!handler.isEnabled()) {
149             write(b);
150             return;
151         }
152         long bytesWritten = 0;
153         long start = 0;
154         try {
155             start = EventHandler.timestamp();
156             write(b);
157             bytesWritten = b.length;
158         } finally {
159             long duration = EventHandler.timestamp();
160             if (handler.shouldCommit(duration)) {
161                 handler.write(start, duration, path, bytesWritten);
162             }
163         }
164     }
165 
166     @SuppressWarnings("deprecation")
167     @JIInstrumentationMethod
168     public void write(byte b[], int off, int len) throws IOException {
169         EventHandler handler = Handlers.FILE_WRITE;
170         if (!handler.isEnabled()) {
171             write(b, off, len);
172             return;
173         }
174         long bytesWritten = 0;
175         long start = 0;
176         try {
177             start = EventHandler.timestamp();
178             write(b, off, len);
179             bytesWritten = len;
180         } finally {
181             long duration = EventHandler.timestamp() - start;
182             if (handler.shouldCommit(duration)) {
183                 handler.write(start, duration, path, bytesWritten);
184             }
185         }

 52         long bytesRead = 0;
 53         boolean endOfFile = false;
 54         long start = 0;
 55         try {
 56             start = EventHandler.timestamp();
 57             result = read();
 58             if (result < 0) {
 59                 endOfFile = true;
 60             } else {
 61                 bytesRead = 1;
 62             }
 63         } finally {
 64             long duration = EventHandler.timestamp() - start;
 65             if (handler.shouldCommit(duration)) {
 66                 handler.write(start, duration, path, bytesRead, endOfFile);
 67             }
 68         }
 69         return result;
 70     }
 71 

























 72     @SuppressWarnings("deprecation")
 73     @JIInstrumentationMethod
 74     public int read(byte b[], int off, int len) throws IOException {
 75         EventHandler handler = Handlers.FILE_READ;
 76         if (!handler.isEnabled()) {
 77             return read(b, off, len);
 78         }
 79         int bytesRead = 0;
 80         long start = 0;
 81         try {
 82             start = EventHandler.timestamp();
 83             bytesRead = read(b, off, len);
 84         } finally {
 85             long duration = EventHandler.timestamp() - start;
 86             if (handler.shouldCommit(duration)) {
 87                 if (bytesRead < 0) {
 88                     handler.write(start, duration, path, 0L, true);
 89                 } else {
 90                     handler.write(start, duration, path, bytesRead, false);
 91                 }

 99     public void write(int b) throws IOException {
100         EventHandler handler = Handlers.FILE_WRITE;
101         if (!handler.isEnabled()) {
102             write(b);
103             return;
104         }
105         long bytesWritten = 0;
106         long start = 0;
107         try {
108             start = EventHandler.timestamp();
109             write(b);
110             bytesWritten = 1;
111         } finally {
112             long duration = EventHandler.timestamp() - start;
113             if (handler.shouldCommit(duration)) {
114                 handler.write(start, duration, path, bytesWritten);
115             }
116         }
117     }
118 






















119     @SuppressWarnings("deprecation")
120     @JIInstrumentationMethod
121     public void write(byte b[], int off, int len) throws IOException {
122         EventHandler handler = Handlers.FILE_WRITE;
123         if (!handler.isEnabled()) {
124             write(b, off, len);
125             return;
126         }
127         long bytesWritten = 0;
128         long start = 0;
129         try {
130             start = EventHandler.timestamp();
131             write(b, off, len);
132             bytesWritten = len;
133         } finally {
134             long duration = EventHandler.timestamp() - start;
135             if (handler.shouldCommit(duration)) {
136                 handler.write(start, duration, path, bytesWritten);
137             }
138         }
< prev index next >