public static ShardingVO getShardingVo(){ return contextHolder.get(); }
/** * Bind the specified stream to the current thread. * * @param input the stream to bind * @return the InputStream that was previously active */ public InputStream bindStream( final InputStream input ) { final InputStream oldValue = m_streams.get(); m_streams.set( input ); return oldValue; }
/** * Binds the specified stream to the current thread. * * @param output * the stream to bind * @return the OutputStream that was previously active */ public OutputStream bindStream(final OutputStream output) { final OutputStream stream = outputStreamThreadLocal.get(); outputStreamThreadLocal.set(output); return stream; }
/** * Return request baseUri previously set by {@link #setBaseUri(java.net.URI)}. * * Returned {@link URI} is used for absolutization of the location header in case that only a relative * {@code URI} was provided. * * @return baseUri of the actual request * @see #location(java.net.URI) * @since 2.4 */ private static URI getBaseUri() { return baseUriThreadLocal.get(); }
/** * Return request baseUri previously set by {@link #setBaseUri(java.net.URI)}. * * Returned {@link URI} is used for absolutization of the location header in case that only a relative * {@code URI} was provided. * * @return baseUri of the actual request * @see #location(java.net.URI) * @since 2.4 */ private static URI getBaseUri() { return baseUriThreadLocal.get(); }
/** * Closes stream associated with current thread. * * @throws IOException * if an error occurs */ @Override public void close() throws IOException { final OutputStream output = outputStreamThreadLocal.get(); if (null != output) { output.close(); } }
/** * Flushes stream associated with current thread. * * @throws IOException * if an error occurs */ @Override public void flush() throws IOException { @SuppressWarnings("resource") final OutputStream output = outputStreamThreadLocal.get(); if (null != output) { output.flush(); } }
/** * Remove the the context identified by the <code>key</code> parameter. */ public void remove(String key) { Map<String, String> map = inheritableThreadLocal.get(); if (map != null) { map.remove(key); } }
/** * Get the context identified by the <code>key</code> parameter. */ public String get(String key) { Map<String, String> map = inheritableThreadLocal.get(); if ((map != null) && (key != null)) { return map.get(key); } else { return null; } }
/** * Closes stream associated with current thread. * * @throws IOException if an error occurs */ @Override public void close() throws IOException { final InputStream input = m_streams.get(); if( null != input ) { input.close(); } }
/** * Return a copy of the current thread's context map. * Returned value may be null. * */ public Map<String, String> getCopyOfContextMap() { Map<String, String> oldMap = inheritableThreadLocal.get(); if (oldMap != null) { return new HashMap<String, String>(oldMap); } else { return null; } }
/** * Writes byte to stream associated with current thread. * * @param ch * the byte to write to stream * @throws IOException * if an error occurs */ @Override public void write(final int ch) throws IOException { @SuppressWarnings("resource") final OutputStream output = outputStreamThreadLocal.get(); if (null != output) { output.write(ch); } } }
/** * Returns the keys in the MDC as a {@link Set} of {@link String}s The * returned value can be null. * * @return the keys in the MDC */ public Set<String> getKeys() { Map<String, String> map = inheritableThreadLocal.get(); if (map != null) { return map.keySet(); } else { return null; } }
/** * Read byte from stream associated with current thread. * * @return the byte read from stream * @throws IOException if an error occurs */ @Override public int read() throws IOException { final InputStream input = m_streams.get(); if( null != input ) { return input.read(); } else { return EOF; } } }
/** * Remove the the context identified by the <code>key</code> parameter. */ public void remove(String key) { Map<String, String> map = inheritableThreadLocal.get(); if (map != null) { map.remove(key); } }
/** * Get the context identified by the <code>key</code> parameter. */ public String get(String key) { Map<String, String> map = inheritableThreadLocal.get(); if ((map != null) && (key != null)) { return map.get(key); } else { return null; } }
/** * Return a copy of the current thread's context map. * Returned value may be null. * */ public Map<String, String> getCopyOfContextMap() { Map<String, String> oldMap = inheritableThreadLocal.get(); if (oldMap != null) { return new HashMap<String, String>(oldMap); } else { return null; } }
/** * Clear all entries in the MDC. */ public void clear() { Map<String, String> map = inheritableThreadLocal.get(); if (map != null) { map.clear(); inheritableThreadLocal.remove(); } }
public static void clearThreadAttempt(String attemptId) { assert attemptId != null; String attemptIdCheck = threadAttemptId.get(); if (!attemptId.equals(attemptIdCheck)) { LOG.error("Thread is clearing context for " + attemptId + ", but " + attemptIdCheck + " expected"); } attemptMap.remove(attemptId); threadAttemptId.remove(); }
/** * Clear all entries in the MDC. */ public void clear() { Map<String, String> map = inheritableThreadLocal.get(); if (map != null) { map.clear(); inheritableThreadLocal.remove(); } }