neuyilan commented on code in PR #9596:
URL: https://github.com/apache/iotdb/pull/9596#discussion_r1165266212
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java:
##########
@@ -59,6 +59,8 @@ public class ClusterQuotaManager {
private final Map<String, List<Integer>> schemaRegionIdMap;
private final Map<String, List<Integer>> dataRegionIdMap;
private final Map<Integer, Long> regionDisk;
+ private static final int UNLIMITED_VALUE = -1;
+ private static final int DEFAULT_VALUE = 0;
Review Comment:
This can be set in the IoTDBConstant class in the node-commans module,
and the visitSetSpaceQuota method in ASTVisitor can also use the
UNLIMITED_VALUE value
##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/sys/quota/ShowSpaceQuotaTask.java:
##########
@@ -46,6 +46,8 @@
public class ShowSpaceQuotaTask implements IConfigTask {
private final ShowSpaceQuotaStatement showSpaceQuotaStatement;
+ private static final float unitSize = 1024.0F;
+ private static final String showUnit = "G";
Review Comment:
the same, if others place using the unit, we can move the parameter to the
IoTDBConstant class
##########
integration-test/src/test/java/org/apache/iotdb/db/it/quotas/IoTDBSpaceQuotaIT.java:
##########
@@ -0,0 +1,492 @@
+/*
+ * 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.db.it.quotas;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBSpaceQuotaIT {
+
+ @Before
+ public void setUp() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(true);
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(false);
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void timeseriesNumExceedTest() {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection();
+ Statement adminStmt = adminCon.createStatement()) {
+ adminStmt.execute("set space quota timeseries=3 on root.sg0");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status1 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status2 with
datatype=BOOLEAN,encoding=PLAIN;");
+ Thread.sleep(1000);
Review Comment:
the same as others
##########
integration-test/src/test/java/org/apache/iotdb/db/it/quotas/IoTDBSpaceQuotaIT.java:
##########
@@ -0,0 +1,492 @@
+/*
+ * 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.db.it.quotas;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBSpaceQuotaIT {
+
+ @Before
+ public void setUp() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(true);
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(false);
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void timeseriesNumExceedTest() {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection();
+ Statement adminStmt = adminCon.createStatement()) {
+ adminStmt.execute("set space quota timeseries=3 on root.sg0");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status1 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status2 with
datatype=BOOLEAN,encoding=PLAIN;");
+ Thread.sleep(1000);
Review Comment:
can we make sure that, after 1000 milliseconds, the datanode will update the
quotas? how about if the heartbeat time increase, may be we should using
heartbeat time(which is `heartbeatIntervalInMs`) and puls some extra time
##########
integration-test/src/test/java/org/apache/iotdb/db/it/quotas/IoTDBSpaceQuotaIT.java:
##########
@@ -0,0 +1,492 @@
+/*
+ * 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.db.it.quotas;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBSpaceQuotaIT {
+
+ @Before
+ public void setUp() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(true);
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
EnvFactory.getEnv().getConfig().getDataNodeCommonConfig().setQuotaEnable(false);
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void timeseriesNumExceedTest() {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection();
+ Statement adminStmt = adminCon.createStatement()) {
+ adminStmt.execute("set space quota timeseries=3 on root.sg0");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status1 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status2 with
datatype=BOOLEAN,encoding=PLAIN;");
+ Thread.sleep(1000);
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status3 with
datatype=BOOLEAN,encoding=PLAIN;");
+ } catch (SQLException | InterruptedException throwables) {
+ Assert.assertEquals(
+ "301: The used quota exceeds the preset quota. Please set a larger
value.",
+ throwables.getMessage());
+ }
+ }
+
+ @Test
+ public void devicesNumExceedTest() {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection();
+ Statement adminStmt = adminCon.createStatement()) {
+ adminStmt.execute("set space quota devices=3 on root.sg0");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf01.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf02.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ adminStmt.execute(
+ "create timeseries root.sg0.wf03.wt01.status0 with
datatype=BOOLEAN,encoding=PLAIN;");
+ Thread.sleep(1000);
Review Comment:
the same
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]