public static ReplicationMap roundRobinMap(int nPartitions, int repFactor, String... hosts) { List<ReplicationEntry> repEntries = new ArrayList<ReplicationEntry>(); for(int i = 0; i < nPartitions; i++) { int toNode = i % hosts.length; ReplicationEntry repEntry = new ReplicationEntry(); repEntry.setShard(i); List<String> shardDNodes = new ArrayList<String>(); for(int j = 0; j < repFactor; j++) { int chosen = (toNode + j) % hosts.length; shardDNodes.add(hosts[chosen]); } repEntry.setNodes(shardDNodes); repEntries.add(repEntry); } return new ReplicationMap(repEntries); }
public static ReplicationMap roundRobinMap(int nPartitions, int repFactor, String... hosts) { List<ReplicationEntry> repEntries = new ArrayList<ReplicationEntry>(); for (int i = 0; i < nPartitions; i++) { int toNode = i % hosts.length; ReplicationEntry repEntry = new ReplicationEntry(); repEntry.setShard(i); List<String> shardDNodes = new ArrayList<String>(); for (int j = 0; j < repFactor; j++) { int chosen = (toNode + j) % hosts.length; shardDNodes.add(hosts[chosen]); } repEntry.setNodes(shardDNodes); repEntries.add(repEntry); } return new ReplicationMap(repEntries); }
/** * Returns a one to one replication map with consecutive shard Ids from a list of hosts. This method is useful for * quickly having an instance of ReplicationMap that has no replication (1 shard -> 1 host). */ public static ReplicationMap oneToOneMap(String... hosts) { List<ReplicationEntry> replicationMap = new ArrayList<ReplicationEntry>(); int shard = 0; for(String host : hosts) { ReplicationEntry entry = new ReplicationEntry(); entry.setNodes(Arrays.asList(new String[] { host })); entry.setShard(shard); replicationMap.add(entry); shard++; } return new ReplicationMap(replicationMap); }
/** * Returns a one to one replication map with consecutive shard Ids from a list of hosts. This method is useful for * quickly having an instance of ReplicationMap that has no replication (1 shard -> 1 host). */ public static ReplicationMap oneToOneMap(String... hosts) { List<ReplicationEntry> replicationMap = new ArrayList<ReplicationEntry>(); int shard = 0; for (String host : hosts) { ReplicationEntry entry = new ReplicationEntry(); entry.setNodes(Arrays.asList(new String[]{host})); entry.setShard(shard); replicationMap.add(entry); shard++; } return new ReplicationMap(replicationMap); }
} else { currentTablespace = new Tablespace(new PartitionMap(partitionMap), new ReplicationMap(replicationMap), versionName, deployDate); tablespaceVersionMap.put(tablespaceVersion, currentTablespace);