• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9633

pending completion
#9633

push

travis_ci

web-flow
Add database limit threshold configuration and check when creating new database.

42 of 42 new or added lines in 7 files covered. (100.0%)

79031 of 165235 relevant lines covered (47.83%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.34
/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.confignode.manager;
21

22
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
23
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
24
import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
25
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
26
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
27
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
28
import org.apache.iotdb.common.rpc.thrift.TSStatus;
29
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
30
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
31
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
32
import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
33
import org.apache.iotdb.commons.cluster.NodeStatus;
34
import org.apache.iotdb.commons.cluster.NodeType;
35
import org.apache.iotdb.commons.conf.CommonConfig;
36
import org.apache.iotdb.commons.conf.CommonDescriptor;
37
import org.apache.iotdb.commons.conf.IoTDBConstant;
38
import org.apache.iotdb.commons.exception.IllegalPathException;
39
import org.apache.iotdb.commons.path.PartialPath;
40
import org.apache.iotdb.commons.path.PathPatternTree;
41
import org.apache.iotdb.commons.service.metric.MetricService;
42
import org.apache.iotdb.commons.utils.AuthUtils;
43
import org.apache.iotdb.commons.utils.PathUtils;
44
import org.apache.iotdb.commons.utils.StatusUtils;
45
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
46
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
47
import org.apache.iotdb.confignode.conf.SystemPropertiesUtils;
48
import org.apache.iotdb.confignode.consensus.request.auth.AuthorPlan;
49
import org.apache.iotdb.confignode.consensus.request.read.database.CountDatabasePlan;
50
import org.apache.iotdb.confignode.consensus.request.read.database.GetDatabasePlan;
51
import org.apache.iotdb.confignode.consensus.request.read.datanode.GetDataNodeConfigurationPlan;
52
import org.apache.iotdb.confignode.consensus.request.read.partition.GetDataPartitionPlan;
53
import org.apache.iotdb.confignode.consensus.request.read.partition.GetNodePathsPartitionPlan;
54
import org.apache.iotdb.confignode.consensus.request.read.partition.GetOrCreateDataPartitionPlan;
55
import org.apache.iotdb.confignode.consensus.request.read.partition.GetOrCreateSchemaPartitionPlan;
56
import org.apache.iotdb.confignode.consensus.request.read.partition.GetSchemaPartitionPlan;
57
import org.apache.iotdb.confignode.consensus.request.read.region.GetRegionInfoListPlan;
58
import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan;
59
import org.apache.iotdb.confignode.consensus.request.write.database.DatabaseSchemaPlan;
60
import org.apache.iotdb.confignode.consensus.request.write.database.SetDataReplicationFactorPlan;
61
import org.apache.iotdb.confignode.consensus.request.write.database.SetSchemaReplicationFactorPlan;
62
import org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan;
63
import org.apache.iotdb.confignode.consensus.request.write.database.SetTimePartitionIntervalPlan;
64
import org.apache.iotdb.confignode.consensus.request.write.datanode.RegisterDataNodePlan;
65
import org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan;
66
import org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan;
67
import org.apache.iotdb.confignode.consensus.response.auth.PermissionInfoResp;
68
import org.apache.iotdb.confignode.consensus.response.database.CountDatabaseResp;
69
import org.apache.iotdb.confignode.consensus.response.database.DatabaseSchemaResp;
70
import org.apache.iotdb.confignode.consensus.response.datanode.ConfigurationResp;
71
import org.apache.iotdb.confignode.consensus.response.datanode.DataNodeConfigurationResp;
72
import org.apache.iotdb.confignode.consensus.response.datanode.DataNodeRegisterResp;
73
import org.apache.iotdb.confignode.consensus.response.datanode.DataNodeToStatusResp;
74
import org.apache.iotdb.confignode.consensus.response.partition.DataPartitionResp;
75
import org.apache.iotdb.confignode.consensus.response.partition.RegionInfoListResp;
76
import org.apache.iotdb.confignode.consensus.response.partition.SchemaNodeManagementResp;
77
import org.apache.iotdb.confignode.consensus.response.partition.SchemaPartitionResp;
78
import org.apache.iotdb.confignode.consensus.response.template.TemplateSetInfoResp;
79
import org.apache.iotdb.confignode.consensus.statemachine.ConfigRegionStateMachine;
80
import org.apache.iotdb.confignode.manager.consensus.ConsensusManager;
81
import org.apache.iotdb.confignode.manager.cq.CQManager;
82
import org.apache.iotdb.confignode.manager.load.LoadManager;
83
import org.apache.iotdb.confignode.manager.load.cache.node.NodeHeartbeatSample;
84
import org.apache.iotdb.confignode.manager.node.ClusterNodeStartUtils;
85
import org.apache.iotdb.confignode.manager.node.NodeManager;
86
import org.apache.iotdb.confignode.manager.node.NodeMetrics;
87
import org.apache.iotdb.confignode.manager.partition.PartitionManager;
88
import org.apache.iotdb.confignode.manager.partition.PartitionMetrics;
89
import org.apache.iotdb.confignode.manager.pipe.PipeManager;
90
import org.apache.iotdb.confignode.manager.schema.ClusterSchemaManager;
91
import org.apache.iotdb.confignode.manager.schema.ClusterSchemaQuotaStatistics;
92
import org.apache.iotdb.confignode.persistence.AuthorInfo;
93
import org.apache.iotdb.confignode.persistence.ModelInfo;
94
import org.apache.iotdb.confignode.persistence.ProcedureInfo;
95
import org.apache.iotdb.confignode.persistence.TriggerInfo;
96
import org.apache.iotdb.confignode.persistence.UDFInfo;
97
import org.apache.iotdb.confignode.persistence.cq.CQInfo;
98
import org.apache.iotdb.confignode.persistence.executor.ConfigPlanExecutor;
99
import org.apache.iotdb.confignode.persistence.node.NodeInfo;
100
import org.apache.iotdb.confignode.persistence.partition.PartitionInfo;
101
import org.apache.iotdb.confignode.persistence.pipe.PipeInfo;
102
import org.apache.iotdb.confignode.persistence.quota.QuotaInfo;
103
import org.apache.iotdb.confignode.persistence.schema.ClusterSchemaInfo;
104
import org.apache.iotdb.confignode.rpc.thrift.TAlterLogicalViewReq;
105
import org.apache.iotdb.confignode.rpc.thrift.TAlterSchemaTemplateReq;
106
import org.apache.iotdb.confignode.rpc.thrift.TClusterParameters;
107
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq;
108
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterResp;
109
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRestartReq;
110
import org.apache.iotdb.confignode.rpc.thrift.TCountTimeSlotListReq;
111
import org.apache.iotdb.confignode.rpc.thrift.TCountTimeSlotListResp;
112
import org.apache.iotdb.confignode.rpc.thrift.TCreateCQReq;
113
import org.apache.iotdb.confignode.rpc.thrift.TCreateFunctionReq;
114
import org.apache.iotdb.confignode.rpc.thrift.TCreateModelReq;
115
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipePluginReq;
116
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq;
117
import org.apache.iotdb.confignode.rpc.thrift.TCreateSchemaTemplateReq;
118
import org.apache.iotdb.confignode.rpc.thrift.TCreateTriggerReq;
119
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
120
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartReq;
121
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartResp;
122
import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionTableResp;
123
import org.apache.iotdb.confignode.rpc.thrift.TDatabaseSchema;
124
import org.apache.iotdb.confignode.rpc.thrift.TDeactivateSchemaTemplateReq;
125
import org.apache.iotdb.confignode.rpc.thrift.TDeleteLogicalViewReq;
126
import org.apache.iotdb.confignode.rpc.thrift.TDeleteTimeSeriesReq;
127
import org.apache.iotdb.confignode.rpc.thrift.TDropCQReq;
128
import org.apache.iotdb.confignode.rpc.thrift.TDropModelReq;
129
import org.apache.iotdb.confignode.rpc.thrift.TDropTriggerReq;
130
import org.apache.iotdb.confignode.rpc.thrift.TGetAllPipeInfoResp;
131
import org.apache.iotdb.confignode.rpc.thrift.TGetAllTemplatesResp;
132
import org.apache.iotdb.confignode.rpc.thrift.TGetDataNodeLocationsResp;
133
import org.apache.iotdb.confignode.rpc.thrift.TGetJarInListReq;
134
import org.apache.iotdb.confignode.rpc.thrift.TGetJarInListResp;
135
import org.apache.iotdb.confignode.rpc.thrift.TGetLocationForTriggerResp;
136
import org.apache.iotdb.confignode.rpc.thrift.TGetPathsSetTemplatesResp;
137
import org.apache.iotdb.confignode.rpc.thrift.TGetPipePluginTableResp;
138
import org.apache.iotdb.confignode.rpc.thrift.TGetRegionIdReq;
139
import org.apache.iotdb.confignode.rpc.thrift.TGetRegionIdResp;
140
import org.apache.iotdb.confignode.rpc.thrift.TGetSeriesSlotListReq;
141
import org.apache.iotdb.confignode.rpc.thrift.TGetSeriesSlotListResp;
142
import org.apache.iotdb.confignode.rpc.thrift.TGetTemplateResp;
143
import org.apache.iotdb.confignode.rpc.thrift.TGetTimeSlotListReq;
144
import org.apache.iotdb.confignode.rpc.thrift.TGetTimeSlotListResp;
145
import org.apache.iotdb.confignode.rpc.thrift.TGetTriggerTableResp;
146
import org.apache.iotdb.confignode.rpc.thrift.TGetUDFTableResp;
147
import org.apache.iotdb.confignode.rpc.thrift.TMigrateRegionReq;
148
import org.apache.iotdb.confignode.rpc.thrift.TPermissionInfoResp;
149
import org.apache.iotdb.confignode.rpc.thrift.TRegionMigrateResultReportReq;
150
import org.apache.iotdb.confignode.rpc.thrift.TRegionRouteMapResp;
151
import org.apache.iotdb.confignode.rpc.thrift.TSchemaNodeManagementResp;
152
import org.apache.iotdb.confignode.rpc.thrift.TSchemaPartitionTableResp;
153
import org.apache.iotdb.confignode.rpc.thrift.TSetDataNodeStatusReq;
154
import org.apache.iotdb.confignode.rpc.thrift.TSetSchemaTemplateReq;
155
import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp;
156
import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
157
import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
158
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
159
import org.apache.iotdb.confignode.rpc.thrift.TShowDatabaseResp;
160
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
161
import org.apache.iotdb.confignode.rpc.thrift.TShowModelResp;
162
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeReq;
163
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeResp;
164
import org.apache.iotdb.confignode.rpc.thrift.TShowThrottleReq;
165
import org.apache.iotdb.confignode.rpc.thrift.TShowTrailReq;
166
import org.apache.iotdb.confignode.rpc.thrift.TShowTrailResp;
167
import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp;
168
import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp;
169
import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp;
170
import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList;
171
import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq;
172
import org.apache.iotdb.confignode.rpc.thrift.TUpdateModelInfoReq;
173
import org.apache.iotdb.confignode.rpc.thrift.TUpdateModelStateReq;
174
import org.apache.iotdb.consensus.common.DataSet;
175
import org.apache.iotdb.db.schemaengine.template.Template;
176
import org.apache.iotdb.db.schemaengine.template.TemplateAlterOperationType;
177
import org.apache.iotdb.db.schemaengine.template.alter.TemplateAlterOperationUtil;
178
import org.apache.iotdb.rpc.RpcUtils;
179
import org.apache.iotdb.rpc.TSStatusCode;
180
import org.apache.iotdb.tsfile.utils.Pair;
181

182
import org.slf4j.Logger;
183
import org.slf4j.LoggerFactory;
184

185
import java.io.IOException;
186
import java.nio.ByteBuffer;
187
import java.util.ArrayList;
188
import java.util.Arrays;
189
import java.util.Collection;
190
import java.util.Collections;
191
import java.util.Comparator;
192
import java.util.HashMap;
193
import java.util.HashSet;
194
import java.util.List;
195
import java.util.Map;
196
import java.util.Set;
197
import java.util.concurrent.atomic.AtomicReference;
198
import java.util.stream.Collectors;
199

200
import static org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCARD;
201

202
/** Entry of all management, AssignPartitionManager, AssignRegionManager. */
203
public class ConfigManager implements IManager {
204

205
  private static final Logger LOGGER = LoggerFactory.getLogger(ConfigManager.class);
1✔
206

207
  private static final ConfigNodeConfig CONF = ConfigNodeDescriptor.getInstance().getConf();
1✔
208
  private static final CommonConfig COMMON_CONF = CommonDescriptor.getInstance().getConfig();
1✔
209

210
  /** Manage PartitionTable read/write requests through the ConsensusLayer. */
211
  private final AtomicReference<ConsensusManager> consensusManager = new AtomicReference<>();
×
212

213
  /** Manage cluster node. */
214
  private final NodeManager nodeManager;
215

216
  /** Manage cluster schemaengine. */
217
  private final ClusterSchemaManager clusterSchemaManager;
218

219
  /** Manage cluster regions and partitions. */
220
  private final PartitionManager partitionManager;
221

222
  /** Manage cluster authorization. */
223
  private final PermissionManager permissionManager;
224

225
  private final LoadManager loadManager;
226

227
  /** Manage procedure. */
228
  private final ProcedureManager procedureManager;
229

230
  /** UDF. */
231
  private final UDFManager udfManager;
232

233
  /** Manage Trigger. */
234
  private final TriggerManager triggerManager;
235

236
  /** CQ. */
237
  private final CQManager cqManager;
238

239
  /** ML Model. */
240
  private final ModelManager modelManager;
241

242
  /** Pipe */
243
  private final PipeManager pipeManager;
244

245
  /** Manage quotas */
246
  private final ClusterQuotaManager clusterQuotaManager;
247

248
  private final ConfigRegionStateMachine stateMachine;
249

250
  private final RetryFailedTasksThread retryFailedTasksThread;
251

252
  private static final String DATABASE = "\tDatabase=";
253

254
  public ConfigManager() throws IOException {
×
255
    // Build the persistence module
256
    NodeInfo nodeInfo = new NodeInfo();
×
257
    ClusterSchemaInfo clusterSchemaInfo = new ClusterSchemaInfo();
×
258
    PartitionInfo partitionInfo = new PartitionInfo();
×
259
    AuthorInfo authorInfo = new AuthorInfo();
×
260
    ProcedureInfo procedureInfo = new ProcedureInfo();
×
261
    UDFInfo udfInfo = new UDFInfo();
×
262
    TriggerInfo triggerInfo = new TriggerInfo();
×
263
    CQInfo cqInfo = new CQInfo();
×
264
    ModelInfo modelInfo = new ModelInfo();
×
265
    PipeInfo pipeInfo = new PipeInfo();
×
266
    QuotaInfo quotaInfo = new QuotaInfo();
×
267

268
    // Build state machine and executor
269
    ConfigPlanExecutor executor =
×
270
        new ConfigPlanExecutor(
271
            nodeInfo,
272
            clusterSchemaInfo,
273
            partitionInfo,
274
            authorInfo,
275
            procedureInfo,
276
            udfInfo,
277
            triggerInfo,
278
            cqInfo,
279
            modelInfo,
280
            pipeInfo,
281
            quotaInfo);
282
    this.stateMachine = new ConfigRegionStateMachine(this, executor);
×
283

284
    // Build the manager module
285
    this.nodeManager = new NodeManager(this, nodeInfo);
×
286
    this.clusterSchemaManager =
×
287
        new ClusterSchemaManager(this, clusterSchemaInfo, new ClusterSchemaQuotaStatistics());
288
    this.partitionManager = new PartitionManager(this, partitionInfo);
×
289
    this.permissionManager = new PermissionManager(this, authorInfo);
×
290
    this.procedureManager = new ProcedureManager(this, procedureInfo);
×
291
    this.udfManager = new UDFManager(this, udfInfo);
×
292
    this.triggerManager = new TriggerManager(this, triggerInfo);
×
293
    this.cqManager = new CQManager(this);
×
294
    this.modelManager = new ModelManager(this, modelInfo);
×
295
    this.pipeManager = new PipeManager(this, pipeInfo);
×
296

297
    // 1. keep PipeManager initialization before LoadManager initialization, because
298
    // LoadManager will register PipeManager as a listener.
299
    // 2. keep RetryFailedTasksThread initialization after LoadManager initialization,
300
    // because RetryFailedTasksThread will keep a reference of LoadManager.
301
    this.loadManager = new LoadManager(this);
×
302

303
    this.retryFailedTasksThread = new RetryFailedTasksThread(this);
×
304
    this.clusterQuotaManager = new ClusterQuotaManager(this, quotaInfo);
×
305
  }
×
306

307
  public void initConsensusManager() throws IOException {
308
    this.consensusManager.set(new ConsensusManager(this, this.stateMachine));
×
309
  }
×
310

311
  public void close() throws IOException {
312
    if (consensusManager.get() != null) {
×
313
      consensusManager.get().close();
×
314
    }
315
    if (partitionManager != null) {
×
316
      partitionManager.getRegionMaintainer().shutdown();
×
317
    }
318
    if (procedureManager != null) {
×
319
      procedureManager.shiftExecutor(false);
×
320
    }
321
  }
×
322

323
  @Override
324
  public DataSet getSystemConfiguration() {
325
    TSStatus status = confirmLeader();
×
326
    ConfigurationResp dataSet;
327
    // Notice: The Seed-ConfigNode must also have the privilege to give system configuration.
328
    // Otherwise, the IoTDB-cluster will not have the ability to restart from scratch.
329
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
330
        || ConfigNodeDescriptor.getInstance().isSeedConfigNode()
×
331
        || SystemPropertiesUtils.isSeedConfigNode()) {
×
332
      dataSet = (ConfigurationResp) nodeManager.getSystemConfiguration();
×
333
    } else {
334
      dataSet = new ConfigurationResp();
×
335
      dataSet.setStatus(status);
×
336
    }
337
    return dataSet;
×
338
  }
339

340
  @Override
341
  public DataSet registerDataNode(TDataNodeRegisterReq req) {
342
    TSStatus status = confirmLeader();
×
343
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
344
      status =
×
345
          ClusterNodeStartUtils.confirmNodeRegistration(
×
346
              NodeType.DataNode,
347
              req.getClusterName(),
×
348
              req.getDataNodeConfiguration().getLocation(),
×
349
              this);
350
      if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
351
        return nodeManager.registerDataNode(
×
352
            new RegisterDataNodePlan(req.getDataNodeConfiguration()));
×
353
      }
354
    }
