本文整理汇总了Java中com.mysql.jdbc.ReplicationConnectionGroupManager.addSlaveHost方法的典型用法代码示例。如果您正苦于以下问题:Java ReplicationConnectionGroupManager.addSlaveHost方法的具体用法?Java ReplicationConnectionGroupManager.addSlaveHost怎么用?Java ReplicationConnectionGroupManager.addSlaveHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysql.jdbc.ReplicationConnectionGroupManager
的用法示例。
在下文中一共展示了ReplicationConnectionGroupManager.addSlaveHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReplicationConnectionMemory
import com.mysql.jdbc.ReplicationConnectionGroupManager; //导入方法依赖的package包/类
public void testReplicationConnectionMemory() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
String replicationGroup = "memoryGroup";
props.setProperty("replicationConnectionGroup", replicationGroup);
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);
ReplicationConnectionGroupManager.promoteSlaveToMaster(replicationGroup, first.getAddress());
ReplicationConnectionGroupManager.removeMasterHost(replicationGroup, second.getAddress());
ReplicationConnectionGroupManager.addSlaveHost(replicationGroup, second.getAddress());
conn2.setReadOnly(false);
assertFalse(conn2.isReadOnly());
assertTrue(conn2.isMasterConnection());
assertTrue(conn2.isHostMaster(first.getAddress()));
assertTrue(conn2.isHostSlave(second.getAddress()));
assertTrue(conn2.isHostSlave(third.getAddress()));
// make sure state changes made are reflected in new connections:
ReplicationConnection conn3 = this.getUnreliableReplicationConnection(configs, props);
conn3.setReadOnly(false);
assertFalse(conn3.isReadOnly());
assertTrue(conn3.isMasterConnection());
assertTrue(conn3.isHostMaster(first.getAddress()));
assertTrue(conn3.isHostSlave(second.getAddress()));
assertTrue(conn3.isHostSlave(third.getAddress()));
}
示例2: addSlaveHost
import com.mysql.jdbc.ReplicationConnectionGroupManager; //导入方法依赖的package包/类
public void addSlaveHost(String groupFilter, String host) throws SQLException {
ReplicationConnectionGroupManager.addSlaveHost(groupFilter, host);
}
示例3: testReplicationConnectionMemory
import com.mysql.jdbc.ReplicationConnectionGroupManager; //导入方法依赖的package包/类
public void testReplicationConnectionMemory() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
String replicationGroup = "memoryGroup";
props.setProperty("replicationConnectionGroup", replicationGroup);
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);
ReplicationConnectionGroupManager.promoteSlaveToMaster(replicationGroup, first.getAddress());
ReplicationConnectionGroupManager.removeMasterHost(replicationGroup, second.getAddress());
ReplicationConnectionGroupManager.addSlaveHost(replicationGroup, second.getAddress());
conn2.setReadOnly(false);
assertFalse(conn2.isReadOnly());
assertTrue(conn2.isMasterConnection());
assertTrue(conn2.isHostMaster(first.getAddress()));
assertTrue(conn2.isHostSlave(second.getAddress()));
assertTrue(conn2.isHostSlave(third.getAddress()));
// make sure state changes made are reflected in new connections:
ReplicationConnection conn3 = this
.getUnreliableReplicationConnection(configs, props);
conn3.setReadOnly(false);
assertFalse(conn3.isReadOnly());
assertTrue(conn3.isMasterConnection());
assertTrue(conn3.isHostMaster(first.getAddress()));
assertTrue(conn3.isHostSlave(second.getAddress()));
assertTrue(conn3.isHostSlave(third.getAddress()));
}
示例4: addSlaveHost
import com.mysql.jdbc.ReplicationConnectionGroupManager; //导入方法依赖的package包/类
public void addSlaveHost(String groupFilter, String host) throws SQLException {
ReplicationConnectionGroupManager.addSlaveHost(groupFilter, host);
}