Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public void testClosedDataNodeGetConnections() throws Exception {
TimeUnit.SECONDS.sleep(1);
}
}
TimeUnit.SECONDS.sleep(3);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void executeRawDataQuery() {
}

@Test
public void tryIfTheServerIsRestart() {
public void tryIfTheServerIsRestart() throws InterruptedException {
ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
SessionDataSetWrapper wrapper = null;
BaseNodeWrapper node = EnvFactory.getEnv().getDataNodeWrapper(0);
Expand All @@ -268,6 +268,7 @@ public void tryIfTheServerIsRestart() {
.ensureNodeStatus(
Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
pool = EnvFactory.getEnv().getSessionPool(3);
TimeUnit.SECONDS.sleep(3);
correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
pool.close();
return;
Expand Down Expand Up @@ -335,7 +336,7 @@ public void tryIfTheServerIsRestartButDataIsGotten() {
}

@Test
public void restart() {
public void restart() throws InterruptedException {
ISessionPool pool = EnvFactory.getEnv().getSessionPool(1);
write10Data(pool, true);
// stop the server.
Expand All @@ -353,6 +354,7 @@ public void restart() {
EnvFactory.getEnv()
.ensureNodeStatus(
Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
TimeUnit.SECONDS.sleep(3);
write10Data(pool, true);
pool.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
import org.apache.iotdb.metrics.utils.MetricType;
import org.apache.iotdb.metrics.utils.SystemType;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.ptr.IntByReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,7 +57,9 @@

@Override
public void bindTo(AbstractMetricService metricService) {
if ((CONFIG.getSystemType() == SystemType.LINUX || CONFIG.getSystemType() == SystemType.MAC)
if ((CONFIG.getSystemType() == SystemType.LINUX
|| CONFIG.getSystemType() == SystemType.MAC
|| CONFIG.getSystemType() == SystemType.WINDOWS)
&& !CONFIG.getPid().isEmpty()) {
this.getOpenFileNumberCommand =
new String[] {"/bin/sh", "-c", String.format("lsof -p %s | wc -l", CONFIG.getPid())};
Expand Down Expand Up @@ -88,6 +95,11 @@
}
}
fdCount = Long.parseLong(result.toString().trim());
} else if (CONFIG.getSystemType() == SystemType.WINDOWS) {
WinNT.HANDLE hProcess = Kernel32.INSTANCE.GetCurrentProcess();

Check warning on line 99 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/file/SystemRelatedFileMetrics.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Local variable name 'hProcess' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZzhaGjCf-wo9cNxFsp4&open=AZzhaGjCf-wo9cNxFsp4&pullRequest=17290
IntByReference handleCount = new IntByReference();
boolean success = Kernel32Ext.INSTANCE.GetProcessHandleCount(hProcess, handleCount);
return success ? handleCount.getValue() : 0L;
}
} catch (IOException e) {
LOGGER.warn("Failed to get open file number, because ", e);
Expand All @@ -97,7 +109,9 @@

@Override
public void unbindFrom(AbstractMetricService metricService) {
if ((CONFIG.getSystemType() == SystemType.LINUX || CONFIG.getSystemType() == SystemType.MAC)
if ((CONFIG.getSystemType() == SystemType.LINUX
|| CONFIG.getSystemType() == SystemType.MAC
|| CONFIG.getSystemType() == SystemType.WINDOWS)
&& !CONFIG.getPid().isEmpty()) {
metricService.remove(
MetricType.AUTO_GAUGE,
Expand All @@ -106,4 +120,10 @@
"open_file_handlers");
}
}

public interface Kernel32Ext extends Library {
Kernel32Ext INSTANCE = Native.load("kernel32", Kernel32Ext.class);

boolean GetProcessHandleCount(WinNT.HANDLE hProcess, IntByReference pdwHandleCount);

Check warning on line 127 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/file/SystemRelatedFileMetrics.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Method name 'GetProcessHandleCount' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9_]*$'.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZzhaGjCf-wo9cNxFsp5&open=AZzhaGjCf-wo9cNxFsp5&pullRequest=17290

Check warning on line 127 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/file/SystemRelatedFileMetrics.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Parameter name 'hProcess' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZzhaGjCf-wo9cNxFsp6&open=AZzhaGjCf-wo9cNxFsp6&pullRequest=17290

Check warning on line 127 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/file/SystemRelatedFileMetrics.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZzhaGjCf-wo9cNxFsp3&open=AZzhaGjCf-wo9cNxFsp3&pullRequest=17290
}
}
Loading
Loading