355

356
    DataNodeRegisterResp resp = new DataNodeRegisterResp();
×
357
    resp.setStatus(status);
×
358
    resp.setConfigNodeList(getNodeManager().getRegisteredConfigNodes());
×
359
    return resp;
×
360
  }
361

362
  @Override
363
  public TDataNodeRestartResp restartDataNode(TDataNodeRestartReq req) {
364
    TSStatus status = confirmLeader();
×
365
    // Notice: The Seed-ConfigNode must also have the privilege to do Node restart check.
366
    // Otherwise, the IoTDB-cluster will not have the ability to restart from scratch.
367
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
368
        || ConfigNodeDescriptor.getInstance().isSeedConfigNode()
×
369
        || SystemPropertiesUtils.isSeedConfigNode()) {
×
370
      status =
×
371
          ClusterNodeStartUtils.confirmNodeRestart(
×
372
              NodeType.DataNode,
373
              req.getClusterName(),
×
374
              req.getDataNodeConfiguration().getLocation().getDataNodeId(),
×
375
              req.getDataNodeConfiguration().getLocation(),
×
376
              this);
377
      if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
378
        return nodeManager.updateDataNodeIfNecessary(req.getDataNodeConfiguration());
×
379
      }
380
    }
381

382
    return new TDataNodeRestartResp()
×
383
        .setStatus(status)
×
384
        .setConfigNodeList(getNodeManager().getRegisteredConfigNodes());
×
385
  }
386

387
  @Override
388
  public DataSet removeDataNode(RemoveDataNodePlan removeDataNodePlan) {
389
    TSStatus status = confirmLeader();
×
390
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
391
      return nodeManager.removeDataNode(removeDataNodePlan);
×
392
    } else {
393
      DataNodeToStatusResp dataSet = new DataNodeToStatusResp();
×
394
      dataSet.setStatus(status);
×
395
      return dataSet;
×
396
    }
397
  }
398

399
  @Override
400
  public TSStatus reportDataNodeShutdown(TDataNodeLocation dataNodeLocation) {
401
    TSStatus status = confirmLeader();
×
402
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
403
      // Force updating the target DataNode's status to Unknown
404
      getLoadManager()
×
405
          .forceUpdateNodeCache(
×
406
              NodeType.DataNode,
407
              dataNodeLocation.getDataNodeId(),
×
408
              NodeHeartbeatSample.generateDefaultSample(NodeStatus.Unknown));
×
409
      LOGGER.info(
×
410
          "[ShutdownHook] The DataNode-{} will be shutdown soon, mark it as Unknown",
411
          dataNodeLocation.getDataNodeId());
×
412
    }
413
    return status;
×
414
  }
415

416
  @Override
417
  public TSStatus reportRegionMigrateResult(TRegionMigrateResultReportReq req) {
418
    TSStatus status = confirmLeader();
×
419
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
420
      procedureManager.reportRegionMigrateResult(req);
×
421
    }
422
    return status;
×
423
  }
424

425
  @Override
