Skip to content

Commit

Permalink
rename future to task
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Nov 14, 2023
1 parent 8bbd22e commit 4b061e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class IoTDB implements IDatabase {
protected static Set<String> storageGroups = Collections.synchronizedSet(new HashSet<>());
protected final String ROOT_SERIES_NAME;
protected ExecutorService service;
protected Future<?> future;
protected Future<?> task;
protected DBConfig dbConfig;
protected Random random = new Random(config.getDATA_SEED());

Expand Down Expand Up @@ -142,8 +142,8 @@ public void close() throws TsdbException {
if (service != null) {
service.shutdownNow();
}
if (future != null) {
future.cancel(true);
if (task != null) {
task.cancel(true);
}
}

Expand Down Expand Up @@ -698,7 +698,7 @@ protected Status executeQueryAndGetStatus(String sql, Operation operation) {
AtomicBoolean isOk = new AtomicBoolean(true);
try (Statement statement = ioTDBConnection.getConnection().createStatement()) {
List<List<Object>> records = new ArrayList<>();
future =
task =
service.submit(
() -> {
try {
Expand Down Expand Up @@ -735,9 +735,9 @@ protected Status executeQueryAndGetStatus(String sql, Operation operation) {
queryResultPointNum.set(resultPointNum);
});
try {
future.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
task.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
future.cancel(true);
task.cancel(true);
return new Status(false, queryResultPointNum.get(), e, executeSQL);
}
if (isOk.get() == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IoTDBSessionBase(DBConfig dbConfig) {

public Status insertOneBatchByTablet(IBatch batch) {
Tablet tablet = genTablet(batch);
future =
task =
service.submit(
() -> {
try {
Expand Down Expand Up @@ -146,7 +146,7 @@ public Status insertOneBatchByRecords(IBatch batch) {
}
batch.next();
}
future =
task =
service.submit(
() -> {
try {
Expand Down Expand Up @@ -180,7 +180,7 @@ protected Status executeQueryAndGetStatus(String sql, Operation operation) {
AtomicBoolean isOk = new AtomicBoolean(true);
try {
List<List<Object>> records = new ArrayList<>();
future =
task =
service.submit(
() -> {
try {
Expand Down Expand Up @@ -233,9 +233,9 @@ protected Status executeQueryAndGetStatus(String sql, Operation operation) {
queryResultPointNum.set(resultPointNum);
});
try {
future.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
task.get(config.getREAD_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
future.cancel(true);
task.cancel(true);
return new Status(false, queryResultPointNum.get(), e, executeSQL);
}
if (isOk.get()) {
Expand Down Expand Up @@ -483,9 +483,9 @@ public Status insertOneBatch(IBatch batch) {

Status waitWriteTaskToFinishAndGetStatus() {
try {
future.get(config.getWRITE_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
task.get(config.getWRITE_OPERATION_TIMEOUT_MS(), TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
future.cancel(true);
task.cancel(true);
LOGGER.error("insertion failed", e);
return new Status(false, 0, e, e.toString());
}
Expand Down

0 comments on commit 4b061e0

Please sign in to comment.