本文整理汇总了Java中com.mysql.fabric.FabricConnection.refreshState方法的典型用法代码示例。如果您正苦于以下问题:Java FabricConnection.refreshState方法的具体用法?Java FabricConnection.refreshState怎么用?Java FabricConnection.refreshState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysql.fabric.FabricConnection
的用法示例。
在下文中一共展示了FabricConnection.refreshState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug82094
import com.mysql.fabric.FabricConnection; //导入方法依赖的package包/类
/**
* Test Bug#82094 - ConcurrentModificationException on Fabric connections after topology changes.
*
* This test requires a Fabric instance running with a HA group (ha_config1_group) containing three servers, one promoted to master and failure detection
* turned on.
* Note that removing one or the other secondary server is a distinct case and only one of them causes the reported failure. This is so because of the order
* the elements on the slave servers HashSet, from the ReplicationConnectionGroup object, are iterated. So, we remove one at a time in this test to make
* sure we cover both cases.
*/
public void testBug82094() throws Exception {
if (!this.isSetForFabricTest) {
return;
}
FabricMySQLDataSource ds = getNewDefaultDataSource();
ds.setFabricServerGroup("ha_config1_group");
this.conn = (FabricMySQLConnection) ds.getConnection(this.username, this.password);
this.conn.createStatement().close(); // Make sure there is an internal ReplicationConnection.
FabricConnection fabricConn = new FabricConnection(this.fabricUrl, this.fabricUsername, this.fabricPassword);
for (Server server : fabricConn.getServerGroup("ha_config1_group").getServers()) {
if (server.isSlave()) {
try {
this.conn.transactionCompleted();
// Remove Secondary server.
fabricConn.getClient().removeServerFromGroup(server.getGroupName(), server.getHostname(), server.getPort());
// Make sure the TTL expires before moving on.
fabricConn.refreshState();
while (!fabricConn.isStateExpired()) {
Thread.sleep(1000);
}
this.conn.transactionCompleted();
} finally {
// Add Secondary server back.
fabricConn.getClient().addServerToGroup(server.getGroupName(), server.getHostname(), server.getPort());
// Make sure the TTL expires before moving on.
fabricConn.refreshState();
while (!fabricConn.isStateExpired()) {
Thread.sleep(1000);
}
}
}
}
this.conn.close();
}