public byte[] getValidValue(ByteArray key) { String keyString = ByteUtils.getString(key.get(), "UTF-8"); if (MetadataStore.CLUSTER_KEY.equals(keyString)) { return ByteUtils.getBytes( new ClusterMapper().writeCluster(ServerTestUtils.getLocalCluster(1)), "UTF-8"); } else if (MetadataStore.STORES_KEY.equals(keyString)) { return ByteUtils.getBytes( new StoreDefinitionsMapper().writeStoreList(ServerTestUtils.getStoreDefs(1)), "UTF-8"); } else if (MetadataStore.SERVER_STATE_KEY.equals(keyString)) { int i = (int) (Math.random() * VoldemortState.values().length); return ByteUtils.getBytes(VoldemortState.values()[i].toString(), "UTF-8"); } else if (MetadataStore.REBALANCING_STEAL_INFO.equals(keyString)) { int size = (int) (Math.random() * 10); List<Integer> partition = new ArrayList<Integer>(); for (int i = 0; i < size; i++) { partition.add((int) Math.random() * 10); } return ByteUtils.getBytes( new RebalancerState( Arrays.asList( new RebalancePartitionsInfo( 0, (int) Math.random() * 5, partition, new ArrayList<Integer>(0), new ArrayList<Integer>(0), Arrays.asList("testStoreName"), new HashMap<String, String>(), new HashMap<String, String>(), (int) Math.random() * 3))) .toJsonString(), "UTF-8"); } else if (MetadataStore.GRANDFATHERING_INFO.equals(keyString)) { int size = (int) (Math.random() * 10); List<Integer> partition = new ArrayList<Integer>(); for (int i = 0; i < size; i++) { partition.add((int) Math.random() * 10); } return ByteUtils.getBytes( new GrandfatherState( Arrays.asList( new RebalancePartitionsInfo( 0, (int) Math.random() * 5, partition, new ArrayList<Integer>(0), new ArrayList<Integer>(0), Arrays.asList("testStoreName"), new HashMap<String, String>(), new HashMap<String, String>(), (int) Math.random() * 3))) .toJsonString(), "UTF-8"); } throw new RuntimeException("Unhandled key:" + keyString + " passed"); }
public byte[] getValidValue(ByteArray key) { String keyString = ByteUtils.getString(key.get(), "UTF-8"); if (MetadataStore.CLUSTER_KEY.equals(keyString) || MetadataStore.REBALANCING_SOURCE_CLUSTER_XML.equals(keyString)) { return ByteUtils.getBytes( new ClusterMapper().writeCluster(ServerTestUtils.getLocalCluster(1)), "UTF-8"); } else if (MetadataStore.STORES_KEY.equals(keyString)) { return ByteUtils.getBytes( new StoreDefinitionsMapper().writeStoreList(ServerTestUtils.getStoreDefs(1)), "UTF-8"); } else if (MetadataStore.SERVER_STATE_KEY.equals(keyString)) { int i = (int) (Math.random() * VoldemortState.values().length); return ByteUtils.getBytes(VoldemortState.values()[i].toString(), "UTF-8"); } else if (MetadataStore.REBALANCING_STEAL_INFO.equals(keyString)) { int size = (int) (Math.random() * 10) + 1; List<Integer> partition = new ArrayList<Integer>(); for (int i = 0; i < size; i++) { partition.add((int) Math.random() * 10); } List<Integer> partitionIds = partition; HashMap<String, List<Integer>> storeToReplicaToPartitionList = Maps.newHashMap(); storeToReplicaToPartitionList.put("test", partitionIds); return ByteUtils.getBytes( new RebalancerState( Arrays.asList( new RebalanceTaskInfo( 0, (int) Math.random() * 5, storeToReplicaToPartitionList, ServerTestUtils.getLocalCluster(1)))) .toJsonString(), "UTF-8"); } throw new RuntimeException("Unhandled key:" + keyString + " passed"); }