426
  public DataSet getDataNodeConfiguration(
427
      GetDataNodeConfigurationPlan getDataNodeConfigurationPlan) {
428
    TSStatus status = confirmLeader();
×
429
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
430
      return nodeManager.getDataNodeConfiguration(getDataNodeConfigurationPlan);
×
431
    } else {
432
      DataNodeConfigurationResp dataSet = new DataNodeConfigurationResp();
×
433
      dataSet.setStatus(status);
×
434
      return dataSet;
×
435
    }
436
  }
437

438
  @Override
439
  public TShowClusterResp showCluster() {
440
    TSStatus status = confirmLeader();
×
441
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
442
      List<TConfigNodeLocation> configNodeLocations = getNodeManager().getRegisteredConfigNodes();
×
443
      configNodeLocations.sort(Comparator.comparingInt(TConfigNodeLocation::getConfigNodeId));
×
444
      List<TDataNodeLocation> dataNodeInfoLocations =
×
445
          getNodeManager().getRegisteredDataNodes().stream()
×
446
              .map(TDataNodeConfiguration::getLocation)
×
447
              .sorted(Comparator.comparingInt(TDataNodeLocation::getDataNodeId))
×
448
              .collect(Collectors.toList());
×
449
      Map<Integer, String> nodeStatus = getLoadManager().getNodeStatusWithReason();
×
450
      return new TShowClusterResp(status, configNodeLocations, dataNodeInfoLocations, nodeStatus);
×
451
    } else {
452
      return new TShowClusterResp(status, new ArrayList<>(), new ArrayList<>(), new HashMap<>());
×
453
    }
454
  }
455

456
  @Override
457
  public TShowVariablesResp showVariables() {
458
    TSStatus status = confirmLeader();
×
459
    TShowVariablesResp resp = new TShowVariablesResp();
×
460
    resp.setStatus(status);
×
461
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
462
      resp.setClusterParameters(getClusterParameters());
×
463
    }
464
    return resp;
×
465
  }
466

467
  public TClusterParameters getClusterParameters() {
468
    TClusterParameters clusterParameters = new TClusterParameters();
×
469
    clusterParameters.setClusterName(CONF.getClusterName());
×
470
    clusterParameters.setConfigNodeConsensusProtocolClass(
×
471
        CONF.getConfigNodeConsensusProtocolClass());
×
472
    clusterParameters.setDataRegionConsensusProtocolClass(
×
473
        CONF.getDataRegionConsensusProtocolClass());
×
474
    clusterParameters.setSchemaRegionConsensusProtocolClass(
×
475
        CONF.getSchemaRegionConsensusProtocolClass());
×
476
    clusterParameters.setSeriesPartitionSlotNum(CONF.getSeriesSlotNum());
×
477
    clusterParameters.setSeriesPartitionExecutorClass(CONF.getSeriesPartitionExecutorClass());
×
478
    clusterParameters.setDefaultTTL(COMMON_CONF.getDefaultTTLInMs());
×
479
    clusterParameters.setTimePartitionInterval(COMMON_CONF.getTimePartitionInterval());
×
480
    clusterParameters.setDataReplicationFactor(CONF.getDataReplicationFactor());
×
481
    clusterParameters.setSchemaReplicationFactor(CONF.getSchemaReplicationFactor());
×
482
    clusterParameters.setDataRegionPerDataNode(CONF.getDataRegionPerDataNode());
×
483
    clusterParameters.setSchemaRegionPerDataNode(CONF.getSchemaRegionPerDataNode());
×
484
    clusterParameters.setDiskSpaceWarningThreshold(COMMON_CONF.getDiskSpaceWarningThreshold());
×
485
    clusterParameters.setReadConsistencyLevel(CONF.getReadConsistencyLevel());
×
486
    clusterParameters.setTimestampPrecision(COMMON_CONF.getTimestampPrecision());
×
487
    clusterParameters.setSchemaEngineMode(COMMON_CONF.getSchemaEngineMode());
×
488
    clusterParameters.setTagAttributeTotalSize(COMMON_CONF.getTagAttributeTotalSize());
×
489
    clusterParameters.setDatabaseLimitThreshold(COMMON_CONF.getDatabaseLimitThreshold());
×
490
    return clusterParameters;
×
491
  }
492

493
  @Override
494
  public TSStatus setTTL(SetTTLPlan setTTLPlan) {
495
    TSStatus status = confirmLeader();
×
496
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
497
      return clusterSchemaManager.setTTL(setTTLPlan);
×
498
    } else {
499
      return status;
×
500
    }
501
  }
502

503
  @Override
504
  public TSStatus setSchemaReplicationFactor(
505
      SetSchemaReplicationFactorPlan setSchemaReplicationFactorPlan) {
506
    TSStatus status = confirmLeader();
×
507
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
508
      return clusterSchemaManager.setSchemaReplicationFactor(setSchemaReplicationFactorPlan);
×
509
    } else {
510
      return status;
×
511
    }
512
  }
513

514
  @Override
515
  public TSStatus setDataReplicationFactor(
516
      SetDataReplicationFactorPlan setDataReplicationFactorPlan) {
517
    TSStatus status = confirmLeader();
×
518
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
519
      return clusterSchemaManager.setDataReplicationFactor(setDataReplicationFactorPlan);
×
520
    } else {
521
      return status;
×
522
    }
523
  }
524

525
  @Override
526
  public TSStatus setTimePartitionInterval(
527
      SetTimePartitionIntervalPlan setTimePartitionIntervalPlan) {
528
    TSStatus status = confirmLeader();
×
529
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
530
      return clusterSchemaManager.setTimePartitionInterval(setTimePartitionIntervalPlan);
×
531
    } else {
532
      return status;
×
533
    }
534
  }
535

536
  @Override
537
  public DataSet countMatchedDatabases(CountDatabasePlan countDatabasePlan) {
538
    TSStatus status = confirmLeader();
×
539
    CountDatabaseResp result = new CountDatabaseResp();
×
540
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
541
      return clusterSchemaManager.countMatchedDatabases(countDatabasePlan);
×
542
    } else {
543
      result.setStatus(status);
×
544
    }
545
    return result;
×
546
  }
547

548
  @Override
549
  public DataSet getMatchedDatabaseSchemas(GetDatabasePlan getDatabaseReq) {
550
    TSStatus status = confirmLeader();
×
551
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
552
      return clusterSchemaManager.getMatchedDatabaseSchema(getDatabaseReq);
×
553
    } else {
554
      DatabaseSchemaResp dataSet = new DatabaseSchemaResp();
×
555
      dataSet.setStatus(status);
×
556
      return dataSet;
×
557
    }
558
  }
559

560
  @Override
561
  public synchronized TSStatus setDatabase(DatabaseSchemaPlan databaseSchemaPlan) {
562
    TSStatus status = confirmLeader();
×
563
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
564
      return clusterSchemaManager.setDatabase(databaseSchemaPlan);
×
565
    } else {
566
      return status;
×
567
    }
568
  }
569

570
  @Override
571
  public TSStatus alterDatabase(DatabaseSchemaPlan databaseSchemaPlan) {
572
    TSStatus status = confirmLeader();
×
573
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
574
      return clusterSchemaManager.alterDatabase(databaseSchemaPlan);
×
575
    } else {
576
      return status;
×
577
    }
578
  }
579

580
  @Override
581
  public synchronized TSStatus deleteDatabases(List<String> deletedPaths) {
582
    TSStatus status = confirmLeader();
×
583
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
584
      // remove wild
585
      Map<String, TDatabaseSchema> deleteDatabaseSchemaMap =
×
586
          getClusterSchemaManager().getMatchedDatabaseSchemasByName(deletedPaths);
×
587
      if (deleteDatabaseSchemaMap.isEmpty()) {
×
588
        return RpcUtils.getStatus(
×
589
            TSStatusCode.PATH_NOT_EXIST.getStatusCode(),
×
590
            String.format("Path %s does not exist", Arrays.toString(deletedPaths.toArray())));
×
591
      }
592
      ArrayList<TDatabaseSchema> parsedDeleteDatabases =
×
593
          new ArrayList<>(deleteDatabaseSchemaMap.values());
×
594
      return procedureManager.deleteDatabases(parsedDeleteDatabases);
×
595
    } else {
596
      return status;
×
597
    }
598
  }
599

600
  private List<TSeriesPartitionSlot> calculateRelatedSlot(PartialPath path, PartialPath database) {
601
    // The path contains `**`
602
    if (path.getFullPath().contains(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD)) {
×
603
      return new ArrayList<>();
×
604
    }
605
    List<PartialPath> innerPathList = path.alterPrefixPath(database);
×
606
    if (innerPathList.size() == 0) {
×
607
      return new ArrayList<>();
×
608
    }
609
    PartialPath innerPath = innerPathList.get(0);
×
610
    // The innerPath contains `*` and the only `*` is not in last level
611
    if (innerPath.getDevice().contains(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)) {
×
612
      return new ArrayList<>();
×
613
    }
614
    return Collections.singletonList(
×
615
        getPartitionManager().getSeriesPartitionSlot(innerPath.getDevice()));
×
616
  }
617

618
  @Override
619
  public TSchemaPartitionTableResp getSchemaPartition(PathPatternTree patternTree) {
620
    // Construct empty response
621
    TSchemaPartitionTableResp resp = new TSchemaPartitionTableResp();
×
622

623
    TSStatus status = confirmLeader();
×
624
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
625
      return resp.setStatus(status);
×
626
    }
627

628
    // Build GetSchemaPartitionPlan
629
    Map<String, Set<TSeriesPartitionSlot>> partitionSlotsMap = new HashMap<>();
×
630
    List<PartialPath> relatedPaths = patternTree.getAllPathPatterns();
×
631
    List<String> allDatabases = getClusterSchemaManager().getDatabaseNames();
×
632
    List<PartialPath> allDatabasePaths = new ArrayList<>();
×
633
    for (String database : allDatabases) {
×
634
      try {
635
        allDatabasePaths.add(new PartialPath(database));
×
636
      } catch (IllegalPathException e) {
×
637
        throw new RuntimeException(e);
×
638
      }
×
639
    }
×
640
    Map<String, Boolean> scanAllRegions = new HashMap<>();
×
641
    for (PartialPath path : relatedPaths) {
×
642
      for (int i = 0; i < allDatabases.size(); i++) {
×
643
        String database = allDatabases.get(i);
×
644
        PartialPath databasePath = allDatabasePaths.get(i);
×
645
        if (path.overlapWithFullPathPrefix(databasePath) && !scanAllRegions.containsKey(database)) {
×
646
          List<TSeriesPartitionSlot> relatedSlot = calculateRelatedSlot(path, databasePath);
×
647
          if (relatedSlot.isEmpty()) {
×
648
            scanAllRegions.put(database, true);
×
649
            partitionSlotsMap.put(database, new HashSet<>());
×
650
          } else {
651
            partitionSlotsMap.computeIfAbsent(database, k -> new HashSet<>()).addAll(relatedSlot);
×
652
          }
653
        }
654
      }
655
    }
