Skip to content

Commit 24113c7

Browse files
committed
openlookeng clean_code
1 parent e7d4114 commit 24113c7

File tree

159 files changed

+833
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+833
-814
lines changed

hetu-common/src/main/java/io/hetu/core/common/util/SslSocketUtil.java

-10
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ public static Optional<SSLContext> buildSslContext(boolean tlsEnabled)
4747
if (!tlsEnabled) {
4848
return Optional.empty();
4949
}
50-
51-
// https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#CustomizingStores
52-
// as per link above, the default SSLContext will be constructed using the default KeyManager and
53-
// default TrustManager. Those can be configured using the following system properties:
54-
// javax.net.ssl.keyStore
55-
// javax.net.ssl.keyStorePassword
56-
// javax.net.ssl.keyStoreType
57-
// javax.net.ssl.trustStore
58-
// javax.net.ssl.trustStorePassword
59-
// see link above for more details
6050
return Optional.of(SSLContext.getDefault());
6151
}
6252

hetu-common/src/main/java/io/hetu/core/common/util/TrustStore.java

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package io.hetu.core.common.util;
1515

16+
import io.airlift.log.Logger;
1617
import io.airlift.security.pem.PemReader;
1718

1819
import javax.security.auth.x500.X500Principal;
@@ -29,6 +30,8 @@
2930

3031
public class TrustStore
3132
{
33+
private static final Logger LOGGER = Logger.get(TrustStore.class);
34+
3235
private TrustStore() {}
3336

3437
public static KeyStore loadTrustStore(File trustStorePath, Optional<String> trustStorePassword)
@@ -48,6 +51,7 @@ public static KeyStore loadTrustStore(File trustStorePath, Optional<String> trus
4851
}
4952
}
5053
catch (IOException | GeneralSecurityException ignored) {
54+
LOGGER.error("loadTrustStore error : %s", ignored.getMessage());
5155
}
5256

