本文整理汇总了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();
}
}
示例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;
}
};
}
示例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);
}
};
}
示例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);
}
示例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();
}
}