@@ -273,16 +273,16 @@ public List<RegionMaintainTask> getRegionMaintainEntryList() {
273273 }
274274
275275 /**
276- * Thread-safely pre-delete the specific StorageGroup .
276+ * Thread-safely pre-delete the specific database .
277277 *
278278 * @param preDeleteDatabasePlan PreDeleteStorageGroupPlan
279279 * @return {@link TSStatusCode#SUCCESS_STATUS}
280280 */
281281 public TSStatus preDeleteDatabase (PreDeleteDatabasePlan preDeleteDatabasePlan ) {
282282 final PreDeleteDatabasePlan .PreDeleteType preDeleteType =
283283 preDeleteDatabasePlan .getPreDeleteType ();
284- final String storageGroup = preDeleteDatabasePlan .getStorageGroup ();
285- DatabasePartitionTable databasePartitionTable = databasePartitionTables .get (storageGroup );
284+ final String database = preDeleteDatabasePlan .getStorageGroup ();
285+ DatabasePartitionTable databasePartitionTable = databasePartitionTables .get (database );
286286 if (databasePartitionTable == null ) {
287287 return new TSStatus (TSStatusCode .SUCCESS_STATUS .getStatusCode ());
288288 }
@@ -305,12 +305,12 @@ public boolean isDatabasePreDeleted(String database) {
305305 }
306306
307307 /**
308- * Thread-safely delete StorageGroup .
308+ * Thread-safely delete database .
309309 *
310- * @param plan DeleteStorageGroupPlan
310+ * @param plan DeleteDatabasePlan
311311 */
312312 public void deleteDatabase (DeleteDatabasePlan plan ) {
313- // Clean the StorageGroupTable cache
313+ // Clean the databaseTable cache
314314 databasePartitionTables .remove (plan .getName ());
315315 }
316316
@@ -325,24 +325,24 @@ public DataSet getSchemaPartition(GetSchemaPartitionPlan plan) {
325325 // TODO: Replace this map with new SchemaPartition
326326 Map <String , SchemaPartitionTable > schemaPartition = new ConcurrentHashMap <>();
327327
328- if (plan .getPartitionSlotsMap ().size () == 0 ) {
328+ if (plan .getPartitionSlotsMap ().isEmpty () ) {
329329 // Return all SchemaPartitions when the queried PartitionSlots are empty
330330 databasePartitionTables .forEach (
331- (storageGroup , databasePartitionTable ) -> {
331+ (database , databasePartitionTable ) -> {
332332 if (databasePartitionTable .isNotPreDeleted ()) {
333- schemaPartition .put (storageGroup , new SchemaPartitionTable ());
333+ schemaPartition .put (database , new SchemaPartitionTable ());
334334
335335 databasePartitionTable .getSchemaPartition (
336- new ArrayList <>(), schemaPartition .get (storageGroup ));
336+ new ArrayList <>(), schemaPartition .get (database ));
337337
338- if (schemaPartition .get (storageGroup ).getSchemaPartitionMap ().isEmpty ()) {
338+ if (schemaPartition .get (database ).getSchemaPartitionMap ().isEmpty ()) {
339339 // Remove empty Map
340- schemaPartition .remove (storageGroup );
340+ schemaPartition .remove (database );
341341 }
342342 }
343343 });
344344 } else {
345- // Return the SchemaPartition for each StorageGroup
345+ // Return the SchemaPartition for each database
346346 plan .getPartitionSlotsMap ()
347347 .forEach (
348348 (database , partitionSlots ) -> {
@@ -506,16 +506,16 @@ public DataSet getSchemaNodeManagementPartition(List<String> matchedDatabases) {
506506 matchedDatabases .stream ()
507507 .filter (this ::isDatabaseExisted )
508508 .forEach (
509- storageGroup -> {
510- schemaPartitionMap .put (storageGroup , new SchemaPartitionTable ());
509+ database -> {
510+ schemaPartitionMap .put (database , new SchemaPartitionTable ());
511511
512512 databasePartitionTables
513- .get (storageGroup )
514- .getSchemaPartition (new ArrayList <>(), schemaPartitionMap .get (storageGroup ));
513+ .get (database )
514+ .getSchemaPartition (new ArrayList <>(), schemaPartitionMap .get (database ));
515515
516- if (schemaPartitionMap .get (storageGroup ).getSchemaPartitionMap ().isEmpty ()) {
516+ if (schemaPartitionMap .get (database ).getSchemaPartitionMap ().isEmpty ()) {
517517 // Remove empty Map
518- schemaPartitionMap .remove (storageGroup );
518+ schemaPartitionMap .remove (database );
519519 }
520520 });
521521
@@ -534,10 +534,10 @@ public DataSet getRegionInfoList(GetRegionInfoListPlan regionsInfoPlan) {
534534 return regionResp ;
535535 }
536536 TShowRegionReq showRegionReq = regionsInfoPlan .getShowRegionReq ();
537- final List <String > storageGroups = showRegionReq != null ? showRegionReq .getDatabases () : null ;
537+ final List <String > databases = showRegionReq != null ? showRegionReq .getDatabases () : null ;
538538 databasePartitionTables .forEach (
539- (storageGroup , databasePartitionTable ) -> {
540- if (storageGroups != null && !storageGroups .contains (storageGroup )) {
539+ (database , databasePartitionTable ) -> {
540+ if (databases != null && !databases .contains (database )) {
541541 return ;
542542 }
543543 regionInfoList .addAll (databasePartitionTable .getRegionInfoList (regionsInfoPlan ));
@@ -602,7 +602,7 @@ public TSStatus removeRegionLocation(RemoveRegionLocationPlan req) {
602602 * @param regionId regionId
603603 * @return database name
604604 */
605- public String getRegionStorageGroup (TConsensusGroupId regionId ) {
605+ public String getRegionDatabase (TConsensusGroupId regionId ) {
606606 Optional <DatabasePartitionTable > sgPartitionTableOptional =
607607 databasePartitionTables .values ().stream ()
608608 .filter (s -> s .containRegionGroup (regionId ))
@@ -617,9 +617,9 @@ public String getRegionStorageGroup(TConsensusGroupId regionId) {
617617 /**
618618 * Only Leader use this interface. Filter unassigned SchemaPartitionSlots.
619619 *
620- * @param partitionSlotsMap Map<StorageGroupName , List<TSeriesPartitionSlot>>
621- * @return Map<StorageGroupName , List<TSeriesPartitionSlot>>, SchemaPartitionSlots that is not
622- * assigned in partitionSlotsMap
620+ * @param partitionSlotsMap Map<database , List<TSeriesPartitionSlot>>
621+ * @return Map<database , List<TSeriesPartitionSlot>>, SchemaPartitionSlots that is not assigned in
622+ * partitionSlotsMap
623623 */
624624 public Map <String , List <TSeriesPartitionSlot >> filterUnassignedSchemaPartitionSlots (
625625 Map <String , List <TSeriesPartitionSlot >> partitionSlotsMap ) {
@@ -642,9 +642,9 @@ public Map<String, List<TSeriesPartitionSlot>> filterUnassignedSchemaPartitionSl
642642 /**
643643 * Only Leader use this interface. Filter unassigned SchemaPartitionSlots
644644 *
645- * @param partitionSlotsMap Map<StorageGroupName , Map<TSeriesPartitionSlot, TTimeSlotList>>
646- * @return Map<StorageGroupName , Map<TSeriesPartitionSlot, TTimeSlotList>>, DataPartitionSlots
647- * that is not assigned in partitionSlotsMap
645+ * @param partitionSlotsMap Map<database , Map<TSeriesPartitionSlot, TTimeSlotList>>
646+ * @return Map<database , Map<TSeriesPartitionSlot, TTimeSlotList>>, DataPartitionSlots that is not
647+ * assigned in partitionSlotsMap
648648 */
649649 public Map <String , Map <TSeriesPartitionSlot , TTimeSlotList >> filterUnassignedDataPartitionSlots (
650650 Map <String , Map <TSeriesPartitionSlot , TTimeSlotList >> partitionSlotsMap ) {
@@ -806,8 +806,8 @@ public int countDataNodeScatterWidth(
806806 *
807807 * @param database DatabaseName
808808 * @param type SchemaRegion or DataRegion
809- * @return Number of Regions currently owned by the specific StorageGroup
810- * @throws DatabaseNotExistsException When the specific StorageGroup doesn't exist
809+ * @return Number of Regions currently owned by the specific database
810+ * @throws DatabaseNotExistsException When the specific database doesn't exist
811811 */
812812 public int getRegionGroupCount (String database , TConsensusGroupType type )
813813 throws DatabaseNotExistsException {
@@ -865,7 +865,9 @@ public List<TConsensusGroupId> getAllRegionGroupIds(String database, TConsensusG
865865 * @return The assigned SeriesPartitionSlots count
866866 */
867867 public int getAssignedSeriesPartitionSlotsCount (String database ) {
868- return databasePartitionTables .get (database ).getAssignedSeriesPartitionSlotsCount ();
868+ return Optional .ofNullable (databasePartitionTables .get (database ))
869+ .map (DatabasePartitionTable ::getAssignedSeriesPartitionSlotsCount )
870+ .orElse (0 );
869871 }
870872
871873 /**
@@ -877,13 +879,15 @@ public int getAssignedSeriesPartitionSlotsCount(String database) {
877879 * @return The assigned TimePartitionSlots count
878880 */
879881 public long getAssignedTimePartitionSlotsCount (String database ) {
880- return databasePartitionTables .get (database ).getTimeSlotCount ();
882+ return Optional .ofNullable (databasePartitionTables .get (database ))
883+ .map (DatabasePartitionTable ::getTimeSlotCount )
884+ .orElse (0L );
881885 }
882886
883887 /**
884- * Get the DataNodes who contain the specific StorageGroup 's Schema or Data.
888+ * Get the DataNodes who contain the specific database 's Schema or Data.
885889 *
886- * @param database The specific StorageGroup 's name
890+ * @param database The specific database 's name
887891 * @param type SchemaRegion or DataRegion
888892 * @return Set {@literal <}TDataNodeLocation{@literal >}, the related DataNodes
889893 */
@@ -897,7 +901,7 @@ public Set<TDataNodeLocation> getDatabaseRelatedDataNodes(
897901 *
898902 * @param database DatabaseName
899903 * @param type SchemaRegion or DataRegion
900- * @return The StorageGroup 's Running or Available Regions that sorted by the number of allocated
904+ * @return The database 's Running or Available Regions that sorted by the number of allocated
901905 * slots
902906 */
903907 public List <Pair <Long , TConsensusGroupId >> getRegionGroupSlotsCounter (
@@ -955,12 +959,12 @@ public boolean processTakeSnapshot(File snapshotDir) throws TException, IOExcept
955959 // serialize nextRegionGroupId
956960 ReadWriteIOUtils .write (nextRegionGroupId .get (), bufferedOutputStream );
957961
958- // serialize StorageGroupPartitionTable
962+ // serialize databasePartitionTable
959963 ReadWriteIOUtils .write (databasePartitionTables .size (), bufferedOutputStream );
960- for (Map .Entry <String , DatabasePartitionTable > storageGroupPartitionTableEntry :
964+ for (Map .Entry <String , DatabasePartitionTable > databasePartitionTableEntry :
961965 databasePartitionTables .entrySet ()) {
962- ReadWriteIOUtils .write (storageGroupPartitionTableEntry .getKey (), bufferedOutputStream );
963- storageGroupPartitionTableEntry .getValue ().serialize (bufferedOutputStream , protocol );
966+ ReadWriteIOUtils .write (databasePartitionTableEntry .getKey (), bufferedOutputStream );
967+ databasePartitionTableEntry .getValue ().serialize (bufferedOutputStream , protocol );
964968 }
965969
966970 // serialize regionCleanList
@@ -1012,17 +1016,16 @@ public void processLoadSnapshot(final File snapshotDir) throws TException, IOExc
10121016 // start to restore
10131017 nextRegionGroupId .set (ReadWriteIOUtils .readInt (fileInputStream ));
10141018
1015- // restore StorageGroupPartitionTable
1019+ // restore databasePartitionTable
10161020 int length = ReadWriteIOUtils .readInt (fileInputStream );
10171021 for (int i = 0 ; i < length ; i ++) {
1018- final String storageGroup = ReadWriteIOUtils .readString (fileInputStream );
1019- if (storageGroup == null ) {
1020- throw new IOException ("Failed to load snapshot because get null StorageGroup name" );
1022+ final String database = ReadWriteIOUtils .readString (fileInputStream );
1023+ if (database == null ) {
1024+ throw new IOException ("Failed to load snapshot because get null database name" );
10211025 }
1022- final DatabasePartitionTable databasePartitionTable =
1023- new DatabasePartitionTable (storageGroup );
1026+ final DatabasePartitionTable databasePartitionTable = new DatabasePartitionTable (database );
10241027 databasePartitionTable .deserialize (fileInputStream , protocol );
1025- databasePartitionTables .put (storageGroup , databasePartitionTable );
1028+ databasePartitionTables .put (database , databasePartitionTable );
10261029 }
10271030
10281031 // restore deletedRegionSet
0 commit comments