5357
try (InputStream in = new FileInputStream(trustStorePath)) {

hetu-hazelcast/src/main/java/io/hetu/core/security/networking/ssl/SslInboundHandler.java

+11-20
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,11 @@ private ByteBuffer enlargeApplicationBuffer(ByteBuffer buffer)
230230
if (logger.isFineEnabled()) {
231231
logger.fine(format("begin to enlargeApplicationBuffer, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
232232
}
233-
if (appBufferSize > buffer.capacity()) {
234-
buffer = newByteBuffer(appBufferSize, config.getOption(DIRECT_BUF));
235-
}
236-
else {
237-
buffer = ByteBuffer.allocate(buffer.capacity() * 2);
238-
}
233+
ByteBuffer tmpBuffer = appBufferSize > buffer.capacity() ? newByteBuffer(appBufferSize, config.getOption(DIRECT_BUF)) : ByteBuffer.allocate(buffer.capacity() * 2);
239234
if (logger.isFineEnabled()) {
240-
logger.fine(format("end to enlargeApplicationBuffer, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
235+
logger.fine(format("end to enlargeApplicationBuffer, channel=%s, buffer=[%s, %s, %s]", channel, tmpBuffer.position(), tmpBuffer.limit(), tmpBuffer.capacity()));
241236
}
242-
return buffer;
237+
return tmpBuffer;
243238
}
244239

245240
private ByteBuffer enlargePacketBuffer(ByteBuffer buffer)
@@ -249,32 +244,28 @@ private ByteBuffer enlargePacketBuffer(ByteBuffer buffer)
249244
if (logger.isFineEnabled()) {
250245
logger.fine(format("begin to enlargePacketBuffer, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
251246
}
252-
if (appBufferSize > buffer.capacity()) {
253-
buffer = newByteBuffer(appBufferSize, config.getOption(DIRECT_BUF));
254-
}
255-
else {
256-
buffer = ByteBuffer.allocate(buffer.capacity() * 2);
257-
}
247+
ByteBuffer tmpBuffer = appBufferSize > buffer.capacity() ? newByteBuffer(appBufferSize, config.getOption(DIRECT_BUF)) : ByteBuffer.allocate(buffer.capacity() * 2);
258248
if (logger.isFineEnabled()) {
259-
logger.fine(format("end to enlargePacketBuffer, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
249+
logger.fine(format("end to enlargePacketBuffer, channel=%s, buffer=[%s, %s, %s]", channel, tmpBuffer.position(), tmpBuffer.limit(), tmpBuffer.capacity()));
260250
}
261-
return buffer;
251+
return tmpBuffer;
262252
}
263253

264254
private ByteBuffer adapterByteBufferIfNotEnough(ByteBuffer buffer, int otherBufferLimit)
265255
{
266256
ChannelOptions config = channel.options();
257+
ByteBuffer tmpBuffer = buffer;
267258
if (buffer.capacity() < otherBufferLimit) {
268259
if (logger.isFineEnabled()) {
269-
logger.fine(format("adapterByteBufferIfNotEnough, begin to enlarge, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
260+
logger.fine(format("adapterByteBufferIfNotEnough, begin to enlarge, channel=%s, buffer=[%s, %s, %s]", channel, tmpBuffer.position(), tmpBuffer.limit(), tmpBuffer.capacity()));
270261
}
271-
buffer = newByteBuffer(otherBufferLimit, config.getOption(DIRECT_BUF));
262+
tmpBuffer = newByteBuffer(otherBufferLimit, config.getOption(DIRECT_BUF));
272263
updateInboundPipeline();
273264
if (logger.isFineEnabled()) {
274-
logger.fine(format("adapterByteBufferIfNotEnough, end to enlarge, channel=%s, buffer=[%s, %s, %s]", channel, buffer.position(), buffer.limit(), buffer.capacity()));
265+
logger.fine(format("adapterByteBufferIfNotEnough, end to enlarge, channel=%s, buffer=[%s, %s, %s]", channel, tmpBuffer.position(), tmpBuffer.limit(), tmpBuffer.capacity()));
275266
}
276267
}
277268

278-
return buffer;
269+
return tmpBuffer;
279270
}
280271
}

hetu-hazelcast/src/main/java/io/hetu/core/security/networking/ssl/SslOutboundHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ private ScheduledFuture applyHandshakeTimeout()
163163
return null;
164164
}
165165

166-
ScheduledFuture<?> timeoutFuture = SslContext.scheduleExecutor.schedule(() -> {
166+
ScheduledFuture<?> tmpTimeoutFuture = SslContext.scheduleExecutor.schedule(() -> {
167167
if (!handshakeFinished.get()) {
168168
isTimeout = true;
169169
}
170170
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
171171

172-
return timeoutFuture;
172+
return tmpTimeoutFuture;
173173
}
174174

175175
private void updateOutboundPipeline()

hetu-heuristic-index/src/test/java/io/hetu/core/heuristicindex/TestHeuristicIndexClient.java

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public void testDeleteSelectedColumnsHelper()
4343
String tableName = "catalog.schema.UT_test";
4444

4545
try (TempFolder folder = new TempFolder()) {
46-
// root/catalog.schema.UT_test/testColumn/bloom/testIndex.index
4746
folder.create();
4847
File tableFolder = new File(folder.getRoot().getPath(), tableName);
4948
assertTrue(tableFolder.mkdir());

hetu-heuristic-index/src/test/java/io/hetu/core/heuristicindex/TestHindex.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -549,21 +549,21 @@ public void testQueryOperator(String testerQuery, String indexType)
549549

550550
String tableName = getNewTableName();
551551
createTable1(tableName);
552-
testerQuery = "SELECT * FROM " + tableName + " WHERE " + testerQuery;
552+
String tmpTesterQuery = "SELECT * FROM " + tableName + " WHERE " + testerQuery;
553553
String indexName = getNewIndexName();
554554

555555
assertQuerySucceeds("CREATE INDEX " + indexName + " USING " +
556556
indexType + " ON " + tableName + " (id)");
557557

558-
MaterializedResult resultLoadingIndex = computeActual(testerQuery);
558+
MaterializedResult resultLoadingIndex = computeActual(tmpTesterQuery);
559559

560560
// Wait before continuing
561561
Thread.sleep(INDEX_LOAD_WAIT_TIME);
562562

563-
MaterializedResult resultIndexLoaded = computeActual(testerQuery);
563+
MaterializedResult resultIndexLoaded = computeActual(tmpTesterQuery);
564564

565565
assertTrue(verifyEqualResults(resultLoadingIndex, resultIndexLoaded),
566-
"The results should be equal for " + testerQuery + " " + indexType);
566+
"The results should be equal for " + tmpTesterQuery + " " + indexType);
567567
}
568568

569569
@Test

hetu-heuristic-index/src/test/java/io/hetu/core/heuristicindex/TestHindexBitmapIndex.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ public void testBitmapOperatorInputRows(String predicateQuery)
3232
createTableBitmapSupportedDataTypes(tableName);
3333
String indexName = getNewIndexName();
3434

35-
predicateQuery = "SELECT * FROM " + tableName + " WHERE " + predicateQuery;
35+
String tmpPredicateQuery = "SELECT * FROM " + tableName + " WHERE " + predicateQuery;
3636

3737
assertQuerySucceeds("CREATE INDEX " + indexName + " USING bitmap ON " + tableName + " (p1)");
3838

39-
MaterializedResult predicateQueryResultLoadingIndex = computeActual(predicateQuery);
40-
long predicateQueryInputRowsLoadingIndex = getInputRowsOfLastQueryExecution(predicateQuery);
39+
MaterializedResult predicateQueryResultLoadingIndex = computeActual(tmpPredicateQuery);
40+
long predicateQueryInputRowsLoadingIndex = getInputRowsOfLastQueryExecution(tmpPredicateQuery);
4141

4242
// Wait before continuing
4343
Thread.sleep(1000);
4444

45-
MaterializedResult predicateQueryResultIndexLoaded = computeActual(predicateQuery);
46-
long predicateQueryInputRowsIndexLoaded = getInputRowsOfLastQueryExecution(predicateQuery);
45+
MaterializedResult predicateQueryResultIndexLoaded = computeActual(tmpPredicateQuery);
46+
long predicateQueryInputRowsIndexLoaded = getInputRowsOfLastQueryExecution(tmpPredicateQuery);
4747

4848
assertTrue(verifyEqualResults(predicateQueryResultLoadingIndex, predicateQueryResultIndexLoaded),
4949
"The results should be equal.");

hetu-heuristic-index/src/test/java/io/hetu/core/heuristicindex/TestPartitionIndexWriter.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package io.hetu.core.heuristicindex;
1616

17+
import io.airlift.log.Logger;
1718
import io.prestosql.spi.HetuConstant;
1819
import io.prestosql.spi.connector.CreateIndexMetadata;
1920
import io.prestosql.spi.filesystem.HetuFileSystemClient;
@@ -39,6 +40,8 @@
3940

4041
public class TestPartitionIndexWriter
4142
{
43+
private static final Logger LOGGER = Logger.get(TestPartitionIndexWriter.class);
44+
4245
@Test
4346
public void testAddValue()
4447
throws IOException
@@ -139,7 +142,7 @@ public void run()
139142
indexWriter.addData(valuesMap, connectorMetadata);
140143
}
141144
catch (IOException e) {
142-
e.printStackTrace();
145+
LOGGER.error("add data error : %s", e.getMessage());
143146
}
144147
latch.countDown();
145148
}

hetu-metastore/src/test/java/io/hetu/core/metastore/jdbc/mysql/TestJdbcHetuMetastore.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public void testCreateDatabaseParallel()
505505
.put("desc", "vschema")
506506
.build();
507507

508-
DatabaseEntity database = DatabaseEntity.builder()
508+
DatabaseEntity tmpDatabase = DatabaseEntity.builder()
509509
.setCatalogName(defaultCatalog.getName())
510510
.setDatabaseName("database100")
511511
.setOwner("root9")
@@ -519,7 +519,7 @@ public void testCreateDatabaseParallel()
519519
for (int i = 0; i < 5; i++) {
520520
threads[i] = new Thread(() -> {
521521
try {
522-
metastore.createDatabaseIfNotExist(database);
522+
metastore.createDatabaseIfNotExist(tmpDatabase);
523523
}
524524
catch (PrestoException e) {
525525
testResult = false;
@@ -533,7 +533,7 @@ public void testCreateDatabaseParallel()
533533
}
534534

535535
assertTrue(testResult);
536-
metastore.dropDatabase(database.getCatalogName(), database.getName());
536+
metastore.dropDatabase(tmpDatabase.getCatalogName(), tmpDatabase.getName());
537537
}
538538

539539
/**
@@ -717,15 +717,15 @@ public void testAlterDatabaseParallel()
717717
.put("desc", "vschema")
718718
.build();
719719

720-
DatabaseEntity database = DatabaseEntity.builder()
720+
DatabaseEntity tmpDatabase = DatabaseEntity.builder()
721721
.setCatalogName(defaultCatalog.getName())
722722
.setDatabaseName("database200")
723723
.setOwner("root9")
724724
.setComment(Optional.of("Hetu create database."))
725725
.setCreateTime(System.currentTimeMillis())
726726
.setParameters(properties)
727727
.build();
728-
metastore.createDatabase(database);
728+
metastore.createDatabase(tmpDatabase);
729729

730730
DatabaseEntity newDatabase = DatabaseEntity.builder()
731731
.setCatalogName(defaultCatalog.getName())
@@ -741,7 +741,7 @@ public void testAlterDatabaseParallel()
741741
for (int i = 0; i < 5; i++) {
742742
threads[i] = new Thread(() -> {
743743
try {
744-
metastore.alterDatabase(database.getCatalogName(), database.getName(), newDatabase);
744+
metastore.alterDatabase(tmpDatabase.getCatalogName(), tmpDatabase.getName(), newDatabase);
745745
}
746746
catch (PrestoException e) {
747747
testResult = false;
@@ -755,7 +755,7 @@ public void testAlterDatabaseParallel()
755755
}
756756

757757
assertTrue(testResult);
758-
metastore.dropDatabase(database.getCatalogName(), database.getName());
758+
metastore.dropDatabase(tmpDatabase.getCatalogName(), tmpDatabase.getName());
759759
}
760760

761761
/**

hetu-opengauss/src/main/java/io/hetu/core/plugin/opengauss/OpenGaussClient.java

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public Optional<ColumnMapping> toPrestoType(ConnectorSession session, Connection
143143
case "timestamptz":
144144
// OpenGauss's "timestamp with time zone" is reported as Types.TIMESTAMP rather than Types.TIMESTAMP_WITH_TIMEZONE
145145
return Optional.of(timestampWithTimeZoneColumnMapping());
146+
default:
147+
break;
146148
}
147149
if (typeHandle.getJdbcType() == Types.VARCHAR && !jdbcTypeName.equals("varchar")) {
148150
// This can be e.g. an ENUM

hetu-oracle/src/test/java/io/hetu/core/plugin/oracle/OracleQueryRunner.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ public static DistributedQueryRunner createOracleQueryRunner(TestingOracleServer
8080

8181
queryRunner.installPlugin(new TpchPlugin());
8282
queryRunner.createCatalog(TPCH_CATALOG, TPCH_CATALOG);
83-
connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties));
84-
connectorProperties.putIfAbsent("connection-url", testingOracleServer.getJdbcUrl());
85-
connectorProperties.putIfAbsent("connection-user", testingOracleServer.getUser());
86-
connectorProperties.putIfAbsent("connection-password", testingOracleServer.getPassWd());
87-
connectorProperties.putIfAbsent("allow-drop-table", "true");
83+
HashMap<String, String> connProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties));
84+
connProperties.putIfAbsent("connection-url", testingOracleServer.getJdbcUrl());
85+
connProperties.putIfAbsent("connection-user", testingOracleServer.getUser());
86+
connProperties.putIfAbsent("connection-password", testingOracleServer.getPassWd());
87+
connProperties.putIfAbsent("allow-drop-table", "true");
8888

8989
queryRunner.installPlugin(new OraclePlugin());
90-
queryRunner.createCatalog(CATALOG, "oracle", connectorProperties);
90+
queryRunner.createCatalog(CATALOG, "oracle", connProperties);
9191

9292
copyTpchTables(queryRunner, TPCH_CATALOG, TINY_SCHEMA_NAME, createSession(), tables);
9393

hetu-oracle/src/test/java/io/hetu/core/plugin/oracle/TestOracleDistributedQueries.java

+8
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ private static void assertUntilTimeout(Runnable assertion, Duration timeout)
138138
/**
139139
* testShowCreateView
140140
*/
141+
@Override
141142
public void testShowCreateView()
142143
{
143144
// view is not supported
@@ -176,6 +177,7 @@ public void testLargeIn()
176177
/**
177178
* testCommentTable
178179
*/
180+
@Override
179181
public void testCommentTable()
180182
{
181183
// commnet is not supported
@@ -184,6 +186,7 @@ public void testCommentTable()
184186
/**
185187
* testInsertArray
186188
*/
189+
@Override
187190
public void testInsertArray()
188191
{
189192
// array is not supported
@@ -200,6 +203,7 @@ public void testView()
200203
/**
201204
* testViewCaseSensitivity
202205
*/
206+
@Override
203207
public void testViewCaseSensitivity()
204208
{
205209
// view is not supported
@@ -208,6 +212,7 @@ public void testViewCaseSensitivity()
208212
/**
209213
* testCompatibleTypeChangeForView
210214
*/
215+
@Override
211216
public void testCompatibleTypeChangeForView()
212217
{
213218
// view is not supported
@@ -216,6 +221,7 @@ public void testCompatibleTypeChangeForView()
216221
/**
217222
* testCompatibleTypeChangeForView2
218223
*/
224+
@Override
219225
public void testCompatibleTypeChangeForView2()
220226
{
221227
// view is not supported
@@ -224,6 +230,7 @@ public void testCompatibleTypeChangeForView2()
224230
/**
225231
* testViewMetadata
226232
*/
233+
@Override
227234
public void testViewMetadata()
228235
{
229236
// view is not supported
@@ -239,6 +246,7 @@ public void testDelete()
239246
}
240247

241248
@Test
249+
@Override
242250
public void testCreateTable()
243251
{
244252
// for now oracle do not support NCLOB(4000, 0) with jdbc type 2011

hetu-state-store/src/test/java/io/hetu/core/statestore/hazelcast/TestHazelcastStateStore.java

+6
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public void testGetLock()
150150
Lock lock1 = stateStore.getLock(STATE_STORE_NAME);
151151
assertFalse(lock1.tryLock());
152152
});
153+
t1.setName("t1");
154+
t1.setUncaughtExceptionHandler((tr, ex) -> System.out.println(tr.getName() + " : " + ex.getMessage()));
153155
t1.start();
154156

155157
TimeUnit.MILLISECONDS.sleep(sleep100);
@@ -159,6 +161,8 @@ public void testGetLock()
159161
Lock lock1 = stateStore.getLock(STATE_STORE_NAME);
160162
assertTrue(lock1.tryLock());
161163
});
164+
t2.setName("t2");
165+
t2.setUncaughtExceptionHandler((tr, ex) -> System.out.println(tr.getName() + " : " + ex.getMessage()));
162166
t2.start();
163167
}
164168

@@ -180,6 +184,8 @@ public void testUnlock()
180184
ignored();
181185
}
182186
});
187+
t1.setName("thread-1");
188+
t1.setUncaughtExceptionHandler((tr, ex) -> System.out.println(tr.getName() + " : " + ex.getMessage()));
183189
t1.start();
184190
try {
185191
Thread.sleep(sleep100);

presto-base-jdbc/src/main/java/io/prestosql/plugin/splitmanager/DataSourceTableSplitManager.java

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public DataSourceTableSplitManager(BaseJdbcConfig config, JdbcClient jdbcClient,
7070
config.getTableSplitStepCalcCalcThreads(), splitConfigs);
7171
Thread stepCalcThread = new Thread(stepCalcManager);
7272
stepCalcThread.setName("step calc thread");
73+
stepCalcThread.setUncaughtExceptionHandler((tr, ex) -> System.out.println(tr.getName() + " : " + ex.getMessage()));
7374
stepCalcThread.setDaemon(true);
7475
stepCalcThread.start();
7576
stepCalcManager.start();

0 commit comments

Comments
 (0)