Committed by
Brian O'Connor
ONOS-1310: less verbose partitions cli command
Change-Id: I2ff341ec7a6760543dddc350425f840b425eff83
Showing
1 changed file
with
5 additions
and
4 deletions
... | @@ -65,6 +65,8 @@ public class DatabaseManager implements StorageService, StorageAdminService { | ... | @@ -65,6 +65,8 @@ public class DatabaseManager implements StorageService, StorageAdminService { |
65 | private static final String PARTITION_DEFINITION_FILE = "tablets.json"; | 65 | private static final String PARTITION_DEFINITION_FILE = "tablets.json"; |
66 | private static final int DATABASE_STARTUP_TIMEOUT_SEC = 60; | 66 | private static final int DATABASE_STARTUP_TIMEOUT_SEC = 60; |
67 | 67 | ||
68 | + private final PartitionedDatabaseConfig databaseConfig = new PartitionedDatabaseConfig(); | ||
69 | + | ||
68 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 70 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
69 | protected ClusterService clusterService; | 71 | protected ClusterService clusterService; |
70 | 72 | ||
... | @@ -114,8 +116,6 @@ public class DatabaseManager implements StorageService, StorageAdminService { | ... | @@ -114,8 +116,6 @@ public class DatabaseManager implements StorageService, StorageAdminService { |
114 | .withMembers(activeNodeUris) | 116 | .withMembers(activeNodeUris) |
115 | .withLocalMember(localNodeUri); | 117 | .withLocalMember(localNodeUri); |
116 | 118 | ||
117 | - PartitionedDatabaseConfig databaseConfig = new PartitionedDatabaseConfig(); | ||
118 | - | ||
119 | partitionMap.forEach((name, nodes) -> { | 119 | partitionMap.forEach((name, nodes) -> { |
120 | Set<String> replicas = nodes.stream().map(this::nodeToUri).collect(Collectors.toSet()); | 120 | Set<String> replicas = nodes.stream().map(this::nodeToUri).collect(Collectors.toSet()); |
121 | DatabaseConfig partitionConfig = new DatabaseConfig() | 121 | DatabaseConfig partitionConfig = new DatabaseConfig() |
... | @@ -181,7 +181,7 @@ public class DatabaseManager implements StorageService, StorageAdminService { | ... | @@ -181,7 +181,7 @@ public class DatabaseManager implements StorageService, StorageAdminService { |
181 | return partitionedDatabase.getRegisteredPartitions() | 181 | return partitionedDatabase.getRegisteredPartitions() |
182 | .values() | 182 | .values() |
183 | .stream() | 183 | .stream() |
184 | - .map(DatabaseManager::toPartitionInfo) | 184 | + .map(db -> toPartitionInfo(db, databaseConfig.partitions().get(db.name()))) |
185 | .collect(Collectors.toList()); | 185 | .collect(Collectors.toList()); |
186 | } | 186 | } |
187 | 187 | ||
... | @@ -191,11 +191,12 @@ public class DatabaseManager implements StorageService, StorageAdminService { | ... | @@ -191,11 +191,12 @@ public class DatabaseManager implements StorageService, StorageAdminService { |
191 | * @param database database containing input data | 191 | * @param database database containing input data |
192 | * @return PartitionInfo object | 192 | * @return PartitionInfo object |
193 | */ | 193 | */ |
194 | - private static PartitionInfo toPartitionInfo(Database database) { | 194 | + private static PartitionInfo toPartitionInfo(Database database, DatabaseConfig dbConfig) { |
195 | return new PartitionInfo(database.name(), | 195 | return new PartitionInfo(database.name(), |
196 | database.cluster().term(), | 196 | database.cluster().term(), |
197 | database.cluster().members().stream() | 197 | database.cluster().members().stream() |
198 | .map(Member::uri) | 198 | .map(Member::uri) |
199 | + .filter(uri -> dbConfig.getReplicas().contains(uri)) | ||
199 | .collect(Collectors.toList()), | 200 | .collect(Collectors.toList()), |
200 | database.cluster().leader() != null ? | 201 | database.cluster().leader() != null ? |
201 | database.cluster().leader().uri() : null); | 202 | database.cluster().leader().uri() : null); | ... | ... |
-
Please register or login to post a comment