Skip to content

Commit 947083e

Browse files
committed
apply suggestions
1 parent fef6199 commit 947083e

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataimport/ImportCommand.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ public Integer call() throws Exception {
6969
spec.commandLine(), dataChunkQueueSize, DataLoaderError.INVALID_DATA_CHUNK_QUEUE_SIZE);
7070
ControlFile controlFile = parseControlFileFromPath(controlFilePath).orElse(null);
7171
ImportOptions importOptions = createImportOptions(controlFile);
72-
ImportLoggerConfig config =
72+
ImportLoggerConfig importLoggerConfig =
7373
ImportLoggerConfig.builder()
7474
.logDirectoryPath(logDirectory)
7575
.isLogRawSourceRecordsEnabled(importOptions.isLogRawRecord())
7676
.isLogSuccessRecordsEnabled(importOptions.isLogSuccessRecords())
7777
.prettyPrint(prettyPrint)
7878
.build();
79-
LogWriterFactory logWriterFactory = createLogWriterFactory(config);
79+
LogWriterFactory logWriterFactory = createLogWriterFactory(importLoggerConfig);
8080
File configFile = new File(configFilePath);
8181
TransactionFactory transactionFactory = TransactionFactory.create(configFile);
8282

@@ -92,8 +92,8 @@ public Integer call() throws Exception {
9292
importOptions,
9393
tableMetadataMap,
9494
reader,
95+
importLoggerConfig,
9596
logWriterFactory,
96-
config,
9797
transactionFactory);
9898
importManager.startImport();
9999
}
@@ -149,17 +149,17 @@ private Map<String, TableMetadata> createTableMetadataMap(
149149
* @param importOptions import options
150150
* @param tableMetadataMap table metadata map
151151
* @param reader buffered reader with source data
152+
* @param importLoggerConfig import logging config
152153
* @param logWriterFactory log writer factory object
153-
* @param config import logging config
154154
* @param transactionFactory transaction factory to use
155155
* @return ImportManager object
156156
*/
157157
private ImportManager createImportManager(
158158
ImportOptions importOptions,
159159
Map<String, TableMetadata> tableMetadataMap,
160160
BufferedReader reader,
161+
ImportLoggerConfig importLoggerConfig,
161162
LogWriterFactory logWriterFactory,
162-
ImportLoggerConfig config,
163163
TransactionFactory transactionFactory)
164164
throws IOException {
165165
ImportProcessorFactory importProcessorFactory = new DefaultImportProcessorFactory();
@@ -172,9 +172,10 @@ private ImportManager createImportManager(
172172
scalarDbMode,
173173
transactionFactory.getTransactionManager());
174174
if (importOptions.getLogMode().equals(LogMode.SPLIT_BY_DATA_CHUNK)) {
175-
importManager.addListener(new SplitByDataChunkImportLogger(config, logWriterFactory));
175+
importManager.addListener(
176+
new SplitByDataChunkImportLogger(importLoggerConfig, logWriterFactory));
176177
} else {
177-
importManager.addListener(new SingleFileImportLogger(config, logWriterFactory));
178+
importManager.addListener(new SingleFileImportLogger(importLoggerConfig, logWriterFactory));
178179
}
179180
return importManager;
180181
}
@@ -275,18 +276,14 @@ void validateTransactionMode(TransactionFactory transactionFactory) {
275276
// Transaction mode is not supported by the configured transaction manager
276277
throw new ParameterException(
277278
spec.commandLine(),
278-
DataLoaderError.INVALID_TRANSACTION_MODE.buildMessage(
279-
"Please try with STORAGE mode or check your ScalarDB configuration. "
280-
+ "Error: "
281-
+ e.getClass().getSimpleName()
282-
+ " - "
283-
+ e.getMessage()));
279+
DataLoaderError.INVALID_TRANSACTION_MODE.buildMessage(e.getMessage()),
280+
e);
284281
} catch (Exception e) {
285282
// Other exceptions - configuration or runtime error
286283
throw new ParameterException(
287284
spec.commandLine(),
288-
DataLoaderError.TRANSACTION_MODE_VALIDATION_FAILED.buildMessage(
289-
"Error: " + e.getClass().getSimpleName() + " - " + e.getMessage()));
285+
DataLoaderError.TRANSACTION_MODE_VALIDATION_FAILED.buildMessage(e.getMessage()),
286+
e);
290287
} finally {
291288
// Ensure transaction is aborted
292289
if (transaction != null) {

data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataimport/ImportCommandTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ void validateTransactionMode_withUnsupportedOperation_shouldThrowException() thr
307307
() -> command.validateTransactionMode(mockFactory));
308308

309309
assertTrue(thrown.getMessage().contains("TRANSACTION mode is not compatible"));
310-
assertTrue(thrown.getMessage().contains("UnsupportedOperationException"));
311310
}
312311

313312
@Test
@@ -331,7 +330,6 @@ void validateTransactionMode_withOtherException_shouldThrowException() throws Ex
331330
() -> command.validateTransactionMode(mockFactory));
332331

333332
assertTrue(thrown.getMessage().contains("Failed to validate TRANSACTION mode"));
334-
assertTrue(thrown.getMessage().contains("RuntimeException"));
335333
assertTrue(thrown.getMessage().contains("Connection failed"));
336334
}
337335
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/DataLoaderError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ public enum DataLoaderError implements ScalarDbError {
219219
INVALID_TRANSACTION_MODE(
220220
Category.USER_ERROR,
221221
"0058",
222-
"TRANSACTION mode is not compatible with the current configuration. %s",
222+
"TRANSACTION mode is not compatible with the current configuration. Please try with STORAGE mode or check your ScalarDB configuration. Details: %s",
223223
"",
224224
""),
225225
TRANSACTION_MODE_VALIDATION_FAILED(
226-
Category.USER_ERROR, "0059", "Failed to validate TRANSACTION mode. %s", "", ""),
226+
Category.USER_ERROR, "0059", "Failed to validate TRANSACTION mode. Details: %s", "", ""),
227227

228228
//
229229
// Errors for the internal error category

0 commit comments

Comments
 (0)