org.apache.flink.util.ResourceGuard Java Examples
The following examples show how to use
org.apache.flink.util.ResourceGuard.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CopyOnWriteSkipListStateMap.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override public CopyOnWriteSkipListStateMapSnapshot<K, N, S> stateSnapshot() { tryToDeleteNodesPhysically(); ResourceGuard.Lease lease; try { lease = resourceGuard.acquireResource(); } catch (Exception e) { throw new RuntimeException("Acquire resource failed, and can't make snapshot of state map", e); } synchronized (snapshotVersions) { // increase the map version for copy-on-write and register the snapshot if (++stateMapVersion < 0) { // this is just a safety net against overflows, but should never happen in practice (i.e., only after 2^31 snapshots) throw new IllegalStateException("Version count overflow. Enforcing restart."); } highestRequiredSnapshotVersionPlusOne = stateMapVersion; snapshotVersions.add(highestRequiredSnapshotVersionPlusOne); } return new CopyOnWriteSkipListStateMapSnapshot<>(this, lease); }
Example #2
Source File: RocksDBSnapshotStrategyBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public RocksDBSnapshotStrategyBase( @Nonnull String description, @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry) { super(description); this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.keySerializer = keySerializer; this.kvStateInformation = kvStateInformation; this.keyGroupRange = keyGroupRange; this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.localRecoveryConfig = localRecoveryConfig; this.cancelStreamRegistry = cancelStreamRegistry; }
Example #3
Source File: RocksFullSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public RocksFullSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull StreamCompressionDecorator keyGroupCompressionDecorator) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.keyGroupCompressionDecorator = keyGroupCompressionDecorator; }
Example #4
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 6 votes |
public RocksFullSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull StreamCompressionDecorator keyGroupCompressionDecorator) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.keyGroupCompressionDecorator = keyGroupCompressionDecorator; }
Example #5
Source File: RocksDBSnapshotStrategyBase.java From flink with Apache License 2.0 | 6 votes |
public RocksDBSnapshotStrategyBase( @Nonnull String description, @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry) { super(description); this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.keySerializer = keySerializer; this.kvStateInformation = kvStateInformation; this.keyGroupRange = keyGroupRange; this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.localRecoveryConfig = localRecoveryConfig; this.cancelStreamRegistry = cancelStreamRegistry; }
Example #6
Source File: RocksDBSnapshotStrategyBase.java From flink with Apache License 2.0 | 6 votes |
public RocksDBSnapshotStrategyBase( @Nonnull String description, @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry) { super(description); this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.keySerializer = keySerializer; this.kvStateInformation = kvStateInformation; this.keyGroupRange = keyGroupRange; this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.localRecoveryConfig = localRecoveryConfig; this.cancelStreamRegistry = cancelStreamRegistry; }
Example #7
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 6 votes |
public RocksFullSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull StreamCompressionDecorator keyGroupCompressionDecorator) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.keyGroupCompressionDecorator = keyGroupCompressionDecorator; }
Example #8
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
SnapshotAsynchronousPartCallable( @Nonnull SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier, @Nonnull ResourceGuard.Lease dbLease, @Nonnull Snapshot snapshot, @Nonnull List<StateMetaInfoSnapshot> stateMetaInfoSnapshots, @Nonnull List<RocksDbKvStateInfo> metaDataCopy, @Nonnull String logPathString) { this.checkpointStreamSupplier = checkpointStreamSupplier; this.dbLease = dbLease; this.snapshot = snapshot; this.stateMetaInfoSnapshots = stateMetaInfoSnapshots; this.metaData = fillMetaData(metaDataCopy); this.logPathString = logPathString; }
Example #9
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
public RocksIncrementalSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull File instanceBasePath, @Nonnull UUID backendUID, @Nonnull SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId, int numberOfTransferingThreads) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.instanceBasePath = instanceBasePath; this.backendUID = backendUID; this.materializedSstFiles = materializedSstFiles; this.lastCompletedCheckpointId = lastCompletedCheckpointId; this.stateUploader = new RocksDBStateUploader(numberOfTransferingThreads); this.localDirectoryName = backendUID.toString().replaceAll("[\\-]", ""); }
Example #10
Source File: CopyOnWriteSkipListStateMap.java From flink with Apache License 2.0 | 5 votes |
public CopyOnWriteSkipListStateMap( @Nonnull TypeSerializer<K> keySerializer, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer, @Nonnull Allocator spaceAllocator, int numKeysToDeleteOneTime, float logicalRemovedKeysRatio) { this.skipListKeySerializer = new SkipListKeySerializer<>(keySerializer, namespaceSerializer); this.skipListValueSerializer = new SkipListValueSerializer<>(stateSerializer); this.spaceAllocator = spaceAllocator; Preconditions.checkArgument(numKeysToDeleteOneTime >= 0, "numKeysToDeleteOneTime should be non-negative, but is " + numKeysToDeleteOneTime); this.numKeysToDeleteOneTime = numKeysToDeleteOneTime; Preconditions.checkArgument(logicalRemovedKeysRatio >= 0 && logicalRemovedKeysRatio <= 1, "logicalRemovedKeysRatio should be in [0, 1], but is " + logicalRemovedKeysRatio); this.logicalRemovedKeysRatio = logicalRemovedKeysRatio; this.levelIndexHeader = new OnHeapLevelIndexHeader(); // Refers to JDK implementation of Xor-shift random number generator, 0x0100 is to ensure non-zero seed. // See https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java#L373 this.randomSeed = ThreadLocalRandom.current().nextInt() | 0x0100; this.stateMapVersion = 0; this.highestRequiredSnapshotVersionPlusOne = 0; this.highestFinishedSnapshotVersion = 0; this.snapshotVersions = new TreeSet<>(); this.totalSize = 0; this.requestCount = 0; this.logicallyRemovedNodes = new HashSet<>(); this.pruningValueNodes = ConcurrentHashMap.newKeySet(); this.closed = new AtomicBoolean(false); this.resourceGuard = new ResourceGuard(); }
Example #11
Source File: CopyOnWriteSkipListStateMapSnapshot.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new {@link CopyOnWriteSkipListStateMap}. * * @param owningStateMap the {@link CopyOnWriteSkipListStateMap} for which this object represents a snapshot. * @param lease the lease protects the state map resources. */ CopyOnWriteSkipListStateMapSnapshot( CopyOnWriteSkipListStateMap<K, N, S> owningStateMap, ResourceGuard.Lease lease) { super(owningStateMap); this.snapshotVersion = owningStateMap.getStateMapVersion(); this.numberOfEntriesInSnapshotData = owningStateMap.size(); this.lease = lease; }
Example #12
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().toString()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }
Example #13
Source File: RocksFullSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
SnapshotAsynchronousPartCallable( @Nonnull SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier, @Nonnull ResourceGuard.Lease dbLease, @Nonnull Snapshot snapshot, @Nonnull List<StateMetaInfoSnapshot> stateMetaInfoSnapshots, @Nonnull List<RocksDbKvStateInfo> metaDataCopy, @Nonnull String logPathString) { this.checkpointStreamSupplier = checkpointStreamSupplier; this.dbLease = dbLease; this.snapshot = snapshot; this.stateMetaInfoSnapshots = stateMetaInfoSnapshots; this.metaData = fillMetaData(metaDataCopy); this.logPathString = logPathString; }
Example #14
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().getPath()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }
Example #15
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
public RocksIncrementalSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull File instanceBasePath, @Nonnull UUID backendUID, @Nonnull SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId, int numberOfTransferingThreads) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.instanceBasePath = instanceBasePath; this.backendUID = backendUID; this.materializedSstFiles = materializedSstFiles; this.lastCompletedCheckpointId = lastCompletedCheckpointId; this.stateUploader = new RocksDBStateUploader(numberOfTransferingThreads); this.localDirectoryName = backendUID.toString().replaceAll("[\\-]", ""); }
Example #16
Source File: RocksFullSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
SnapshotAsynchronousPartCallable( @Nonnull SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier, @Nonnull ResourceGuard.Lease dbLease, @Nonnull Snapshot snapshot, @Nonnull List<StateMetaInfoSnapshot> stateMetaInfoSnapshots, @Nonnull List<RocksDbKvStateInfo> metaDataCopy, @Nonnull String logPathString) { this.checkpointStreamSupplier = checkpointStreamSupplier; this.dbLease = dbLease; this.snapshot = snapshot; this.stateMetaInfoSnapshots = stateMetaInfoSnapshots; this.metaData = fillMetaData(metaDataCopy); this.logPathString = logPathString; }
Example #17
Source File: RocksIncrementalSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().getPath()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }
Example #18
Source File: RocksIncrementalSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public RocksIncrementalSnapshotStrategy( @Nonnull RocksDB db, @Nonnull ResourceGuard rocksDBResourceGuard, @Nonnull TypeSerializer<K> keySerializer, @Nonnull LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int keyGroupPrefixBytes, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull CloseableRegistry cancelStreamRegistry, @Nonnull File instanceBasePath, @Nonnull UUID backendUID, @Nonnull SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId, int numberOfTransferingThreads) { super( DESCRIPTION, db, rocksDBResourceGuard, keySerializer, kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry); this.instanceBasePath = instanceBasePath; this.backendUID = backendUID; this.materializedSstFiles = materializedSstFiles; this.lastCompletedCheckpointId = lastCompletedCheckpointId; this.stateUploader = new RocksDBStateUploader(numberOfTransferingThreads); this.localDirectoryName = backendUID.toString().replaceAll("[\\-]", ""); }
Example #19
Source File: RocksDBKeyedStateBackendBuilder.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private SnapshotStrategy<K> initializeSavepointAndCheckpointStrategies( CloseableRegistry cancelStreamRegistry, ResourceGuard rocksDBResourceGuard, LinkedHashMap<String, RocksDBKeyedStateBackend.RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, RocksDB db, UUID backendUID, SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId) { RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy = new RocksFullSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, keyGroupCompressionDecorator); RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy; if (enableIncrementalCheckpointing) { // TODO eventually we might want to separate savepoint and snapshot strategy, i.e. having 2 strategies. checkpointSnapshotStrategy = new RocksIncrementalSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, instanceBasePath, backendUID, materializedSstFiles, lastCompletedCheckpointId, numberOfTransferingThreads); } else { checkpointSnapshotStrategy = savepointSnapshotStrategy; } return new SnapshotStrategy<>(checkpointSnapshotStrategy, savepointSnapshotStrategy); }
Example #20
Source File: RocksDBKeyedStateBackendBuilder.java From flink with Apache License 2.0 | 4 votes |
private SnapshotStrategy<K> initializeSavepointAndCheckpointStrategies( CloseableRegistry cancelStreamRegistry, ResourceGuard rocksDBResourceGuard, LinkedHashMap<String, RocksDBKeyedStateBackend.RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, RocksDB db, UUID backendUID, SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId) { RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy = new RocksFullSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, keyGroupCompressionDecorator); RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy; if (enableIncrementalCheckpointing) { // TODO eventually we might want to separate savepoint and snapshot strategy, i.e. having 2 strategies. checkpointSnapshotStrategy = new RocksIncrementalSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, instanceBasePath, backendUID, materializedSstFiles, lastCompletedCheckpointId, numberOfTransferingThreads); } else { checkpointSnapshotStrategy = savepointSnapshotStrategy; } return new SnapshotStrategy<>(checkpointSnapshotStrategy, savepointSnapshotStrategy); }
Example #21
Source File: RocksDBKeyedStateBackend.java From flink with Apache License 2.0 | 4 votes |
public RocksDBKeyedStateBackend( ClassLoader userCodeClassLoader, File instanceBasePath, RocksDBResourceContainer optionsContainer, Function<String, ColumnFamilyOptions> columnFamilyOptionsFactory, TaskKvStateRegistry kvStateRegistry, TypeSerializer<K> keySerializer, ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, RocksDB db, LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, ResourceGuard rocksDBResourceGuard, RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy, RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy, RocksDBWriteBatchWrapper writeBatchWrapper, ColumnFamilyHandle defaultColumnFamilyHandle, RocksDBNativeMetricMonitor nativeMetricMonitor, RocksDBSerializedCompositeKeyBuilder<K> sharedRocksKeyBuilder, PriorityQueueSetFactory priorityQueueFactory, RocksDbTtlCompactFiltersManager ttlCompactFiltersManager, InternalKeyContext<K> keyContext, @Nonnegative long writeBatchSize) { super( kvStateRegistry, keySerializer, userCodeClassLoader, executionConfig, ttlTimeProvider, cancelStreamRegistry, keyGroupCompressionDecorator, keyContext); this.ttlCompactFiltersManager = ttlCompactFiltersManager; // ensure that we use the right merge operator, because other code relies on this this.columnFamilyOptionsFactory = Preconditions.checkNotNull(columnFamilyOptionsFactory); this.optionsContainer = Preconditions.checkNotNull(optionsContainer); this.instanceBasePath = Preconditions.checkNotNull(instanceBasePath); this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.kvStateInformation = kvStateInformation; this.writeOptions = optionsContainer.getWriteOptions(); this.readOptions = optionsContainer.getReadOptions(); checkArgument(writeBatchSize >= 0, "Write batch size have to be no negative value."); this.writeBatchSize = writeBatchSize; this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.checkpointSnapshotStrategy = checkpointSnapshotStrategy; this.savepointSnapshotStrategy = savepointSnapshotStrategy; this.writeBatchWrapper = writeBatchWrapper; this.defaultColumnFamily = defaultColumnFamilyHandle; this.nativeMetricMonitor = nativeMetricMonitor; this.sharedRocksKeyBuilder = sharedRocksKeyBuilder; this.priorityQueueFactory = priorityQueueFactory; }
Example #22
Source File: CopyOnWriteSkipListStateMap.java From flink with Apache License 2.0 | 4 votes |
@VisibleForTesting ResourceGuard getResourceGuard() { return resourceGuard; }
Example #23
Source File: RocksDBKeyedStateBackendBuilder.java From flink with Apache License 2.0 | 4 votes |
private SnapshotStrategy<K> initializeSavepointAndCheckpointStrategies( CloseableRegistry cancelStreamRegistry, ResourceGuard rocksDBResourceGuard, LinkedHashMap<String, RocksDBKeyedStateBackend.RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, RocksDB db, UUID backendUID, SortedMap<Long, Set<StateHandleID>> materializedSstFiles, long lastCompletedCheckpointId) { RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy = new RocksFullSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, keyGroupCompressionDecorator); RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy; if (enableIncrementalCheckpointing) { // TODO eventually we might want to separate savepoint and snapshot strategy, i.e. having 2 strategies. checkpointSnapshotStrategy = new RocksIncrementalSnapshotStrategy<>( db, rocksDBResourceGuard, keySerializerProvider.currentSchemaSerializer(), kvStateInformation, keyGroupRange, keyGroupPrefixBytes, localRecoveryConfig, cancelStreamRegistry, instanceBasePath, backendUID, materializedSstFiles, lastCompletedCheckpointId, numberOfTransferingThreads); } else { checkpointSnapshotStrategy = savepointSnapshotStrategy; } return new SnapshotStrategy<>(checkpointSnapshotStrategy, savepointSnapshotStrategy); }
Example #24
Source File: RocksDBKeyedStateBackend.java From flink with Apache License 2.0 | 4 votes |
public RocksDBKeyedStateBackend( ClassLoader userCodeClassLoader, File instanceBasePath, DBOptions dbOptions, Function<String, ColumnFamilyOptions> columnFamilyOptionsFactory, TaskKvStateRegistry kvStateRegistry, TypeSerializer<K> keySerializer, ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, RocksDB db, LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, ResourceGuard rocksDBResourceGuard, RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy, RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy, RocksDBWriteBatchWrapper writeBatchWrapper, ColumnFamilyHandle defaultColumnFamilyHandle, RocksDBNativeMetricMonitor nativeMetricMonitor, RocksDBSerializedCompositeKeyBuilder<K> sharedRocksKeyBuilder, PriorityQueueSetFactory priorityQueueFactory, RocksDbTtlCompactFiltersManager ttlCompactFiltersManager, InternalKeyContext<K> keyContext) { super( kvStateRegistry, keySerializer, userCodeClassLoader, executionConfig, ttlTimeProvider, cancelStreamRegistry, keyGroupCompressionDecorator, keyContext); this.ttlCompactFiltersManager = ttlCompactFiltersManager; // ensure that we use the right merge operator, because other code relies on this this.columnFamilyOptionsFactory = Preconditions.checkNotNull(columnFamilyOptionsFactory); this.dbOptions = Preconditions.checkNotNull(dbOptions); this.instanceBasePath = Preconditions.checkNotNull(instanceBasePath); this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.kvStateInformation = kvStateInformation; this.writeOptions = new WriteOptions().setDisableWAL(true); this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.checkpointSnapshotStrategy = checkpointSnapshotStrategy; this.savepointSnapshotStrategy = savepointSnapshotStrategy; this.writeBatchWrapper = writeBatchWrapper; this.defaultColumnFamily = defaultColumnFamilyHandle; this.nativeMetricMonitor = nativeMetricMonitor; this.sharedRocksKeyBuilder = sharedRocksKeyBuilder; this.priorityQueueFactory = priorityQueueFactory; }
Example #25
Source File: RocksDBKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public RocksDBKeyedStateBackend( ClassLoader userCodeClassLoader, File instanceBasePath, DBOptions dbOptions, Function<String, ColumnFamilyOptions> columnFamilyOptionsFactory, TaskKvStateRegistry kvStateRegistry, StateSerializerProvider<K> keySerializerProvider, int numberOfKeyGroups, KeyGroupRange keyGroupRange, ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, RocksDB db, LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation, int keyGroupPrefixBytes, CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, ResourceGuard rocksDBResourceGuard, RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy, RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy, RocksDBWriteBatchWrapper writeBatchWrapper, ColumnFamilyHandle defaultColumnFamilyHandle, RocksDBNativeMetricMonitor nativeMetricMonitor, RocksDBSerializedCompositeKeyBuilder<K> sharedRocksKeyBuilder, PriorityQueueSetFactory priorityQueueFactory, RocksDbTtlCompactFiltersManager ttlCompactFiltersManager) { super(kvStateRegistry, keySerializerProvider, userCodeClassLoader, numberOfKeyGroups, keyGroupRange, executionConfig, ttlTimeProvider, cancelStreamRegistry, keyGroupCompressionDecorator); this.ttlCompactFiltersManager = ttlCompactFiltersManager; // ensure that we use the right merge operator, because other code relies on this this.columnFamilyOptionsFactory = Preconditions.checkNotNull(columnFamilyOptionsFactory); this.dbOptions = Preconditions.checkNotNull(dbOptions); this.instanceBasePath = Preconditions.checkNotNull(instanceBasePath); this.keyGroupPrefixBytes = keyGroupPrefixBytes; this.kvStateInformation = kvStateInformation; this.writeOptions = new WriteOptions().setDisableWAL(true); this.db = db; this.rocksDBResourceGuard = rocksDBResourceGuard; this.checkpointSnapshotStrategy = checkpointSnapshotStrategy; this.savepointSnapshotStrategy = savepointSnapshotStrategy; this.writeBatchWrapper = writeBatchWrapper; this.defaultColumnFamily = defaultColumnFamilyHandle; this.nativeMetricMonitor = nativeMetricMonitor; this.sharedRocksKeyBuilder = sharedRocksKeyBuilder; this.priorityQueueFactory = priorityQueueFactory; }
Example #26
Source File: NonClosingCheckpointOutputStream.java From flink with Apache License 2.0 | 2 votes |
/** * Returns a {@link org.apache.flink.util.ResourceGuard.Lease} that prevents closing this stream. To allow the system * to close this stream, each of the acquired leases need to call {@link Lease#close()}, on their acquired leases. */ public final ResourceGuard.Lease acquireLease() throws IOException { return resourceGuard.acquireResource(); }
Example #27
Source File: NonClosingCheckpointOutputStream.java From flink with Apache License 2.0 | 2 votes |
/** * Returns a {@link org.apache.flink.util.ResourceGuard.Lease} that prevents closing this stream. To allow the system * to close this stream, each of the acquired leases need to call {@link Lease#close()}, on their acquired leases. */ public final ResourceGuard.Lease acquireLease() throws IOException { return resourceGuard.acquireResource(); }