×
656

657
    // Return empty resp if the partitionSlotsMap is empty
658
    if (partitionSlotsMap.isEmpty()) {
×
659
      return resp.setStatus(StatusUtils.OK).setSchemaPartitionTable(new HashMap<>());
×
660
    }
661

662
    GetSchemaPartitionPlan getSchemaPartitionPlan =
×
663
        new GetSchemaPartitionPlan(
664
            partitionSlotsMap.entrySet().stream()
×
665
                .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArrayList<>(e.getValue()))));
×
666
    SchemaPartitionResp queryResult =
×
667
        (SchemaPartitionResp) partitionManager.getSchemaPartition(getSchemaPartitionPlan);
×
668
    resp = queryResult.convertToRpcSchemaPartitionTableResp();
×
669

670
    LOGGER.debug("GetSchemaPartition receive paths: {}, return: {}", relatedPaths, resp);
×
671

672
    return resp;
×
673
  }
674

675
  @Override
676
  public TSchemaPartitionTableResp getOrCreateSchemaPartition(PathPatternTree patternTree) {
677
    // Construct empty response
678
    TSchemaPartitionTableResp resp = new TSchemaPartitionTableResp();
×
679

680
    TSStatus status = confirmLeader();
×
681
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
682
      return resp.setStatus(status);
×
683
    }
684

685
    List<String> devicePaths = patternTree.getAllDevicePatterns();
×
686
    List<String> databases = getClusterSchemaManager().getDatabaseNames();
×
687

688
    // Build GetOrCreateSchemaPartitionPlan
689
    Map<String, List<TSeriesPartitionSlot>> partitionSlotsMap = new HashMap<>();
×
690
    for (String devicePath : devicePaths) {
×
691
      if (!devicePath.contains("*")) {
×
692
        // Only check devicePaths that without "*"
693
        for (String database : databases) {
×
694
          if (PathUtils.isStartWith(devicePath, database)) {
×
695
            partitionSlotsMap
×
696
                .computeIfAbsent(database, key -> new ArrayList<>())
×
697
                .add(getPartitionManager().getSeriesPartitionSlot(devicePath));
×
698
            break;
×
699
          }
700
        }
×
701
      }
702
    }
×
703
    GetOrCreateSchemaPartitionPlan getOrCreateSchemaPartitionPlan =
×
704
        new GetOrCreateSchemaPartitionPlan(partitionSlotsMap);
705

706
    SchemaPartitionResp queryResult =
×
707
        partitionManager.getOrCreateSchemaPartition(getOrCreateSchemaPartitionPlan);
×
708
    resp = queryResult.convertToRpcSchemaPartitionTableResp();
×
709

710
    if (CONF.isEnablePrintingNewlyCreatedPartition()) {
×
711
      printNewCreatedSchemaPartition(devicePaths, resp);
×
712
    }
713

714
    return resp;
×
715
  }
716

717
  private void printNewCreatedSchemaPartition(
718
      List<String> devicePaths, TSchemaPartitionTableResp resp) {
719
    final String lineSeparator = System.lineSeparator();
×
720
    StringBuilder devicePathString = new StringBuilder("{");
×
721
    for (String devicePath : devicePaths) {
×
722
      devicePathString.append(lineSeparator).append("\t").append(devicePath).append(",");
×
723
    }
×
724
    devicePathString.append(lineSeparator).append("}");
×
725

726
    StringBuilder schemaPartitionRespString = new StringBuilder("{");
×
727
    schemaPartitionRespString
×
728
        .append(lineSeparator)
×
729
        .append("\tTSStatus=")
×
730
        .append(resp.getStatus().getCode())
×
731
        .append(",");
×
732
    Map<String, Map<TSeriesPartitionSlot, TConsensusGroupId>> schemaPartitionTable =
×
733
        resp.getSchemaPartitionTable();
×
734
    for (Map.Entry<String, Map<TSeriesPartitionSlot, TConsensusGroupId>> databaseEntry :
735
        schemaPartitionTable.entrySet()) {
×
736
      String database = databaseEntry.getKey();
×
737
      schemaPartitionRespString
×
738
          .append(lineSeparator)
×
739
          .append(DATABASE)
×
740
          .append(database)
×
741
          .append(": {");
×
742
      for (Map.Entry<TSeriesPartitionSlot, TConsensusGroupId> slotEntry :
743
          databaseEntry.getValue().entrySet()) {
×
744
        schemaPartitionRespString
×
745
            .append(lineSeparator)
×
746
            .append("\t\t")
×
747
            .append(slotEntry.getKey())
×
748
            .append(", ")
×
749
            .append(slotEntry.getValue())
×
750
            .append(",");
×
751
      }
×
752
      schemaPartitionRespString.append(lineSeparator).append("\t},");
×
753
    }
×
754
    schemaPartitionRespString.append(lineSeparator).append("}");
×
755
    LOGGER.info(
×
756
        "[GetOrCreateSchemaPartition]:{} Receive PathPatternTree: {}, Return TSchemaPartitionTableResp: {}",
757
        lineSeparator,
758
        devicePathString,
759
        schemaPartitionRespString);
760
  }
×
761

762
  @Override
763
  public TSchemaNodeManagementResp getNodePathsPartition(PartialPath partialPath, Integer level) {
764
    TSStatus status = confirmLeader();
×
765
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
766
      GetNodePathsPartitionPlan getNodePathsPartitionPlan = new GetNodePathsPartitionPlan();
×
767
      getNodePathsPartitionPlan.setPartialPath(partialPath);
×
768
      if (null != level) {
×
769
        getNodePathsPartitionPlan.setLevel(level);
×
770
      }
771
      SchemaNodeManagementResp resp =
×
772
          partitionManager.getNodePathsPartition(getNodePathsPartitionPlan);
×
773
      TSchemaNodeManagementResp result =
×
774
          resp.convertToRpcSchemaNodeManagementPartitionResp(
×
775
              getLoadManager().getRegionPriorityMap());
×
776

777
      LOGGER.info(
×
778
          "getNodePathsPartition receive devicePaths: {}, level: {}, return TSchemaNodeManagementResp: {}",
779
          partialPath,
780
          level,
781
          result);
782

783
      return result;
×
784
    } else {
785
      return new TSchemaNodeManagementResp().setStatus(status);
×
786
    }
787
  }
788

789
  @Override
790
  public TDataPartitionTableResp getDataPartition(GetDataPartitionPlan getDataPartitionPlan) {
791
    // Construct empty response
792
    TDataPartitionTableResp resp = new TDataPartitionTableResp();
×
793

794
    TSStatus status = confirmLeader();
×
795
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
796
      return resp.setStatus(status);
×
797
    }
798
    DataPartitionResp queryResult =
×
799
        (DataPartitionResp) partitionManager.getDataPartition(getDataPartitionPlan);
×
800

801
    resp = queryResult.convertToTDataPartitionTableResp();
×
802

803
    LOGGER.debug(
×
804
        "GetDataPartition interface receive PartitionSlotsMap: {}, return: {}",
805
        getDataPartitionPlan.getPartitionSlotsMap(),
×
806
        resp);
807

808
    return resp;
×
809
  }
810

811
  @Override
812
  public TDataPartitionTableResp getOrCreateDataPartition(
813
      GetOrCreateDataPartitionPlan getOrCreateDataPartitionPlan) {
814
    // Construct empty response
815
    TDataPartitionTableResp resp = new TDataPartitionTableResp();
×
816

817
    TSStatus status = confirmLeader();
×
818
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
819
      return resp.setStatus(status);
×
820
    }
821

822
    DataPartitionResp queryResult =
×
823
        partitionManager.getOrCreateDataPartition(getOrCreateDataPartitionPlan);
×
824
    resp = queryResult.convertToTDataPartitionTableResp();
×
825

826
    if (CONF.isEnablePrintingNewlyCreatedPartition()) {
×
827
      printNewCreatedDataPartition(getOrCreateDataPartitionPlan, resp);
×
828
    }
829

830
    return resp;
×
831
  }
832

833
  private void printNewCreatedDataPartition(
834
      GetOrCreateDataPartitionPlan getOrCreateDataPartitionPlan, TDataPartitionTableResp resp) {
835
    final String lineSeparator = System.lineSeparator();
×
836
    StringBuilder partitionSlotsMapString = new StringBuilder("{");
×
837
    for (Map.Entry<String, Map<TSeriesPartitionSlot, TTimeSlotList>> databaseEntry :
838
        getOrCreateDataPartitionPlan.getPartitionSlotsMap().entrySet()) {
×
839
      String database = databaseEntry.getKey();
×
840
      partitionSlotsMapString.append(lineSeparator).append(DATABASE).append(database).append(": {");
×
841
      for (Map.Entry<TSeriesPartitionSlot, TTimeSlotList> slotEntry :
842
          databaseEntry.getValue().entrySet()) {
×
843
        partitionSlotsMapString
×
844
            .append(lineSeparator)
×
845
            .append("\t\t")
×
846
            .append(slotEntry.getKey())
×
847
            .append(",")
×
848
            .append(slotEntry.getValue());
×
849
      }
×
850
      partitionSlotsMapString.append(lineSeparator).append("\t},");
×
851
    }
×
852
    partitionSlotsMapString.append(lineSeparator).append("}");
×
853

854
    StringBuilder dataPartitionRespString = new StringBuilder("{");
×
855
    dataPartitionRespString
×
856
        .append(lineSeparator)
×
857
        .append("\tTSStatus=")
×
858
        .append(resp.getStatus().getCode())
×
859
        .append(",");
×
860
    Map<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TConsensusGroupId>>>>
861
        dataPartitionTable = resp.getDataPartitionTable();
×
862
    for (Map.Entry<
863
            String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TConsensusGroupId>>>>
864
        databaseEntry : dataPartitionTable.entrySet()) {
×
865
      String database = databaseEntry.getKey();
×
866
      dataPartitionRespString.append(lineSeparator).append(DATABASE).append(database).append(": {");
×
867
      for (Map.Entry<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TConsensusGroupId>>>
868
          seriesSlotEntry : databaseEntry.getValue().entrySet()) {
×
869
        dataPartitionRespString
×
870
            .append(lineSeparator)
×
871
            .append("\t\t")
×
872
            .append(seriesSlotEntry.getKey())
×
873
            .append(": {");
×
874
        for (Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>> timeSlotEntry :
875
            seriesSlotEntry.getValue().entrySet()) {
×
876
          dataPartitionRespString
×
877
              .append(lineSeparator)
×
878
              .append("\t\t\t")
×
879
              .append(timeSlotEntry.getKey())
×
880
              .append(", ")
×
881
              .append(timeSlotEntry.getValue())
×
882
              .append(",");
×
883
        }
×
884
        dataPartitionRespString.append(lineSeparator).append("\t\t},");
×
885
      }
×
886
      dataPartitionRespString.append(lineSeparator).append("\t}");
×
887
    }
×
888
    dataPartitionRespString.append(lineSeparator).append("}");
×
889

890
    LOGGER.info(
×
891
        "[GetOrCreateDataPartition]:{} Receive PartitionSlotsMap: {}, Return TDataPartitionTableResp: {}",
892
        lineSeparator,
893
        partitionSlotsMapString,
894
        dataPartitionRespString);
895
  }
