Merge lp:~pbeaman/akiban-persistit/add-mxbeans-accessor into lp:akiban-persistit
- add-mxbeans-accessor
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 326 |
Proposed branch: | lp:~pbeaman/akiban-persistit/add-mxbeans-accessor |
Merge into: | lp:akiban-persistit |
Diff against target: |
808 lines (+224/-114) 12 files modified
src/main/java/com/persistit/AlertMonitor.java (+95/-9) src/main/java/com/persistit/CleanupManager.java (+2/-2) src/main/java/com/persistit/IOMeter.java (+9/-33) src/main/java/com/persistit/JournalManager.java (+14/-13) src/main/java/com/persistit/Management.java (+26/-0) src/main/java/com/persistit/ManagementImpl.java (+21/-10) src/main/java/com/persistit/Persistit.java (+7/-1) src/main/java/com/persistit/VolumeStorageT2.java (+4/-4) src/main/java/com/persistit/VolumeStorageV2.java (+9/-6) src/main/java/com/persistit/VolumeStructure.java (+17/-15) src/main/java/com/persistit/mxbeans/IOMeterMXBean.java (+12/-13) src/test/java/com/persistit/AlertMonitorTest.java (+8/-8) |
To merge this branch: | bzr merge lp:~pbeaman/akiban-persistit/add-mxbeans-accessor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Akiban Build User | Needs Fixing | ||
Thomas Jones-Low | Needs Fixing | ||
Review via email: mp+111441@code.launchpad.net |
Commit message
Description of the change
This branch adds of a couple of items needed for the information schema work.
1. In the Management/
Map<ObjectName, Object> getMXBeans();
This method returns a map. The key is an javax.managemen
2. IOMeterMXBean adds a new constant array OPERATION_NAMES[] with descriptive string element corresponding to each 2-character code in the OPERATIONS array.
Thomas Jones-Low (tjoneslo) wrote : | # |
Peter Beaman (pbeaman) wrote : | # |
Works for me.
Thomas Jones-Low (tjoneslo) wrote : | # |
This looks like we cleaned up some other things in the code as well.
Approving, though not understanding all the changes, to complete the Storage ADD changes.
Akiban Build User (build-akiban) wrote : | # |
There were 2 failures during build/test:
* job persistit-build failed at build number 369: http://
* view must-pass failed: persistit-build is yellow
Thomas Jones-Low (tjoneslo) wrote : | # |
The persisit build failed due to this error.
java.lang.
at org.junit.
at org.junit.
at org.junit.
at org.junit.
at org.junit.
at com.persistit.
Peter Beaman (pbeaman) wrote : | # |
Unrelated failure - seems to be an occasional accident of timing. We need to fix that, but I'm going to Approve this branch again and since it's unrelated.
Akiban Build User (build-akiban) wrote : | # |
There was one failure during build/test:
* bzr error: Nothing to merge.
Thomas Jones-Low (tjoneslo) wrote : | # |
LBJ is confused about the persistit build. We'll need to revert the build branch before trying this merge proposal again.
Preview Diff
1 | === modified file 'src/main/java/com/persistit/AlertMonitor.java' |
2 | --- src/main/java/com/persistit/AlertMonitor.java 2012-05-25 18:50:59 +0000 |
3 | +++ src/main/java/com/persistit/AlertMonitor.java 2012-06-22 19:37:18 +0000 |
4 | @@ -23,6 +23,7 @@ |
5 | import java.util.ArrayList; |
6 | import java.util.List; |
7 | import java.util.Map; |
8 | +import java.util.SortedMap; |
9 | import java.util.TreeMap; |
10 | import java.util.concurrent.Executors; |
11 | import java.util.concurrent.atomic.AtomicLong; |
12 | @@ -288,7 +289,7 @@ |
13 | * @param level |
14 | * the <code>AlertLevel</code> that should be assigned to it |
15 | */ |
16 | - private void addEvent(final Event event, final AlertLevel level) { |
17 | + private void addEvent(final Event event) { |
18 | trim(_historyLength - 1); |
19 | _eventList.add(event); |
20 | _count++; |
21 | @@ -297,7 +298,7 @@ |
22 | _firstEvent = event; |
23 | } |
24 | event.added(this); |
25 | - _level = level; |
26 | + _level = event.getLevel(); |
27 | } |
28 | |
29 | /** |
30 | @@ -320,6 +321,7 @@ |
31 | * event was posted. |
32 | */ |
33 | public static class Event { |
34 | + private AlertLevel _level; |
35 | private final LogItem _logItem; |
36 | private final Object[] _args; |
37 | private final long _time; |
38 | @@ -328,19 +330,23 @@ |
39 | * Construct an <code>Event</code> for the specified {@link LogItem} and |
40 | * arguments with the current system time. |
41 | * |
42 | + * @param level |
43 | + * AlertLevel assigned to this event by the posting process |
44 | * @param logItem |
45 | * <code>LogItem</code> to be used in logging this event |
46 | * @param args |
47 | * arguments specific to the <code>LogItem</code> |
48 | */ |
49 | - public Event(LogItem logItem, Object... args) { |
50 | - this(System.currentTimeMillis(), logItem, args); |
51 | + public Event(AlertLevel level, LogItem logItem, Object... args) { |
52 | + this(level, System.currentTimeMillis(), logItem, args); |
53 | } |
54 | |
55 | /** |
56 | * Construct an <code>Event</code> for the specified {@link LogItem} and |
57 | * arguments with the specified system time. |
58 | * |
59 | + * @param level |
60 | + * AlertLevel assigned to this event by the posting process |
61 | * @param time |
62 | * System time in milliseconds at which the event occurred |
63 | * @param logItem |
64 | @@ -348,13 +354,22 @@ |
65 | * @param args |
66 | * arguments specific to the <code>LogItem</code> |
67 | */ |
68 | - public Event(long time, LogItem logItem, Object... args) { |
69 | + public Event(AlertLevel level, long time, LogItem logItem, Object... args) { |
70 | + _level = level; |
71 | _logItem = logItem; |
72 | _args = args; |
73 | _time = time; |
74 | } |
75 | |
76 | /** |
77 | + * |
78 | + * @return the AlertLevel assigned to this Event. |
79 | + */ |
80 | + public AlertLevel getLevel() { |
81 | + return _level; |
82 | + } |
83 | + |
84 | + /** |
85 | * @return The {@link LogItem} assigned to the event |
86 | */ |
87 | public LogItem getLogItem() { |
88 | @@ -417,14 +432,61 @@ |
89 | // Default: do nothing |
90 | } |
91 | |
92 | + public String logMessage() { |
93 | + return _logItem.logMessage(_args); |
94 | + } |
95 | + |
96 | /** |
97 | * @return a description of the event with human-readable time and log |
98 | * message |
99 | */ |
100 | @Override |
101 | public String toString() { |
102 | - return Util.date(_time) + " " + _logItem.logMessage(_args); |
103 | - } |
104 | + return Util.date(_time) + " " + logMessage(); |
105 | + } |
106 | + } |
107 | + |
108 | + public static class AlertRecord { |
109 | + final String _category; |
110 | + final AlertLevel _level; |
111 | + final long _time; |
112 | + final String _message; |
113 | + |
114 | + private AlertRecord(final String category, final Event event) { |
115 | + _category = category; |
116 | + _level = event.getLevel(); |
117 | + _time = event.getTime(); |
118 | + _message = event.logMessage(); |
119 | + } |
120 | + |
121 | + /** |
122 | + * @return the category |
123 | + */ |
124 | + public String getCategory() { |
125 | + return _category; |
126 | + } |
127 | + |
128 | + /** |
129 | + * @return the level |
130 | + */ |
131 | + public AlertLevel getLevel() { |
132 | + return _level; |
133 | + } |
134 | + |
135 | + /** |
136 | + * @return the _time |
137 | + */ |
138 | + public long getTime() { |
139 | + return _time; |
140 | + } |
141 | + |
142 | + /** |
143 | + * @return the message |
144 | + */ |
145 | + public String getMessage() { |
146 | + return _message; |
147 | + } |
148 | + |
149 | } |
150 | |
151 | final static String NOTIFICATION_TYPE = "com.persistit.AlertMonitor"; |
152 | @@ -478,13 +540,13 @@ |
153 | * @param level |
154 | * Indicates whether this event is a warning or an error. |
155 | */ |
156 | - public synchronized final void post(Event event, final String category, AlertLevel level) { |
157 | + public synchronized final void post(Event event, final String category) { |
158 | History history = _historyMap.get(category); |
159 | if (history == null) { |
160 | history = new History(); |
161 | _historyMap.put(category, history); |
162 | } |
163 | - history.addEvent(event, level); |
164 | + history.addEvent(event); |
165 | history.poll(event.getTime(), false); |
166 | } |
167 | |
168 | @@ -563,6 +625,14 @@ |
169 | } |
170 | |
171 | /** |
172 | + * @return Map sorted by category name of all History elements. |
173 | + */ |
174 | + |
175 | + public synchronized SortedMap<String, History> getHistoryMap() { |
176 | + return new TreeMap<String, History>(_historyMap); |
177 | + } |
178 | + |
179 | + /** |
180 | * Set the number of <code>Event</code>s per category to keep in the |
181 | * <code>History</code>. Once the number of events exceeds this count, |
182 | * earlier events are removed when new events are added. (However, the first |
183 | @@ -583,6 +653,22 @@ |
184 | } |
185 | |
186 | /** |
187 | + * Generate a list of event data suitable for the Akiban Server in-memory |
188 | + * tables implementation. |
189 | + * |
190 | + * @return List of AlertRecord elements. |
191 | + */ |
192 | + public synchronized AlertRecord[] getAlertRecordArray() { |
193 | + List<AlertRecord> list = new ArrayList<AlertRecord>(); |
194 | + for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
195 | + for (final Event event : entry.getValue().getEventList()) { |
196 | + list.add(new AlertRecord(entry.getKey(), event)); |
197 | + } |
198 | + } |
199 | + return list.toArray(new AlertRecord[list.size()]); |
200 | + } |
201 | + |
202 | + /** |
203 | * Called periodically to issue any pending log messages or notifications. |
204 | * |
205 | * @param force |
206 | |
207 | === modified file 'src/main/java/com/persistit/CleanupManager.java' |
208 | --- src/main/java/com/persistit/CleanupManager.java 2012-05-25 18:50:59 +0000 |
209 | +++ src/main/java/com/persistit/CleanupManager.java 2012-06-22 19:37:18 +0000 |
210 | @@ -155,8 +155,8 @@ |
211 | _performed.incrementAndGet(); |
212 | } catch (PersistitException e) { |
213 | lastException(e); |
214 | - _persistit.getAlertMonitor().post(new Event(_persistit.getLogBase().cleanupException, e, action), |
215 | - AlertMonitor.CLEANUP_CATEGORY, AlertLevel.ERROR); |
216 | + _persistit.getAlertMonitor().post(new Event(AlertLevel.ERROR, _persistit.getLogBase().cleanupException, e, action), |
217 | + AlertMonitor.CLEANUP_CATEGORY); |
218 | _errors.incrementAndGet(); |
219 | } |
220 | } |
221 | |
222 | === modified file 'src/main/java/com/persistit/IOMeter.java' |
223 | --- src/main/java/com/persistit/IOMeter.java 2012-06-14 20:15:48 +0000 |
224 | +++ src/main/java/com/persistit/IOMeter.java 2012-06-22 19:37:18 +0000 |
225 | @@ -68,17 +68,13 @@ |
226 | private final static int READ_PAGE_FROM_JOURNAL = 2; |
227 | private final static int COPY_PAGE_TO_VOLUME = 3; |
228 | private final static int WRITE_PAGE_TO_JOURNAL = 4; |
229 | - private final static int WRITE_TS_TO_JOURNAL = 5; |
230 | - private final static int WRITE_TC_TO_JOURNAL = 6; |
231 | - private final static int WRITE_SR_TO_JOURNAL = 7; |
232 | - private final static int WRITE_DR_TO_JOURNAL = 8; |
233 | - private final static int WRITE_DT_TO_JOURNAL = 9; |
234 | - private final static int WRITE_OTHER_TO_JOURNAL = 10; |
235 | - private final static int EVICT_PAGE_FROM_POOL = 11; |
236 | - private final static int FLUSH_JOURNAL = 12; |
237 | - private final static int GET_PAGE = 13; |
238 | + private final static int WRITE_TX_TO_JOURNAL = 5; |
239 | + private final static int WRITE_OTHER_TO_JOURNAL = 6; |
240 | + private final static int EVICT_PAGE_FROM_POOL = 7; |
241 | + private final static int FLUSH_JOURNAL = 8; |
242 | + private final static int GET_PAGE = 9; |
243 | |
244 | - private final static int ITEM_COUNT = 14; |
245 | + private final static int ITEM_COUNT = 10; |
246 | |
247 | private long _quiescentIOthreshold = DEFAULT_QUIESCENT_IO_THRESHOLD; |
248 | |
249 | @@ -321,29 +317,9 @@ |
250 | charge(size, WRITE_PAGE_TO_JOURNAL); |
251 | } |
252 | |
253 | - public void chargeWriteTStoJournal(final int size, final long journalAddress) { |
254 | - log(WRITE_TS_TO_JOURNAL, null, -1, size, journalAddress, -1); |
255 | - charge(size, WRITE_TS_TO_JOURNAL); |
256 | - } |
257 | - |
258 | - public void chargeWriteTCtoJournal(final int size, final long journalAddress) { |
259 | - log(WRITE_TC_TO_JOURNAL, null, -1, size, journalAddress, -1); |
260 | - charge(size, WRITE_TC_TO_JOURNAL); |
261 | - } |
262 | - |
263 | - public void chargeWriteSRtoJournal(final int size, final long journalAddress) { |
264 | - log(WRITE_SR_TO_JOURNAL, null, -1, size, journalAddress, -1); |
265 | - charge(size, WRITE_SR_TO_JOURNAL); |
266 | - } |
267 | - |
268 | - public void chargeWriteDRtoJournal(final int size, final long journalAddress) { |
269 | - log(WRITE_DR_TO_JOURNAL, null, -1, size, journalAddress, -1); |
270 | - charge(size, WRITE_DR_TO_JOURNAL); |
271 | - } |
272 | - |
273 | - public void chargeWriteDTtoJournal(final int size, final long journalAddress) { |
274 | - log(WRITE_DT_TO_JOURNAL, null, -1, size, journalAddress, -1); |
275 | - charge(size, WRITE_DT_TO_JOURNAL); |
276 | + public void chargeWriteTXtoJournal(final int size, final long journalAddress) { |
277 | + log(WRITE_TX_TO_JOURNAL, null, -1, size, journalAddress, -1); |
278 | + charge(size, WRITE_TX_TO_JOURNAL); |
279 | } |
280 | |
281 | public void chargeWriteOtherToJournal(final int size, final long journalAddress) { |
282 | |
283 | === modified file 'src/main/java/com/persistit/JournalManager.java' |
284 | --- src/main/java/com/persistit/JournalManager.java 2012-05-25 18:50:59 +0000 |
285 | +++ src/main/java/com/persistit/JournalManager.java 2012-06-22 19:37:18 +0000 |
286 | @@ -685,8 +685,8 @@ |
287 | return false; |
288 | } |
289 | |
290 | - PageNode pn = new PageNode(pnLookup.getVolumeHandle(), pnLookup.getPageAddress(), |
291 | - pnLookup.getJournalAddress(), pnLookup.getTimestamp()); |
292 | + PageNode pn = new PageNode(pnLookup.getVolumeHandle(), pnLookup.getPageAddress(), pnLookup.getJournalAddress(), |
293 | + pnLookup.getTimestamp()); |
294 | sequence(PAGE_MAP_READ_INVALIDATE_A); |
295 | |
296 | /* |
297 | @@ -1125,6 +1125,7 @@ |
298 | TX.putTimestamp(_writeBuffer, startTimestamp); |
299 | TX.putCommitTimestamp(_writeBuffer, commitTimestamp); |
300 | TX.putBackchainAddress(_writeBuffer, backchainAddress); |
301 | + _persistit.getIOMeter().chargeWriteTXtoJournal(recordSize, _currentAddress); |
302 | advance(TX.OVERHEAD); |
303 | try { |
304 | _writeBuffer.put(buffer); |
305 | @@ -2305,9 +2306,9 @@ |
306 | _closed.set(true); |
307 | } else if (e instanceof PersistitException) { |
308 | _persistit.getAlertMonitor().post( |
309 | - new Event(_persistit.getLogBase().journalWriteError, e, |
310 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().journalWriteError, e, |
311 | addressToFile(_writeBufferAddress), addressToOffset(_writeBufferAddress)), |
312 | - AlertMonitor.JOURNAL_CATEGORY, AlertLevel.ERROR); |
313 | + AlertMonitor.JOURNAL_CATEGORY); |
314 | } else { |
315 | _persistit.getLogBase().journalWriteError.log(e, addressToFile(_writeBufferAddress), |
316 | addressToOffset(_writeBufferAddress)); |
317 | @@ -2630,17 +2631,17 @@ |
318 | int journalFileCount = getJournalFileCount(); |
319 | if (journalFileCount != _lastReportedJournalFileCount) { |
320 | if (journalFileCount > TOO_MANY_ERROR_THRESHOLD) { |
321 | - _persistit.getAlertMonitor().post( |
322 | - new Event(_persistit.getLogBase().tooManyJournalFilesError, journalFileCount), |
323 | - AlertMonitor.MANY_JOURNAL_FILES, AlertLevel.ERROR); |
324 | + _persistit.getAlertMonitor() |
325 | + .post(new Event(AlertLevel.ERROR, _persistit.getLogBase().tooManyJournalFilesError, |
326 | + journalFileCount), AlertMonitor.MANY_JOURNAL_FILES); |
327 | } else if (journalFileCount > TOO_MANY_WARN_THRESHOLD) { |
328 | - _persistit.getAlertMonitor().post( |
329 | - new Event(_persistit.getLogBase().tooManyJournalFilesWarning, journalFileCount), |
330 | - AlertMonitor.MANY_JOURNAL_FILES, AlertLevel.WARN); |
331 | + _persistit.getAlertMonitor() |
332 | + .post(new Event(AlertLevel.WARN, _persistit.getLogBase().tooManyJournalFilesWarning, |
333 | + journalFileCount), AlertMonitor.MANY_JOURNAL_FILES); |
334 | } else { |
335 | _persistit.getAlertMonitor().post( |
336 | - new Event(_persistit.getLogBase().normalJournalFileCount, journalFileCount), |
337 | - AlertMonitor.MANY_JOURNAL_FILES, AlertLevel.NORMAL); |
338 | + new Event(AlertLevel.NORMAL, _persistit.getLogBase().normalJournalFileCount, journalFileCount), |
339 | + AlertMonitor.MANY_JOURNAL_FILES); |
340 | } |
341 | _lastReportedJournalFileCount = journalFileCount; |
342 | } |
343 | @@ -2687,7 +2688,7 @@ |
344 | } |
345 | |
346 | class ProactiveRollbackListener implements TransactionPlayerListener { |
347 | - |
348 | + |
349 | TransactionStatus status; |
350 | |
351 | @Override |
352 | |
353 | === modified file 'src/main/java/com/persistit/Management.java' |
354 | --- src/main/java/com/persistit/Management.java 2012-05-25 18:50:59 +0000 |
355 | +++ src/main/java/com/persistit/Management.java 2012-06-22 19:37:18 +0000 |
356 | @@ -25,6 +25,9 @@ |
357 | import java.rmi.Remote; |
358 | import java.rmi.RemoteException; |
359 | import java.util.Date; |
360 | +import java.util.Map; |
361 | + |
362 | +import javax.management.ObjectName; |
363 | |
364 | import com.persistit.encoding.CoderContext; |
365 | import com.persistit.mxbeans.ManagementMXBean; |
366 | @@ -698,6 +701,29 @@ |
367 | public void setDisplayFilter(DisplayFilter displayFilter) throws RemoteException; |
368 | |
369 | /** |
370 | + * Return an unmodifiable map of all MXBeans registered in the Persistit |
371 | + * instance. The map key is the ObjectName used in identifying the MXBean |
372 | + * within the JMX framework. For most of the MXBean instance you can |
373 | + * construct the ObjectName from a constant in the interface. for example |
374 | + * |
375 | + * <code><pre> |
376 | + * ObjectName on = |
377 | + * new ObjectName(JournalManagerMXBean.MXBEAN_NAME); |
378 | + * </pre></code> |
379 | + * |
380 | + * For BufferPoolMXBean instances, use |
381 | + * |
382 | + * <code><pre> |
383 | + * ObjectName on = |
384 | + * new ObjectName(BufferPoolMXBean.MXBEAN_NAME + "." + bufferSize); |
385 | + * </pre></code> |
386 | + * |
387 | + * |
388 | + * @return Map of ObjectName to Object for all registered MXBeans |
389 | + */ |
390 | + Map<ObjectName, Object> getMXBeans() throws RemoteException; |
391 | + |
392 | + /** |
393 | * A DisplayFilter formats the String value presented in the Tree tab of the |
394 | * AdminUI. Invoke {@link ManagementImpl#setDisplayFilter(DisplayFilter)} to |
395 | * supply a non-default DisplayFilter. |
396 | |
397 | === modified file 'src/main/java/com/persistit/ManagementImpl.java' |
398 | --- src/main/java/com/persistit/ManagementImpl.java 2012-05-25 18:50:59 +0000 |
399 | +++ src/main/java/com/persistit/ManagementImpl.java 2012-06-22 19:37:18 +0000 |
400 | @@ -27,11 +27,15 @@ |
401 | import java.rmi.registry.LocateRegistry; |
402 | import java.rmi.server.UnicastRemoteObject; |
403 | import java.util.ArrayList; |
404 | +import java.util.Collections; |
405 | import java.util.HashMap; |
406 | import java.util.Iterator; |
407 | import java.util.List; |
408 | +import java.util.Map; |
409 | import java.util.Vector; |
410 | |
411 | +import javax.management.ObjectName; |
412 | + |
413 | import com.persistit.encoding.CoderContext; |
414 | import com.persistit.encoding.ValueCoder; |
415 | import com.persistit.exception.PersistitException; |
416 | @@ -162,6 +166,11 @@ |
417 | return getVolumeInfoArray(); |
418 | } |
419 | |
420 | + @Override |
421 | + public Map<ObjectName, Object> getMXBeans() { |
422 | + return _persistit.getMXBeans(); |
423 | + } |
424 | + |
425 | /** |
426 | * Indicates whether Persistit will suspend its shutdown activities on |
427 | * invocation of {@link #close}. This flag is intended for use by management |
428 | @@ -273,11 +282,13 @@ |
429 | public String getDefaultCommitPolicy() { |
430 | return _persistit.getDefaultTransactionCommitPolicy().toString(); |
431 | } |
432 | - |
433 | + |
434 | /** |
435 | - * Modify the current default <code>CommitPolicy</code>. The |
436 | - * policy name must be one of "hard", "group" or "commit". |
437 | - * @param policyName name of the <code>CommitPolicy</code> to set. |
438 | + * Modify the current default <code>CommitPolicy</code>. The policy name |
439 | + * must be one of "hard", "group" or "commit". |
440 | + * |
441 | + * @param policyName |
442 | + * name of the <code>CommitPolicy</code> to set. |
443 | */ |
444 | @Override |
445 | public void setDefaultCommitPolicy(String policyName) { |
446 | @@ -1030,8 +1041,8 @@ |
447 | * @throws RemoteException |
448 | */ |
449 | @Override |
450 | - public synchronized long startTask(String description, String owner, String commandLine, long maximumTime, int verbosity) |
451 | - throws RemoteException { |
452 | + public synchronized long startTask(String description, String owner, String commandLine, long maximumTime, |
453 | + int verbosity) throws RemoteException { |
454 | try { |
455 | Task task = CLI.parseTask(_persistit, commandLine); |
456 | if (task == null) { |
457 | @@ -1047,8 +1058,7 @@ |
458 | throw new WrappedRemoteException(ex); |
459 | } |
460 | } |
461 | - |
462 | - |
463 | + |
464 | /** |
465 | * Queries the current status of one or all tasks. If the specified taskId |
466 | * value is -1, this method returns status information for all currently |
467 | @@ -1069,7 +1079,7 @@ |
468 | public synchronized TaskStatus[] queryTaskStatus(long taskId, boolean details, boolean clearMessages) { |
469 | return queryTaskStatus(taskId, details, clearMessages, true); |
470 | } |
471 | - |
472 | + |
473 | /** |
474 | * Queries the current status of one or all tasks. If the specified taskId |
475 | * value is -1, this method returns status information for all currently |
476 | @@ -1090,7 +1100,8 @@ |
477 | * @throws RemoteException |
478 | */ |
479 | @Override |
480 | - public synchronized TaskStatus[] queryTaskStatus(long taskId, boolean details, boolean clearMessages, boolean clearTasks) { |
481 | + public synchronized TaskStatus[] queryTaskStatus(long taskId, boolean details, boolean clearMessages, |
482 | + boolean clearTasks) { |
483 | if (taskId == -1) { |
484 | int size = _tasks.size(); |
485 | int index = 0; |
486 | |
487 | === modified file 'src/main/java/com/persistit/Persistit.java' |
488 | --- src/main/java/com/persistit/Persistit.java 2012-06-14 20:15:48 +0000 |
489 | +++ src/main/java/com/persistit/Persistit.java 2012-06-22 19:37:18 +0000 |
490 | @@ -774,6 +774,8 @@ |
491 | monitor.setObjectName(on); |
492 | emitter = monitor; |
493 | } |
494 | + |
495 | + @SuppressWarnings({ "unchecked", "rawtypes" }) |
496 | MXBeanWrapper wrapper = new MXBeanWrapper(mbean, mbeanInterface, emitter); |
497 | server.registerMBean(wrapper, on); |
498 | |
499 | @@ -783,6 +785,10 @@ |
500 | _alertMonitors.add((AlertMonitorMXBean) mbean); |
501 | } |
502 | } |
503 | + |
504 | + Map<ObjectName, Object> getMXBeans() { |
505 | + return Collections.unmodifiableMap(_mxbeans); |
506 | + } |
507 | |
508 | private void unregisterMXBeans() { |
509 | MBeanServer server = java.lang.management.ManagementFactory.getPlatformMBeanServer(); |
510 | @@ -2169,7 +2175,7 @@ |
511 | return _ioMeter; |
512 | } |
513 | |
514 | - AlertMonitor getAlertMonitor() { |
515 | + public AlertMonitor getAlertMonitor() { |
516 | return _alertMonitor; |
517 | } |
518 | |
519 | |
520 | === modified file 'src/main/java/com/persistit/VolumeStorageT2.java' |
521 | --- src/main/java/com/persistit/VolumeStorageT2.java 2012-05-25 18:50:59 +0000 |
522 | +++ src/main/java/com/persistit/VolumeStorageT2.java 2012-06-22 19:37:18 +0000 |
523 | @@ -282,8 +282,8 @@ |
524 | _volume.getStatistics().bumpReadCounter(); |
525 | } catch (IOException ioe) { |
526 | _persistit.getAlertMonitor().post( |
527 | - new Event(_persistit.getLogBase().readException, ioe, _volume, page, buffer.getIndex()), |
528 | - AlertMonitor.READ_PAGE_CATEGORY, AlertLevel.ERROR); |
529 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().readException, ioe, _volume, page, buffer |
530 | + .getIndex()), AlertMonitor.READ_PAGE_CATEGORY); |
531 | throw new PersistitIOException(ioe); |
532 | } |
533 | } finally { |
534 | @@ -319,8 +319,8 @@ |
535 | |
536 | } catch (IOException ioe) { |
537 | _persistit.getAlertMonitor().post( |
538 | - new Event(_persistit.getLogBase().writeException, ioe, _volume, page), |
539 | - AlertMonitor.WRITE_PAGE_CATEGORY, AlertLevel.ERROR); |
540 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().writeException, ioe, _volume, page), |
541 | + AlertMonitor.WRITE_PAGE_CATEGORY); |
542 | throw new PersistitIOException(ioe); |
543 | } |
544 | } finally { |
545 | |
546 | === modified file 'src/main/java/com/persistit/VolumeStorageV2.java' |
547 | --- src/main/java/com/persistit/VolumeStorageV2.java 2012-05-25 18:50:59 +0000 |
548 | +++ src/main/java/com/persistit/VolumeStorageV2.java 2012-06-22 19:37:18 +0000 |
549 | @@ -450,8 +450,9 @@ |
550 | _volume.getStatistics().bumpReadCounter(); |
551 | |
552 | } catch (IOException ioe) { |
553 | - _persistit.getAlertMonitor().post(new Event(_persistit.getLogBase().readException, ioe, _volume, page, buffer.getIndex()), |
554 | - AlertMonitor.READ_PAGE_CATEGORY, AlertLevel.ERROR); |
555 | + _persistit.getAlertMonitor().post( |
556 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().readException, ioe, _volume, page, buffer |
557 | + .getIndex()), AlertMonitor.READ_PAGE_CATEGORY); |
558 | throw new PersistitIOException(ioe); |
559 | } |
560 | } finally { |
561 | @@ -488,8 +489,9 @@ |
562 | try { |
563 | _channel.write(bb, page * _volume.getStructure().getPageSize()); |
564 | } catch (IOException ioe) { |
565 | - _persistit.getAlertMonitor().post(new Event(_persistit.getLogBase().writeException, ioe, _volume, page), |
566 | - AlertMonitor.WRITE_PAGE_CATEGORY, AlertLevel.ERROR); |
567 | + _persistit.getAlertMonitor().post( |
568 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().writeException, ioe, _volume, page), |
569 | + AlertMonitor.WRITE_PAGE_CATEGORY); |
570 | throw new PersistitIOException(ioe); |
571 | } |
572 | } |
573 | @@ -625,8 +627,9 @@ |
574 | _volume.getStatistics().setLastExtensionTime(System.currentTimeMillis()); |
575 | _extendedPageCount = pageCount; |
576 | } catch (IOException ioe) { |
577 | - _persistit.getAlertMonitor().post(new Event(_persistit.getLogBase().extendException, ioe, currentSize, newSize), |
578 | - AlertMonitor.EXTEND_VOLUME_CATEGORY, AlertLevel.ERROR); |
579 | + _persistit.getAlertMonitor().post( |
580 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().extendException, ioe, currentSize, newSize), |
581 | + AlertMonitor.EXTEND_VOLUME_CATEGORY); |
582 | throw new PersistitIOException(ioe); |
583 | } |
584 | } |
585 | |
586 | === modified file 'src/main/java/com/persistit/VolumeStructure.java' |
587 | --- src/main/java/com/persistit/VolumeStructure.java 2012-05-25 18:50:59 +0000 |
588 | +++ src/main/java/com/persistit/VolumeStructure.java 2012-06-22 19:37:18 +0000 |
589 | @@ -192,10 +192,10 @@ |
590 | _treeNameHashMap.put(name, new WeakReference<Tree>(tree)); |
591 | return tree; |
592 | } |
593 | - |
594 | + |
595 | /** |
596 | - * Helper method used by pruning. Allows access to directory tree |
597 | - * by name. |
598 | + * Helper method used by pruning. Allows access to directory tree by name. |
599 | + * |
600 | * @param name |
601 | * @return |
602 | * @throws PersistitException |
603 | @@ -252,7 +252,7 @@ |
604 | if (!tree.claim(true)) { |
605 | throw new InUseException("Unable to acquire writer claim on " + tree); |
606 | } |
607 | - |
608 | + |
609 | final int treeDepth = tree.getDepth(); |
610 | final long treeRootPage = tree.getRootPageAddr(); |
611 | |
612 | @@ -348,8 +348,9 @@ |
613 | storeTreeStatistics(tree); |
614 | } |
615 | } catch (Exception e) { |
616 | - _persistit.getAlertMonitor().post(new Event(_persistit.getLogBase().adminFlushException, e), |
617 | - AlertMonitor.FLUSH_STATISTICS_CATEGORY, AlertLevel.ERROR); |
618 | + _persistit.getAlertMonitor().post( |
619 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().adminFlushException, e), |
620 | + AlertMonitor.FLUSH_STATISTICS_CATEGORY); |
621 | } |
622 | } |
623 | |
624 | @@ -442,7 +443,7 @@ |
625 | boolean solitaire = rightPage == -1; |
626 | buffer = _pool.get(_volume, page, true, !solitaire); |
627 | buffer.writePageOnCheckpoint(timestamp); |
628 | - |
629 | + |
630 | Debug.$assert0.t(buffer.getPageAddress() > 0); |
631 | |
632 | long nextGarbagePage = solitaire ? -1 : buffer.getRightSibling(); |
633 | @@ -477,7 +478,8 @@ |
634 | _volume.getStorage().releaseHeadBuffer(); |
635 | } |
636 | /* |
637 | - * If there was no garbage chain above then we need to allocate a new page from the volume. |
638 | + * If there was no garbage chain above then we need to allocate a new |
639 | + * page from the volume. |
640 | */ |
641 | long page = _volume.getStorage().allocNewPage(); |
642 | buffer = _pool.get(_volume, page, true, false); |
643 | @@ -500,8 +502,8 @@ |
644 | if (garbagePage != 0) { |
645 | if (left == garbagePage || right == garbagePage) { |
646 | Debug.$assert0.t(false); |
647 | - throw new IllegalStateException("De-allocating page that is already garbage: " |
648 | - + "root=" + garbagePage + " left=" + left + " right=" + right); |
649 | + throw new IllegalStateException("De-allocating page that is already garbage: " + "root=" |
650 | + + garbagePage + " left=" + left + " right=" + right); |
651 | } |
652 | |
653 | garbageBuffer = _pool.get(_volume, garbagePage, true, true); |
654 | @@ -567,7 +569,7 @@ |
655 | } |
656 | return anyLongRecords; |
657 | } |
658 | - |
659 | + |
660 | private Buffer releaseBuffer(final Buffer buffer) { |
661 | if (buffer != null) { |
662 | buffer.releaseTouched(); |
663 | @@ -595,7 +597,7 @@ |
664 | public long getGarbageRoot() { |
665 | return _garbageRoot; |
666 | } |
667 | - |
668 | + |
669 | List<Long> getGarbageList() throws PersistitException { |
670 | List<Long> garbageList = new ArrayList<Long>(); |
671 | _volume.getStorage().claimHeadBuffer(); |
672 | @@ -605,11 +607,11 @@ |
673 | garbageList.add(root); |
674 | Buffer buffer = _pool.get(_volume, root, true, true); |
675 | try { |
676 | - for(Management.RecordInfo rec : buffer.getRecords()) { |
677 | + for (Management.RecordInfo rec : buffer.getRecords()) { |
678 | if (rec._garbageLeftPage > 0) { |
679 | garbageList.add(rec._garbageLeftPage); |
680 | } |
681 | - if (rec._garbageRightPage> 0) { |
682 | + if (rec._garbageRightPage > 0) { |
683 | garbageList.add(rec._garbageRightPage); |
684 | } |
685 | } |
686 | @@ -651,7 +653,7 @@ |
687 | } |
688 | return "@<" + buffer.getPageAddress() + ":" + buffer.getAlloc() + ">"; |
689 | } |
690 | - |
691 | + |
692 | synchronized boolean treeMapContainsName(String treeName) { |
693 | return _treeNameHashMap.containsKey(treeName); |
694 | } |
695 | |
696 | === modified file 'src/main/java/com/persistit/mxbeans/IOMeterMXBean.java' |
697 | --- src/main/java/com/persistit/mxbeans/IOMeterMXBean.java 2012-05-25 18:50:59 +0000 |
698 | +++ src/main/java/com/persistit/mxbeans/IOMeterMXBean.java 2012-06-22 19:37:18 +0000 |
699 | @@ -21,6 +21,8 @@ |
700 | package com.persistit.mxbeans; |
701 | |
702 | import java.io.IOException; |
703 | +import java.util.HashMap; |
704 | +import java.util.Map; |
705 | |
706 | import javax.management.MXBean; |
707 | |
708 | @@ -47,30 +49,27 @@ |
709 | * <dt>RJ</dt> |
710 | * <dd>Read page from Journal</dd> |
711 | * <dt>CC</dt> |
712 | - * <dd>Page copy from Journal to Volume</dd> |
713 | + * <dd>Copy page from journal to volume</dd> |
714 | * <dt>WJ</dt> |
715 | * <dd>Write page from Journal</dd> |
716 | - * <dt>TS</dt> |
717 | - * <dd>Transaction Start</dd> |
718 | - * <dt>TC</dt> |
719 | - * <dd>Transaction Commit</dd> |
720 | - * <dt>SR</dt> |
721 | - * <dd>Store Record</dd> |
722 | - * <dt>DR</dt> |
723 | - * <dd>Delete Record or Range</dd> |
724 | - * <dt>DT</dt> |
725 | - * <dd>Delete Tree</dd> |
726 | + * <dt>TJ</dt> |
727 | + * <dd>Write Transaction to Journal</dd> |
728 | * <dt>XX</dt> |
729 | * <dd>Other</dd> |
730 | * <dt>EV</dt>D |
731 | * <dd>Evict page from pool</dd> |
732 | * <dt>FJ</dt> |
733 | * <dd>Flush journal</dd> |
734 | + * <dt>GP</dt> |
735 | + * <dd>Get Page</dd> |
736 | * </dl> |
737 | * |
738 | */ |
739 | - public final static String[] OPERATIONS = { "??", "RV", "RJ", "CC", "WJ", "TS", "TC", "SR", "DR", "DT", "XX", "EV", |
740 | - "FJ", "GP" }; |
741 | + public final static String[] OPERATION_NAMES = { "Unknown", "Read page from Volume", "Read page from Journal", |
742 | + "Copy page from journal to volume", "Write page from Journal", "Write Transaction to Journal", "Other", |
743 | + "Evict page from pool", "Flush journal", "Get page" }; |
744 | + |
745 | + public final static String[] OPERATIONS = { "??", "RV", "RJ", "CC", "WJ", "TJ", "XX", "EV", "FJ", "GP" }; |
746 | |
747 | public final static String[] SUMMARY_ITEMS = { "CC", "RV", "RJ", "WJ", "EV", "FJ" }; |
748 | |
749 | |
750 | === modified file 'src/test/java/com/persistit/AlertMonitorTest.java' |
751 | --- src/test/java/com/persistit/AlertMonitorTest.java 2012-05-25 18:50:59 +0000 |
752 | +++ src/test/java/com/persistit/AlertMonitorTest.java 2012-06-22 19:37:18 +0000 |
753 | @@ -78,8 +78,8 @@ |
754 | |
755 | class AggregatingEvent extends Event { |
756 | |
757 | - AggregatingEvent(LogItem logItem, Object... args) { |
758 | - super(logItem, args); |
759 | + AggregatingEvent(AlertLevel level, LogItem logItem, Object... args) { |
760 | + super(level, logItem, args); |
761 | } |
762 | |
763 | protected void added(final History h) { |
764 | @@ -102,7 +102,7 @@ |
765 | public void testPostEvents() throws Exception { |
766 | AlertMonitor monitor = _persistit.getAlertMonitor(); |
767 | for (int index = 0; index < 100; index++) { |
768 | - monitor.post(new Event(_persistit.getLogBase().copyright, index), CATEGORY, AlertLevel.NORMAL); |
769 | + monitor.post(new Event(AlertLevel.NORMAL, _persistit.getLogBase().copyright, index), CATEGORY); |
770 | } |
771 | History history = monitor.getHistory(CATEGORY); |
772 | assertNotNull(history); |
773 | @@ -120,8 +120,8 @@ |
774 | monitor.poll(true); |
775 | assertNull("At AlertLevel.NORMAL there should not be a log message", _lastMessage); |
776 | for (int index = 0; index < 100; index++) { |
777 | - monitor.post(new Event(_persistit.getLogBase().exception, new RuntimeException("Bogus " + index)), |
778 | - CATEGORY, AlertLevel.ERROR); |
779 | + monitor.post(new Event(AlertLevel.ERROR, _persistit.getLogBase().exception, new RuntimeException("Bogus " |
780 | + + index)), CATEGORY); |
781 | } |
782 | monitor.poll(true); |
783 | assertNotNull("At AlertLevel.ERROR there should be a log message", _lastMessage); |
784 | @@ -140,13 +140,13 @@ |
785 | public void testChangeHistoryLength() throws Exception { |
786 | AlertMonitor monitor = _persistit.getAlertMonitor(); |
787 | for (int index = 0; index < 100; index++) { |
788 | - monitor.post(new AggregatingEvent(_persistit.getLogBase().copyright, index), CATEGORY, AlertLevel.NORMAL); |
789 | + monitor.post(new AggregatingEvent(AlertLevel.NORMAL, _persistit.getLogBase().copyright, index), CATEGORY); |
790 | } |
791 | History history = monitor.getHistory(CATEGORY); |
792 | assertEquals("History should have 10 events", 10, history.getEventList().size()); |
793 | monitor.setHistoryLength(5); |
794 | assertEquals("History should now have 5 events", 5, history.getEventList().size()); |
795 | - monitor.post(new AggregatingEvent(_persistit.getLogBase().copyright, 101), CATEGORY, AlertLevel.NORMAL); |
796 | + monitor.post(new AggregatingEvent(AlertLevel.NORMAL, _persistit.getLogBase().copyright, 101), CATEGORY); |
797 | assertEquals("History should still have 5 events", 5, history.getEventList().size()); |
798 | assertEquals("Total of 101 events added", 101, _added); |
799 | assertEquals("Total of 101-5 events removed", 101 - 5, _removed); |
800 | @@ -161,7 +161,7 @@ |
801 | ((AlertMonitorTest) handback)._notification = notification; |
802 | } |
803 | }, null, this); |
804 | - monitor.post(new Event(_persistit.getLogBase().copyright, 2012), CATEGORY, AlertLevel.ERROR); |
805 | + monitor.post(new Event(AlertLevel.ERROR, _persistit.getLogBase().copyright, 2012), CATEGORY); |
806 | Thread.sleep(1000); |
807 | assertNotNull(_notification); |
808 | } |
I have more items for this list, if you don't mind. If we can hold on on approving this until I complete my list we should be able have all these changes in one merge.