@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); }
public static void addTracer(Class<?> type, String method, Channel channel, int max) { channel.setAttribute(TRACE_MAX, max); channel.setAttribute(TRACE_COUNT, new AtomicInteger()); String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName(); Set<Channel> channels = tracers.get(key); if (channels == null) { tracers.putIfAbsent(key, new ConcurrentHashSet<>()); channels = tracers.get(key); } channels.add(channel); }
public static void addTracer(Class<?> type, String method, Channel channel, int max) { channel.setAttribute(TRACE_MAX, max); channel.setAttribute(TRACE_COUNT, new AtomicInteger()); String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName(); Set<Channel> channels = tracers.get(key); if (channels == null) { tracers.putIfAbsent(key, new ConcurrentHashSet<>()); channels = tracers.get(key); } channels.add(channel); }
@Override public void setAttribute(String key, Object value) { Channel channel = getChannel(); if (channel == null) { return; } channel.setAttribute(key, value); }
@Override public void setAttribute(String key, Object value) { Channel channel = getChannel(); if (channel == null) { return; } channel.setAttribute(key, value); }
@Override public void connected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.connected(exchangeChannel); } finally { HeaderExchangeChannel.removeChannelIfDisconnected(channel); } }
@Override public void connected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.connected(exchangeChannel); } finally { HeaderExchangeChannel.removeChannelIfDisconnected(channel); } }
void handlerEvent(Channel channel, Request req) throws RemotingException { if (req.getData() != null && req.getData().equals(Request.READONLY_EVENT)) { channel.setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); } }
@Override public void disconnected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.disconnected(exchangeChannel); } finally { DefaultFuture.closeChannel(channel); HeaderExchangeChannel.removeChannelIfDisconnected(channel); } }
void handlerEvent(Channel channel, Request req) throws RemotingException { if (req.getData() != null && req.getData().equals(Request.READONLY_EVENT)) { channel.setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); } }
@Override public void disconnected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); try { handler.disconnected(exchangeChannel); } finally { DefaultFuture.closeChannel(channel); HeaderExchangeChannel.removeChannelIfDisconnected(channel); } }
private static void decreaseInstanceCount(Channel channel, String countkey) { try { Integer count = (Integer) channel.getAttribute(countkey); if (count == null || count <= 0) { return; } else { count--; } channel.setAttribute(countkey, count); } catch (Exception e) { logger.error(e.getMessage(), e); } }
private static void decreaseInstanceCount(Channel channel, String countkey) { try { Integer count = (Integer) channel.getAttribute(countkey); if (count == null || count <= 0) { return; } else { count--; } channel.setAttribute(countkey, count); } catch (Exception e) { logger.error(e.getMessage(), e); } }
static HeaderExchangeChannel getOrAddChannel(Channel ch) { if (ch == null) { return null; } HeaderExchangeChannel ret = (HeaderExchangeChannel) ch.getAttribute(CHANNEL_KEY); if (ret == null) { ret = new HeaderExchangeChannel(ch); if (ch.isConnected()) { ch.setAttribute(CHANNEL_KEY, ret); } } return ret; }
static HeaderExchangeChannel getOrAddChannel(Channel ch) { if (ch == null) { return null; } HeaderExchangeChannel ret = (HeaderExchangeChannel) ch.getAttribute(CHANNEL_KEY); if (ret == null) { ret = new HeaderExchangeChannel(ch); if (ch.isConnected()) { ch.setAttribute(CHANNEL_KEY, ret); } } return ret; }