Package com.alibaba.otter.shared.communication.model.config

Examples of com.alibaba.otter.shared.communication.model.config.FindMediaEvent


    public MediaSubscribeManager(){
        // 注册一下事件处理
        ComputeFunction function = new ComputeFunction<String, String>() {

            public String apply(final String key, String oldValue) {
                FindMediaEvent event = new FindMediaEvent();
                event.setDataId(key);
                try {
                    Object obj = arbitrateCommmunicationClient.callManager(event);
                    if (obj != null && obj instanceof String) {
                        final String value = (String) obj;
                        if (!StringUtils.equalsIgnoreCase(oldValue, value)) {
                            // 触发一下变化
                            executor.submit(new Runnable() {

                                public void run() {
                                    Set<SubscribeCallback> callbacks = getCallbacks(key, null);
                                    for (SubscribeCallback callback : callbacks) {
                                        callback.callback(value);
                                    }
                                }
                            });
                        }
                        return value;
                    } else {
                        throw new ConfigException("No Such dataId[" + key + "]");
                    }
                } catch (Exception e) {
                    logger.error("call_manager_error", event.toString(), e);
                }
                // 其他情况直接返回内存中的旧值
                return oldValue;
            }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.communication.model.config.FindMediaEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.