本文整理了Java中org.apache.zookeeper.server.ZooKeeperServerBean.<init>()
方法的一些代码示例,展示了ZooKeeperServerBean.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperServerBean.<init>()
方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZooKeeperServerBean
类名称: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;
}
}
内容来源于网络,如有侵权,请联系作者删除!