use of com.datastax.oss.dsbulk.workflow.commons.settings.BatchSettings in project dsbulk by datastax.
the class LoadWorkflow method init.
@Override
public void init() throws Exception {
settingsManager.init("LOAD", true, SchemaGenerationStrategy.MAP_AND_WRITE);
executionId = settingsManager.getExecutionId();
LogSettings logSettings = settingsManager.getLogSettings();
logSettings.init();
ConnectorSettings connectorSettings = settingsManager.getConnectorSettings();
connectorSettings.init(logSettings.isSources());
connector = connectorSettings.getConnector();
connector.init();
DriverSettings driverSettings = settingsManager.getDriverSettings();
SchemaSettings schemaSettings = settingsManager.getSchemaSettings();
BatchSettings batchSettings = settingsManager.getBatchSettings();
ExecutorSettings executorSettings = settingsManager.getExecutorSettings();
CodecSettings codecSettings = settingsManager.getCodecSettings();
MonitoringSettings monitoringSettings = settingsManager.getMonitoringSettings();
engineSettings = settingsManager.getEngineSettings();
driverSettings.init(true);
logSettings.logEffectiveSettings(settingsManager.getEffectiveBulkLoaderConfig(), driverSettings.getDriverConfig());
monitoringSettings.init();
codecSettings.init();
executorSettings.init();
engineSettings.init();
ConvertingCodecFactory codecFactory = codecSettings.createCodecFactory(schemaSettings.isAllowExtraFields(), schemaSettings.isAllowMissingFields());
session = driverSettings.newSession(executionId, codecFactory.getCodecRegistry(), monitoringSettings.getRegistry());
ClusterInformationUtils.printDebugInfoAboutCluster(session);
schemaSettings.init(session, codecFactory, connector.supports(CommonConnectorFeature.INDEXED_RECORDS), connector.supports(CommonConnectorFeature.MAPPED_RECORDS));
logManager = logSettings.newLogManager(session, true);
logManager.init();
batchSettings.init();
batchingEnabled = batchSettings.isBatchingEnabled();
batchBufferSize = batchSettings.getBufferSize();
RecordMapper recordMapper;
try {
recordMapper = schemaSettings.createRecordMapper(session, connector.getRecordMetadata(), batchingEnabled);
} catch (NestedBatchException e) {
LOGGER.warn(e.getMessage());
batchingEnabled = false;
recordMapper = schemaSettings.createRecordMapper(session, connector.getRecordMetadata(), false);
}
mapper = recordMapper::map;
if (batchingEnabled) {
batcher = batchSettings.newStatementBatcher(session)::batchByGroupingKey;
}
metricsManager = monitoringSettings.newMetricsManager(true, batchingEnabled, logManager.getOperationDirectory(), logSettings.getVerbosity(), session.getContext().getProtocolVersion(), session.getContext().getCodecRegistry(), schemaSettings.getRowType());
metricsManager.init();
executor = executorSettings.newWriteExecutor(session, metricsManager.getExecutionListener());
dryRun = engineSettings.isDryRun();
if (dryRun) {
LOGGER.info("Dry-run mode enabled.");
}
closed.set(false);
totalItemsMonitor = metricsManager.newTotalItemsMonitor();
failedRecordsMonitor = metricsManager.newFailedItemsMonitor();
failedStatementsMonitor = metricsManager.newFailedItemsMonitor();
batcherMonitor = metricsManager.newBatcherMonitor();
totalItemsCounter = logManager.newTotalItemsCounter();
failedRecordsHandler = logManager.newFailedRecordsHandler();
unmappableStatementsHandler = logManager.newUnmappableStatementsHandler();
queryWarningsHandler = logManager.newQueryWarningsHandler();
failedWritesHandler = logManager.newFailedWritesHandler();
resultPositionsHndler = logManager.newResultPositionsHandler();
terminationHandler = logManager.newTerminationHandler();
numCores = Runtime.getRuntime().availableProcessors();
if (connector.readConcurrency() < 1) {
throw new IllegalArgumentException("Invalid read concurrency: " + connector.readConcurrency());
}
readConcurrency = connector.readConcurrency();
hasManyReaders = readConcurrency >= Math.max(4, numCores / 4);
LOGGER.debug("Using read concurrency: {}", readConcurrency);
writeConcurrency = engineSettings.getMaxConcurrentQueries().orElseGet(this::determineWriteConcurrency);
LOGGER.debug("Using write concurrency: {} (user-supplied: {})", writeConcurrency, engineSettings.getMaxConcurrentQueries().isPresent());
}
Aggregations