gpt4 book ai didi

org.apache.zookeeper.server.ZooKeeperServerBean.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 17:29:31 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.zookeeper.server.ZooKeeperServerBean.<init>()方法的一些代码示例,展示了ZooKeeperServerBean.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperServerBean.<init>()方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZooKeeperServerBean
类名称:ZooKeeperServerBean
方法名:<init>

ZooKeeperServerBean.<init>介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

protected void registerJMX() {
  // register with JMX
  try {
    jmxServerBean = new ZooKeeperServerBean(this);
    MBeanRegistry.getInstance().register(jmxServerBean, null);
    try {
      jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
      MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
    } catch (Exception e) {
      LOG.warn("Failed to register with JMX", e);
      jmxDataTreeBean = null;
    }
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxServerBean = null;
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

protected void registerJMX() {
  // register with JMX
  try {
    jmxServerBean = new ZooKeeperServerBean(this);
    MBeanRegistry.getInstance().register(jmxServerBean, null);
    
    try {
      jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
      MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
    } catch (Exception e) {
      LOG.warn("Failed to register with JMX", e);
      jmxDataTreeBean = null;
    }
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxServerBean = null;
  }
}

代码示例来源:origin: apache/zookeeper

@Test
public void testGetSecureClientAddress() throws IOException {
  ZooKeeperServer zks = new ZooKeeperServer();
  /**
   * case 1: When secure client is not configured getSecureClientAddress
   * should return empty string
   */
  ZooKeeperServerBean serverBean = new ZooKeeperServerBean(zks);
  String result = serverBean.getSecureClientPort();
  assertEquals("", result);
  /**
   * case 2: When secure client is configured getSecureClientAddress
   * should return configured SecureClientAddress
   */
  ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
  int secureClientPort = 8443;
  InetSocketAddress address = new InetSocketAddress(secureClientPort);
  cnxnFactory.configure(address, 5, true);
  zks.setSecureServerCnxnFactory(cnxnFactory);
  result = serverBean.getSecureClientAddress();
  String ipv4 = "0.0.0.0:" + secureClientPort;
  String ipv6 = "0:0:0:0:0:0:0:0:" + secureClientPort;
  assertTrue(result.equals(ipv4) || result.equals(ipv6));
  // cleanup
  cnxnFactory.shutdown();
}

代码示例来源:origin: apache/zookeeper

@Test
public void testGetSecureClientPort() throws IOException {
  ZooKeeperServer zks = new ZooKeeperServer();
  /**
   * case 1: When secure client is not configured GetSecureClientPort
   * should return empty string
   */
  ZooKeeperServerBean serverBean = new ZooKeeperServerBean(zks);
  String result = serverBean.getSecureClientPort();
  assertEquals("", result);
  /**
   * case 2: When secure client is configured GetSecureClientPort should
   * return configured port
   */
  ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
  int secureClientPort = 8443;
  InetSocketAddress address = new InetSocketAddress(secureClientPort);
  cnxnFactory.configure(address, 5, true);
  zks.setSecureServerCnxnFactory(cnxnFactory);
  result = serverBean.getSecureClientPort();
  assertEquals(Integer.toString(secureClientPort), result);
  // cleanup
  cnxnFactory.shutdown();
}

代码示例来源:origin: apache/zookeeper

@Test
public void testTxnLogElapsedSyncTime() throws IOException {
  File tmpDir = ClientBase.createEmptyTestDir();
  FileTxnSnapLog fileTxnSnapLog = new FileTxnSnapLog(new File(tmpDir, "data"),
      new File(tmpDir, "data_txnlog"));
  ZooKeeperServer zks = new ZooKeeperServer();
  zks.setTxnLogFactory(fileTxnSnapLog);
  ZooKeeperServerBean serverBean = new ZooKeeperServerBean(zks);
  long elapsedTime = serverBean.getTxnLogElapsedSyncTime();
  assertEquals(-1, elapsedTime);
  TxnHeader hdr = new TxnHeader(1, 1, 1, 1, ZooDefs.OpCode.setData);
  Record txn = new SetDataTxn("/foo", new byte[0], 1);
  Request req = new Request(0, 0, 0, hdr, txn, 0);
  try {
    zks.getTxnLogFactory().append(req);
    zks.getTxnLogFactory().commit();
    elapsedTime = serverBean.getTxnLogElapsedSyncTime();
    assertNotEquals(-1, elapsedTime);
    assertEquals(elapsedTime, serverBean.getTxnLogElapsedSyncTime());
  } finally {
    fileTxnSnapLog.close();
  }
}

代码示例来源:origin: org.apache.hadoop/zookeeper

protected void registerJMX() {
  // register with JMX
  try {
    jmxServerBean = new ZooKeeperServerBean(this);
    MBeanRegistry.getInstance().register(jmxServerBean, null);
    
    try {
      jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
      MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
    } catch (Exception e) {
      LOG.warn("Failed to register with JMX", e);
      jmxDataTreeBean = null;
    }
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxServerBean = null;
  }
}

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