当前位置: 首页>>代码示例>>Java>>正文


Java FabricConnection.refreshState方法代码示例

本文整理汇总了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();
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:49,代码来源:TestRegressions.java


注:本文中的com.mysql.fabric.FabricConnection.refreshState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。