public static Map<String, Object> toMap(KuduTable table) { Map<String, Object> properties = new HashMap<>(); LinkedHashMap<String, ColumnDesign> columns = getColumns(table); PartitionDesign partitionDesign = getPartitionDesign(table); List<RangePartition> rangePartitionList = getRangePartitionList(table, DEFAULT_DEADLINE); try { if (partitionDesign.getHash() != null) { List<HashPartitionDefinition> list = partitionDesign.getHash(); if (!list.isEmpty()) { properties.put(PARTITION_BY_HASH_COLUMNS, list.get(0).getColumns()); properties.put(PARTITION_BY_HASH_BUCKETS, list.get(0).getBuckets()); } if (list.size() >= 2) { properties.put(PARTITION_BY_HASH_COLUMNS_2, list.get(1).getColumns()); properties.put(PARTITION_BY_HASH_BUCKETS_2, list.get(1).getBuckets()); } } if (partitionDesign.getRange() != null) { properties.put(PARTITION_BY_RANGE_COLUMNS, partitionDesign.getRange().getColumns()); } String partitionRangesValue = mapper.writeValueAsString(rangePartitionList); properties.put(RANGE_PARTITIONS, partitionRangesValue); properties.put(NUM_REPLICAS, table.getNumReplicas()); return properties; } catch (IOException e) { throw new RuntimeException(e); } }
public static Map<String, Object> toMap(KuduTable table) { Map<String, Object> properties = new HashMap<>(); LinkedHashMap<String, ColumnDesign> columns = getColumns(table); PartitionDesign partitionDesign = getPartitionDesign(table); List<RangePartition> rangePartitionList = getRangePartitionList(table, DEFAULT_DEADLINE); try { String columnDesignValue = mapper.writeValueAsString(columns); properties.put(COLUMN_DESIGN, columnDesignValue); String partitionDesignValue = mapper.writeValueAsString(partitionDesign); properties.put(PARTITION_DESIGN, partitionDesignValue); String partitionRangesValue = mapper.writeValueAsString(rangePartitionList); properties.put(RANGE_PARTITIONS, partitionRangesValue); properties.put(NUM_REPLICAS, table.getNumReplicas()); return properties; } catch (IOException e) { throw new RuntimeException(e); } }
public static Map<String, Object> toMap(KuduTable table) { Map<String, Object> properties = new HashMap<>(); LinkedHashMap<String, ColumnDesign> columns = getColumns(table); PartitionDesign partitionDesign = getPartitionDesign(table); List<RangePartition> rangePartitionList = getRangePartitionList(table, DEFAULT_DEADLINE); try { if (partitionDesign.getHash() != null) { List<HashPartitionDefinition> list = partitionDesign.getHash(); if (!list.isEmpty()) { properties.put(PARTITION_BY_HASH_COLUMNS, list.get(0).getColumns()); properties.put(PARTITION_BY_HASH_BUCKETS, list.get(0).getBuckets()); } if (list.size() >= 2) { properties.put(PARTITION_BY_HASH_COLUMNS_2, list.get(1).getColumns()); properties.put(PARTITION_BY_HASH_BUCKETS_2, list.get(1).getBuckets()); } } if (partitionDesign.getRange() != null) { properties.put(PARTITION_BY_RANGE_COLUMNS, partitionDesign.getRange().getColumns()); } String partitionRangesValue = mapper.writeValueAsString(rangePartitionList); properties.put(RANGE_PARTITIONS, partitionRangesValue); properties.put(NUM_REPLICAS, table.getNumReplicas()); return properties; } catch (IOException e) { throw new RuntimeException(e); } }
@Test(timeout = 100000) public void testNumReplicas() throws Exception { for (int i = 1; i <= 3; i++) { // Ignore even numbers. if (i % 2 != 0) { String tableName = "testNumReplicas" + "-" + i; CreateTableOptions options = getBasicCreateTableOptions(); options.setNumReplicas(i); client.createTable(tableName, basicSchema, options); KuduTable table = client.openTable(tableName); assertEquals(i, table.getNumReplicas()); } } } }