×
896

897
  private TSStatus confirmLeader() {
898
    // Make sure the consensus layer has been initialized
899
    if (getConsensusManager() == null) {
×
900
      return new TSStatus(TSStatusCode.CONSENSUS_NOT_INITIALIZED.getStatusCode())
×
901
          .setMessage(
×
902
              "ConsensusManager of target-ConfigNode is not initialized, "
903
                  + "please make sure the target-ConfigNode has been started successfully.");
904
    }
905
    return getConsensusManager().confirmLeader();
×
906
  }
907

908
  @Override
909
  public NodeManager getNodeManager() {
910
    return nodeManager;
×
911
  }
912

913
  @Override
914
  public ClusterSchemaManager getClusterSchemaManager() {
915
    return clusterSchemaManager;
×
916
  }
917

918
  @Override
919
  public ConsensusManager getConsensusManager() {
920
    return consensusManager.get();
×
921
  }
922

923
  @Override
924
  public PartitionManager getPartitionManager() {
925
    return partitionManager;
×
926
  }
927

928
  @Override
929
  public LoadManager getLoadManager() {
930
    return loadManager;
×
931
  }
932

933
  @Override
934
  public TriggerManager getTriggerManager() {
935
    return triggerManager;
×
936
  }
937

938
  @Override
939
  public ModelManager getModelManager() {
940
    return modelManager;
×
941
  }
942

943
  @Override
944
  public PipeManager getPipeManager() {
945
    return pipeManager;
×
946
  }
947

948
  @Override
949
  public TSStatus operatePermission(AuthorPlan authorPlan) {
950
    TSStatus status = confirmLeader();
×
951
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
952
      return permissionManager.operatePermission(authorPlan);
×
953
    } else {
954
      return status;
×
955
    }
956
  }
957

958
  @Override
959
  public DataSet queryPermission(AuthorPlan authorPlan) {
960
    TSStatus status = confirmLeader();
×
961
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
962
      return permissionManager.queryPermission(authorPlan);
×
963
    } else {
964
      PermissionInfoResp dataSet = new PermissionInfoResp();
×
965
      dataSet.setStatus(status);
×
966
      return dataSet;
×
967
    }
968
  }
969

970
  @Override
971
  public TPermissionInfoResp login(String username, String password) {
972
    TSStatus status = confirmLeader();
×
973
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
974
      return permissionManager.login(username, password);
×
975
    } else {
976
      TPermissionInfoResp resp = AuthUtils.generateEmptyPermissionInfoResp();
×
977
      resp.setStatus(status);
×
978
      return resp;
×
979
    }
980
  }
981

982
  @Override
983
  public TPermissionInfoResp checkUserPrivileges(
984
      String username, List<PartialPath> paths, int permission) {
985
    TSStatus status = confirmLeader();
×
986
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
987
      return permissionManager.checkUserPrivileges(username, paths, permission);
×
988
    } else {
989
      TPermissionInfoResp resp = AuthUtils.generateEmptyPermissionInfoResp();
×
990
      resp.setStatus(status);
×
991
      return resp;
×
992
    }
993
  }
994

995
  @Override
996
  public TConfigNodeRegisterResp registerConfigNode(TConfigNodeRegisterReq req) {
997
    final int ERROR_STATUS_NODE_ID = -1;
×
998

999
    TSStatus status = confirmLeader();
×
1000
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1001
      // Make sure the global configurations are consist
1002
      status = checkConfigNodeGlobalConfig(req);
×
1003
      if (status == null) {
×
1004
        status =
×
1005
            ClusterNodeStartUtils.confirmNodeRegistration(
×
1006
                NodeType.ConfigNode,
1007
                req.getClusterParameters().getClusterName(),
×
1008
                req.getConfigNodeLocation(),
×
1009
                this);
1010
        if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1011
          return nodeManager.registerConfigNode(req);
×
1012
        }
1013
      }
1014
    }
1015

1016
    return new TConfigNodeRegisterResp().setStatus(status).setConfigNodeId(ERROR_STATUS_NODE_ID);
×
1017
  }
1018

1019
  @Override
1020
  public TSStatus restartConfigNode(TConfigNodeRestartReq req) {
1021
    TSStatus status = confirmLeader();
×
1022
    // Notice: The Seed-ConfigNode must also have the privilege to do Node restart check.
1023
    // Otherwise, the IoTDB-cluster will not have the ability to restart from scratch.
1024
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1025
        || ConfigNodeDescriptor.getInstance().isSeedConfigNode()
×
1026
        || SystemPropertiesUtils.isSeedConfigNode()) {
×
1027
      status =
×
1028
          ClusterNodeStartUtils.confirmNodeRestart(
×
1029
              NodeType.ConfigNode,
1030
              req.getClusterName(),
×
1031
              req.getConfigNodeLocation().getConfigNodeId(),
×
1032
              req.getConfigNodeLocation(),
×
1033
              this);
1034
      if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1035
        return nodeManager.restartConfigNode(req.getConfigNodeLocation());
×
1036
      }
1037
    }
1038
    return status;
×
1039
  }
1040

1041
  public TSStatus checkConfigNodeGlobalConfig(TConfigNodeRegisterReq req) {
1042
    final String errorPrefix = "Reject register, please ensure that the parameter ";
×
1043
    final String errorSuffix = " is consistent with the Seed-ConfigNode.";
×
1044
    TSStatus errorStatus = new TSStatus(TSStatusCode.CONFIGURATION_ERROR.getStatusCode());
×
1045
    TClusterParameters clusterParameters = req.getClusterParameters();
×
1046

1047
    if (!clusterParameters
×
1048
        .getConfigNodeConsensusProtocolClass()
×
1049
        .equals(CONF.getConfigNodeConsensusProtocolClass())) {
×
1050
      return errorStatus.setMessage(
×
1051
          errorPrefix + "config_node_consensus_protocol_class" + errorSuffix);
1052
    }
1053
    if (!clusterParameters
×
1054
        .getDataRegionConsensusProtocolClass()
×
1055
        .equals(CONF.getDataRegionConsensusProtocolClass())) {
×
1056
      return errorStatus.setMessage(
×
1057
          errorPrefix + "data_region_consensus_protocol_class" + errorSuffix);
1058
    }
1059
    if (!clusterParameters
×
1060
        .getSchemaRegionConsensusProtocolClass()
×
1061
        .equals(CONF.getSchemaRegionConsensusProtocolClass())) {
×
1062
      return errorStatus.setMessage(
×
1063
          errorPrefix + "schema_region_consensus_protocol_class" + errorSuffix);
1064
    }
1065

1066
    if (clusterParameters.getSeriesPartitionSlotNum() != CONF.getSeriesSlotNum()) {
×
1067
      return errorStatus.setMessage(errorPrefix + "series_partition_slot_num" + errorSuffix);
×
1068
    }
1069
    if (!clusterParameters
×
1070
        .getSeriesPartitionExecutorClass()
×
1071
        .equals(CONF.getSeriesPartitionExecutorClass())) {
×
1072
      return errorStatus.setMessage(errorPrefix + "series_partition_executor_class" + errorSuffix);
×
1073
    }
1074

1075
    if (clusterParameters.getDefaultTTL()
×
1076
        != CommonDescriptor.getInstance().getConfig().getDefaultTTLInMs()) {
×
1077
      return errorStatus.setMessage(errorPrefix + "default_ttl" + errorSuffix);
×
1078
    }
1079
    if (clusterParameters.getTimePartitionInterval() != COMMON_CONF.getTimePartitionInterval()) {
×
1080
      return errorStatus.setMessage(errorPrefix + "time_partition_interval" + errorSuffix);
×
1081
    }
1082

1083
    if (clusterParameters.getSchemaReplicationFactor() != CONF.getSchemaReplicationFactor()) {
×
1084
      return errorStatus.setMessage(errorPrefix + "schema_replication_factor" + errorSuffix);
×
1085
    }
1086
    if (clusterParameters.getDataReplicationFactor() != CONF.getDataReplicationFactor()) {
×
1087
      return errorStatus.setMessage(errorPrefix + "data_replication_factor" + errorSuffix);
×
1088
    }
1089

1090
    if (clusterParameters.getSchemaRegionPerDataNode() != CONF.getSchemaRegionPerDataNode()) {
×
1091
      return errorStatus.setMessage(errorPrefix + "schema_region_per_data_node" + errorSuffix);
×
1092
    }
1093
    if (clusterParameters.getDataRegionPerDataNode() != CONF.getDataRegionPerDataNode()) {
×
1094
      return errorStatus.setMessage(errorPrefix + "data_region_per_data_node" + errorSuffix);
×
1095
    }
1096

1097
    if (!clusterParameters.getReadConsistencyLevel().equals(CONF.getReadConsistencyLevel())) {
×
1098
      return errorStatus.setMessage(errorPrefix + "read_consistency_level" + errorSuffix);
×
1099
    }
1100

1101
    if (clusterParameters.getDiskSpaceWarningThreshold()
×
1102
        != COMMON_CONF.getDiskSpaceWarningThreshold()) {
×
1103
      return errorStatus.setMessage(errorPrefix + "disk_space_warning_threshold" + errorSuffix);
×
1104
    }
1105

1106
    if (!clusterParameters.getTimestampPrecision().equals(COMMON_CONF.getTimestampPrecision())) {
×
1107
      return errorStatus.setMessage(errorPrefix + "timestamp_precision" + errorSuffix);
×
1108
    }
1109

1110
    if (!clusterParameters.getSchemaEngineMode().equals(COMMON_CONF.getSchemaEngineMode())) {
×
1111
      return errorStatus.setMessage(errorPrefix + "schema_engine_mode" + errorSuffix);
×
1112
    }
1113

1114
    if (clusterParameters.getTagAttributeTotalSize() != COMMON_CONF.getTagAttributeTotalSize()) {
×
1115
      return errorStatus.setMessage(errorPrefix + "tag_attribute_total_size" + errorSuffix);
×
1116
    }
1117

1118
    if (clusterParameters.getDatabaseLimitThreshold() != COMMON_CONF.getDatabaseLimitThreshold()) {
×
1119
      return errorStatus.setMessage(errorPrefix + "database_limit_threshold" + errorSuffix);
×
1120
    }
1121

1122
    return null;
×
1123
  }
1124

1125
  @Override
