Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem: benchmark won't quit when DataNode accidently shutdown #384

Merged
Merged
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 @@ -25,6 +25,7 @@
import cn.edu.tsinghua.iot.benchmark.measurement.enums.SystemMetrics;
import cn.edu.tsinghua.iot.benchmark.measurement.persistence.TestDataPersistence;
import cn.edu.tsinghua.iot.benchmark.mode.enums.BenchmarkMode;
import cn.edu.tsinghua.iot.benchmark.utils.NamedThreadFactory;
import cn.edu.tsinghua.iot.benchmark.utils.ZipUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -141,7 +142,7 @@ public CSVRecorder() {
LOGGER.error("", ioException);
}
}
service = Executors.newSingleThreadExecutor();
service = Executors.newSingleThreadExecutor(new NamedThreadFactory("CSVRecorder"));
}

/** write header of csv file */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig;
import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException;
import cn.edu.tsinghua.iot.benchmark.utils.NamedThreadFactory;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
Expand Down Expand Up @@ -189,22 +190,7 @@ public IoTDBClusterSession(DBConfig dbConfig) {
@Override
public void init() throws TsdbException {
// do nothing
this.service = Executors.newSingleThreadExecutor();
}

@Override
public void close() throws TsdbException {
if (sessionWrapper != null) {
try {
sessionWrapper.close();
} catch (IoTDBConnectionException ignored) {
// should never happen
}
}
if (ioTDBConnection != null) {
ioTDBConnection.close();
}
this.service.shutdown();
this.service = Executors.newSingleThreadExecutor(new NamedThreadFactory("ClusterSession"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.iotdb.tsfile.write.record.Tablet;

import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig;
import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException;
import cn.edu.tsinghua.iot.benchmark.utils.NamedThreadFactory;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
Expand Down Expand Up @@ -183,7 +183,7 @@ public void init() {
} else {
sessionWrapper.open();
}
this.service = Executors.newSingleThreadExecutor();
this.service = Executors.newSingleThreadExecutor(new NamedThreadFactory("Session"));
} catch (IoTDBConnectionException e) {
LOGGER.error("Failed to add session", e);
}
Expand All @@ -208,20 +208,4 @@ public void cleanup() {
LOGGER.error("Failed to execute statement:" + e.getMessage());
}
}

@Override
public void close() throws TsdbException {
try {
if (sessionWrapper != null) {
sessionWrapper.close();
}
if (ioTDBConnection != null) {
ioTDBConnection.close();
}
this.service.shutdown();
} catch (IoTDBConnectionException ioTDBConnectionException) {
LOGGER.error("Failed to close session.");
throw new TsdbException(ioTDBConnectionException);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,20 @@ Status waitWriteTaskToFinishAndGetStatus() {
}
return new Status(true);
}

@Override
public void close() throws TsdbException {
try {
if (sessionWrapper != null) {
sessionWrapper.close();
}
if (ioTDBConnection != null) {
ioTDBConnection.close();
}
} catch (IoTDBConnectionException e) {
throw new TsdbException(e);
} finally {
this.service.shutdown();
}
}
}
Loading