StatisticsHandler.java revision adf530d70e0ee974cd0bace4db9967617819cec1
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyrighted [year] [name of copyright owner]".
*
* Copyright © 2012 ForgeRock AS. All rights reserved.
*/
/**
* Event handler for monitoring and statistics
*
* @author aegloff
*/
public class StatisticsHandler implements
/**
* Access to the ring buffer for monitoring/history display purposes
*/
//Disruptor<DisruptorEventEntry> disruptor;
/**
* Keep track of monitoring data per event Name
*/
public StatisticsHandler(
/*Disruptor<DisruptorEventEntry> disruptor*/
try {
}
}
/**
* @inheritDoc
*/
}
return stats;
}
/**
* @inheritDoc
*/
// TODO: consider adding history for not yet end()ed events
// Present history ordered by start time, with latest start time first
}
}
}
return recent;
}
/**
* @inheritDoc
*/
public void resetAllStatistics() {
}
}
/**
* @inheritDoc
*/
} else {
throw new IllegalArgumentException("Event name " + eventName + " does not match an existing name.");
}
}
// TODO: move out of statistics
/**
* @inheritDoc
*/
} else {
throw new IllegalArgumentException("Event name " + eventName + " does not match an existing name.");
}
}
// TODO: move out of statistics
/**
* @inheritDoc
*/
}
return enabledMap;
}
// TODO: move out of statistics
/**
* @inheritDoc
*/
} else {
throw new IllegalArgumentException("Event name " + eventName + " does not match an existing name.");
}
}
// TODO: move out of statistics
/**
* @inheritDoc
*/
}
return enabledMap;
}
/**
* TODO: if DisruptorShortEventEntry gets removed, remove as well
*
* Consumes the events off the ring buffer
*/
public void onEvent(final DisruptorShortEventEntry eventEntry, final long sequence, final boolean endOfBatch) throws Exception {
// Oddly enough in initial tests this seems slower than requiring map lookups
/*
MonitoringInfo info = eventEntry.eventName.monitoring;
info.totalTime += diff;
++info.totalInvokes;
*/
entry = new MonitoringInfo();
}
}
// TODO: more research on latency of batched end time option
// Mark the beginning of processing a batch of events
boolean newBatch = true;
long batchTime = -1;
/**
* Consumes the events off the ring buffer
*/
public void onEvent(final DisruptorReferringEventEntry eventEntryWrap, final long sequence, final boolean endOfBatch) throws Exception {
if (newBatch) {
}
// TODO: provide switch for batch or individual end time
// eventEntryWrap.endTime = batchTime;
entry = new MonitoringInfo();
}
if (endOfBatch) {
newBatch = true;
} else {
newBatch = false;
}
}
/**
* Helper to format nanosecond difference in human readable ms
* if a negative value is passed, returns "N/A"
*/
// Convert from nanoseconds to milliseconds
if (nanoseconds >= 0) {
} else {
return "N/A";
}
}
}