1126
  public TSStatus createPeerForConsensusGroup(List<TConfigNodeLocation> configNodeLocations) {
1127
    for (int i = 0; i < 30; i++) {
×
1128
      try {
1129
        if (consensusManager.get() == null) {
×
1130
          Thread.sleep(1000);
×
1131
        } else {
1132
          // When add non Seed-ConfigNode to the ConfigNodeGroup, the parameter should be emptyList
1133
          consensusManager.get().createPeerForConsensusGroup(Collections.emptyList());
×
1134
          return StatusUtils.OK;
×
1135
        }
1136
      } catch (InterruptedException e) {
×
1137
        Thread.currentThread().interrupt();
×
1138
        LOGGER.warn("Unexpected interruption during retry creating peer for consensus group");
×
1139
      } catch (Exception e) {
×
1140
        LOGGER.error("Failed to create peer for consensus group", e);
×
1141
        break;
×
1142
      }
×
1143
    }
1144
    return StatusUtils.INTERNAL_ERROR;
×
1145
  }
1146

1147
  @Override
1148
  public TSStatus removeConfigNode(RemoveConfigNodePlan removeConfigNodePlan) {
1149
    TSStatus status = confirmLeader();
×
1150

1151
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1152
      status = nodeManager.checkConfigNodeBeforeRemove(removeConfigNodePlan);
×
1153
      if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1154
        procedureManager.removeConfigNode(removeConfigNodePlan);
×
1155
      }
1156
    }
1157

1158
    return status;
×
1159
  }
1160

1161
  @Override
1162
  public TSStatus reportConfigNodeShutdown(TConfigNodeLocation configNodeLocation) {
1163
    TSStatus status = confirmLeader();
×
1164
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1165
      // Force updating the target ConfigNode's status to Unknown
1166
      getLoadManager()
×
1167
          .forceUpdateNodeCache(
×
1168
              NodeType.ConfigNode,
1169
              configNodeLocation.getConfigNodeId(),
×
1170
              NodeHeartbeatSample.generateDefaultSample(NodeStatus.Unknown));
×
1171
      LOGGER.info(
×
1172
          "[ShutdownHook] The ConfigNode-{} will be shutdown soon, mark it as Unknown",
1173
          configNodeLocation.getConfigNodeId());
×
1174
    }
1175
    return status;
×
1176
  }
1177

1178
  @Override
1179
  public TSStatus createFunction(TCreateFunctionReq req) {
1180
    TSStatus status = confirmLeader();
×
1181
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1182
        ? udfManager.createFunction(req)
×
1183
        : status;
×
1184
  }
1185

1186
  @Override
1187
  public TSStatus dropFunction(String udfName) {
1188
    TSStatus status = confirmLeader();
×
1189
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1190
        ? udfManager.dropFunction(udfName)
×
1191
        : status;
×
1192
  }
1193

1194
  @Override
1195
  public TGetUDFTableResp getUDFTable() {
1196
    TSStatus status = confirmLeader();
×
1197
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1198
        ? udfManager.getUDFTable()
×
1199
        : new TGetUDFTableResp(status, Collections.emptyList());
×
1200
  }
1201

1202
  @Override
1203
  public TGetJarInListResp getUDFJar(TGetJarInListReq req) {
1204
    TSStatus status = confirmLeader();
×
1205
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1206
        ? udfManager.getUDFJar(req)
×
1207
        : new TGetJarInListResp(status, Collections.emptyList());
×
1208
  }
1209

1210
  @Override
1211
  public TSStatus createTrigger(TCreateTriggerReq req) {
1212
    TSStatus status = confirmLeader();
×
1213
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1214
        ? triggerManager.createTrigger(req)
×
1215
        : status;
×
1216
  }
1217

1218
  @Override
1219
  public TSStatus dropTrigger(TDropTriggerReq req) {
1220
    TSStatus status = confirmLeader();
×
1221
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1222
        ? triggerManager.dropTrigger(req)
×
1223
        : status;
×
1224
  }
1225

1226
  @Override
1227
  public TGetTriggerTableResp getTriggerTable() {
1228
    TSStatus status = confirmLeader();
×
1229
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1230
        ? triggerManager.getTriggerTable(false)
×
1231
        : new TGetTriggerTableResp(status, Collections.emptyList());
×
1232
  }
1233

1234
  @Override
1235
  public TGetTriggerTableResp getStatefulTriggerTable() {
1236
    TSStatus status = confirmLeader();
×
1237
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1238
        ? triggerManager.getTriggerTable(true)
×
1239
        : new TGetTriggerTableResp(status, Collections.emptyList());
×
1240
  }
1241

1242
  @Override
1243
  public TGetLocationForTriggerResp getLocationOfStatefulTrigger(String triggerName) {
1244
    TSStatus status = confirmLeader();
×
1245
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1246
        ? triggerManager.getLocationOfStatefulTrigger(triggerName)
×
1247
        : new TGetLocationForTriggerResp(status);
×
1248
  }
1249

1250
  @Override
1251
  public TGetJarInListResp getTriggerJar(TGetJarInListReq req) {
1252
    TSStatus status = confirmLeader();
×
1253
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1254
        ? triggerManager.getTriggerJar(req)
×
1255
        : new TGetJarInListResp(status, Collections.emptyList());
×
1256
  }
1257

1258
  @Override
1259
  public TSStatus createPipePlugin(TCreatePipePluginReq req) {
1260
    TSStatus status = confirmLeader();
×
1261
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1262
        ? pipeManager.getPipePluginCoordinator().createPipePlugin(req)
×
1263
        : status;
×
1264
  }
1265

1266
  @Override
1267
  public TSStatus dropPipePlugin(String pipePluginName) {
1268
    TSStatus status = confirmLeader();
×
1269
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1270
        ? pipeManager.getPipePluginCoordinator().dropPipePlugin(pipePluginName)
×
1271
        : status;
×
1272
  }
1273

1274
  @Override
1275
  public TGetPipePluginTableResp getPipePluginTable() {
1276
    TSStatus status = confirmLeader();
×
1277
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1278
        ? pipeManager.getPipePluginCoordinator().getPipePluginTable()
×
1279
        : new TGetPipePluginTableResp(status, Collections.emptyList());
×
1280
  }
1281

1282
  @Override
1283
  public TGetJarInListResp getPipePluginJar(TGetJarInListReq req) {
1284
    TSStatus status = confirmLeader();
×
1285
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1286
        ? pipeManager.getPipePluginCoordinator().getPipePluginJar(req)
×
1287
        : new TGetJarInListResp(status, Collections.emptyList());
×
1288
  }
1289

1290
  @Override
1291
  public TSStatus merge() {
1292
    TSStatus status = confirmLeader();
×
1293
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1294
        ? RpcUtils.squashResponseStatusList(nodeManager.merge())
×
1295
        : status;
×
1296
  }
1297

1298
  @Override
1299
  public TSStatus flush(TFlushReq req) {
1300
    TSStatus status = confirmLeader();
×
1301
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1302
        ? RpcUtils.squashResponseStatusList(nodeManager.flush(req))
×
1303
        : status;
×
1304
  }
1305

1306
  @Override
1307
  public TSStatus clearCache() {
1308
    TSStatus status = confirmLeader();
×
1309
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1310
        ? RpcUtils.squashResponseStatusList(nodeManager.clearCache())
×
1311
        : status;
×
1312
  }
1313

1314
  @Override
1315
  public TSStatus loadConfiguration() {
1316
    TSStatus status = confirmLeader();
×
1317
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1318
        ? RpcUtils.squashResponseStatusList(nodeManager.loadConfiguration())
×
1319
        : status;
×
1320
  }
1321

1322
  @Override
1323
  public TSStatus setSystemStatus(String systemStatus) {
1324
    TSStatus status = confirmLeader();
×
1325
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1326
        ? RpcUtils.squashResponseStatusList(nodeManager.setSystemStatus(systemStatus))
×
1327
        : status;
×
1328
  }
1329

1330
  @Override
1331
  public TSStatus setDataNodeStatus(TSetDataNodeStatusReq req) {
1332
    TSStatus status = confirmLeader();
×
1333
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1334
        ? nodeManager.setDataNodeStatus(req)
×
1335
        : status;
×
1336
  }
1337

1338
  @Override
1339
  public TSStatus killQuery(String queryId, int dataNodeId) {
1340
    TSStatus status = confirmLeader();
×
1341
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1342
        ? nodeManager.killQuery(queryId, dataNodeId)
×
1343
        : status;
×
1344
  }
1345

1346
  @Override
1347
  public TGetDataNodeLocationsResp getRunningDataNodeLocations() {
1348
    TSStatus status = confirmLeader();
×
1349
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1350
        ? new TGetDataNodeLocationsResp(
×
1351
            new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()),
×
1352
            nodeManager.filterDataNodeThroughStatus(NodeStatus.Running).stream()
×
1353
                .map(TDataNodeConfiguration::getLocation)
×
1354
                .collect(Collectors.toList()))
×
1355
        : new TGetDataNodeLocationsResp(status, Collections.emptyList());
×
1356
  }
1357

1358
  @Override
1359
  public TRegionRouteMapResp getLatestRegionRouteMap() {
1360
    TSStatus status = confirmLeader();
×
1361
    TRegionRouteMapResp resp = new TRegionRouteMapResp(status);
×
1362

1363
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1364
      resp.setTimestamp(System.currentTimeMillis());
×
1365
      resp.setRegionRouteMap(getLoadManager().getRegionPriorityMap());
×
1366
    }
1367

1368
    return resp;
×
1369
  }
1370

1371
  @Override
1372
  public UDFManager getUDFManager() {
1373
    return udfManager;
×
1374
  }
1375

1376
  @Override
1377
  public RegionInfoListResp showRegion(GetRegionInfoListPlan getRegionInfoListPlan) {
1378
    TSStatus status = confirmLeader();
×
1379
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1380
      return partitionManager.getRegionInfoList(getRegionInfoListPlan);
×
1381
    } else {
1382
      RegionInfoListResp regionResp = new RegionInfoListResp();
×
1383
      regionResp.setStatus(status);
×
1384
      return regionResp;
×
1385
    }
1386
  }
1387

1388
  @Override
1389
  public TShowDataNodesResp showDataNodes() {
1390
    TSStatus status = confirmLeader();
×
1391
    TShowDataNodesResp resp = new TShowDataNodesResp();
×
1392
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1393
      return resp.setDataNodesInfoList(nodeManager.getRegisteredDataNodeInfoList())
×
1394
          .setStatus(StatusUtils.OK);
×
1395
    } else {
1396
      return resp.setStatus(status);
×
1397
    }
1398
  }
1399

1400
  @Override
1401
  public TShowConfigNodesResp showConfigNodes() {
1402
    TSStatus status = confirmLeader();
×
1403
    TShowConfigNodesResp resp = new TShowConfigNodesResp();
×
1404
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1405
      return resp.setConfigNodesInfoList(nodeManager.getRegisteredConfigNodeInfoList())
×
1406
          .setStatus(StatusUtils.OK);
×
1407
    } else {
1408
      return resp.setStatus(status);
×
1409
    }
