Skip to content

Commit b103385

Browse files
authored
Add SchemaRegion Interfaces to SchemaEngine (#5349)
1 parent bbfa720 commit b103385

File tree

70 files changed

+1746
-1082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1746
-1082
lines changed

cluster/src/main/java/org/apache/iotdb/cluster/metadata/CSchemaEngine.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,16 +445,6 @@ public boolean isPathExist(PartialPath path) {
445445
}
446446
}
447447

448-
@Override
449-
protected IMNode getDeviceNodeWithAutoCreate(PartialPath path)
450-
throws MetadataException, IOException {
451-
return getDeviceNodeWithAutoCreate(
452-
path,
453-
ClusterDescriptor.getInstance().getConfig().isEnableAutoCreateSchema(),
454-
false,
455-
config.getDefaultStorageGroupLevel());
456-
}
457-
458448
private static class RemoteMetaCache extends LRUCache<PartialPath, IMeasurementMNode> {
459449

460450
RemoteMetaCache(int cacheSize) {

cluster/src/test/java/org/apache/iotdb/cluster/log/applier/AsyncDataLogApplierTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public class AsyncDataLogApplierTest {
5252
public void setUp() throws Exception {
5353
logsToApply = new ArrayList<>();
5454
appliedLogs = new ConcurrentSkipListSet<>();
55-
IoTDB.schemaEngine.init();
55+
IoTDB.configManager.init();
5656
for (int i = 0; i < 10; i++) {
5757
IoTDB.schemaEngine.setStorageGroup(new PartialPath(TestUtils.getTestSg(i)));
5858
}
5959
}
6060

6161
@After
6262
public void tearDown() throws IOException {
63-
IoTDB.schemaEngine.clear();
63+
IoTDB.configManager.clear();
6464
EnvironmentUtils.cleanAllDir();
6565
}
6666

cluster/src/test/java/org/apache/iotdb/cluster/log/catchup/CatchUpTaskTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private boolean dummyMatchTerm(long index, long term) {
185185

186186
@Before
187187
public void setUp() {
188-
IoTDB.schemaEngine.init();
188+
IoTDB.configManager.init();
189189
prevUseAsyncServer = ClusterDescriptor.getInstance().getConfig().isUseAsyncServer();
190190
ClusterDescriptor.getInstance().getConfig().setUseAsyncServer(true);
191191
receivedLogs = new ArrayList<>();
@@ -197,7 +197,7 @@ public void setUp() {
197197

198198
@After
199199
public void tearDown() throws Exception {
200-
IoTDB.schemaEngine.clear();
200+
IoTDB.configManager.clear();
201201
sender.stop();
202202
sender.closeLogManager();
203203
EnvironmentUtils.cleanAllDir();

cluster/src/test/java/org/apache/iotdb/cluster/partition/SchemaEngineWhiteBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static SchemaEngine newSchemaEngine(String logFilePath) {
3535
SchemaEngine schemaEngine = constructor.newInstance();
3636
new File(logFilePath).getParentFile().mkdirs();
3737
Whitebox.setInternalState(schemaEngine, "logFilePath", logFilePath);
38-
schemaEngine.initForMultiSchemaEngineTest();
38+
// schemaEngine.initForMultiSchemaEngineTest();
3939
return schemaEngine;
4040
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
4141
e.printStackTrace();

cluster/src/test/java/org/apache/iotdb/cluster/partition/SlotPartitionTableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void setUp() throws MetadataException {
111111
prevPartitionInterval = StorageEngine.getTimePartitionInterval();
112112
StorageEngine.setEnablePartition(true);
113113

114-
IoTDB.schemaEngine.init();
114+
IoTDB.configManager.init();
115115
StorageEngine.setTimePartitionInterval(7 * 24 * 3600 * 1000L);
116116
nodes = new ArrayList<>();
117117
IntStream.range(0, 20).forEach(i -> nodes.add(getNode(i)));
@@ -175,7 +175,7 @@ public void tearDown() throws IOException, StorageEngineException {
175175
ClusterDescriptor.getInstance().getConfig().setReplicationNum(prevReplicaNum);
176176
if (schemaEngines != null) {
177177
for (SchemaEngine schemaEngine : schemaEngines) {
178-
schemaEngine.clear();
178+
// schemaEngine.clear();
179179
}
180180
}
181181
EnvironmentUtils.cleanEnv();

integration/src/test/java/org/apache/iotdb/db/integration/IoTDBCheckConfigIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void testSaveTimeEncoderToSystemProperties() throws Exception {
105105
public void testAlterTimeEncoderAfterStartService() throws Exception {
106106
EnvironmentUtils.shutdownDaemon();
107107
EnvironmentUtils.stopDaemon();
108-
IoTDB.schemaEngine.clear();
108+
IoTDB.configManager.clear();
109109
systemProperties.put("time_encoder", "REGULAR");
110110
writeSystemFile();
111111
EnvironmentUtils.reactiveDaemon();
@@ -123,7 +123,7 @@ public void testAlterTimeEncoderAfterStartService() throws Exception {
123123
public void testSameTimeEncoderAfterStartService() throws Exception {
124124
EnvironmentUtils.shutdownDaemon();
125125
EnvironmentUtils.stopDaemon();
126-
IoTDB.schemaEngine.clear();
126+
IoTDB.configManager.clear();
127127
systemProperties.put("time_encoder", "TS_2DIFF");
128128
writeSystemFile();
129129
EnvironmentUtils.reactiveDaemon();

integration/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import org.apache.iotdb.itbase.category.LocalStandaloneTest;
2525
import org.apache.iotdb.itbase.category.RemoteTest;
2626

27-
import com.google.gson.Gson;
28-
import com.google.gson.JsonObject;
2927
import org.junit.After;
3028
import org.junit.Assert;
3129
import org.junit.Before;
@@ -45,7 +43,6 @@
4543
import java.util.HashSet;
4644
import java.util.Set;
4745

48-
import static org.apache.iotdb.db.metadata.SchemaEngine.TIME_SERIES_TREE_HEADER;
4946
import static org.junit.Assert.assertEquals;
5047
import static org.junit.Assert.fail;
5148

@@ -222,19 +219,6 @@ public void showStorageGroupTest() throws SQLException {
222219
}
223220
}
224221

225-
@Test
226-
@Category({LocalStandaloneTest.class})
227-
public void databaseMetaDataTest() throws SQLException {
228-
try (Connection connection = EnvFactory.getEnv().getConnection()) {
229-
databaseMetaData = connection.getMetaData();
230-
showTimeseriesInJson();
231-
232-
} catch (Exception e) {
233-
logger.error("databaseMetaDataTest() failed", e);
234-
fail(e.getMessage());
235-
}
236-
}
237-
238222
@Test
239223
@Category({LocalStandaloneTest.class})
240224
public void showVersionTest() throws SQLException {
@@ -605,25 +589,6 @@ public void showCountNodes() throws SQLException {
605589
}
606590
}
607591

608-
/** show metadata in json */
609-
private void showTimeseriesInJson() {
610-
String metadataInJson = databaseMetaData.toString();
611-
String standard =
612-
"=== Timeseries Tree ===\n"
613-
+ "\n"
614-
+ "{\"root\":{\"ln2\":{\"wf01\":{\"wt01\":{\"temperature\":{\"DataType\":\"FLOAT\",\"Encoding\":\"RLE\",\"Compressor\":\"SNAPPY\",\"args\":\"{max_point_number=3}\",\"StorageGroup\":\"root.ln2.wf01.wt01\"},\"status\":{\"DataType\":\"BOOLEAN\",\"Encoding\":\"PLAIN\",\"Compressor\":\"SNAPPY\",\"StorageGroup\":\"root.ln2.wf01.wt01\"}}}},\"ln\":{\"wf01\":{\"wt02\":{\"s1\":{\"DataType\":\"INT32\",\"Encoding\":\"RLE\",\"Compressor\":\"SNAPPY\",\"StorageGroup\":\"root.ln.wf01.wt02\"},\"s2\":{\"DataType\":\"DOUBLE\",\"Encoding\":\"GORILLA\",\"Compressor\":\"SNAPPY\",\"StorageGroup\":\"root.ln.wf01.wt02\"}},\"wt01\":{\"temperature\":{\"DataType\":\"FLOAT\",\"Encoding\":\"RLE\",\"Compressor\":\"SNAPPY\",\"args\":\"{max_point_number=3}\",\"StorageGroup\":\"root.ln.wf01.wt01\"},\"status\":{\"DataType\":\"BOOLEAN\",\"Encoding\":\"PLAIN\",\"Compressor\":\"SNAPPY\",\"StorageGroup\":\"root.ln.wf01.wt01\"}}}},\"ln1\":{\"wf01\":{\"wt01\":{\"temperature\":{\"DataType\":\"FLOAT\",\"Encoding\":\"RLE\",\"Compressor\":\"SNAPPY\",\"args\":\"{max_point_number=3}\",\"StorageGroup\":\"root.ln1.wf01.wt01\"},\"status\":{\"DataType\":\"BOOLEAN\",\"Encoding\":\"PLAIN\",\"Compressor\":\"SNAPPY\",\"StorageGroup\":\"root.ln1.wf01.wt01\"}}}}}}";
615-
// TODO Remove the constant json String.
616-
// Do not depends on the sequence of property in json string if you do not
617-
// explictly mark the sequence, when we use jackson, the json result may change again
618-
String rawJsonString = metadataInJson.substring(TIME_SERIES_TREE_HEADER.length());
619-
Gson gson = new Gson();
620-
JsonObject actual = gson.fromJson(rawJsonString, JsonObject.class);
621-
JsonObject expected =
622-
gson.fromJson(standard.substring(TIME_SERIES_TREE_HEADER.length()), JsonObject.class);
623-
624-
Assert.assertEquals(expected, actual);
625-
}
626-
627592
@Test
628593
@Category({LocalStandaloneTest.class, ClusterTest.class, RemoteTest.class})
629594
public void showAlignedTimeseriesWithAliasAndTags() throws SQLException {

node-commons/src/main/java/org/apache/iotdb/commons/partition/SchemaRegionId.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
*/
1919
package org.apache.iotdb.commons.partition;
2020

21+
import java.util.Objects;
22+
2123
public class SchemaRegionId {
2224
private int schemaRegionId;
2325

26+
public SchemaRegionId(int schemaRegionId) {
27+
this.schemaRegionId = schemaRegionId;
28+
}
29+
2430
public int getSchemaRegionId() {
2531
return schemaRegionId;
2632
}
@@ -29,6 +35,19 @@ public void setSchemaRegionId(int schemaRegionId) {
2935
this.schemaRegionId = schemaRegionId;
3036
}
3137

38+
@Override
39+
public boolean equals(Object o) {
40+
if (this == o) return true;
41+
if (o == null || getClass() != o.getClass()) return false;
42+
SchemaRegionId that = (SchemaRegionId) o;
43+
return schemaRegionId == that.schemaRegionId;
44+
}
45+
46+
@Override
47+
public int hashCode() {
48+
return Objects.hash(schemaRegionId);
49+
}
50+
3251
public String toString() {
3352
return String.format("SchemaRegion-%d", schemaRegionId);
3453
}

0 commit comments

Comments
 (0)