/** * Calls close() on all SpanReceivers created by this SpanReceiverHost. */ public synchronized void closeReceivers() { if (closed) return; closed = true; for (SpanReceiver rcvr : receivers) { try { rcvr.close(); } catch (IOException e) { LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e); } } } }
public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException { TracerPool pool = TracerPool.getGlobalTracerPool(); SpanReceiver[] receivers = pool.getReceivers(); SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length]; for (int i = 0; i < receivers.length; i++) { SpanReceiver receiver = receivers[i]; info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName()); } return info; }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
/** * Calls close() on all SpanReceivers created by this SpanReceiverHost. */ public synchronized void closeReceivers() { if (closed) return; closed = true; for (SpanReceiver rcvr : receivers) { try { rcvr.close(); } catch (IOException e) { LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e); } } } }
public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException { SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers(); for (SpanReceiver receiver : receivers) { if (receiver.getId() == spanReceiverId) { TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver); LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName()); return; } } throw new IOException("There is no span receiver with id " + spanReceiverId); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
/** * Calls close() on all SpanReceivers created by this SpanReceiverHost. */ public synchronized void closeReceivers() { if (closed) return; closed = true; for (SpanReceiver rcvr : receivers) { try { rcvr.close(); } catch (IOException e) { LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e); } } } }
public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException { StringBuilder configStringBuilder = new StringBuilder(); String prefix = ""; for (ConfigurationPair pair : info.configPairs) { configStringBuilder.append(prefix).append(pair.getKey()). append(" = ").append(pair.getValue()); prefix = ", "; } SpanReceiver rcvr = null; try { rcvr = new SpanReceiver.Builder(TraceUtils.wrapHadoopConf( confPrefix, conf, info.configPairs)). className(info.getClassName().trim()). build(); } catch (RuntimeException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } TracerPool.getGlobalTracerPool().addReceiver(rcvr); LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString()); return rcvr.getId(); }
/** * Remove and close all of the span receivers. */ private synchronized void removeAndCloseAllSpanReceivers() { SpanReceiver[] receivers = curReceivers; curReceivers = new SpanReceiver[0]; for (SpanReceiver receiver : receivers) { try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } } }
public synchronized SpanReceiverInfo[] listSpanReceivers() throws IOException { TracerPool pool = TracerPool.getGlobalTracerPool(); SpanReceiver[] receivers = pool.getReceivers(); SpanReceiverInfo[] info = new SpanReceiverInfo[receivers.length]; for (int i = 0; i < receivers.length; i++) { SpanReceiver receiver = receivers[i]; info[i] = new SpanReceiverInfo(receiver.getId(), receiver.getClass().getName()); } return info; }
/** * Remove and close all of the span receivers. */ private synchronized void removeAndCloseAllSpanReceivers() { SpanReceiver[] receivers = curReceivers; curReceivers = new SpanReceiver[0]; for (SpanReceiver receiver : receivers) { try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } } }
public synchronized void removeSpanReceiver(long spanReceiverId) throws IOException { SpanReceiver[] receivers = TracerPool.getGlobalTracerPool().getReceivers(); for (SpanReceiver receiver : receivers) { if (receiver.getId() == spanReceiverId) { TracerPool.getGlobalTracerPool().removeAndCloseReceiver(receiver); LOG.info("Successfully removed SpanReceiver " + spanReceiverId + " with class " + receiver.getClass().getName()); return; } } throw new IOException("There is no span receiver with id " + spanReceiverId); } }
/** * Remove and close all of the span receivers. */ private synchronized void removeAndCloseAllSpanReceivers() { SpanReceiver[] receivers = curReceivers; curReceivers = new SpanReceiver[0]; for (SpanReceiver receiver : receivers) { try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } } }
public synchronized long addSpanReceiver(SpanReceiverInfo info) throws IOException { StringBuilder configStringBuilder = new StringBuilder(); String prefix = ""; for (ConfigurationPair pair : info.configPairs) { configStringBuilder.append(prefix).append(pair.getKey()). append(" = ").append(pair.getValue()); prefix = ", "; } SpanReceiver rcvr = null; try { rcvr = new SpanReceiver.Builder(TraceUtils.wrapHadoopConf( confPrefix, conf, info.configPairs)). className(info.getClassName().trim()). build(); } catch (RuntimeException e) { LOG.info("Failed to add SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString(), e); throw e; } TracerPool.getGlobalTracerPool().addReceiver(rcvr); LOG.info("Successfully added SpanReceiver " + info.getClassName() + " with configuration " + configStringBuilder.toString()); return rcvr.getId(); }
public static void stopReceiver(SpanReceiver receiver) { if (receiver != null) { try { receiver.close(); receiver = null; } catch (IOException e) { Assert.fail("failed to close span receiver. " + e.getMessage()); } } } }
/** * Remove and close a span receiver. * * @param receiver The receiver to remove. * * @return True if the receiver was removed; false if it * did not exist in this pool. */ public boolean removeAndCloseReceiver(SpanReceiver receiver) { if (!removeReceiver(receiver)) { return false; } try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } return true; }
/** * Remove and close a span receiver. * * @param receiver The receiver to remove. * * @return True if the receiver was removed; false if it * did not exist in this pool. */ public boolean removeAndCloseReceiver(SpanReceiver receiver) { if (!removeReceiver(receiver)) { return false; } try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } return true; }
/** * Remove and close a span receiver. * * @param receiver The receiver to remove. * * @return True if the receiver was removed; false if it * did not exist in this pool. */ public boolean removeAndCloseReceiver(SpanReceiver receiver) { if (!removeReceiver(receiver)) { return false; } try { LOG.trace(toString() + ": closing receiver " + receiver.toString()); receiver.close(); } catch (Throwable t) { LOG.error(toString() + ": error closing " + receiver.toString(), t); } return true; }