1410
  }
1411

1412
  @Override
1413
  public TShowDatabaseResp showDatabase(GetDatabasePlan getDatabasePlan) {
1414
    TSStatus status = confirmLeader();
×
1415
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1416
      return getClusterSchemaManager().showDatabase(getDatabasePlan);
×
1417
    } else {
1418
      return new TShowDatabaseResp().setStatus(status);
×
1419
    }
1420
  }
1421

1422
  @Override
1423
  public ProcedureManager getProcedureManager() {
1424
    return procedureManager;
×
1425
  }
1426

1427
  @Override
1428
  public CQManager getCQManager() {
1429
    return cqManager;
×
1430
  }
1431

1432
  @Override
1433
  public ClusterQuotaManager getClusterQuotaManager() {
1434
    return clusterQuotaManager;
×
1435
  }
1436

1437
  @Override
1438
  public RetryFailedTasksThread getRetryFailedTasksThread() {
1439
    return retryFailedTasksThread;
×
1440
  }
1441

1442
  @Override
1443
  public void addMetrics() {
1444
    MetricService.getInstance().addMetricSet(new NodeMetrics(getNodeManager()));
×
1445
    MetricService.getInstance().addMetricSet(new PartitionMetrics(this));
×
1446
  }
×
1447

1448
  @Override
1449
  public TSStatus createSchemaTemplate(TCreateSchemaTemplateReq req) {
1450
    TSStatus status = confirmLeader();
×
1451
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1452
      CreateSchemaTemplatePlan createSchemaTemplatePlan =
×
1453
          new CreateSchemaTemplatePlan(req.getSerializedTemplate());
×
1454
      return clusterSchemaManager.createTemplate(createSchemaTemplatePlan);
×
1455
    } else {
1456
      return status;
×
1457
    }
1458
  }
1459

1460
  @Override
1461
  public TGetAllTemplatesResp getAllTemplates() {
1462
    TSStatus status = confirmLeader();
×
1463
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1464
      return clusterSchemaManager.getAllTemplates();
×
1465
    } else {
1466
      return new TGetAllTemplatesResp().setStatus(status);
×
1467
    }
1468
  }
1469

1470
  @Override
1471
  public TGetTemplateResp getTemplate(String req) {
1472
    TSStatus status = confirmLeader();
×
1473
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1474
      return clusterSchemaManager.getTemplate(req);
×
1475
    } else {
1476
      return new TGetTemplateResp().setStatus(status);
×
1477
    }
1478
  }
1479

1480
  @Override
1481
  public synchronized TSStatus setSchemaTemplate(TSetSchemaTemplateReq req) {
1482
    TSStatus status = confirmLeader();
×
1483
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1484
      return procedureManager.setSchemaTemplate(req.getQueryId(), req.getName(), req.getPath());
×
1485
    } else {
1486
      return status;
×
1487
    }
1488
  }
1489

1490
  @Override
1491
  public TGetPathsSetTemplatesResp getPathsSetTemplate(String req) {
1492
    TSStatus status = confirmLeader();
×
1493
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1494
      return clusterSchemaManager.getPathsSetTemplate(req);
×
1495
    } else {
1496
      return new TGetPathsSetTemplatesResp(status);
×
1497
    }
1498
  }
1499

1500
  @Override
1501
  public TSStatus deactivateSchemaTemplate(TDeactivateSchemaTemplateReq req) {
1502
    TSStatus status = confirmLeader();
×
1503
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1504
      return status;
×
1505
    }
1506

1507
    PathPatternTree patternTree =
×
1508
        PathPatternTree.deserialize(ByteBuffer.wrap(req.getPathPatternTree()));
×
1509

1510
    List<PartialPath> patternList = patternTree.getAllPathPatterns();
×
1511
    TemplateSetInfoResp templateSetInfoResp = clusterSchemaManager.getTemplateSetInfo(patternList);
×
1512
    if (templateSetInfoResp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1513
      return templateSetInfoResp.getStatus();
×
1514
    }
1515

1516
    Map<PartialPath, List<Template>> templateSetInfo = templateSetInfoResp.getPatternTemplateMap();
×
1517
    if (templateSetInfo.isEmpty()) {
×
1518
      return RpcUtils.getStatus(
×
1519
          TSStatusCode.TEMPLATE_NOT_SET,
1520
          String.format(
×
1521
              "Schema Template %s is not set on any prefix path of %s",
1522
              req.getTemplateName(), patternList));
×
1523
    }
1524

1525
    if (!req.getTemplateName().equals(ONE_LEVEL_PATH_WILDCARD)) {
×
1526
      Map<PartialPath, List<Template>> filteredTemplateSetInfo = new HashMap<>();
×
1527
      for (Map.Entry<PartialPath, List<Template>> entry : templateSetInfo.entrySet()) {
×
1528
        for (Template template : entry.getValue()) {
×
1529
          if (template.getName().equals(req.getTemplateName())) {
×
1530
            filteredTemplateSetInfo.put(entry.getKey(), Collections.singletonList(template));
×
1531
            break;
×
1532
          }
1533
        }
×
1534
      }
×
1535

1536
      if (filteredTemplateSetInfo.isEmpty()) {
×
1537
        return RpcUtils.getStatus(
×
1538
            TSStatusCode.TEMPLATE_NOT_SET,
1539
            String.format(
×
1540
                "Schema Template %s is not set on any prefix path of %s",
1541
                req.getTemplateName(), patternList));
×
1542
      }
1543

1544
      templateSetInfo = filteredTemplateSetInfo;
×
1545
    }
1546

1547
    return procedureManager.deactivateTemplate(req.getQueryId(), templateSetInfo);
×
1548
  }
1549

1550
  @Override
1551
  public synchronized TSStatus unsetSchemaTemplate(TUnsetSchemaTemplateReq req) {
1552
    TSStatus status = confirmLeader();
×
1553
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1554
      return status;
×
1555
    }
1556
    Pair<TSStatus, Template> checkResult =
×
1557
        clusterSchemaManager.checkIsTemplateSetOnPath(req.getTemplateName(), req.getPath());
×
1558
    if (checkResult.left.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1559
      try {
1560
        return procedureManager.unsetSchemaTemplate(
×
1561
            req.getQueryId(), checkResult.right, new PartialPath(req.getPath()));
×
1562
      } catch (IllegalPathException e) {
×
1563
        return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
×
1564
      }
1565
    } else {
1566
      return checkResult.left;
×
1567
    }
1568
  }
1569

1570
  @Override
1571
  public TSStatus dropSchemaTemplate(String templateName) {
1572
    TSStatus status = confirmLeader();
×
1573
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1574
      return clusterSchemaManager.dropSchemaTemplate(templateName);
×
1575
    } else {
1576
      return status;
×
1577
    }
1578
  }
1579

1580
  @Override
1581
  public TSStatus alterSchemaTemplate(TAlterSchemaTemplateReq req) {
1582
    TSStatus status = confirmLeader();
×
1583
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1584
      ByteBuffer buffer = ByteBuffer.wrap(req.getTemplateAlterInfo());
×
1585
      TemplateAlterOperationType operationType =
×
1586
          TemplateAlterOperationUtil.parseOperationType(buffer);
×
1587
      if (operationType.equals(TemplateAlterOperationType.EXTEND_TEMPLATE)) {
×
1588
        return clusterSchemaManager.extendSchemaTemplate(
×
1589
            TemplateAlterOperationUtil.parseTemplateExtendInfo(buffer));
×
1590
      }
1591
      return RpcUtils.getStatus(TSStatusCode.UNSUPPORTED_OPERATION);
×
1592
    } else {
1593
      return status;
×
1594
    }
1595
  }
1596

1597
  @Override
1598
  public TSStatus deleteTimeSeries(TDeleteTimeSeriesReq req) {
1599
    TSStatus status = confirmLeader();
×
1600
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1601
      return procedureManager.deleteTimeSeries(req);
×
1602
    } else {
1603
      return status;
×
1604
    }
1605
  }
1606

1607
  @Override
1608
  public TSStatus deleteLogicalView(TDeleteLogicalViewReq req) {
1609
    TSStatus status = confirmLeader();
×
1610
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1611
      return procedureManager.deleteLogicalView(req);
×
1612
    } else {
1613
      return status;
×
1614
    }
1615
  }
1616

1617
  @Override
1618
  public TSStatus alterLogicalView(TAlterLogicalViewReq req) {
1619
    TSStatus status = confirmLeader();
×
1620
    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1621
      return procedureManager.alterLogicalView(req);
×
1622
    } else {
1623
      return status;
×
1624
    }
1625
  }
1626

1627
  @Override
1628
  public TSStatus createPipe(TCreatePipeReq req) {
1629
    TSStatus status = confirmLeader();
×
1630
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1631
        ? pipeManager.getPipeTaskCoordinator().createPipe(req)
×
1632
        : status;
×
1633
  }
1634

1635
  @Override
1636
  public TSStatus startPipe(String pipeName) {
1637
    TSStatus status = confirmLeader();
×
1638
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1639
        ? pipeManager.getPipeTaskCoordinator().startPipe(pipeName)
×
1640
        : status;
×
1641
  }
1642

1643
  @Override
1644
  public TSStatus stopPipe(String pipeName) {
1645
    TSStatus status = confirmLeader();
×
1646
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1647
        ? pipeManager.getPipeTaskCoordinator().stopPipe(pipeName)
×
1648
        : status;
×
1649
  }
1650

1651
  @Override
1652
  public TSStatus dropPipe(String pipeName) {
1653
    TSStatus status = confirmLeader();
×
1654
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1655
        ? pipeManager.getPipeTaskCoordinator().dropPipe(pipeName)
×
1656
        : status;
×
1657
  }
1658

1659
  @Override
1660
  public TShowPipeResp showPipe(TShowPipeReq req) {
1661
    TSStatus status = confirmLeader();
×
1662
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1663
        ? pipeManager.getPipeTaskCoordinator().showPipes(req)
×
1664
        : new TShowPipeResp().setStatus(status);
×
1665
  }
1666

1667
  @Override
1668
  public TGetAllPipeInfoResp getAllPipeInfo() {
1669
    TSStatus status = confirmLeader();
×
1670
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1671
        ? pipeManager.getPipeTaskCoordinator().getAllPipeInfo()
×
1672
        : new TGetAllPipeInfoResp().setStatus(status);
×
1673
  }
1674

1675
  @Override
1676
  public TGetRegionIdResp getRegionId(TGetRegionIdReq req) {
1677
    TSStatus status = confirmLeader();
×
1678
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1679
        ? partitionManager.getRegionId(req).convertToRpcGetRegionIdResp()
×
1680
        : new TGetRegionIdResp(status);
×
1681
  }
1682

1683
  @Override
