private UpdatePod initBuilderPod(PodBuilderConfig podConfig) { UpdatePodBuilder podBuilder = new UpdatePodBuilder(); podBuilder.name(podConfig.getId()); podBuilder.cluster(podConfig.getCluster()); ArrayList<ServerBartender> serverList = podConfig.getServers(); /* int depth = Math.min(3, serverList.size()); if (depth <= 0) { depth = 3; } */ int depth = 3; podBuilder.depth(depth); ServerPod[] servers = null; switch (podConfig.getType()) { case solo: case lazy: podBuilder.primaryCount(1); servers = buildClusterServers(podConfig.getCluster(), depth); break; case web: podBuilder.primaryCount(1); servers = buildClusterServers(podConfig.getCluster(), depth); break; case pair: podBuilder.primaryCount(2); servers = buildClusterServers(podConfig.getCluster(), depth); break; case triad: podBuilder.primaryCount(3); servers = buildClusterServers(podConfig.getCluster(), depth); break; case cluster: podBuilder.primaryCount(Math.max(3, serverList.size())); servers = buildClusterServers(podConfig.getCluster(), Math.max(serverList.size(), depth)); break; default: throw new IllegalStateException(String.valueOf(podConfig.getType())); } int len = Math.min(serverList.size(), servers.length); podBuilder.type(podConfig.getType()); podBuilder.pod(servers); return podBuilder.build(); }
/** The local pod refers to the server itself. */ private UpdatePod initLocalPod() { ServerBartender serverSelf = _bartender.serverSelf(); ServicesAmp rampManager = AmpSystem.currentManager(); UpdatePodBuilder podBuilder = new UpdatePodBuilder(); podBuilder.name("local"); podBuilder.cluster(_bartender.serverSelf().getCluster()); // int count = Math.min(3, rack.getServerLength()); ServerPod serverPod = new ServerPod(0, serverSelf); ServerPod[] servers = new ServerPod[] {serverPod}; podBuilder.pod(servers); // int depth = Math.min(3, handles.length); podBuilder.primaryCount(1); podBuilder.depth(1); UpdatePod updatePod = podBuilder.build(); return new UpdatePod(updatePod, new String[] {serverSelf.getId()}, 0); }
private UpdatePod initClusterPodHub(ClusterHeartbeat cluster) { // ServiceManagerAmp rampManager = AmpSystem.currentManager(); UpdatePodBuilder podBuilder = new UpdatePodBuilder(); podBuilder.name("cluster_hub"); podBuilder.cluster(cluster); // int count = Math.min(3, rack.getServerLength()); ServerPod[] servers = buildClusterServers(cluster, 3); // PodBuilderConfig podCluster = _podMap.get(cluster.getId()); // System.out.println("PC: " + cluster + " " + cluster.getId()); // if (podCluster != null) { // ArrayList<ServerBartender> serversHint = podCluster.getServers(); // List<ServerHeartbeat> serversHint = cluster.getSeedServers(); int index = 0; boolean isFullHint = false; /* for (ServerHeartbeat server : cluster.getSeedServers()) { // ServerPod server = servers[i]; ServerBartender serverCluster = server; // serversHint.get(i); if (servers.length <= index) { } else if (server.isDynamic()) { } else if (! serverCluster.getId().startsWith("127")) { //System.out.println("ZOHP: " + serverCluster.getAddress()); //server.setHintServerId(serverCluster.getHintServerId()); servers[index++].setHintServerId(serverCluster.getId()); isFullHint = true; } else if (! isFullHint) { servers[index++].setHintPort(serverCluster.getPort()); } } //} */ podBuilder.pod(servers); // int depth = Math.min(3, handles.length); podBuilder.primaryCount(3); podBuilder.depth(3); UpdatePod update = podBuilder.build(); return update; }
private UpdatePod initClusterPod(ClusterHeartbeat cluster) { ServicesAmp rampManager = AmpSystem.currentManager(); RackHeartbeat rack = cluster.findRack("rack"); if (rack == null) { return null; } String podName = "cluster." + cluster.id(); PodBuilderConfig podConfig = _podMap.get(podName); if (podConfig != null) { return null; } UpdatePodBuilder podBuilder = new UpdatePodBuilder(); podBuilder.name("cluster"); podBuilder.cluster(cluster); List<ServerHeartbeat> seedServers = cluster.getServers(); int count = Math.max(3, seedServers.size()); ServerPod[] servers = buildClusterServers(cluster, count); int index = 0; /* for (ServerHeartbeat server : cluster.getSeedServers()) { // ServerPod server = servers[i]; ServerBartender serverCluster = server; // serversHint.get(i); if (index < servers.length && ! serverCluster.getId().startsWith("127")) { //System.out.println("ZOHP: " + serverCluster.getAddress()); //server.setHintServerId(serverCluster.getHintServerId()); servers[index++].setHintServerId(serverCluster.getId()); } } */ /* for (int i = 0; i < servers.length; i++) { ServerPod server = servers[i]; if (i < seedServers.size()) { String hintId = seedServers.get(i).getId(); if (! hintId.startsWith("127")) { server.setHintServerId(hintId); } } } */ podBuilder.pod(servers); podBuilder.depth(3); podBuilder.primaryCount(count); return podBuilder.build(); }