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


Java ServerRole类代码示例

本文整理汇总了Java中com.mysql.fabric.ServerRole的典型用法代码示例。如果您正苦于以下问题:Java ServerRole类的具体用法?Java ServerRole怎么用?Java ServerRole使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerRole类属于com.mysql.fabric包,在下文中一共展示了ServerRole类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDumpServersAll

import com.mysql.fabric.ServerRole; //导入依赖的package包/类
/**
 * Test the Client.getServers() without a match pattern (all servers).
 */
public void testDumpServersAll() throws Exception {
    if (!this.isSetForFabricTest) {
        return;
    }
    Set<ServerGroup> serverGroups = this.client.getServerGroups().getData();
    List<Server> servers = new ArrayList<Server>();
    for (ServerGroup g : serverGroups) {
        servers.addAll(g.getServers());
    }
    Collections.sort(servers, serverHostnamePortSorter);
    assertEquals(3, servers.size());

    assertEquals("fabric_test1_global", servers.get(0).getGroupName());
    assertEquals("fabric_test1_shard1", servers.get(1).getGroupName());
    assertEquals("fabric_test1_shard2", servers.get(2).getGroupName());

    assertEquals((this.globalHost != null ? this.globalHost : "127.0.0.1"), servers.get(0).getHostname());
    assertEquals((this.shard1Host != null ? this.shard1Host : "127.0.0.1"), servers.get(1).getHostname());
    assertEquals((this.shard2Host != null ? this.shard2Host : "127.0.0.1"), servers.get(2).getHostname());

    assertEquals((this.globalPort != null ? Integer.valueOf(this.globalPort) : 3401), servers.get(0).getPort());
    assertEquals((this.shard1Port != null ? Integer.valueOf(this.shard1Port) : 3402), servers.get(1).getPort());
    assertEquals((this.shard2Port != null ? Integer.valueOf(this.shard2Port) : 3403), servers.get(2).getPort());

    assertEquals(ServerMode.READ_WRITE, servers.get(0).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(0).getRole());
    assertEquals(ServerMode.READ_WRITE, servers.get(1).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(1).getRole());
    assertEquals(ServerMode.READ_WRITE, servers.get(2).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(2).getRole());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:35,代码来源:TestDumpCommands.java

示例2: unmarshallServer

import com.mysql.fabric.ServerRole; //导入依赖的package包/类
/**
 * Unmarshall a response representing a server.
 */
private static Server unmarshallServer(Map<String, ?> serverData) throws FabricCommunicationException {
    ServerMode mode;
    ServerRole role;

    String host;
    int port;

    try {
        // dump.servers returns integer mode/status
        if (Integer.class.equals(serverData.get(FIELD_MODE).getClass())) {
            mode = ServerMode.getFromConstant((Integer) serverData.get(FIELD_MODE));
            role = ServerRole.getFromConstant((Integer) serverData.get(FIELD_STATUS));
            host = (String) serverData.get(FIELD_HOST);
            port = (Integer) serverData.get(FIELD_PORT);
        } else {
            // sharding.lookup_servers returns a different format
            mode = ServerMode.valueOf((String) serverData.get(FIELD_MODE));
            role = ServerRole.valueOf((String) serverData.get(FIELD_STATUS));
            String hostnameAndPort[] = ((String) serverData.get(FIELD_ADDRESS)).split(":");
            host = hostnameAndPort[0];
            port = Integer.valueOf(hostnameAndPort[1]);
        }
        Server s = new Server((String) serverData.get(FIELD_GROUP_ID), (String) serverData.get(FIELD_SERVER_UUID), host, port, mode, role,
                (Double) serverData.get(FIELD_WEIGHT));
        return s;
    } catch (Exception ex) {
        throw new FabricCommunicationException("Unable to parse server definition", ex);
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:33,代码来源:XmlRpcClient.java

示例3: unmarshallServer

import com.mysql.fabric.ServerRole; //导入依赖的package包/类
/**
 * Unmarshall a response representing a server.
 */
private static Server unmarshallServer(Map serverData) throws FabricCommunicationException {
    ServerMode mode;
    ServerRole role;

    String host;
    int port;

    try {
        // dump.servers returns integer mode/status
        if (Integer.class.equals(serverData.get(FIELD_MODE).getClass())) {
            mode = ServerMode.getFromConstant((Integer) serverData.get(FIELD_MODE));
            role = ServerRole.getFromConstant((Integer) serverData.get(FIELD_STATUS));
            host = (String) serverData.get(FIELD_HOST);
            port = (Integer) serverData.get(FIELD_PORT);
        } else {
            // sharding.lookup_servers returns a different format
            mode = ServerMode.valueOf((String) serverData.get(FIELD_MODE));
            role = ServerRole.valueOf((String) serverData.get(FIELD_STATUS));
            String hostnameAndPort[] = ((String) serverData.get(FIELD_ADDRESS)).split(":");
            host = hostnameAndPort[0];
            port = Integer.valueOf(hostnameAndPort[1]);
        }
        Server s = new Server((String) serverData.get(FIELD_GROUP_ID), (String) serverData.get(FIELD_SERVER_UUID), host, port, mode, role,
                (Double) serverData.get(FIELD_WEIGHT));
        return s;
    } catch (Exception ex) {
        throw new FabricCommunicationException("Unable to parse server definition", ex);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:XmlRpcClient.java

示例4: testDumpServersAll

import com.mysql.fabric.ServerRole; //导入依赖的package包/类
/**
 * Test the Client.getServers() without a match pattern (all servers).
 */
public void testDumpServersAll() throws Exception {
    Set<ServerGroup> serverGroups = this.client.getServerGroups().getData();
    List<Server> servers = new ArrayList<Server>();
    for (ServerGroup g : serverGroups) {
        servers.addAll(g.getServers());
    }
    Collections.sort(servers, serverHostnamePortSorter);
    assertEquals(3, servers.size());

    assertEquals("fabric_test1_global", servers.get(0).getGroupName());
    assertEquals("fabric_test1_shard1", servers.get(1).getGroupName());
    assertEquals("fabric_test1_shard2", servers.get(2).getGroupName());

    String ghost = System.getProperty("com.mysql.fabric.testsuite.global.host");
    String gport = System.getProperty("com.mysql.fabric.testsuite.global.port");
    String s1host = System.getProperty("com.mysql.fabric.testsuite.shard1.host");
    String s1port = System.getProperty("com.mysql.fabric.testsuite.shard1.port");
    String s2host = System.getProperty("com.mysql.fabric.testsuite.shard2.host");
    String s2port = System.getProperty("com.mysql.fabric.testsuite.shard2.port");

    assertEquals((ghost != null ? ghost : "127.0.0.1"), servers.get(0).getHostname());
    assertEquals((s1host != null ? s1host : "127.0.0.1"), servers.get(1).getHostname());
    assertEquals((s2host != null ? s2host : "127.0.0.1"), servers.get(2).getHostname());

    assertEquals((gport != null ? Integer.valueOf(gport) : 3401), servers.get(0).getPort());
    assertEquals((s1port != null ? Integer.valueOf(s1port) : 3402), servers.get(1).getPort());
    assertEquals((s2port != null ? Integer.valueOf(s2port) : 3403), servers.get(2).getPort());

    assertEquals(ServerMode.READ_WRITE, servers.get(0).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(0).getRole());
    assertEquals(ServerMode.READ_WRITE, servers.get(1).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(1).getRole());
    assertEquals(ServerMode.READ_WRITE, servers.get(2).getMode());
    assertEquals(ServerRole.PRIMARY, servers.get(2).getRole());
}
 
开发者ID:Prometheus-ETSIIT,项目名称:locaviewer,代码行数:39,代码来源:TestDumpCommands.java


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