private class Updater implements Runnable {
public void run() {
try {
Collection<Monitorable<?>> monitorablesToUpdate = new ArrayList<Monitorable<?>>();
PcpWriter writerCopy;
while ((writerCopy = pcpWriter) != null) {
try {
monitorablesToUpdate.add(monitorablesPendingUpdate.take());
monitorablesPendingUpdate.drainTo(monitorablesToUpdate);
for (Monitorable<?> monitorable : monitorablesToUpdate) {
writerCopy.updateMetric(mapper.map(monitorable
.getName()), monitorable.get());
}
if (monitorablesPendingUpdate.size() >= UPDATE_QUEUE_SIZE) {
LOG.warn("Update queue was full - some updates may have been lost.");
}