jt2594838 commented on code in PR #18484: URL: https://github.com/apache/iotdb/pull/18484#discussion_r3851518742
########## iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImplDiskTest.java: ########## @@ -0,0 +1,109 @@ +/* + * 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.protocol.thrift.impl; + +import org.apache.iotdb.common.rpc.thrift.TLoadSample; +import org.apache.iotdb.commons.cluster.NodeStatus; +import org.apache.iotdb.commons.conf.CommonConfig; +import org.apache.iotdb.commons.conf.CommonDescriptor; +import org.apache.iotdb.db.conf.IoTDBConfig; +import org.apache.iotdb.db.conf.IoTDBDescriptor; +import org.apache.iotdb.db.service.DataNode.DataNodeContext; +import org.apache.iotdb.metrics.metricsets.system.SystemMetrics; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DataNodeInternalRPCServiceImplDiskTest { + + private final CommonConfig commonConfig = CommonDescriptor.getInstance().getConfig(); + private final IoTDBConfig dataNodeConfig = IoTDBDescriptor.getInstance().getConfig(); + private NodeStatus originalStatus; + private String originalStatusReason; + private double originalDiskSpaceWarningThreshold; + private int originalDataNodeId; + + @Before + public void setUp() { + originalStatus = commonConfig.getNodeStatus(); + originalStatusReason = commonConfig.getStatusReason(); + originalDiskSpaceWarningThreshold = commonConfig.getDiskSpaceWarningThreshold(); + originalDataNodeId = dataNodeConfig.getDataNodeId(); + + dataNodeConfig.setDataNodeId(0); + commonConfig.setNodeStatus(NodeStatus.Running); + commonConfig.setStatusReason(null); + commonConfig.setDiskSpaceWarningThreshold(0.05); + commonConfig.setNodeStatus(NodeStatus.ReadOnly); + commonConfig.setStatusReason(NodeStatus.DISK_FULL); + } + + @After + public void tearDown() { + commonConfig.setNodeStatus(originalStatus); + commonConfig.setStatusReason(originalStatusReason); + commonConfig.setDiskSpaceWarningThreshold(originalDiskSpaceWarningThreshold); + dataNodeConfig.setDataNodeId(originalDataNodeId); + } + + @Test + public void testPipeReceiverDiskDoesNotBlockRunningRecovery() { + SystemMetrics systemMetrics = mock(SystemMetrics.class); Review Comment: How is this test related to PipeReceiver disk? ########## iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/rescon/disk/FolderManagerTest.java: ########## @@ -186,4 +191,24 @@ public void testEventuallyThrowsDiskFullAfterRetries() { fail("Should have thrown DiskSpaceInsufficientException"); } } + + @Test + public void testPipeFolderManagerDoesNotChangeNodeStatusWhenDiskFull() { Review Comment: The test does not seem to involve Pipe, either. ########## iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/disk/strategy/DirectoryStrategy.java: ########## @@ -61,8 +67,12 @@ public void setFolders(List<String> folders) throws DiskSpaceInsufficientExcepti } } if (!hasSpace) { - LOGGER.error(UtilMessages.DISK_SPACE_INSUFFICIENT_READ_ONLY); - CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly); + if (changeSystemStatusToReadOnly) { + LOGGER.error(UtilMessages.DISK_SPACE_INSUFFICIENT_READ_ONLY); + CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly); + } else { + LOGGER.error(UtilMessages.MESSAGE_DISK_SPACE_INSUFFICIENT_DF6205B0); + } Review Comment: Will this be printed frequently under certain circumstances? -- 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]
