@Override public String toString() { return String.format("{ label:%s, enqueued:%d, dequeued:%d, max_wait_time:%.2f ms, max_run_time:%.2f ms, total_run_time:%.2f ms, total_wait_time:%.2f ms }", queue.getLabel(), enqueued, dequeued, maxWaitTimeNS / 1000000.0f, maxRunTimeNS / 1000000.0f, totalRunTimeNS / 1000000.0f, totalWaitTimeNS / 1000000.0f); } }
public static class KeyState { int readyOps; final NioAttachment attachment; public SelectionKey key() { return attachment.key(); } public KeyState(NioAttachment attachment) { this.attachment = attachment; } @Override public String toString() { return "{ready: "+opsToString(readyOps)+" }"; } }
private void trace(String message) { if( LOG.isTraceEnabled() ) { final String label = dispatchQueue.getLabel(); if( label !=null ) { LOG.trace(label +" | "+message); } else { LOG.trace(message); } } }
private void trace(String message) { if( LOG.isTraceEnabled() ) { final String label = dispatchQueue.getLabel(); if( label !=null ) { LOG.trace(label +" | "+message); } else { LOG.trace(message); } } }
public static CompositeData convert(Metrics metric, TimeUnit timeUnit) throws OpenDataException { Map<String, Object> fields = new HashMap<String, Object>(); fields.put("label", metric.queue.getLabel()); fields.put("duration", ((double)metric.durationNS) / timeUnit.toNanos(1)); fields.put("enqueued", metric.enqueued); fields.put("enqueueTimeMean", (((double)metric.totalWaitTimeNS) / timeUnit.toNanos(1))/ metric.dequeued); fields.put("enqueueTimeMax", ((double)metric.maxWaitTimeNS) / timeUnit.toNanos(1) ); fields.put("enqueueTimeTotal", ((double)metric.totalWaitTimeNS) / timeUnit.toNanos(1)); fields.put("executed", metric.dequeued); fields.put("executeTimeMean", (((double)metric.totalRunTimeNS) / timeUnit.toNanos(1))/ metric.dequeued); fields.put("executeTimeMax", ((double)metric.maxRunTimeNS) / timeUnit.toNanos(1)); fields.put("executeTimeTotal", ((double)metric.totalRunTimeNS) / timeUnit.toNanos(1)); return new CompositeDataSupport(METRICS_COMPOSITE_TYPE, fields); }
String assertMessage(String label) { StringBuilder sb = new StringBuilder(); sb.append("Dispatch queue '"); if(label!=null ) { sb.append(label); } else { sb.append("<no-label>"); } sb.append("' was not executing, (currently executing: '"); DispatchQueue q = getCurrentQueue(); if( q!=null ) { if( q.getLabel()!=null ) { sb.append(q.getLabel()); } else { sb.append("<no-label>"); } } else { sb.append("<not-dispatched>"); } sb.append("')"); return sb.toString(); }
public void setTargetQueue(DispatchQueue next) { super.setTargetQueue(next); // The target thread queue might be different. Optimize by switching the selector to it. // Do we need to switch selector threads? DispatchQueue queue = next; while( queue.getQueueType()!=THREAD_QUEUE && queue.getTargetQueue() !=null ) { queue = queue.getTargetQueue(); } if( queue.getQueueType()==THREAD_QUEUE && queue!=selectorQueue ) { DispatchQueue previous = selectorQueue; final DispatchQueue newQueue = queue; debug("Switching to " + newQueue.getLabel()); selectorQueue = queue; if( previous!=null ) { previous.execute(new Task(){ public void run() { key_cancel(); register_on(newQueue); } }); } else { register_on(newQueue); } } }