当前位置: 首页>>代码示例>>Java>>正文


Java Monitor类代码示例

本文整理汇总了Java中com.alibaba.dubbo.monitor.Monitor的典型用法代码示例。如果您正苦于以下问题:Java Monitor类的具体用法?Java Monitor怎么用?Java Monitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Monitor类属于com.alibaba.dubbo.monitor包,在下文中一共展示了Monitor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMonitor

import com.alibaba.dubbo.monitor.Monitor; //导入依赖的package包/类
public Monitor getMonitor(URL url) {
	url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName());
	String key = url.toServiceString();
    LOCK.lock();
    try {
        Monitor monitor = MONITORS.get(key);
        if (monitor != null) {
            return monitor;
        }
        monitor = createMonitor(url);
        if (monitor == null) {
            throw new IllegalStateException("Can not create monitor " + url);
        }
        MONITORS.put(key, monitor);
        return monitor;
    } finally {
        // 释放锁
        LOCK.unlock();
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:AbstractMonitorFactory.java

示例2: createMonitor

import com.alibaba.dubbo.monitor.Monitor; //导入依赖的package包/类
protected Monitor createMonitor(final URL url) {
        return new Monitor() {

public URL getUrl() {
	return url;
}

public boolean isAvailable() {
	return true;
}

            public void destroy() {
            }
            
public void collect(URL statistics) {
}

public List<URL> lookup(URL query) {
	return null;
}
            
        };
    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:AbstractMonitorFactoryTest.java

示例3: getMonitor

import com.alibaba.dubbo.monitor.Monitor; //导入依赖的package包/类
public Monitor getMonitor(final URL url) {
        return new Monitor() {
            public URL getUrl() {
                return url;
            }
            public boolean isAvailable() {
                return true;
            }
            public void destroy() {
            }
            public void collect(URL statistics) {
                MonitorFilterTest.this.lastStatistics = statistics;
            }
public List<URL> lookup(URL query) {
	return Arrays.asList(MonitorFilterTest.this.lastStatistics);
}
        };
    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:MonitorFilterTest.java

示例4: createMonitor

import com.alibaba.dubbo.monitor.Monitor; //导入依赖的package包/类
@Override
protected Monitor createMonitor(URL url) {
    url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo"));
    if (url.getPath() == null || url.getPath().length() == 0) {
        url = url.setPath(MonitorService.class.getName());
    }
    String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY);
    if (filter == null || filter.length() == 0) {
        filter = "";
    } else {
        filter = filter + ",";
    }
    url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), 
            Constants.REFERENCE_FILTER_KEY, filter + "-monitor");
    Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url);
    MonitorService monitorService = proxyFactory.getProxy(monitorInvoker);
    return new DubboMonitor(monitorInvoker, monitorService);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:DubboMonitorFactroy.java

示例5: getMonitor

import com.alibaba.dubbo.monitor.Monitor; //导入依赖的package包/类
public Monitor getMonitor(URL url) {
	url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName());
	String key = url.toServiceString();
    LOCK.lock();
    try {//这里依然采用了缓存技术
        Monitor monitor = MONITORS.get(key);
        if (monitor != null) {
            return monitor;
        }
        monitor = createMonitor(url);
        if (monitor == null) {
            throw new IllegalStateException("Can not create monitor " + url);
        }
        MONITORS.put(key, monitor);
        return monitor;
    } finally {
        // 释放锁
        LOCK.unlock();
    }
}
 
开发者ID:DoubleSmile,项目名称:dubbo-learning,代码行数:21,代码来源:AbstractMonitorFactory.java


注:本文中的com.alibaba.dubbo.monitor.Monitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。