本文整理汇总了Java中com.mysql.jdbc.jmx.ReplicationGroupManagerMBean类的典型用法代码示例。如果您正苦于以下问题:Java ReplicationGroupManagerMBean类的具体用法?Java ReplicationGroupManagerMBean怎么用?Java ReplicationGroupManagerMBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReplicationGroupManagerMBean类属于com.mysql.jdbc.jmx包,在下文中一共展示了ReplicationGroupManagerMBean类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReplicationJMXInterfaces
import com.mysql.jdbc.jmx.ReplicationGroupManagerMBean; //导入依赖的package包/类
public void testReplicationJMXInterfaces() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
String replicationGroup = "testReplicationJMXInterfaces";
props.setProperty("replicationConnectionGroup", replicationGroup);
props.setProperty("replicationEnableJMX", "true");
Set<MockConnectionConfiguration> configs = new HashSet<MockConnectionConfiguration>();
MockConnectionConfiguration first = new MockConnectionConfiguration("first", "slave", null, false);
MockConnectionConfiguration second = new MockConnectionConfiguration("second", "master", null, false);
MockConnectionConfiguration third = new MockConnectionConfiguration("third", "slave", null, false);
configs.add(first);
configs.add(second);
configs.add(third);
ReplicationConnection conn2 = this.getUnreliableReplicationConnection(configs, props);
ReplicationGroupManagerMBean bean = getReplicationMBean();
assertEquals(1, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(1, bean.getTotalLogicalConnectionCount(replicationGroup));
assertEquals(0, bean.getSlavePromotionCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
assertEquals(2, bean.getActiveSlaveHostCount(replicationGroup));
bean.removeSlaveHost(replicationGroup, first.getAddress());
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(first.getAddress()));
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
conn2.close();
assertEquals(0, bean.getActiveLogicalConnectionCount(replicationGroup));
conn2 = this.getUnreliableReplicationConnection(configs, props);
assertEquals(1, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(2, bean.getTotalLogicalConnectionCount(replicationGroup));
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
bean.promoteSlaveToMaster(replicationGroup, third.getAddress());
assertEquals(2, bean.getActiveMasterHostCount(replicationGroup));
assertEquals(0, bean.getActiveSlaveHostCount(replicationGroup));
// confirm this works when no group filter is specified:
bean.addSlaveHost(null, first.getAddress());
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(2, bean.getActiveMasterHostCount(replicationGroup));
bean.removeMasterHost(replicationGroup, second.getAddress());
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
ReplicationConnection conn3 = this.getUnreliableReplicationConnection(configs, props);
assertEquals(2, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(3, bean.getTotalLogicalConnectionCount(replicationGroup));
assertTrue(bean.getMasterHostsList(replicationGroup).contains(third.getAddress()));
assertFalse(bean.getMasterHostsList(replicationGroup).contains(first.getAddress()));
assertFalse(bean.getMasterHostsList(replicationGroup).contains(second.getAddress()));
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(third.getAddress()));
assertTrue(bean.getSlaveHostsList(replicationGroup).contains(first.getAddress()));
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(second.getAddress()));
assertTrue(bean.getMasterHostsList(replicationGroup).contains(conn3.getMasterConnection().getHost()));
assertTrue(bean.getSlaveHostsList(replicationGroup).contains(conn3.getSlavesConnection().getHost()));
assertTrue(bean.getRegisteredConnectionGroups().contains(replicationGroup));
}
示例2: testReplicationJMXInterfaces
import com.mysql.jdbc.jmx.ReplicationGroupManagerMBean; //导入依赖的package包/类
public void testReplicationJMXInterfaces() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
String replicationGroup = "testReplicationJMXInterfaces";
props.setProperty("replicationConnectionGroup", replicationGroup);
props.setProperty("replicationEnableJMX", "true");
Set<MockConnectionConfiguration> configs = new HashSet<MockConnectionConfiguration>();
MockConnectionConfiguration first = new MockConnectionConfiguration("first", "slave", null, false);
MockConnectionConfiguration second = new MockConnectionConfiguration("second", "master", null, false);
MockConnectionConfiguration third = new MockConnectionConfiguration("third", "slave", null, false);
configs.add(first);
configs.add(second);
configs.add(third);
ReplicationConnection conn2 = this
.getUnreliableReplicationConnection(configs, props);
ReplicationGroupManagerMBean bean = getReplicationMBean();
assertEquals(1, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(1, bean.getTotalLogicalConnectionCount(replicationGroup));
assertEquals(0, bean.getSlavePromotionCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
assertEquals(2, bean.getActiveSlaveHostCount(replicationGroup));
bean.removeSlaveHost(replicationGroup, first.getAddress());
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(first.getAddress()));
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
conn2.close();
assertEquals(0, bean.getActiveLogicalConnectionCount(replicationGroup));
conn2 = this.getUnreliableReplicationConnection(configs, props);
assertEquals(1, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(2, bean.getTotalLogicalConnectionCount(replicationGroup));
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
bean.promoteSlaveToMaster(replicationGroup, third.getAddress());
assertEquals(2, bean.getActiveMasterHostCount(replicationGroup));
assertEquals(0, bean.getActiveSlaveHostCount(replicationGroup));
// confirm this works when no group filter is specified:
bean.addSlaveHost(null, first.getAddress());
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(2, bean.getActiveMasterHostCount(replicationGroup));
bean.removeMasterHost(replicationGroup, second.getAddress());
assertEquals(1, bean.getActiveSlaveHostCount(replicationGroup));
assertEquals(1, bean.getActiveMasterHostCount(replicationGroup));
ReplicationConnection conn3 = this
.getUnreliableReplicationConnection(configs, props);
assertEquals(2, bean.getActiveLogicalConnectionCount(replicationGroup));
assertEquals(3, bean.getTotalLogicalConnectionCount(replicationGroup));
assertTrue(bean.getMasterHostsList(replicationGroup).contains(third.getAddress()));
assertFalse(bean.getMasterHostsList(replicationGroup).contains(first.getAddress()));
assertFalse(bean.getMasterHostsList(replicationGroup).contains(second.getAddress()));
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(third.getAddress()));
assertTrue(bean.getSlaveHostsList(replicationGroup).contains(first.getAddress()));
assertFalse(bean.getSlaveHostsList(replicationGroup).contains(second.getAddress()));
assertTrue(bean.getMasterHostsList(replicationGroup).contains(conn3.getMasterConnection().getHost()));
assertTrue(bean.getSlaveHostsList(replicationGroup).contains(conn3.getSlavesConnection().getHost()));
assertTrue(bean.getRegisteredConnectionGroups().contains(replicationGroup));
}
示例3: getReplicationMBean
import com.mysql.jdbc.jmx.ReplicationGroupManagerMBean; //导入依赖的package包/类
private ReplicationGroupManagerMBean getReplicationMBean() throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName mbeanName = new ObjectName("com.mysql.jdbc.jmx:type=ReplicationGroupManager");
return (ReplicationGroupManagerMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, mbeanName, ReplicationGroupManagerMBean.class, false);
}
示例4: getReplicationMBean
import com.mysql.jdbc.jmx.ReplicationGroupManagerMBean; //导入依赖的package包/类
private ReplicationGroupManagerMBean getReplicationMBean() throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName mbeanName = new ObjectName("com.mysql.jdbc.jmx:type=ReplicationGroupManager");
return (ReplicationGroupManagerMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, mbeanName, ReplicationGroupManagerMBean.class, false);
}