Class SqlSegmentMetadataTransactionFactory
java.lang.Object
org.apache.druid.metadata.segment.SqlSegmentMetadataReadOnlyTransactionFactory
org.apache.druid.metadata.segment.SqlSegmentMetadataTransactionFactory
- All Implemented Interfaces:
SegmentMetadataTransactionFactory
public class SqlSegmentMetadataTransactionFactory
extends SqlSegmentMetadataReadOnlyTransactionFactory
Factory for
SegmentMetadataTransactions. If the
SegmentMetadataCache is enabled and ready, the transaction may
read/write from the cache as applicable.
This class serves as a wrapper over the SQLMetadataConnector to
perform transactions specific to segment metadata.
Only the Overlord can perform write operations on the metadata store or the
cache via this transaction factory. The Coordinator performs read operations
directly on the metadata store and uses the cache only to build the timeline
in SqlSegmentsMetadataManagerV2. There is currently only one method
called by the Coordinator that could benefit from reading from the cache,
MetadataResource.getUsedSegmentsInDataSourceForIntervals(), but for
now, it continues to read directly from the metadata store for consistency
with older Druid versions.
-
Constructor Summary
ConstructorsConstructorDescriptionSqlSegmentMetadataTransactionFactory(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, MetadataStorageTablesConfig tablesConfig, SQLMetadataConnector connector, DruidLeaderSelector leaderSelector, SegmentMetadataCache segmentMetadataCache, ServiceEmitter emitter) -
Method Summary
Modifier and TypeMethodDescription<T> TinReadOnlyDatasourceTransaction(String dataSource, SegmentMetadataReadTransaction.Callback<T> callback) Creates and executes a new read-only transaction for the given datasource.<T> TinReadWriteDatasourceTransaction(String dataSource, SegmentMetadataTransaction.Callback<T> callback) Creates and executes a new read-write transaction for the given datasource.Methods inherited from class org.apache.druid.metadata.segment.SqlSegmentMetadataReadOnlyTransactionFactory
createSqlTransaction, executeReadAndClose, getMaxRetries, getQuietRetries
-
Constructor Details
-
SqlSegmentMetadataTransactionFactory
@Inject public SqlSegmentMetadataTransactionFactory(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, MetadataStorageTablesConfig tablesConfig, SQLMetadataConnector connector, DruidLeaderSelector leaderSelector, SegmentMetadataCache segmentMetadataCache, ServiceEmitter emitter)
-
-
Method Details
-
inReadOnlyDatasourceTransaction
public <T> T inReadOnlyDatasourceTransaction(String dataSource, SegmentMetadataReadTransaction.Callback<T> callback) Description copied from interface:SegmentMetadataTransactionFactoryCreates and executes a new read-only transaction for the given datasource. The implementation may retry the transaction until it succeeds.- Specified by:
inReadOnlyDatasourceTransactionin interfaceSegmentMetadataTransactionFactory- Overrides:
inReadOnlyDatasourceTransactionin classSqlSegmentMetadataReadOnlyTransactionFactory
-
inReadWriteDatasourceTransaction
public <T> T inReadWriteDatasourceTransaction(String dataSource, SegmentMetadataTransaction.Callback<T> callback) Description copied from interface:SegmentMetadataTransactionFactoryCreates and executes a new read-write transaction for the given datasource. The implementation may retry the transaction until it succeeds.- Specified by:
inReadWriteDatasourceTransactionin interfaceSegmentMetadataTransactionFactory- Overrides:
inReadWriteDatasourceTransactionin classSqlSegmentMetadataReadOnlyTransactionFactory
-