Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Sep 21, 2023
1 parent 24817a3 commit de052f3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public abstract class DataClient implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(DataClient.class);
Expand Down Expand Up @@ -90,7 +89,9 @@ public DataClient(int id, CountDownLatch countDownLatch, CyclicBarrier barrier)
this.deviceSchemas = MetaDataSchema.getInstance().getDeviceSchemaByClientId(clientThreadId);
this.deviceSchemasSize = deviceSchemas.size();
this.measurement = new Measurement();
this.service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("ShowWorkProgress-"+String.valueOf(clientThreadId)));
this.service =
Executors.newSingleThreadScheduledExecutor(
new NamedThreadFactory("ShowWorkProgress-" + String.valueOf(clientThreadId)));
initDBWrappers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public abstract class TestDataPersistence {
protected static final Logger LOGGER = LoggerFactory.getLogger(TestDataPersistence.class);
protected static final Config config = ConfigDescriptor.getInstance().getConfig();
protected ExecutorService service =
Executors.newFixedThreadPool(config.getTEST_DATA_MAX_CONNECTION(), new NamedThreadFactory("ResultPersistence"));
Executors.newFixedThreadPool(
config.getTEST_DATA_MAX_CONNECTION(), new NamedThreadFactory("ResultPersistence"));

/**
* Store system resources metrics data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public abstract class BaseMode {
private static final double NANO_TO_SECOND = 1000000000.0d;

protected ExecutorService schemaExecutorService =
Executors.newFixedThreadPool(config.getCLIENT_NUMBER(), new NamedThreadFactory("SchemaClient"));
Executors.newFixedThreadPool(
config.getCLIENT_NUMBER(), new NamedThreadFactory("SchemaClient"));
protected ExecutorService executorService =
Executors.newFixedThreadPool(config.getCLIENT_NUMBER(), new NamedThreadFactory("DataClient"));
protected CountDownLatch schemaDownLatch = new CountDownLatch(config.getCLIENT_NUMBER());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import java.util.concurrent.atomic.AtomicInteger;

public class NamedThreadFactory implements ThreadFactory {
private final String poolName;
private final AtomicInteger count = new AtomicInteger(1);
private final ThreadFactory threadFactory;
private final String poolName;
private final AtomicInteger count = new AtomicInteger(1);
private final ThreadFactory threadFactory;

public NamedThreadFactory(String name) {
this.poolName = name;
this.threadFactory = Executors.defaultThreadFactory();
}
public NamedThreadFactory(String name) {
this.poolName = name;
this.threadFactory = Executors.defaultThreadFactory();
}

private String getThreadName() {
return poolName + "-thread-" + String.valueOf(count.getAndIncrement());
}
private String getThreadName() {
return poolName + "-thread-" + String.valueOf(count.getAndIncrement());
}

@Override
public Thread newThread(Runnable r) {
Thread thread = threadFactory.newThread(r);
thread.setName(getThreadName());
return thread;
}
@Override
public Thread newThread(Runnable r) {
Thread thread = threadFactory.newThread(r);
thread.setName(getThreadName());
return thread;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package cn.edu.tsinghua.iot.benchmark.iotdb110;

import cn.edu.tsinghua.iot.benchmark.utils.NamedThreadFactory;
import org.apache.iotdb.isession.template.Template;
import org.apache.iotdb.isession.util.Version;
import org.apache.iotdb.rpc.IoTDBConnectionException;
Expand All @@ -44,6 +43,7 @@
import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig;
import cn.edu.tsinghua.iot.benchmark.tsdb.IDatabase;
import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException;
import cn.edu.tsinghua.iot.benchmark.utils.NamedThreadFactory;
import cn.edu.tsinghua.iot.benchmark.utils.TimeUtils;
import cn.edu.tsinghua.iot.benchmark.workload.query.impl.AggRangeQuery;
import cn.edu.tsinghua.iot.benchmark.workload.query.impl.AggRangeValueQuery;
Expand Down Expand Up @@ -116,7 +116,8 @@ public void init() throws TsdbException {
try {
ioTDBConnection = new SingleNodeJDBCConnection(dbConfig);
ioTDBConnection.init();
this.service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DataClientExecuteJob"));
this.service =
Executors.newSingleThreadExecutor(new NamedThreadFactory("DataClientExecuteJob"));
} catch (Exception e) {
throw new TsdbException(e);
}
Expand Down

0 comments on commit de052f3

Please sign in to comment.