@@ -78,7 +78,7 @@ public class SchemaEngine {
7878 private final SchemaRegionLoader schemaRegionLoader ;
7979
8080 @ SuppressWarnings ("java:S3077" )
81- private volatile Map <SchemaRegionId , ISchemaRegion > schemaRegionMap ;
81+ private final Map <SchemaRegionId , ISchemaRegion > schemaRegionMap = new ConcurrentHashMap <>() ;
8282
8383 private ScheduledExecutorService timedForceMLogThread ;
8484
@@ -117,8 +117,6 @@ public void init() {
117117 // CacheMemoryManager
118118 schemaMetricManager = new SchemaMetricManager (schemaEngineStatistics );
119119
120- schemaRegionMap = new ConcurrentHashMap <>();
121-
122120 initSchemaRegion ();
123121
124122 if (!(config .getSchemaRegionConsensusProtocolClass ().equals (ConsensusFactory .RATIS_CONSENSUS ))
@@ -213,11 +211,8 @@ private void initSchemaEngineStatistics() {
213211 }
214212
215213 public void forceMlog () {
216- Map <SchemaRegionId , ISchemaRegion > schemaRegionMap = this .schemaRegionMap ;
217- if (schemaRegionMap != null ) {
218- for (ISchemaRegion schemaRegion : schemaRegionMap .values ()) {
219- schemaRegion .forceMlog ();
220- }
214+ for (ISchemaRegion schemaRegion : schemaRegionMap .values ()) {
215+ schemaRegion .forceMlog ();
221216 }
222217 }
223218
@@ -232,15 +227,13 @@ public synchronized void clear() {
232227 timedForceMLogThread = null ;
233228 }
234229
235- if (schemaRegionMap != null ) {
236- // SchemaEngineStatistics will be clear after clear all schema region
237- for (ISchemaRegion schemaRegion : schemaRegionMap .values ()) {
238- schemaRegion .clear ();
239- }
240- schemaRegionMap .clear ();
241- schemaRegionMap = null ;
242- logger .info ("clear schema region map." );
230+ // SchemaEngineStatistics will be clear after clear all schema region
231+ for (ISchemaRegion schemaRegion : schemaRegionMap .values ()) {
232+ schemaRegion .clear ();
243233 }
234+ schemaRegionMap .clear ();
235+ logger .info ("clear schema region map." );
236+
244237 // SchemaMetric should be cleared lastly
245238 if (schemaMetricManager != null ) {
246239 schemaMetricManager .clear ();
@@ -348,7 +341,7 @@ public synchronized void deleteSchemaRegion(SchemaRegionId schemaRegionId)
348341 }
349342
350343 public int getSchemaRegionNumber () {
351- return schemaRegionMap == null ? 0 : schemaRegionMap .size ();
344+ return schemaRegionMap .size ();
352345 }
353346
354347 public Map <Integer , Long > countDeviceNumBySchemaRegion (final List <Integer > schemaIds ) {
0 commit comments