1684
  public TGetTimeSlotListResp getTimeSlotList(TGetTimeSlotListReq req) {
1685
    TSStatus status = confirmLeader();
×
1686
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1687
        ? partitionManager.getTimeSlotList(req).convertToRpcGetTimeSlotListResp()
×
1688
        : new TGetTimeSlotListResp(status);
×
1689
  }
1690

1691
  @Override
1692
  public TCountTimeSlotListResp countTimeSlotList(TCountTimeSlotListReq req) {
1693
    TSStatus status = confirmLeader();
×
1694
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1695
        ? partitionManager.countTimeSlotList(req).convertToRpcCountTimeSlotListResp()
×
1696
        : new TCountTimeSlotListResp(status);
×
1697
  }
1698

1699
  @Override
1700
  public TGetSeriesSlotListResp getSeriesSlotList(TGetSeriesSlotListReq req) {
1701
    TSStatus status = confirmLeader();
×
1702
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1703
        ? partitionManager.getSeriesSlotList(req).convertToRpcGetSeriesSlotListResp()
×
1704
        : new TGetSeriesSlotListResp(status);
×
1705
  }
1706

1707
  @Override
1708
  public TSStatus migrateRegion(TMigrateRegionReq req) {
1709
    TSStatus status = confirmLeader();
×
1710
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1711
        ? procedureManager.migrateRegion(req)
×
1712
        : status;
×
1713
  }
1714

1715
  @Override
1716
  public TSStatus createCQ(TCreateCQReq req) {
1717
    TSStatus status = confirmLeader();
×
1718
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1719
        ? cqManager.createCQ(req)
×
1720
        : status;
×
1721
  }
1722

1723
  @Override
1724
  public TSStatus dropCQ(TDropCQReq req) {
1725
    TSStatus status = confirmLeader();
×
1726
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1727
        ? cqManager.dropCQ(req)
×
1728
        : status;
×
1729
  }
1730

1731
  @Override
1732
  public TShowCQResp showCQ() {
1733
    TSStatus status = confirmLeader();
×
1734
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1735
        ? cqManager.showCQ()
×
1736
        : new TShowCQResp(status, Collections.emptyList());
×
1737
  }
1738

1739
  /**
1740
   * Get all related schemaRegion which may contains the timeseries matched by given patternTree.
1741
   */
1742
  public Map<TConsensusGroupId, TRegionReplicaSet> getRelatedSchemaRegionGroup(
1743
      PathPatternTree patternTree) {
1744
    Map<String, Map<TSeriesPartitionSlot, TConsensusGroupId>> schemaPartitionTable =
×
1745
        getSchemaPartition(patternTree).getSchemaPartitionTable();
×
1746

1747
    List<TRegionReplicaSet> allRegionReplicaSets = getPartitionManager().getAllReplicaSets();
×
1748
    Set<TConsensusGroupId> groupIdSet =
×
1749
        schemaPartitionTable.values().stream()
×
1750
            .flatMap(m -> m.values().stream())
×
1751
            .collect(Collectors.toSet());
×
1752
    Map<TConsensusGroupId, TRegionReplicaSet> filteredRegionReplicaSets = new HashMap<>();
×
1753
    for (TRegionReplicaSet regionReplicaSet : allRegionReplicaSets) {
×
1754
      if (groupIdSet.contains(regionReplicaSet.getRegionId())) {
×
1755
        filteredRegionReplicaSets.put(regionReplicaSet.getRegionId(), regionReplicaSet);
×
1756
      }
1757
    }
×
1758
    return filteredRegionReplicaSets;
×
1759
  }
1760

1761
  /**
1762
   * Get all related dataRegion which may contains the data of specific timeseries matched by given
1763
   * patternTree
1764
   */
1765
  public Map<TConsensusGroupId, TRegionReplicaSet> getRelatedDataRegionGroup(
1766
      PathPatternTree patternTree) {
1767
    // Get all databases and slots by getting schemaengine partition
1768
    Map<String, Map<TSeriesPartitionSlot, TConsensusGroupId>> schemaPartitionTable =
×
1769
        getSchemaPartition(patternTree).getSchemaPartitionTable();
×
1770

1771
    // Construct request for getting data partition
1772
    Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> partitionSlotsMap = new HashMap<>();
×
1773
    schemaPartitionTable.forEach(
×
1774
        (key, value) -> {
1775
          Map<TSeriesPartitionSlot, TTimeSlotList> slotListMap = new HashMap<>();
×
1776
          value
×
1777
              .keySet()
×
1778
              .forEach(
×
1779
                  slot ->
1780
                      slotListMap.put(
×
1781
                          slot, new TTimeSlotList(Collections.emptyList(), true, true)));
×
1782
          partitionSlotsMap.put(key, slotListMap);
×
1783
        });
×
1784

1785
    // Get all data partitions
1786
    GetDataPartitionPlan getDataPartitionPlan = new GetDataPartitionPlan(partitionSlotsMap);
×
1787
    Map<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, List<TConsensusGroupId>>>>
1788
        dataPartitionTable = getDataPartition(getDataPartitionPlan).getDataPartitionTable();
×
1789

1790
    // Get all region replicaset of target data partitions
1791
    List<TRegionReplicaSet> allRegionReplicaSets = getPartitionManager().getAllReplicaSets();
×
1792
    Set<TConsensusGroupId> groupIdSet =
×
1793
        dataPartitionTable.values().stream()
×
1794
            .flatMap(
×
1795
                tSeriesPartitionSlotMapMap ->
1796
                    tSeriesPartitionSlotMapMap.values().stream()
×
1797
                        .flatMap(
×
1798
                            tTimePartitionSlotListMap ->
1799
                                tTimePartitionSlotListMap.values().stream()
×
1800
                                    .flatMap(Collection::stream)))
×
1801
            .collect(Collectors.toSet());
×
1802
    Map<TConsensusGroupId, TRegionReplicaSet> filteredRegionReplicaSets = new HashMap<>();
×
1803
    for (TRegionReplicaSet regionReplicaSet : allRegionReplicaSets) {
×
1804
      if (groupIdSet.contains(regionReplicaSet.getRegionId())) {
×
1805
        filteredRegionReplicaSets.put(regionReplicaSet.getRegionId(), regionReplicaSet);
×
1806
      }
1807
    }
×
1808
    return filteredRegionReplicaSets;
×
1809
  }
1810

1811
  public TSStatus transfer(List<TDataNodeLocation> newUnknownDataList) {
1812
    Map<Integer, TDataNodeLocation> runningDataNodeLocationMap = new HashMap<>();
×
1813
    nodeManager
×
1814
        .filterDataNodeThroughStatus(NodeStatus.Running)
×
1815
        .forEach(
×
1816
            dataNodeConfiguration ->
1817
                runningDataNodeLocationMap.put(
×
1818
                    dataNodeConfiguration.getLocation().getDataNodeId(),
×
1819
                    dataNodeConfiguration.getLocation()));
×
1820
    if (runningDataNodeLocationMap.isEmpty()) {
×
1821
      // No running DataNode, will not transfer and print log
1822
      return new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
×
1823
    }
1824

1825
    newUnknownDataList.forEach(
×
1826
        dataNodeLocation -> runningDataNodeLocationMap.remove(dataNodeLocation.getDataNodeId()));
×
1827

1828
    LOGGER.info("Start transfer of {}", newUnknownDataList);
×
1829
    // Transfer trigger
1830
    TSStatus transferResult =
×
1831
        triggerManager.transferTrigger(newUnknownDataList, runningDataNodeLocationMap);
×
1832
    if (transferResult.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
×
1833
      LOGGER.warn("Fail to transfer because {}, will retry", transferResult.getMessage());
×
1834
    }
1835

1836
    return transferResult;
×
1837
  }
1838

1839
  @Override
1840
  public TSStatus createModel(TCreateModelReq req) {
1841
    TSStatus status = confirmLeader();
×
1842
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1843
        ? modelManager.createModel(req)
×
1844
        : status;
×
1845
  }
1846

1847
  @Override
1848
  public TSStatus dropModel(TDropModelReq req) {
1849
    TSStatus status = confirmLeader();
×
1850
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1851
        ? modelManager.dropModel(req)
×
1852
        : status;
×
1853
  }
1854

1855
  @Override
1856
  public TShowModelResp showModel(TShowModelReq req) {
1857
    TSStatus status = confirmLeader();
×
1858
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1859
        ? modelManager.showModel(req)
×
1860
        : new TShowModelResp(status, Collections.emptyList());
×
1861
  }
1862

1863
  @Override
1864
  public TShowTrailResp showTrail(TShowTrailReq req) {
1865
    TSStatus status = confirmLeader();
×
1866
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1867
        ? modelManager.showTrail(req)
×
1868
        : new TShowTrailResp(status, Collections.emptyList());
×
1869
  }
1870

1871
  @Override
1872
  public TSStatus updateModelInfo(TUpdateModelInfoReq req) {
1873
    TSStatus status = confirmLeader();
×
1874
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1875
        ? modelManager.updateModelInfo(req)
×
1876
        : status;
×
1877
  }
1878

1879
  @Override
1880
  public TSStatus updateModelState(TUpdateModelStateReq req) {
1881
    TSStatus status = confirmLeader();
×
1882
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1883
        ? modelManager.updateModelState(req)
×
1884
        : status;
×
1885
  }
1886

1887
  @Override
1888
  public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) {
1889
    TSStatus status = confirmLeader();
×
1890
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1891
        ? clusterQuotaManager.setSpaceQuota(req)
×
1892
        : status;
×
1893
  }
1894

1895
  public TSpaceQuotaResp showSpaceQuota(List<String> databases) {
1896
    TSStatus status = confirmLeader();
×
1897
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1898
        ? clusterQuotaManager.showSpaceQuota(databases)
×
1899
        : new TSpaceQuotaResp(status);
×
1900
  }
1901

1902
  public TSpaceQuotaResp getSpaceQuota() {
1903
    TSStatus status = confirmLeader();
×
1904
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1905
        ? clusterQuotaManager.getSpaceQuota()
×
1906
        : new TSpaceQuotaResp(status);
×
1907
  }
1908

1909
  public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) {
1910
    TSStatus status = confirmLeader();
×
1911
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1912
        ? clusterQuotaManager.setThrottleQuota(req)
×
1913
        : status;
×
1914
  }
1915

1916
  public TThrottleQuotaResp showThrottleQuota(TShowThrottleReq req) {
1917
    TSStatus status = confirmLeader();
×
1918
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1919
        ? clusterQuotaManager.showThrottleQuota(req)
×
1920
        : new TThrottleQuotaResp(status);
×
1921
  }
1922

1923
  public TThrottleQuotaResp getThrottleQuota() {
1924
    TSStatus status = confirmLeader();
×
1925
    return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
×
1926
        ? clusterQuotaManager.getThrottleQuota()
×
1927
        : new TThrottleQuotaResp(status);
×
1928
  }
1929
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc