Java Code Examples for com.alibaba.dubbo.remoting.Channel#removeAttribute()

The following examples show how to use com.alibaba.dubbo.remoting.Channel#removeAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeTelnetHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public String telnet(Channel channel, String message) {
    if (message == null || message.length() == 0) {
        return "Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService";
    }
    StringBuilder buf = new StringBuilder();
    if (message.equals("/") || message.equals("..")) {
        String service = (String) channel.getAttribute(SERVICE_KEY);
        channel.removeAttribute(SERVICE_KEY);
        buf.append("Cancelled default service " + service + ".");
    } else {
        boolean found = false;
        for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
            if (message.equals(exporter.getInvoker().getInterface().getSimpleName())
                    || message.equals(exporter.getInvoker().getInterface().getName())
                    || message.equals(exporter.getInvoker().getUrl().getPath())) {
                found = true;
                break;
            }
        }
        if (found) {
            channel.setAttribute(SERVICE_KEY, message);
            buf.append("Used the " + message + " as default.\r\nYou can cancel default service by command: cd /");
        } else {
            buf.append("No such service " + message);
        }
    }
    return buf.toString();
}
 
Example 2
Source File: TraceFilter.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public static void removeTracer(Class<?> type, String method, Channel channel) {
    channel.removeAttribute(TRACE_MAX);
    channel.removeAttribute(TRACE_COUNT);
    String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
    Set<Channel> channels = tracers.get(key);
    if (channels != null) {
        channels.remove(channel);
    }
}
 
Example 3
Source File: ChangeTelnetHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public String telnet(Channel channel, String message) {
    if (message == null || message.length() == 0) {
        return "Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService";
    }
    StringBuilder buf = new StringBuilder();
    if (message.equals("/") || message.equals("..")) {
        String service = (String) channel.getAttribute(SERVICE_KEY);
        channel.removeAttribute(SERVICE_KEY);
        buf.append("Cancelled default service " + service + ".");
    } else {
        boolean found = false;
        for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
            if (message.equals(exporter.getInvoker().getInterface().getSimpleName())
                    || message.equals(exporter.getInvoker().getInterface().getName())
                    || message.equals(exporter.getInvoker().getUrl().getPath())) {
                found = true;
                break;
            }
        }
        if (found) {
            channel.setAttribute(SERVICE_KEY, message);
            buf.append("Used the " + message + " as default.\r\nYou can cancel default service by command: cd /");
        } else {
            buf.append("No such service " + message);
        }
    }
    return buf.toString();
}
 
Example 4
Source File: TraceFilter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void removeTracer(Class<?> type, String method, Channel channel) {
    channel.removeAttribute(TRACE_MAX);
    channel.removeAttribute(TRACE_COUNT);
    String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
    Set<Channel> channels = tracers.get(key);
    if (channels != null) {
        channels.remove(channel);
    }
}
 
Example 5
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(Channel ch) {
    if (ch != null && ! ch.isConnected()) {
        ch.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 6
Source File: HeartbeatHandler.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
private void clearReadTimestamp(Channel channel) {
    channel.removeAttribute(KEY_READ_TIMESTAMP);
}
 
Example 7
Source File: HeartbeatHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void clearWriteTimestamp(Channel channel) {
    channel.removeAttribute(KEY_WRITE_TIMESTAMP);
}
 
Example 8
Source File: AbstractClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void removeAttribute(String key) {
    Channel channel = getChannel();
    if (channel == null)
        return;
    channel.removeAttribute(key);
}
 
Example 9
Source File: HeartbeatHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void clearWriteTimestamp(Channel channel) {
    channel.removeAttribute(KEY_WRITE_TIMESTAMP);
}
 
Example 10
Source File: HeaderExchangeChannel.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(Channel ch) {
    if (ch != null && ! ch.isConnected()) {
        ch.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 11
Source File: HeartbeatHandler.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
private void clearWriteTimestamp(Channel channel) {
    channel.removeAttribute(KEY_WRITE_TIMESTAMP);
}
 
Example 12
Source File: HeartbeatHandler.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
private void clearReadTimestamp(Channel channel) {
    channel.removeAttribute(KEY_READ_TIMESTAMP);
}
 
Example 13
Source File: AbstractClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void removeAttribute(String key) {
    Channel channel = getChannel();
    if (channel == null)
        return;
    channel.removeAttribute(key);
}
 
Example 14
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(Channel ch) {
    if (ch != null && ! ch.isConnected()) {
        ch.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 15
Source File: HeartbeatHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void clearWriteTimestamp(Channel channel) {
    channel.removeAttribute(KEY_WRITE_TIMESTAMP);
}
 
Example 16
Source File: HeartbeatHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void clearReadTimestamp(Channel channel) {
    channel.removeAttribute(KEY_READ_TIMESTAMP);
}
 
Example 17
Source File: HeartbeatHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void clearReadTimestamp(Channel channel) {
    channel.removeAttribute(KEY_READ_TIMESTAMP);
}
 
Example 18
Source File: HeaderExchangeChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(Channel ch) {
    if (ch != null && ! ch.isConnected()) {
        ch.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 19
Source File: HeaderExchangeChannel.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(Channel ch) {
    if (ch != null && !ch.isConnected()) {
        ch.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 20
Source File: HeartbeatHandler.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
private void clearWriteTimestamp(Channel channel) {
    channel.removeAttribute(KEY_WRITE_TIMESTAMP);
}