gpt4 book ai didi

org.apache.helix.monitoring.mbeans.ZkClientMonitor类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:47:44 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.helix.monitoring.mbeans.ZkClientMonitor类的一些代码示例,展示了ZkClientMonitor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClientMonitor类的具体详情如下:
包路径:org.apache.helix.monitoring.mbeans.ZkClientMonitor
类名称: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;
 }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com