- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.monitoring.mbeans.ZkClientMonitor
类的一些代码示例,展示了ZkClientMonitor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClientMonitor
类的具体详情如下:
包路径:org.apache.helix.monitoring.mbeans.ZkClientMonitor
类名称:ZkClientMonitor
暂无
代码示例来源:origin: org.apache.helix/helix-core
private void recordStateChange(boolean stateChanged, boolean dataChanged) {
// update state change counter.
if (_monitor != null) {
if (stateChanged) {
_monitor.increaseStateChangeEventCounter();
}
if (dataChanged) {
_monitor.increaseDataChangeEventCounter();
}
}
}
}
代码示例来源:origin: apache/helix
private void record(String path, byte[] data, long startTimeMilliSec, ZkClientMonitor.AccessType accessType) {
if (_monitor != null) {
int dataSize = (data != null) ? data.length : 0;
_monitor.record(path, dataSize, startTimeMilliSec, accessType);
}
}
代码示例来源:origin: apache/helix
ZkClientMonitor monitor = new ZkClientMonitor(TEST_TAG, TEST_KEY, TEST_INSTANCE, false, null);
monitor.register();
monitor.increaseDataChangeEventCounter();
long eventCount = (long) _beanServer.getAttribute(name, "DataChangeEventCounter");
Assert.assertEquals(eventCount, 1);
monitor.increaseStateChangeEventCounter();
long stateChangeCount = (long) _beanServer.getAttribute(name, "StateChangeEventCounter");
Assert.assertEquals(stateChangeCount, 1);
monitor.increaseOutstandingRequestGauge();
long requestGauge = (long) _beanServer.getAttribute(name, "OutstandingRequestGauge");
Assert.assertEquals(requestGauge, 1);
monitor.decreaseOutstandingRequestGauge();
requestGauge = (long) _beanServer.getAttribute(name, "OutstandingRequestGauge");
Assert.assertEquals(requestGauge, 0);
monitor.record("TEST/IDEALSTATES/myResource", 0, System.currentTimeMillis() - 10,
ZkClientMonitor.AccessType.READ);
Assert.assertEquals((long) _beanServer.getAttribute(rootName, "ReadCounter"), 1);
Assert.assertEquals((long) _beanServer.getAttribute(idealStateName, "ReadCounter"), 1);
Assert.assertTrue((long) _beanServer.getAttribute(rootName, "ReadLatencyGauge.Max") >= 10);
monitor.record("TEST/INSTANCES/testDB0", 0, System.currentTimeMillis() - 15,
ZkClientMonitor.AccessType.READ);
Assert.assertEquals((long) _beanServer.getAttribute(rootName, "ReadCounter"), 2);
monitor.record("TEST/INSTANCES/node_1/CURRENTSTATES/session_1/Resource", 5,
代码示例来源:origin: apache/helix
@Test
public void testMBeanRegisteration() throws JMException {
final String TEST_TAG_1 = "test_tag_1";
final String TEST_KEY_1 = "test_key_1";
ZkClientMonitor monitor = new ZkClientMonitor(TEST_TAG_1, TEST_KEY_1, null, true, null);
Assert.assertFalse(_beanServer.isRegistered(buildObjectName(TEST_TAG_1, TEST_KEY_1, null)));
monitor.register();
Assert.assertTrue(_beanServer.isRegistered(buildObjectName(TEST_TAG_1, TEST_KEY_1, null)));
// no per-path monitor items created since "monitorRootPathOnly" = true
Assert.assertFalse(_beanServer.isRegistered(
buildPathMonitorObjectName(TEST_TAG_1, TEST_KEY_1, null,
ZkClientPathMonitor.PredefinedPath.IdealStates.name())));
ZkClientMonitor monitorDuplicate = new ZkClientMonitor(TEST_TAG_1, TEST_KEY_1, null, true, null);
monitorDuplicate.register();
Assert.assertTrue(_beanServer.isRegistered(buildObjectName(TEST_TAG_1, TEST_KEY_1, null, 1)));
monitor.unregister();
monitorDuplicate.unregister();
Assert.assertFalse(_beanServer.isRegistered(buildObjectName(TEST_TAG_1, TEST_KEY_1, null)));
Assert.assertFalse(_beanServer.isRegistered(buildObjectName(TEST_TAG_1, TEST_KEY_1, null, 1)));
}
代码示例来源:origin: apache/helix
protected ZkClient(IZkConnection zkConnection, int connectionTimeout, long operationRetryTimeout,
PathBasedZkSerializer zkSerializer, String monitorType, String monitorKey,
String monitorInstanceName, boolean monitorRootPathOnly) {
if (zkConnection == null) {
throw new NullPointerException("Zookeeper connection is null!");
}
_connection = zkConnection;
_pathBasedZkSerializer = zkSerializer;
_operationRetryTimeoutInMillis = operationRetryTimeout;
connect(connectionTimeout, this);
// initiate monitor
try {
if (monitorKey != null && !monitorKey.isEmpty() && monitorType != null && !monitorType
.isEmpty()) {
_monitor =
new ZkClientMonitor(monitorType, monitorKey, monitorInstanceName, monitorRootPathOnly,
_eventThread);
_monitor.register();
} else {
LOG.info("ZkClient monitor key or type is not provided. Skip monitoring.");
}
} catch (JMException e) {
LOG.error("Error in creating ZkClientMonitor", e);
}
}
代码示例来源:origin: apache/helix
_monitor.increaseOutstandingRequestGauge();
_monitor.decreaseOutstandingRequestGauge();
代码示例来源:origin: org.apache.helix/helix-core
protected ZkClient(IZkConnection zkConnection, int connectionTimeout, long operationRetryTimeout,
PathBasedZkSerializer zkSerializer, String monitorType, String monitorKey,
String monitorInstanceName, boolean monitorRootPathOnly) {
if (zkConnection == null) {
throw new NullPointerException("Zookeeper connection is null!");
}
_connection = zkConnection;
_pathBasedZkSerializer = zkSerializer;
_operationRetryTimeoutInMillis = operationRetryTimeout;
connect(connectionTimeout, this);
// initiate monitor
try {
if (monitorKey != null && !monitorKey.isEmpty() && monitorType != null && !monitorType
.isEmpty()) {
_monitor =
new ZkClientMonitor(monitorType, monitorKey, monitorInstanceName, monitorRootPathOnly);
_monitor.setZkEventThread(_eventThread);
} else {
LOG.info("ZkClient monitor key or type is not provided. Skip monitoring.");
}
} catch (JMException e) {
LOG.error("Error in creating ZkClientMonitor", e);
}
}
代码示例来源:origin: apache/helix
private ObjectName buildObjectName(String tag, String key, String instance) throws MalformedObjectNameException {
return ZkClientMonitor.getObjectName(tag, key, instance);
}
代码示例来源:origin: apache/helix
@Override
public DynamicMBeanProvider register() throws JMException {
List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
attributeList.add(_dataChangeEventCounter);
attributeList.add(_outstandingRequestGauge);
attributeList.add(_stateChangeEventCounter);
if (_zkEventThreadMetric != null) {
attributeList.add(_zkEventThreadMetric);
}
doRegister(attributeList, MBEAN_DESCRIPTION,
getObjectName(_monitorType, _monitorKey, _monitorInstanceName));
for (ZkClientPathMonitor.PredefinedPath path : ZkClientPathMonitor.PredefinedPath.values()) {
// If monitor root path only, check if the current path is Root.
// Otherwise, add monitors for every path.
if (!_monitorRootOnly || path.equals(ZkClientPathMonitor.PredefinedPath.Root)) {
_zkClientPathMonitorMap.put(path,
new ZkClientPathMonitor(path, _monitorType, _monitorKey, _monitorInstanceName)
.register());
}
}
return this;
}
代码示例来源:origin: org.apache.helix/helix-core
getEventLock().unlock();
if (_monitor != null) {
_monitor.unregister();
代码示例来源:origin: apache/helix
public ZkClientPathMonitor register() throws JMException {
List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
attributeList.add(_readCounter);
attributeList.add(_writeCounter);
attributeList.add(_readBytesCounter);
attributeList.add(_writeBytesCounter);
attributeList.add(_readFailureCounter);
attributeList.add(_writeFailureCounter);
attributeList.add(_readTotalLatencyCounter);
attributeList.add(_writeTotalLatencyCounter);
attributeList.add(_readLatencyGauge);
attributeList.add(_writeLatencyGauge);
attributeList.add(_readBytesGauge);
attributeList.add(_writeBytesGauge);
ObjectName objectName = new ObjectName(String
.format("%s,%s=%s", ZkClientMonitor.getObjectName(_type, _key, _instanceName).toString(),
MONITOR_PATH, _path.name()));
doRegister(attributeList, ZkClientMonitor.MBEAN_DESCRIPTION, objectName);
return this;
}
代码示例来源:origin: apache/helix
getEventLock().unlock();
if (_monitor != null) {
_monitor.unregister();
代码示例来源:origin: org.apache.helix/helix-core
private void record(String path, byte[] data, long startTimeMilliSec, ZkClientMonitor.AccessType accessType) {
if (_monitor != null) {
int dataSize = (data != null) ? data.length : 0;
_monitor.record(path, dataSize, startTimeMilliSec, accessType);
}
}
代码示例来源:origin: apache/helix
private void recordStateChange(boolean stateChanged, boolean dataChanged) {
// update state change counter.
if (_monitor != null) {
if (stateChanged) {
_monitor.increaseStateChangeEventCounter();
}
if (dataChanged) {
_monitor.increaseDataChangeEventCounter();
}
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
public ZkClientPathMonitor register() throws JMException {
List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
attributeList.add(_readCounter);
attributeList.add(_writeCounter);
attributeList.add(_readBytesCounter);
attributeList.add(_writeBytesCounter);
attributeList.add(_readFailureCounter);
attributeList.add(_writeFailureCounter);
attributeList.add(_readTotalLatencyCounter);
attributeList.add(_writeTotalLatencyCounter);
attributeList.add(_readLatencyGauge);
attributeList.add(_writeLatencyGauge);
attributeList.add(_readBytesGauge);
attributeList.add(_writeBytesGauge);
ObjectName objectName = new ObjectName(String.format("%s,%s=%s",
ZkClientMonitor.getObjectName(_type, _key, _instanceName).toString(),
MONITOR_PATH, _path.name()));
doRegister(attributeList, MBEAN_DESCRIPTION, objectName);
return this;
}
代码示例来源:origin: apache/helix
public void recordFailure(String path, AccessType accessType) {
switch (accessType) {
case READ:
record(path, 0, 0, true, true);
return;
case WRITE:
record(path, 0, 0, true, false);
return;
default:
return;
}
}
代码示例来源:origin: org.apache.helix/helix-core
public ZkClientMonitor(String monitorType, String monitorKey, String monitorInstanceName,
boolean monitorRootPathOnly) throws JMException {
if (monitorKey == null || monitorKey.isEmpty() || monitorType == null || monitorType
.isEmpty()) {
throw new HelixException("Cannot create ZkClientMonitor without monitor key and type.");
}
_sensorName =
String.format("%s.%s.%s", MonitorDomainNames.HelixZkClient.name(), monitorType, monitorKey);
_objectName =
MBeanRegistrar.register(this, getObjectName(monitorType, monitorKey, monitorInstanceName));
for (ZkClientPathMonitor.PredefinedPath path : ZkClientPathMonitor.PredefinedPath.values()) {
// If monitor root path only, check if the current path is Root.
// Otherwise, add monitors for every path.
if (!monitorRootPathOnly || path.equals(ZkClientPathMonitor.PredefinedPath.Root)) {
_zkClientPathMonitorMap.put(path,
new ZkClientPathMonitor(path, monitorType, monitorKey, monitorInstanceName).register());
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
public void recordFailure(String path, AccessType accessType) {
switch (accessType) {
case READ:
record(path, 0, 0, true, true);
return;
case WRITE:
record(path, 0, 0, true, false);
return;
default:
return;
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
public void record(String path, int dataSize, long startTimeMilliSec, AccessType accessType) {
switch (accessType) {
case READ:
record(path, dataSize, System.currentTimeMillis() - startTimeMilliSec, false, true);
return;
case WRITE:
record(path, dataSize, System.currentTimeMillis() - startTimeMilliSec, false, false);
return;
default:
return;
}
}
代码示例来源:origin: apache/helix
public void record(String path, int dataSize, long startTimeMilliSec, AccessType accessType) {
switch (accessType) {
case READ:
record(path, dataSize, System.currentTimeMillis() - startTimeMilliSec, false, true);
return;
case WRITE:
record(path, dataSize, System.currentTimeMillis() - startTimeMilliSec, false, false);
return;
default:
return;
}
}
我是 iOS 开发新手。我正在解决的是如何在 iPhone 中运行我的应用程序时获取有关该应用程序的信息。 例如:当我在 Android 中开发时,我连接手机(使用净化模式)并打开 Android M
我仍然不确定这两个调用之间的区别。来自 MSDN, Monitor.Enter(Object) 获取指定对象的独占锁。 Monitor.Wait(Object) 释放对象上的锁并阻塞当前线程,直到它重
我是 GCP 的新手并且来自 Azure 背景。在 GCP 端是否有等效的“Azure Application Insights”用于监控应用程序? 让我用一个例子更清楚地解释我的用例:如果我有一个基
这是说明问题的最小代码: StringBuilder input = new StringBuilder(); void ToUpper() { lock (input) {
我在 ASP.NET 中有一个生产者-消费者场景。我设计了一个Producer 类,一个Consumer 类和一个用于保存共享对象并负责Producer 和Consumer 之间通信的类,我们称它为M
是否可以检测是否是同一个线程试图释放锁?我们在代码中有很多地方看起来像: try { try { if(!Monitor.TryEnter(obj, 2000))
我对并发编程有点陌生,正在尝试了解使用 Monitor.Pulse 和 Monitor.Wait 的好处。 MSDN 的例子如下: class MonitorSample { const in
如果您想在退出和清理对象时阻止执行某些代码块,是否可以使用锁来阻止执行? Monitor.TryEnter(cleanupLock, ref acquiredLock); TryEnter 可用于确保
Monitor.Enter 和 Monitor.Exit 设计为从同一线程调用。但是,如果我需要在与获得的线程不同的线程中释放锁怎么办? 例如:有共享资源和使用该资源的异步操作。该操作以 BeginO
Monitor.PulseAll 通知队列中的所有等待线程。 Monitor.Pulse 通知等待队列中的一个线程。 (下一个等待线程) 只有下一个线程(一个线程)才能获取锁。那有什么区别呢? 什么时
我正在尝试在我的 terraform 代码库中集成对 sshd 进程的 Datadog 监视器检查,但我收到 datadog_monitor.host_is_up2: error updating m
这里的问题是:如果获取对象独占锁的线程(例如通过使用 Monitor.Enter)终止,是否会神奇地释放该对象的独占锁?如果那是真的,那么假设我们从另一个线程调用 Monitor.Exit - 因为我
我正在研究 .NET 中的 Monitor 类,所以我找到了一段似乎可以正常工作的代码,但是当我将它循环一段时间时,它会抛出 OutOfMemoryException。 我在具有 8 GB RAM 的
ECMA-335 规范规定如下: *获取锁(System.Threading.Monitor.Enter 或进入同步方法)应隐式执行 volatile 读取操作,并释放锁(System.Threadi
我在 dll 中使用 OmniThreadLibrary 2.09,主应用程序和 dll 使用相同的 SimpleShareMem 内存管理器。 我用以下代码创建了自己的监视器: FMonitor
我正在使用 R 包 monitoR并收到一条我无法理解的错误消息。 我正在尝试使用 dbUploadTemplate 命令将关联模板列表(“bithTemps”)上传到 MySQL 数据库(“noh”
我想我遗漏了一些关于 Monitor.Enter 和 Monitor.TryEnter 正确行为的信息。这是我编写的一段代码,用于将问题与其余代码分开: object lockObj = new ob
我正在尝试实现一个多线程库,该库将使用线程池同时运行任务。基本上它会从它收到的收集参数中将任务添加到线程池,然后等待直到正在处理的最后一个任务发送脉冲信号。我在早期的测试中取得了成功,但是当我想测试处
我想用redis lua来实现monitor命令,而不是redis-cli monitor。但我不知道怎么办。 redis.call('monitor') 不起作用。 最佳答案 您不能从 Redis
根据语言规范,lock(obj) statement; 会被编译为: object lockObj = obj; // (the langspec doesn't mention this var,
我是一名优秀的程序员,十分优秀!