idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
23,400 | public static DelimitedStringParser parser ( String pairDelimiter , String keyValueDelimiter ) { Exceptions . checkNotNullOrEmpty ( pairDelimiter , "pairDelimiter" ) ; Exceptions . checkNotNullOrEmpty ( keyValueDelimiter , "keyValueDelimiter" ) ; Preconditions . checkArgument ( ! pairDelimiter . equals ( keyValueDelimi... | Creates a new DelimitedStringParser with the given Pair and KeyValue delimiters . |
23,401 | public void parse ( String s ) { Preconditions . checkNotNull ( s , "s" ) ; if ( s . length ( ) == 0 ) { return ; } val pairs = s . split ( pairDelimiter ) ; for ( String pair : pairs ) { int delimiterPos = pair . indexOf ( keyValueDelimiter ) ; if ( delimiterPos < 0 ) { throw new IllegalArgumentException ( String . fo... | Parses the given string using the configuration set on this parser . |
23,402 | public < T > CompletableFuture < VersionedMetadata < T > > getCachedData ( String table , String key , Function < byte [ ] , T > fromBytes ) { return cache . getCachedData ( new TableCacheKey < > ( table , key , fromBytes ) ) . thenApply ( this :: getVersionedMetadata ) ; } | Api to read cached value for the specified key from the requested table . |
23,403 | public void invalidateCache ( String table , String key ) { cache . invalidateCache ( new TableCacheKey < > ( table , key , x -> null ) ) ; } | Method to invalidate cached value in the cache for the specified table . |
23,404 | public CompletableFuture < Void > createTable ( String tableName ) { log . debug ( "create table called for table: {}" , tableName ) ; return Futures . toVoid ( withRetries ( ( ) -> segmentHelper . createTableSegment ( tableName , authToken . get ( ) , RequestTag . NON_EXISTENT_ID ) , ( ) -> String . format ( "create t... | Method to create a new Table . If the table already exists segment helper responds with success . |
23,405 | public CompletableFuture < Void > addNewEntriesIfAbsent ( String tableName , Map < String , byte [ ] > toAdd ) { List < TableEntry < byte [ ] , byte [ ] > > entries = toAdd . entrySet ( ) . stream ( ) . map ( x -> new TableEntryImpl < > ( new TableKeyImpl < > ( x . getKey ( ) . getBytes ( Charsets . UTF_8 ) , KeyVersio... | Method to add a batch of entries if absent . Table implementation on segment store guarantees that either all or none of the entries are added . If segment store responds with success then it is guaranteed that all entries are added to the store . However it is important to note that the segment store could respond wit... |
23,406 | public CompletableFuture < Version > updateEntry ( String tableName , String key , byte [ ] value , Version ver ) { log . trace ( "updateEntry entry called for : {} key : {} version {}" , tableName , key , ver . asLongVersion ( ) . getLongValue ( ) ) ; KeyVersionImpl version = new KeyVersionImpl ( ver . asLongVersion (... | Method to update a single entry . |
23,407 | public CompletableFuture < Void > removeEntry ( String tableName , String key ) { log . trace ( "remove entry called for : {} key : {}" , tableName , key ) ; List < TableKey < byte [ ] > > keys = Collections . singletonList ( new TableKeyImpl < > ( key . getBytes ( Charsets . UTF_8 ) , null ) ) ; return expectingDataNo... | Method to remove entry from the store . |
23,408 | public CompletableFuture < Void > removeEntries ( String tableName , Collection < String > keys ) { log . trace ( "remove entry called for : {} keys : {}" , tableName , keys ) ; List < TableKey < byte [ ] > > listOfKeys = keys . stream ( ) . map ( x -> new TableKeyImpl < > ( x . getBytes ( Charsets . UTF_8 ) , null ) )... | Removes a batch of entries from the table store . Ignores data not found exception and treats it as success . If table store throws dataNotFound for a subset of entries there is no way for this method to disambiguate . So it is the responsibility of the caller to use this api if they are guaranteed to always attempt to... |
23,409 | public CompletableFuture < Map . Entry < ByteBuf , List < String > > > getKeysPaginated ( String tableName , ByteBuf continuationToken , int limit ) { log . trace ( "get keys paginated called for : {}" , tableName ) ; return withRetries ( ( ) -> segmentHelper . readTableKeys ( tableName , limit , IteratorState . fromBy... | Method to get paginated list of keys with a continuation token . |
23,410 | public < T > CompletableFuture < Map . Entry < ByteBuf , List < Map . Entry < String , VersionedMetadata < T > > > > > getEntriesPaginated ( String tableName , ByteBuf continuationToken , int limit , Function < byte [ ] , T > fromBytes ) { log . trace ( "get entries paginated called for : {}" , tableName ) ; return wit... | Method to get paginated list of entries with a continuation token . |
23,411 | public < K , V > CompletableFuture < Map < K , V > > getEntriesWithFilter ( String table , Function < String , K > fromStringKey , Function < byte [ ] , V > fromBytesValue , BiFunction < K , V , Boolean > filter , int limit ) { Map < K , V > result = new ConcurrentHashMap < > ( ) ; AtomicBoolean canContinue = new Atomi... | Method to retrieve a collection of entries bounded by the specified limit size that satisfy the supplied filter . This function makes calls into segment store and includes entries that satisfy the supplied predicate . It makes repeated paginated calls into segment store until it has either collected deseried number of ... |
23,412 | public AsyncIterator < String > getAllKeys ( String tableName ) { return new ContinuationTokenAsyncIterator < > ( token -> getKeysPaginated ( tableName , token , 1000 ) . thenApplyAsync ( result -> { token . release ( ) ; return new AbstractMap . SimpleEntry < > ( result . getKey ( ) , result . getValue ( ) ) ; } , exe... | Method to retrieve all keys in the table . It returns an asyncIterator which can be used to iterate over the returned keys . |
23,413 | public < T > AsyncIterator < Map . Entry < String , VersionedMetadata < T > > > getAllEntries ( String tableName , Function < byte [ ] , T > fromBytes ) { return new ContinuationTokenAsyncIterator < > ( token -> getEntriesPaginated ( tableName , token , 1000 , fromBytes ) . thenApplyAsync ( result -> { token . release ... | Method to retrieve all entries in the table . It returns an asyncIterator which can be used to iterate over the returned entries . |
23,414 | public void initialize ( ) throws DurableDataLogException { Preconditions . checkState ( this . bookKeeper . get ( ) == null , "BookKeeperLogFactory is already initialized." ) ; try { this . bookKeeper . set ( startBookKeeperClient ( ) ) ; } catch ( IllegalArgumentException | NullPointerException ex ) { close ( ) ; thr... | region DurableDataLogFactory Implementation |
23,415 | public DebugLogWrapper createDebugLogWrapper ( int logId ) { Preconditions . checkState ( this . bookKeeper . get ( ) != null , "BookKeeperLogFactory is not initialized." ) ; return new DebugLogWrapper ( logId , this . zkClient , this . bookKeeper . get ( ) , this . config , this . executor ) ; } | Creates a new DebugLogWrapper that can be used for debugging purposes . This should not be used for regular operations . |
23,416 | private static String getSegmentBaseName ( String segmentQualifiedName ) { int endOfStreamNamePos = segmentQualifiedName . lastIndexOf ( TRANSACTION_DELIMITER ) ; if ( endOfStreamNamePos < 0 || endOfStreamNamePos + TRANSACTION_DELIMITER . length ( ) + TRANSACTION_ID_LENGTH > segmentQualifiedName . length ( ) ) { return... | Get base name of segment with the potential transaction delimiter removed . |
23,417 | public static String [ ] createHostTag ( ) { String [ ] hostTag = { MetricsTags . TAG_HOST , null } ; try { hostTag [ 1 ] = InetAddress . getLocalHost ( ) . getHostName ( ) ; } catch ( UnknownHostException e ) { hostTag [ 1 ] = "unknown" ; } return hostTag ; } | Create host tag based on the local host . |
23,418 | public void append ( long streamSegmentId , long offset , byte [ ] data ) throws StreamSegmentNotExistsException { Exceptions . checkNotClosed ( this . closed . get ( ) , this ) ; log . debug ( "{}: append (StreamSegmentId = {}, Offset = {}, DataLength = {})." , this . traceObjectId , streamSegmentId , offset , data . ... | region ReadIndex Implementation |
23,419 | private StreamSegmentReadIndex getOrCreateIndex ( long streamSegmentId ) throws StreamSegmentNotExistsException { StreamSegmentReadIndex index ; synchronized ( this . lock ) { index = getIndex ( streamSegmentId ) ; if ( index == null ) { SegmentMetadata segmentMetadata = this . metadata . getStreamSegmentMetadata ( str... | Gets a reference to the existing StreamSegmentRead index for the given StreamSegment Id . Creates a new one if necessary . |
23,420 | public void add ( int value ) { int newIndex = ( this . lastIndex + 1 ) % this . samples . length ; if ( this . count >= this . samples . length ) { this . sum -= this . samples [ newIndex ] ; } else { this . count ++ ; } this . samples [ newIndex ] = value ; this . sum += value ; this . lastIndex = newIndex ; } | Adds the given value to the moving average . If the moving average is already at capacity this will overwrite the oldest value in the series . |
23,421 | private void executeStorageRead ( Request request ) { try { byte [ ] buffer = new byte [ request . length ] ; getHandle ( ) . thenComposeAsync ( handle -> this . storage . read ( handle , request . offset , buffer , 0 , buffer . length , request . getTimeout ( ) ) , this . executor ) . thenAcceptAsync ( bytesRead -> re... | Executes the Storage Read for the given request . |
23,422 | @ GuardedBy ( "lock" ) private Request findOverlappingRequest ( Request request ) { Map . Entry < Long , Request > previousEntry = this . pendingRequests . floorEntry ( request . getOffset ( ) ) ; if ( previousEntry != null && request . getOffset ( ) < previousEntry . getValue ( ) . getEndOffset ( ) ) { return previous... | Finds a pending Request that overlaps with the given request based on the given request s Offset . |
23,423 | public void serialize ( RevisionDataOutput dataOutput , T object ) throws IOException { serialize ( dataOutput . getBaseStream ( ) , object ) ; } | Serializes the given object to the given RevisionDataOutput . This overload is usually invoked for serializing nested classes or collections . |
23,424 | void processHeader ( InputStream dataInput ) throws IOException { int formatVersion = dataInput . read ( ) ; if ( formatVersion < 0 ) { throw new EOFException ( ) ; } ensureCondition ( formatVersion == SERIALIZER_VERSION , "Unsupported format version %d." , formatVersion ) ; } | Reads a single unsigned byte from the given InputStream and interprets it as a Serializer Format Version after which it validates that it is supported . |
23,425 | void ensureCondition ( boolean condition , String messageFormat , Object ... args ) throws SerializationException { if ( ! condition ) { throw new SerializationException ( String . format ( messageFormat , args ) ) ; } } | Verifies that the given condition is true . If not throws a SerializationException . |
23,426 | private void removeDuplicates ( NavigableMap < Double , SegmentWithRange > result ) { Segment last = null ; for ( Iterator < SegmentWithRange > iterator = result . descendingMap ( ) . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { SegmentWithRange current = iterator . next ( ) ; if ( current . getSegment ( ) ... | This combines consecutive entries in the map that refer to the same segment . This happens following a merge because the preceeding segments are replaced one at a time . |
23,427 | private void verifyReplacementRange ( SegmentWithRange replacedSegment , StreamSegmentsWithPredecessors replacementSegments ) { log . debug ( "Verification of replacement segments {} with the current segments {}" , replacementSegments , segments ) ; Map < Long , List < SegmentWithRange > > replacementRanges = replaceme... | Checks that replacementSegments provided are consistent with the segments that are currently being used . |
23,428 | public static Map < UUID , Long > getCoreNonNullAttributes ( Map < UUID , Long > attributes ) { return attributes . entrySet ( ) . stream ( ) . filter ( e -> Attributes . isCoreAttribute ( e . getKey ( ) ) && e . getValue ( ) != NULL_ATTRIBUTE_VALUE ) . collect ( Collectors . toMap ( Map . Entry :: getKey , Map . Entry... | Returns a new Map of Attribute Ids to Values containing only those Core Attributes from the given Map that do not have a null value . |
23,429 | static SegmentChunk forSegment ( String segmentName , long startOffset ) { return new SegmentChunk ( StreamSegmentNameUtils . getSegmentChunkName ( segmentName , startOffset ) , startOffset ) ; } | Creates a new instance of the SegmentChunk class . |
23,430 | SegmentChunk withNewOffset ( long newOffset ) { SegmentChunk ns = new SegmentChunk ( this . name , newOffset ) ; ns . setLength ( getLength ( ) ) ; if ( isSealed ( ) ) { ns . markSealed ( ) ; } if ( ! exists ( ) ) { ns . markInexistent ( ) ; } return ns ; } | Creates a new instance of the SegmentChunk class with the same information as this one but with a new offset . |
23,431 | synchronized void increaseLength ( long delta ) { Preconditions . checkState ( ! this . sealed , "Cannot increase the length of a sealed SegmentChunk." ) ; Preconditions . checkArgument ( delta >= 0 , "Cannot decrease the length of a SegmentChunk." ) ; this . length += delta ; } | Increases the length of the SegmentChunk by the given delta . |
23,432 | synchronized void setLength ( long length ) { Preconditions . checkState ( ! this . sealed , "Cannot increase the length of a sealed SegmentChunk." ) ; Preconditions . checkArgument ( length >= 0 , "length must be a non-negative number." ) ; this . length = length ; } | Sets the length of the SegmentChunk . |
23,433 | public void registerHost ( Host host ) { Preconditions . checkNotNull ( host , "host" ) ; Exceptions . checkArgument ( ! entryMap . containsKey ( host ) , "host" , "host is already registered to cluster." ) ; String hostPath = ZKPaths . makePath ( getPathPrefix ( ) , host . toString ( ) ) ; PersistentNode node = new Pe... | Register Host to cluster . |
23,434 | public void deregisterHost ( Host host ) { Preconditions . checkNotNull ( host , "host" ) ; PersistentNode node = entryMap . get ( host ) ; Preconditions . checkNotNull ( node , "Host is not present in cluster." ) ; entryMap . remove ( host ) ; close ( node ) ; } | Remove Host from cluster . |
23,435 | public void addListener ( ClusterListener listener ) { Preconditions . checkNotNull ( listener , "listener" ) ; if ( ! cache . isPresent ( ) ) { initializeCache ( ) ; } cache . get ( ) . getListenable ( ) . addListener ( pathChildrenCacheListener ( listener ) ) ; } | Add Listener to the cluster . |
23,436 | public Set < Host > getClusterMembers ( ) { if ( ! cache . isPresent ( ) ) { initializeCache ( ) ; } List < ChildData > data = cache . get ( ) . getCurrentData ( ) ; return data . stream ( ) . map ( d -> Host . fromBytes ( d . getData ( ) ) ) . collect ( Collectors . toSet ( ) ) ; } | Get the current cluster members . |
23,437 | public static boolean validateInputRange ( final List < Long > segmentsToSeal , final List < Map . Entry < Double , Double > > newRanges , final EpochRecord currentEpoch ) { boolean newRangesCheck = newRanges . stream ( ) . noneMatch ( x -> x . getKey ( ) >= x . getValue ( ) && x . getValue ( ) > 0 ) ; if ( newRangesCh... | Method to validate supplied scale input . It performs a check that new ranges are identical to sealed ranges . |
23,438 | public static boolean canScaleFor ( final List < Long > segmentsToSeal , final EpochRecord currentEpoch ) { return segmentsToSeal . stream ( ) . allMatch ( x -> currentEpoch . getSegment ( x ) != null ) ; } | Method to check that segments to seal are present in current epoch . |
23,439 | public static boolean verifyRecordMatchesInput ( List < Long > segmentsToSeal , List < Map . Entry < Double , Double > > newRanges , boolean isManualScale , EpochTransitionRecord record ) { boolean newRangeMatch = newRanges . stream ( ) . allMatch ( x -> record . getNewSegmentsWithRange ( ) . values ( ) . stream ( ) . ... | Method to verify if supplied epoch transition record matches the supplied input which includes segments to seal new ranges to create . For manual scale it will verify that segments to seal match and epoch transition record share the same segment number . |
23,440 | public static EpochTransitionRecord computeEpochTransition ( EpochRecord currentEpoch , List < Long > segmentsToSeal , List < Map . Entry < Double , Double > > newRanges , long scaleTimestamp ) { Preconditions . checkState ( segmentsToSeal . stream ( ) . allMatch ( currentEpoch :: containsSegment ) , "Invalid epoch tra... | Method to compute epoch transition record . It takes segments to seal and new ranges and all the tables and computes the next epoch transition record . |
23,441 | public static UUID generateTxnId ( int epoch , int msb , long lsb ) { long msb64Bit = ( long ) epoch << 32 | msb & 0xFFFFFFFFL ; return new UUID ( msb64Bit , lsb ) ; } | region transaction id |
23,442 | public static boolean streamCutComparator ( Map < Long , Long > streamCut1 , Map < StreamSegmentRecord , Integer > span1 , Map < Long , Long > streamCut2 , Map < StreamSegmentRecord , Integer > span2 ) { return span1 . entrySet ( ) . stream ( ) . allMatch ( e1 -> span2 . entrySet ( ) . stream ( ) . noneMatch ( e2 -> ( ... | Method to compare two stream cuts given their spans . |
23,443 | private static List < Map . Entry < Double , Double > > reduce ( List < Map . Entry < Double , Double > > input ) { List < Map . Entry < Double , Double > > ranges = new ArrayList < > ( input ) ; ranges . sort ( Comparator . comparingDouble ( Map . Entry :: getKey ) ) ; List < Map . Entry < Double , Double > > result =... | Helper method to compute list of continuous ranges . For example two neighbouring key ranges where range1 . high == range2 . low then they are considered neighbours . This method reduces input range into distinct continuous blocks . |
23,444 | public long getStreamSegmentId ( String streamSegmentName , boolean updateLastUsed ) { synchronized ( this . lock ) { StreamSegmentMetadata metadata = this . metadataByName . getOrDefault ( streamSegmentName , null ) ; if ( updateLastUsed && metadata != null ) { metadata . setLastUsed ( getOperationSequenceNumber ( ) )... | region SegmentMetadataCollection Implementation |
23,445 | public Collection < SegmentMetadata > getEvictionCandidates ( long sequenceNumberCutoff , int maxCount ) { long adjustedCutoff = Math . min ( sequenceNumberCutoff , this . lastTruncatedSequenceNumber . get ( ) ) ; List < SegmentMetadata > candidates ; synchronized ( this . lock ) { candidates = this . metadataById . va... | region EvictableMetadata Implementation |
23,446 | public void recordTruncationMarker ( long operationSequenceNumber , LogAddress address ) { Exceptions . checkArgument ( operationSequenceNumber >= 0 , "operationSequenceNumber" , "Operation Sequence Number must be a positive number." ) ; Preconditions . checkNotNull ( address , "address" ) ; synchronized ( this . trunc... | region TruncationMarkerRepository Implementation |
23,447 | public void close ( ) throws IOException { if ( this . remaining > 0 ) { int toSkip = this . remaining ; long skipped = skip ( toSkip ) ; if ( skipped != toSkip ) { throw new SerializationException ( String . format ( "Read %d fewer byte(s) than expected only able to skip %d." , toSkip , skipped ) ) ; } } else if ( thi... | region InputStream Implementation |
23,448 | public BoundedInputStream subStream ( int bound ) { Preconditions . checkArgument ( bound >= 0 && bound <= this . remaining , "bound must be a non-negative integer and less than or equal to the remaining length." ) ; this . remaining -= bound ; return new BoundedInputStream ( this . in , bound ) ; } | Creates a new BoundedInputStream wrapping the same InputStream as this one starting at the current position with the given bound . |
23,449 | protected void startUp ( ) throws Exception { long traceId = LoggerHelpers . traceEnterWithContext ( log , this . objectId , "startUp" ) ; try { log . info ( "Starting gRPC server listening on port: {}" , this . config . getPort ( ) ) ; this . server . start ( ) ; } finally { LoggerHelpers . traceLeave ( log , this . o... | Start gRPC server . |
23,450 | protected void shutDown ( ) throws Exception { long traceId = LoggerHelpers . traceEnterWithContext ( log , this . objectId , "shutDown" ) ; try { log . info ( "Stopping gRPC server listening on port: {}" , this . config . getPort ( ) ) ; this . server . shutdown ( ) ; log . info ( "Awaiting termination of gRPC server"... | Gracefully stop gRPC server . |
23,451 | private boolean exceedsThresholds ( ) { boolean isFirstAppend = this . operations . size ( ) > 0 && isAppendOperation ( this . operations . getFirst ( ) ) ; long length = isFirstAppend ? this . operations . getFirst ( ) . getLength ( ) : 0 ; if ( isFirstAppend && length == 0 && ! ( ( AggregatedAppendOperation ) this . ... | Gets a value indicating whether the Flush thresholds are exceeded for this SegmentAggregator . |
23,452 | private boolean isReconciling ( ) { AggregatorState currentState = this . state . get ( ) ; return currentState == AggregatorState . ReconciliationNeeded || currentState == AggregatorState . Reconciling ; } | Gets a value indicating whether the SegmentAggregator is currently in a Reconciliation state . |
23,453 | public void add ( SegmentOperation operation ) throws DataCorruptionException { ensureInitializedAndNotClosed ( ) ; checkValidOperation ( operation ) ; boolean isDelete = isDeleteOperation ( operation ) ; if ( isDelete ) { addDeleteOperation ( ( DeleteSegmentOperation ) operation ) ; log . debug ( "{}: Add {}." , this ... | Adds the given SegmentOperation to the Aggregator . |
23,454 | private void addUpdateAttributesOperation ( UpdateAttributesOperation operation ) { if ( ! this . metadata . isSealedInStorage ( ) ) { Map < UUID , Long > attributes = getExtendedAttributes ( operation ) ; if ( ! attributes . isEmpty ( ) ) { AggregatedAppendOperation aggregatedAppend = getOrCreateAggregatedAppend ( thi... | Processes an UpdateAttributesOperation . |
23,455 | private void processNewOperation ( StorageOperation operation ) { if ( operation instanceof MergeSegmentOperation ) { this . operations . add ( operation ) ; this . mergeTransactionCount . incrementAndGet ( ) ; } else if ( operation instanceof StreamSegmentSealOperation ) { this . operations . add ( operation ) ; this ... | Processes an operation that would result in a change to the underlying Storage . |
23,456 | public CompletableFuture < WriterFlushResult > flush ( Duration timeout ) { ensureInitializedAndNotClosed ( ) ; if ( this . metadata . isDeletedInStorage ( ) ) { return CompletableFuture . completedFuture ( new WriterFlushResult ( ) ) ; } long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId... | Flushes the contents of the Aggregator to the Storage . |
23,457 | private CompletableFuture < WriterFlushResult > flushNormally ( TimeoutTimer timer ) { assert this . state . get ( ) == AggregatorState . Writing : "flushNormally cannot be called if state == " + this . state ; long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId , "flushNormally" , this . ... | Repeatedly flushes the contents of the Aggregator to the Storage as long as something immediate needs to be flushed such as a Seal or Merge operation . |
23,458 | private CompletableFuture < WriterFlushResult > flushPendingTruncate ( WriterFlushResult flushResult , Duration timeout ) { StorageOperation op = this . operations . getFirst ( ) ; if ( ! isTruncateOperation ( op ) || ! this . storage . supportsTruncation ( ) ) { return CompletableFuture . completedFuture ( flushResult... | Flushes a pending StreamSegmentTruncateOperation if that is the next pending one . |
23,459 | private CompletableFuture < WriterFlushResult > flushPendingAppends ( Duration timeout ) { FlushArgs flushArgs ; try { flushArgs = getFlushArgs ( ) ; } catch ( DataCorruptionException ex ) { return Futures . failedFuture ( ex ) ; } long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId , "flu... | Flushes all Append Operations that can be flushed up to the maximum allowed flush size . |
23,460 | private FlushArgs getFlushArgs ( ) throws DataCorruptionException { StorageOperation first = this . operations . getFirst ( ) ; if ( ! ( first instanceof AggregatedAppendOperation ) ) { return new FlushArgs ( null , 0 , Collections . emptyMap ( ) ) ; } AggregatedAppendOperation appendOp = ( AggregatedAppendOperation ) ... | Returns a FlushArgs which contains the data needing to be flushed to Storage . |
23,461 | private CompletableFuture < WriterFlushResult > mergeWith ( UpdateableSegmentMetadata transactionMetadata , MergeSegmentOperation mergeOp , TimeoutTimer timer ) { long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId , "mergeWith" , transactionMetadata . getId ( ) , transactionMetadata . get... | Merges the Transaction StreamSegment with given metadata into this one at the current offset . |
23,462 | private CompletableFuture < SegmentProperties > mergeInStorage ( SegmentMetadata transactionMetadata , MergeSegmentOperation mergeOp , TimeoutTimer timer ) { return this . storage . getStreamSegmentInfo ( transactionMetadata . getName ( ) , timer . getRemaining ( ) ) . thenAcceptAsync ( transProperties -> { if ( transP... | Executes the merge of the Source StreamSegment with given metadata into this one in Storage . |
23,463 | private void mergeCompleted ( SegmentProperties segmentProperties , UpdateableSegmentMetadata transactionMetadata , MergeSegmentOperation mergeOp ) { StorageOperation processedOperation = this . operations . removeFirst ( ) ; assert processedOperation != null && processedOperation instanceof MergeSegmentOperation : "Fi... | Executes post - Storage merge tasks including state and metadata updates . |
23,464 | private CompletableFuture < WriterFlushResult > sealIfNecessary ( WriterFlushResult flushResult , TimeoutTimer timer ) { if ( ! this . hasSealPending . get ( ) || ! ( this . operations . getFirst ( ) instanceof StreamSegmentSealOperation ) ) { return CompletableFuture . completedFuture ( flushResult ) ; } long traceId ... | Seals the StreamSegment in Storage if necessary . |
23,465 | private CompletableFuture < Void > sealAttributes ( Duration timeout ) { return handleAttributeException ( this . dataSource . sealAttributes ( this . metadata . getId ( ) , timeout ) ) ; } | Seals the Attribute Index for this Segment . |
23,466 | private CompletableFuture < WriterFlushResult > reconcileOperation ( StorageOperation op , SegmentProperties storageInfo , TimeoutTimer timer ) { CompletableFuture < WriterFlushResult > result ; if ( isAppendOperation ( op ) ) { result = reconcileAppendOperation ( ( AggregatedAppendOperation ) op , storageInfo , timer ... | Attempts to reconcile the given StorageOperation . |
23,467 | private CompletableFuture < WriterFlushResult > reconcileAppendOperation ( AggregatedAppendOperation op , SegmentProperties storageInfo , TimeoutTimer timer ) { CompletableFuture < Boolean > reconcileResult ; WriterFlushResult flushResult = new WriterFlushResult ( ) ; if ( op . getLength ( ) > 0 ) { reconcileResult = r... | Attempts to reconcile data and attributes for the given AggregatedAppendOperation . Since Append Operations can be partially flushed reconciliation may be for the full operation or for a part of it . |
23,468 | private CompletableFuture < Integer > reconcileData ( AggregatedAppendOperation op , SegmentProperties storageInfo , TimeoutTimer timer ) { InputStream appendStream = this . dataSource . getAppendData ( op . getStreamSegmentId ( ) , op . getStreamSegmentOffset ( ) , ( int ) op . getLength ( ) ) ; if ( appendStream == n... | Attempts to reconcile the data for the given AggregatedAppendOperation . Since Append Operations can be partially flushed reconciliation may be for the full operation or for a part of it . |
23,469 | private CompletableFuture < WriterFlushResult > reconcileMergeOperation ( MergeSegmentOperation op , SegmentProperties storageInfo , TimeoutTimer timer ) { UpdateableSegmentMetadata transactionMeta = this . dataSource . getStreamSegmentMetadata ( op . getSourceSegmentId ( ) ) ; if ( transactionMeta == null ) { return F... | Attempts to reconcile the given MergeSegmentOperation . |
23,470 | private CompletableFuture < WriterFlushResult > reconcileSealOperation ( SegmentProperties storageInfo , Duration timeout ) { if ( storageInfo . isSealed ( ) || storageInfo . getLength ( ) == 0 ) { return sealAttributes ( timeout ) . thenApplyAsync ( v -> { updateStatePostSeal ( ) ; return new WriterFlushResult ( ) ; }... | Attempts to reconcile a StreamSegmentSealOperation . |
23,471 | private CompletableFuture < Void > reconcileAttributes ( AggregatedAppendOperation op , TimeoutTimer timer ) { return handleAttributeException ( this . dataSource . persistAttributes ( this . metadata . getId ( ) , op . attributes , timer . getRemaining ( ) ) ) ; } | Attempts to reconcile the attributes for a given operation . There is no verification done ; this operation simply re - writes all the attributes to the index which is much more efficient than trying to read the values from the index and then comparing them . |
23,472 | private CompletableFuture < Void > handleAttributeException ( CompletableFuture < Void > future ) { return Futures . exceptionallyExpecting ( future , ex -> ( ex instanceof StreamSegmentSealedException && this . metadata . isSealedInStorage ( ) ) || ( ( ex instanceof StreamSegmentNotExistsException || ex instanceof Str... | Handles expected Attribute - related exceptions . Since the attribute index is a separate segment from the main one it is highly likely that it may get temporarily out of sync with the main one thus causing spurious StreamSegmentSealedExceptions or StreamSegmentNotExistsExceptions . If we get either of those and they a... |
23,473 | private void checkValidStorageOperation ( StorageOperation operation ) throws DataCorruptionException { Preconditions . checkArgument ( ! ( operation instanceof StreamSegmentAppendOperation ) , "SegmentAggregator cannot process StreamSegmentAppendOperations." ) ; long offset = operation . getStreamSegmentOffset ( ) ; l... | Validates that the given StorageOperation can be processed given the current accumulated state of the Segment . |
23,474 | private WriterFlushResult updateStatePostFlush ( FlushArgs flushArgs ) { long newLength = this . metadata . getStorageLength ( ) + flushArgs . getLength ( ) ; this . metadata . setStorageLength ( newLength ) ; boolean reachedEnd = false ; while ( this . operations . size ( ) > 0 && ! reachedEnd ) { StorageOperation fir... | Updates the metadata and the internal state after a flush was completed . |
23,475 | private void updateStatePostSeal ( ) { this . metadata . markSealedInStorage ( ) ; this . operations . removeFirst ( ) ; assert this . operations . size ( ) - this . truncateCount . get ( ) == 0 : "there are outstanding non-truncate operations after a Seal" ; this . hasSealPending . set ( false ) ; } | Updates the metadata and the internal state after a Seal was completed . |
23,476 | private void updateMetadata ( SegmentProperties segmentProperties ) { this . metadata . setStorageLength ( segmentProperties . getLength ( ) ) ; if ( segmentProperties . isSealed ( ) && ! this . metadata . isSealedInStorage ( ) ) { this . metadata . markSealed ( ) ; this . metadata . markSealedInStorage ( ) ; } } | Updates the metadata and based on the given SegmentProperties object . |
23,477 | private CompletableFuture < SegmentProperties > openWrite ( String segmentName , AtomicReference < SegmentHandle > handleRef , Duration timeout ) { return this . storage . openWrite ( segmentName ) . thenComposeAsync ( handle -> { handleRef . set ( handle ) ; return this . storage . getStreamSegmentInfo ( segmentName ,... | Opens the given segment for writing . |
23,478 | private Map < UUID , Long > getExtendedAttributes ( AttributeUpdaterOperation operation ) { Collection < AttributeUpdate > updates = operation . getAttributeUpdates ( ) ; if ( updates == null ) { return Collections . emptyMap ( ) ; } return updates . stream ( ) . filter ( au -> ! Attributes . isCoreAttribute ( au . get... | Collects the extended Attributes from the AttributeUpdates of the given operation . |
23,479 | void runAsync ( ) { synchronized ( this ) { Exceptions . checkNotClosed ( this . closed , this ) ; if ( this . running ) { this . runAgain = true ; return ; } this . running = true ; } runInternal ( ) ; } | Executes one instance of the task or queues it up at most once should the task be currently running . |
23,480 | public static final StreamConfiguration getCreateStreamConfig ( final CreateStreamRequest createStreamRequest ) { ScalingPolicy scalingPolicy ; if ( createStreamRequest . getScalingPolicy ( ) . getType ( ) == ScalingConfig . TypeEnum . FIXED_NUM_SEGMENTS ) { scalingPolicy = ScalingPolicy . fixed ( createStreamRequest .... | This method translates the REST request object CreateStreamRequest into internal object StreamConfiguration . |
23,481 | public static final StreamConfiguration getUpdateStreamConfig ( final UpdateStreamRequest updateStreamRequest ) { ScalingPolicy scalingPolicy ; if ( updateStreamRequest . getScalingPolicy ( ) . getType ( ) == ScalingConfig . TypeEnum . FIXED_NUM_SEGMENTS ) { scalingPolicy = ScalingPolicy . fixed ( updateStreamRequest .... | This method translates the REST request object UpdateStreamRequest into internal object StreamConfiguration . |
23,482 | public static final StreamProperty encodeStreamResponse ( String scope , String streamName , final StreamConfiguration streamConfiguration ) { ScalingConfig scalingPolicy = new ScalingConfig ( ) ; if ( streamConfiguration . getScalingPolicy ( ) . getScaleType ( ) == ScalingPolicy . ScaleType . FIXED_NUM_SEGMENTS ) { sc... | The method translates the internal object StreamConfiguration into REST response object . |
23,483 | public < T > T getConfig ( Supplier < ? extends ConfigBuilder < ? extends T > > constructor ) { return constructor . get ( ) . rebase ( this . properties ) . build ( ) ; } | Gets a new instance of a Configuration for this builder . |
23,484 | public void store ( File file ) throws IOException { try ( val s = new FileOutputStream ( file , false ) ) { this . properties . store ( s , "" ) ; } } | Stores the contents of the ServiceBuilderConfig into the given File . |
23,485 | public static ServiceBuilderConfig getDefaultConfig ( ) { return new Builder ( ) . include ( ServiceConfig . builder ( ) . with ( ServiceConfig . CONTAINER_COUNT , 1 ) ) . build ( ) ; } | Gets a default set of configuration values in absence of any real configuration . These configuration values are the default ones from all component configurations except that it will create only one container to host segments . |
23,486 | public < V > ConfigBuilder < T > with ( Property < V > property , V value ) { String key = String . format ( "%s.%s" , this . namespace , property . getName ( ) ) ; this . properties . setProperty ( key , value == null ? "" : value . toString ( ) ) ; return this ; } | Includes the given property and its value in the builder . |
23,487 | public ConfigBuilder < T > withUnsafe ( Property < ? > property , Object value ) { String key = String . format ( "%s.%s" , this . namespace , property . getName ( ) ) ; this . properties . setProperty ( key , value . toString ( ) ) ; return this ; } | Includes the given property and its value in the builder without Property - Value type - enforcement . |
23,488 | protected void outputLogSummary ( int logId , ReadOnlyLogMetadata m ) { if ( m == null ) { output ( "Log %d: No metadata." , logId ) ; } else { output ( "Log %d: Epoch=%d, Version=%d, Enabled=%s, Ledgers=%d, Truncation={%s}" , logId , m . getEpoch ( ) , m . getUpdateVersion ( ) , m . isEnabled ( ) , m . getLedgers ( ) ... | Outputs a summary for the given Log . |
23,489 | protected Context createContext ( ) throws DurableDataLogException { val serviceConfig = getServiceConfig ( ) ; val bkConfig = getCommandArgs ( ) . getState ( ) . getConfigBuilder ( ) . include ( BookKeeperConfig . builder ( ) . with ( BookKeeperConfig . ZK_ADDRESS , serviceConfig . getZkURL ( ) ) ) . build ( ) . getCo... | Creates a new Context to be used by the BookKeeper command . |
23,490 | void add ( TableKey key , UUID hash , int length ) { Item item = new Item ( key , hash , this . length ) ; this . items . add ( item ) ; this . length += length ; if ( key . hasVersion ( ) ) { this . versionedItems . add ( item ) ; } } | Adds a new Item to this TableKeyBatch . |
23,491 | private void processWritesSync ( ) { if ( this . closed . get ( ) ) { return ; } if ( getWriteLedger ( ) . ledger . isClosed ( ) ) { this . rolloverProcessor . runAsync ( ) ; } else if ( ! processPendingWrites ( ) && ! this . closed . get ( ) ) { this . writeProcessor . runAsync ( ) ; } } | Write Processor main loop . This method is not thread safe and should only be invoked as part of the Write Processor . |
23,492 | private boolean processPendingWrites ( ) { long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId , "processPendingWrites" ) ; val cs = this . writes . removeFinishedWrites ( ) ; if ( cs == WriteQueue . CleanupStatus . WriteFailed ) { close ( ) ; LoggerHelpers . traceLeave ( log , this . trac... | Executes pending Writes to BookKeeper . This method is not thread safe and should only be invoked as part of the Write Processor . |
23,493 | private List < Write > getWritesToExecute ( ) { final long maxTotalSize = this . config . getBkLedgerMaxSize ( ) - getWriteLedger ( ) . ledger . getLength ( ) ; List < Write > toExecute = this . writes . getWritesToExecute ( maxTotalSize ) ; if ( handleClosedLedgers ( toExecute ) ) { toExecute = this . writes . getWrit... | Collects an ordered list of Writes to execute to BookKeeper . |
23,494 | private boolean executeWrites ( List < Write > toExecute ) { log . debug ( "{}: Executing {} writes." , this . traceObjectId , toExecute . size ( ) ) ; for ( int i = 0 ; i < toExecute . size ( ) ; i ++ ) { Write w = toExecute . get ( i ) ; try { int attemptCount = w . beginAttempt ( ) ; if ( attemptCount > this . confi... | Executes the given Writes to BookKeeper . |
23,495 | @ SneakyThrows ( DurableDataLogException . class ) private long fetchLastAddConfirmed ( WriteLedger writeLedger , Map < Long , Long > lastAddsConfirmed ) { long ledgerId = writeLedger . ledger . getId ( ) ; long lac = lastAddsConfirmed . getOrDefault ( ledgerId , - 1L ) ; long traceId = LoggerHelpers . traceEnterWithCo... | Reliably gets the LastAddConfirmed for the WriteLedger |
23,496 | private void addCallback ( int rc , LedgerHandle handle , long entryId , Object ctx ) { Write write = ( Write ) ctx ; try { assert handle . getId ( ) == write . getWriteLedger ( ) . ledger . getId ( ) : "Handle.Id mismatch: " + write . getWriteLedger ( ) . ledger . getId ( ) + " vs " + handle . getId ( ) ; write . setE... | Callback for BookKeeper appends . |
23,497 | private void completeWrite ( Write write ) { Timer t = write . complete ( ) ; if ( t != null ) { this . metrics . bookKeeperWriteCompleted ( write . data . getLength ( ) , t . getElapsed ( ) ) ; } } | Completes the given Write and makes any necessary internal updates . |
23,498 | private void handleWriteException ( Throwable ex ) { if ( ex instanceof ObjectClosedException && ! this . closed . get ( ) ) { log . warn ( "{}: Caught ObjectClosedException but not closed; closing now." , this . traceObjectId , ex ) ; close ( ) ; } } | Handles a general Write exception . |
23,499 | private void handleWriteException ( int responseCode , Write write ) { assert responseCode != BKException . Code . OK : "cannot handle an exception when responseCode == " + BKException . Code . OK ; Exception ex = BKException . create ( responseCode ) ; try { if ( ex instanceof BKException . BKLedgerFencedException ) {... | Handles an exception after a Write operation converts it to a Pravega Exception and completes the given future exceptionally using it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.