未验证 提交 af5549d3 编写于 作者: 任宇华 提交者: GitHub

[IOTDB-3966] [IOTDB-4079]Show leadership when show Regions && fix region id duplicated (#6939)

上级 f1787b83
......@@ -20,12 +20,14 @@
package org.apache.iotdb.confignode.manager;
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.commons.cluster.RegionRoleType;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.IllegalPathException;
......@@ -849,10 +851,26 @@ public class ConfigManager implements IManager {
}
@Override
public DataSet showRegion(GetRegionInfoListPlan getRegionInfoListPlan) {
public RegionInfoListResp showRegion(GetRegionInfoListPlan getRegionInfoListPlan) {
TSStatus status = confirmLeader();
if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
return partitionManager.getRegionInfoList(getRegionInfoListPlan);
RegionInfoListResp regionInfoListResp =
(RegionInfoListResp) partitionManager.getRegionInfoList(getRegionInfoListPlan);
regionInfoListResp
.getRegionInfoList()
.forEach(
regionInfo -> {
Map<TConsensusGroupId, Integer> allLeadership = loadManager.getAllLeadership();
if (!allLeadership.isEmpty()) {
String regionType =
regionInfo.getDataNodeId()
== allLeadership.get(regionInfo.getConsensusGroupId())
? RegionRoleType.Leader.toString()
: RegionRoleType.Follower.toString();
regionInfo.setRoleType(regionType);
}
});
return regionInfoListResp;
} else {
RegionInfoListResp regionResp = new RegionInfoListResp();
regionResp.setStatus(status);
......
......@@ -217,11 +217,29 @@ public class LoadManager {
*/
public Map<TConsensusGroupId, Integer> getAllLeadership() {
Map<TConsensusGroupId, Integer> result = new ConcurrentHashMap<>();
regionGroupCacheMap.forEach(
(consensusGroupId, regionGroupCache) ->
result.put(consensusGroupId, regionGroupCache.getLeaderDataNodeId()));
if (ConfigNodeDescriptor.getInstance()
.getConf()
.getDataRegionConsensusProtocolClass()
.equals(ConsensusFactory.MultiLeaderConsensus)) {
regionGroupCacheMap.forEach(
(consensusGroupId, regionGroupCache) -> {
if (consensusGroupId.getType().equals(TConsensusGroupType.SchemaRegion)) {
result.put(consensusGroupId, regionGroupCache.getLeaderDataNodeId());
}
});
routeBalancer
.getRouteMap()
.forEach(
(consensusGroupId, regionReplicaSet) -> {
result.put(
consensusGroupId,
regionReplicaSet.getDataNodeLocations().get(0).getDataNodeId());
});
} else {
regionGroupCacheMap.forEach(
(consensusGroupId, regionGroupCache) ->
result.put(consensusGroupId, regionGroupCache.getLeaderDataNodeId()));
}
return result;
}
......
......@@ -109,4 +109,8 @@ public class RouteBalancer {
private LoadManager getLoadManager() {
return configManager.getLoadManager();
}
public Map<TConsensusGroupId, TRegionReplicaSet> getRouteMap() {
return lazyGreedyRouter.getRouteMap();
}
}
......@@ -151,4 +151,8 @@ public class LazyGreedyRouter implements IRouter {
(dataNodeId, counter) -> (counter == null ? 1 : counter + 1));
routeMap.put(newRouteEntry.getRegionId(), newRouteEntry);
}
public Map<TConsensusGroupId, TRegionReplicaSet> getRouteMap() {
return routeMap;
}
}
......@@ -104,7 +104,7 @@ public class PartitionInfo implements SnapshotProcessor {
public PartitionInfo() {
this.storageGroupPartitionTables = new ConcurrentHashMap<>();
this.nextRegionGroupId = new AtomicInteger(0);
this.nextRegionGroupId = new AtomicInteger(-1);
// Ensure that the PartitionTables of the StorageGroups who've been logically deleted
// are unreadable and un-writable
......@@ -149,7 +149,7 @@ public class PartitionInfo implements SnapshotProcessor {
}
public int generateNextRegionGroupId() {
return nextRegionGroupId.getAndIncrement();
return nextRegionGroupId.incrementAndGet();
}
// ======================================================
......@@ -427,6 +427,7 @@ public class PartitionInfo implements SnapshotProcessor {
List<TRegionInfo> regionInfoList = new ArrayList<>();
if (storageGroupPartitionTables.isEmpty()) {
regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
regionResp.setRegionInfoList(new ArrayList<>());
return regionResp;
}
TShowRegionReq showRegionReq = regionsInfoPlan.getShowRegionReq();
......@@ -753,7 +754,7 @@ public class PartitionInfo implements SnapshotProcessor {
}
public void clear() {
nextRegionGroupId.set(0);
nextRegionGroupId.set(-1);
storageGroupPartitionTables.clear();
deletedRegionSet.clear();
}
......
......@@ -354,22 +354,22 @@ public class StorageGroupPartitionTable {
.getDataNodeLocations()
.forEach(
(dataNodeLocation) -> {
TRegionInfo tRegionInfoList = new TRegionInfo();
tRegionInfoList.setConsensusGroupId(replicaSet.getRegionId());
tRegionInfoList.setStorageGroup(storageGroupName);
TRegionInfo regionInfo = new TRegionInfo();
regionInfo.setConsensusGroupId(replicaSet.getRegionId());
regionInfo.setStorageGroup(storageGroupName);
if (replicaSet.getRegionId().getType() == TConsensusGroupType.DataRegion) {
tRegionInfoList.setSeriesSlots(dataPartitionTable.getDataPartitionMap().size());
tRegionInfoList.setTimeSlots(regionGroup.getCounter());
regionInfo.setSeriesSlots(dataPartitionTable.getDataPartitionMap().size());
regionInfo.setTimeSlots(regionGroup.getCounter());
} else if (replicaSet.getRegionId().getType() == TConsensusGroupType.SchemaRegion) {
tRegionInfoList.setSeriesSlots(regionGroup.getCounter());
tRegionInfoList.setTimeSlots(0);
regionInfo.setSeriesSlots(regionGroup.getCounter());
regionInfo.setTimeSlots(0);
}
tRegionInfoList.setDataNodeId(dataNodeLocation.getDataNodeId());
tRegionInfoList.setClientRpcIp(dataNodeLocation.getClientRpcEndPoint().getIp());
tRegionInfoList.setClientRpcPort(dataNodeLocation.getClientRpcEndPoint().getPort());
regionInfo.setDataNodeId(dataNodeLocation.getDataNodeId());
regionInfo.setClientRpcIp(dataNodeLocation.getClientRpcEndPoint().getIp());
regionInfo.setClientRpcPort(dataNodeLocation.getClientRpcEndPoint().getPort());
// TODO: Wait for data migration. And then add the state
tRegionInfoList.setStatus(RegionStatus.Up.getStatus());
regionInfoList.add(tRegionInfoList);
regionInfo.setStatus(RegionStatus.Up.getStatus());
regionInfoList.add(regionInfo);
});
}
......
......@@ -534,8 +534,7 @@ public class ConfigNodeRPCServiceProcessor implements IConfigNodeRPCService.Ifac
@Override
public TShowRegionResp showRegion(TShowRegionReq showRegionReq) throws TException {
GetRegionInfoListPlan getRegionInfoListPlan = new GetRegionInfoListPlan(showRegionReq);
RegionInfoListResp dataSet =
(RegionInfoListResp) configManager.showRegion(getRegionInfoListPlan);
RegionInfoListResp dataSet = configManager.showRegion(getRegionInfoListPlan);
TShowRegionResp showRegionResp = new TShowRegionResp();
showRegionResp.setStatus(dataSet.getStatus());
showRegionResp.setRegionInfoList(dataSet.getRegionInfoList());
......
......@@ -142,112 +142,112 @@ Currently, IoTDB supports Region query using the following SQL:
- `SHOW DATA REGIONS`: Show all DataRegion distribution
- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: Show region distribution of specified storage groups
```sql
First, let's take a look at the distribution of Regions under three copies:
```
IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 6
It costs 0.032s
```
Then take a look at the distribution of Regions under a single copy:
```sql
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 2
It costs 0.035s
It costs 0.128s
```
Show the distribution information of Schema Region and Data Region:
```
IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1| DataRegion| Up| root.sg| 1| 1| 1|127.0.0.1|6669|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 3
It costs 0.010s
IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show data regions
+--------+----------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+----------+------+-------------+------------+----------+----------+---------+----+
| 1|DataRegion| Up| root.sg| 1| 1| 1|127.0.0.1|6669|
| 2|DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6669|
+--------+----------+------+-------------+------------+----------+----------+---------+----+
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.011s
IoTDB> show schema regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.012s
IoTDB> show regions of storage group root.sg1
show regions of storage group root.sg1
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 10|SchemaRegion| Up| root.sg1| 1| 0| 4|127.0.0.1|6669|
| 11| DataRegion| Up| root.sg1| 1| 1| 5|127.0.0.1|6671|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 2
It costs 0.005s
```
IoTDB> show regions of storage group root.sg1, root.sg2
show regions of storage group root.sg1, root.sg2
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 10|SchemaRegion| Up| root.sg1| 1| 0| 4|127.0.0.1|6669|
| 11| DataRegion| Up| root.sg1| 1| 1| 5|127.0.0.1|6671|
| 12|SchemaRegion| Up| root.sg2| 1| 0| 4|127.0.0.1|6669|
| 13| DataRegion| Up| root.sg2| 1| 1| 4|127.0.0.1|6669|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 4
It costs 0.005s
Show region distribution of specified storage groups
IoTDB> show regions of storage group root.*.sg_2
show regions of storage group root.*.sg_2
+--------+------------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
| 14|SchemaRegion| Up|root.sg_1.sg_2| 1| 0| 3|127.0.0.1|6667|
| 15| DataRegion| Up|root.sg_1.sg_2| 1| 1| 5|127.0.0.1|6671|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
```
IoTDB> show regions of storage group root.sg
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.004s
IoTDB> show data regions of storage group root.*.sg_2
show data regions of storage group root.*.sg_2
+--------+----------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+----------+------+--------------+------------+----------+----------+---------+----+
| 15|DataRegion| Up|root.sg_1.sg_2| 1| 1| 5|127.0.0.1|6671|
+--------+----------+------+--------------+------------+----------+----------+---------+----+
Total line number = 1
It costs 0.004s
IoTDB> show schema regions of storage group root.*.sg_2
show schema regions of storage group root.*.sg_2
+--------+------------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
| 14|SchemaRegion| Up|root.sg_1.sg_2| 1| 0| 5|127.0.0.1|6671|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
Total line number = 1
It costs 0.102s
It costs 0.005s
IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> show regions of storage group root.*.wf01
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
Total line number = 3
It costs 0.012s
```
## Monitoring tool for cluster Node distribution
### Show all DataNode information
......@@ -268,12 +268,12 @@ Msg: The statement is executed successfully.
IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 2
It costs 0.013s
......@@ -290,13 +290,13 @@ It costs 0.007s
IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|
| 2| DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|Leader|
| 2| DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6667|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 3
It costs 0.008s
IoTDB> show datanodes
......
......@@ -135,116 +135,113 @@ KILL QUERY <queryId>
- `SHOW REGIONS`: 展示所有 Region
- `SHOW SCHEMA REGIONS`: 展示所有 SchemaRegion 分布
- `SHOW DATA REGIONS`: 展示所有 DataRegion 分布
- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: 展示指定的存储组<sg1,sg2,...>对应的Region分布
- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: 展示指定的存储组<sg1,sg2,...>对应的Region分布
首先来看一下三副本下Region的分布情况:
```sql
```
IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 6
It costs 0.032s
```
然后再来看一下单副本下Region的分布情况:
```sql
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 2
It costs 0.035s
It costs 0.128s
```
查看Schema Region和Data Region的分布信息:
```
IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1| DataRegion| Up| root.sg| 1| 1| 1|127.0.0.1|6669|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 3
It costs 0.010s
IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show data regions
+--------+----------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+----------+------+-------------+------------+----------+----------+---------+----+
| 1|DataRegion| Up| root.sg| 1| 1| 1|127.0.0.1|6669|
| 2|DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6669|
+--------+----------+------+-------------+------------+----------+----------+---------+----+
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.011s
IoTDB> show schema regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6671|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.012s
```
IoTDB> show regions of storage group root.sg1
show regions of storage group root.sg1
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 10|SchemaRegion| Up| root.sg1| 1| 0| 4|127.0.0.1|6669|
| 11| DataRegion| Up| root.sg1| 1| 1| 5|127.0.0.1|6671|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 2
It costs 0.005s
展示指定的存储组<sg1,sg2,...>对应的Region分布:
IoTDB> show regions of storage group root.sg1, root.sg2
show regions of storage group root.sg1, root.sg2
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 10|SchemaRegion| Up| root.sg1| 1| 0| 4|127.0.0.1|6669|
| 11| DataRegion| Up| root.sg1| 1| 1| 5|127.0.0.1|6671|
| 12|SchemaRegion| Up| root.sg2| 1| 0| 4|127.0.0.1|6669|
| 13| DataRegion| Up| root.sg2| 1| 1| 4|127.0.0.1|6669|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
Total line number = 4
```
IoTDB> show regions of storage group root.sg
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
Total line number = 2
It costs 0.005s
IoTDB> show regions of storage group root.*.sg_2
show regions of storage group root.*.sg_2
+--------+------------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
| 14|SchemaRegion| Up|root.sg_1.sg_2| 1| 0| 3|127.0.0.1|6667|
| 15| DataRegion| Up|root.sg_1.sg_2| 1| 1| 5|127.0.0.1|6671|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
Total line number = 2
It costs 0.004s
IoTDB> show data regions of storage group root.*.sg_2
show data regions of storage group root.*.sg_2
+--------+----------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+----------+------+--------------+------------+----------+----------+---------+----+
| 15|DataRegion| Up|root.sg_1.sg_2| 1| 1| 5|127.0.0.1|6671|
+--------+----------+------+--------------+------------+----------+----------+---------+----+
Total line number = 1
It costs 0.004s
IoTDB> show schema regions of storage group root.*.sg_2
show schema regions of storage group root.*.sg_2
+--------+------------+------+--------------+------------+----------+----------+---------+----+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
| 14|SchemaRegion| Up|root.sg_1.sg_2| 1| 0| 5|127.0.0.1|6671|
+--------+------------+------+--------------+------------+----------+----------+---------+----+
Total line number = 1
It costs 0.102s
IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> show regions of storage group root.*.wf01
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
Total line number = 3
It costs 0.012s
```
## 集群节点分布式监控工具
### 查看DataNode节点信息
......@@ -265,12 +262,12 @@ Msg: The statement is executed successfully.
IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 2
It costs 0.013s
......@@ -287,13 +284,13 @@ It costs 0.007s
IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
Msg: The statement is executed successfully.
IoTDB> show regions
+--------+------------+------+-------------+------------+----------+----------+---------+----+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|
| 2| DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6667|
+--------+------------+------+-------------+------------+----------+----------+---------+----+
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
| 0|SchemaRegion| Up| root.sg| 2| 0| 1|127.0.0.1|6667|Leader|
| 1|SchemaRegion| Up| root.ln| 1| 0| 2|127.0.0.1|6668|Leader|
| 2| DataRegion| Up| root.ln| 1| 1| 1|127.0.0.1|6667|Leader|
+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
Total line number = 3
It costs 0.008s
IoTDB> show datanodes
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.commons.cluster;
/** Region Role for showing regions */
public enum RegionRoleType {
// Region role type : Leader
Leader("Leader"),
// Region role type : Follower
Follower("Follower");
private final String status;
RegionRoleType(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
}
......@@ -78,6 +78,7 @@ public class HeaderConstant {
public static final String COLUMN_DATANODE_ID = "DataNodeId";
public static final String COLUMN_SERIES_SLOTS = "Series Slots";
public static final String COLUMN_TIME_SLOTS = "Time Slots";
public static final String COLUMN_ROLE = "Role";
// column names for show datanodes
public static final String COLUMN_DATA_REGION_NUM = "DataRegionNum";
......@@ -258,7 +259,8 @@ public class HeaderConstant {
new ColumnHeader(COLUMN_TIME_SLOTS, TSDataType.INT64),
new ColumnHeader(COLUMN_DATANODE_ID, TSDataType.INT32),
new ColumnHeader(COLUMN_HOST, TSDataType.TEXT),
new ColumnHeader(COLUMN_PORT, TSDataType.INT32)),
new ColumnHeader(COLUMN_PORT, TSDataType.INT32),
new ColumnHeader(COLUMN_ROLE, TSDataType.TEXT)),
true);
}
......
......@@ -79,6 +79,7 @@ public class ShowRegionTask implements IConfigTask {
builder.getColumnBuilder(6).writeInt(regionInfo.getDataNodeId());
builder.getColumnBuilder(7).writeBinary(Binary.valueOf(regionInfo.getClientRpcIp()));
builder.getColumnBuilder(8).writeInt(regionInfo.getClientRpcPort());
builder.getColumnBuilder(9).writeBinary(Binary.valueOf(regionInfo.getRoleType()));
builder.declarePosition();
}
}
......
......@@ -295,6 +295,7 @@ struct TRegionInfo {
6: required i64 seriesSlots
7: required i64 timeSlots
8: optional string status
9: optional string roleType
}
struct TShowRegionResp {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册