• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServerGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getServerGroups

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
/**
 * Facade for "dump.servers". Will not return empty server groups.
 */
public FabricStateResponse<Set<ServerGroup>> getServerGroups(String groupPattern) throws FabricCommunicationException {
    int version = 0; // necessary but unused
    Response response = errorSafeCallMethod(METHOD_DUMP_SERVERS, new Object[] { version, groupPattern });
    // collect all servers by group name
    Map<String, Set<Server>> serversByGroupName = new HashMap<String, Set<Server>>();
    for (Map<String, ?> server : response.getResultSet()) {
        Server s = unmarshallServer(server);
        if (serversByGroupName.get(s.getGroupName()) == null) {
            serversByGroupName.put(s.getGroupName(), new HashSet<Server>());
        }
        serversByGroupName.get(s.getGroupName()).add(s);
    }
    // create group set
    Set<ServerGroup> serverGroups = new HashSet<ServerGroup>();
    for (Map.Entry<String, Set<Server>> entry : serversByGroupName.entrySet()) {
        ServerGroup g = new ServerGroup(entry.getKey(), entry.getValue());
        serverGroups.add(g);
    }
    return new FabricStateResponse<Set<ServerGroup>>(serverGroups, response.getTtl());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:24,代码来源:XmlRpcClient.java


示例2: getServerGroups

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
/**
 * Facade for "dump.servers". Will not return empty server groups.
 */
public FabricStateResponse<Set<ServerGroup>> getServerGroups(String groupPattern) throws FabricCommunicationException {
    int version = 0; // necessary but unused
    Response response = errorSafeCallMethod(METHOD_DUMP_SERVERS, new Object[] { version, groupPattern });
    // collect all servers by group name
    Map<String, Set<Server>> serversByGroupName = new HashMap<String, Set<Server>>();
    for (Map server : response.getResultSet()) {
        Server s = unmarshallServer(server);
        if (serversByGroupName.get(s.getGroupName()) == null) {
            serversByGroupName.put(s.getGroupName(), new HashSet<Server>());
        }
        serversByGroupName.get(s.getGroupName()).add(s);
    }
    // create group set
    Set<ServerGroup> serverGroups = new HashSet<ServerGroup>();
    for (Map.Entry<String, Set<Server>> entry : serversByGroupName.entrySet()) {
        ServerGroup g = new ServerGroup(entry.getKey(), entry.getValue());
        serverGroups.add(g);
    }
    return new FabricStateResponse<Set<ServerGroup>>(serverGroups, response.getTtl());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:XmlRpcClient.java


示例3: getServerGroups

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
/**
 * Facade for "dump.servers".
 */
public FabricStateResponse<Set<ServerGroup>> getServerGroups(String groupPattern) throws FabricCommunicationException {
	int version = 0; // necessary but unused
	DumpResponse response = callDumpMethod("dump.servers", new Object[] {version, groupPattern});
	// collect all servers by group name
	Map<String, Set<Server>> serversByGroupName = new HashMap<String, Set<Server>>();
	for (List server : (List<List>) response.getReturnValue()) {
		Server s = unmarshallServer(server);
		if (serversByGroupName.get(s.getGroupName()) == null) {
			serversByGroupName.put(s.getGroupName(), new HashSet<Server>());
		}
		serversByGroupName.get(s.getGroupName()).add(s);
	}
	// create group set
	Set<ServerGroup> serverGroups = new HashSet<ServerGroup>();
	for (Map.Entry<String, Set<Server>> entry : serversByGroupName.entrySet()) {
		ServerGroup g = new ServerGroup(entry.getKey(), entry.getValue());
		serverGroups.add(g);
	}
	return new FabricStateResponse<Set<ServerGroup>>(serverGroups, response.getTtl());
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:24,代码来源:XmlRpcClient.java


示例4: testDumpServersAll

import com.mysql.fabric.ServerGroup; //导入依赖的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


示例5: getReadWriteConnectionFromServerGroup

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
/**
 * Find a server with mode READ_WRITE in the given server group and create a JDBC connection to it.
 * 
 * @returns a {@link Connection} to an arbitrary MySQL server
 * @throws SQLException
 *             if connection fails or a READ_WRITE server is not contained in the group
 */
private Connection getReadWriteConnectionFromServerGroup(ServerGroup serverGroup) throws SQLException {
    for (Server s : serverGroup.getServers()) {
        if (ServerMode.READ_WRITE.equals(s.getMode())) {
            String jdbcUrl = String.format("jdbc:mysql://%s:%s/%s", s.getHostname(), s.getPort(), this.database);
            return DriverManager.getConnection(jdbcUrl, this.user, this.password);
        }
    }
    throw new SQLException("Unable to find r/w server for chosen shard mapping in group " + serverGroup.getName());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:17,代码来源:FabricMultiTenantConnectionProvider.java


示例6: getServerGroup

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
public ServerGroup getServerGroup(String groupName) throws FabricCommunicationException {
    Set<ServerGroup> groups = getServerGroups(groupName).getData();
    if (groups.size() == 1) {
        return groups.iterator().next();
    }
    return null;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:8,代码来源:XmlRpcClient.java


示例7: promoteServerInGroup

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
public void promoteServerInGroup(String groupName, String hostname, int port) throws FabricCommunicationException {
    ServerGroup serverGroup = getServerGroup(groupName);
    for (Server s : serverGroup.getServers()) {
        if (s.getHostname().equals(hostname) && s.getPort() == port) {
            errorSafeCallMethod(METHOD_GROUP_PROMOTE, new Object[] { groupName, s.getUuid() });
            break;
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:10,代码来源:XmlRpcClient.java


示例8: getConnection

import com.mysql.fabric.ServerGroup; //导入依赖的package包/类
/**
 * Get a connection to access data association with the provided `tenantIdentifier' (or shard
 * key in Fabric-speak). The returned connection is a READ_WRITE connection.
 */
public Connection getConnection(String tenantIdentifier) throws SQLException {
    String serverGroupName = this.shardMapping.getGroupNameForKey(tenantIdentifier);
    try {
        ServerGroup serverGroup = this.fabricConnection.getServerGroup(serverGroupName);
        return getReadWriteConnectionFromServerGroup(serverGroup);
    } catch (FabricCommunicationException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:FabricMultiTenantConnectionProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AAShapePipe类代码示例发布时间:2022-05-21
下一篇:
Java IEvaluationContext类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap