idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
23,300 | @ Task ( name = "createStream" , version = "1.0" , resource = "{scope}/{stream}" ) public CompletableFuture < CreateStreamStatus . Status > createStream ( String scope , String stream , StreamConfiguration config , long createTimestamp ) { return execute ( new Resource ( scope , stream ) , new Serializable [ ] { scope ... | Create stream . |
23,301 | public CompletableFuture < UpdateStreamStatus . Status > updateStream ( String scope , String stream , StreamConfiguration newConfig , OperationContext contextOpt ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : contextOpt ; final long requestId = reques... | Update stream s configuration . |
23,302 | public CompletableFuture < StreamCutRecord > generateStreamCut ( final String scope , final String stream , final StreamCutRecord previous , final OperationContext contextOpt , String delegationToken ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : conte... | Generate a new stream cut . |
23,303 | public CompletableFuture < UpdateStreamStatus . Status > truncateStream ( final String scope , final String stream , final Map < Long , Long > streamCut , final OperationContext contextOpt ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : contextOpt ; fin... | Truncate a stream . |
23,304 | public CompletableFuture < UpdateStreamStatus . Status > sealStream ( String scope , String stream , OperationContext contextOpt ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : contextOpt ; final long requestId = requestTracker . getRequestIdFor ( "seal... | Seal a stream . |
23,305 | public CompletableFuture < DeleteStreamStatus . Status > deleteStream ( final String scope , final String stream , final OperationContext contextOpt ) { final OperationContext context = contextOpt == null ? streamMetadataStore . createContext ( scope , stream ) : contextOpt ; final long requestId = requestTracker . get... | Delete a stream . Precondition for deleting a stream is that the stream sholud be sealed . |
23,306 | public CompletableFuture < ScaleResponse > manualScale ( String scope , String stream , List < Long > segmentsToSeal , List < Map . Entry < Double , Double > > newRanges , long scaleTimestamp , OperationContext context ) { final long requestId = requestTracker . getRequestIdFor ( "scaleStream" , scope , stream , String... | Helper method to perform scale operation against an scale request . This method posts a request in the request stream and then starts the scale operation while tracking it s progress . Eventually after scale completion it sends a response to the caller . |
23,307 | public CompletableFuture < ScaleStatusResponse > checkScale ( String scope , String stream , int epoch , OperationContext context ) { CompletableFuture < EpochRecord > activeEpochFuture = streamMetadataStore . getActiveEpoch ( scope , stream , context , true , executor ) ; CompletableFuture < State > stateFuture = stre... | Helper method to check if scale operation against an epoch completed or not . |
23,308 | public StreamCutReferenceRecord findStreamCutReferenceForTime ( long time ) { int beforeIndex = getGreatestLowerBound ( this , time , StreamCutReferenceRecord :: getRecordingTime ) ; if ( beforeIndex < 0 ) { return null ; } return retentionRecords . get ( beforeIndex ) ; } | Find retention record on or before the given time . |
23,309 | public StreamCutReferenceRecord findStreamCutReferenceForSize ( long size ) { int beforeIndex = getGreatestLowerBound ( this , size , StreamCutReferenceRecord :: getRecordingSize ) ; if ( beforeIndex < 0 ) { return null ; } return retentionRecords . get ( beforeIndex ) ; } | Find retention record on or before the given size . |
23,310 | public static RetentionSet removeStreamCutBefore ( RetentionSet set , StreamCutReferenceRecord record ) { Preconditions . checkNotNull ( record ) ; int beforeIndex = getGreatestLowerBound ( set , record . getRecordingTime ( ) , StreamCutReferenceRecord :: getRecordingTime ) ; if ( beforeIndex < 0 ) { return set ; } if ... | Creates a new retention set object by removing all records on or before given record . |
23,311 | public CompletableFuture < Void > initialize ( Duration timeout ) { Preconditions . checkState ( ! this . initialized . get ( ) , "TableMetadataStore is already initialized." ) ; val attributes = TableAttributes . DEFAULT_VALUES . entrySet ( ) . stream ( ) . map ( e -> new AttributeUpdate ( e . getKey ( ) , AttributeUp... | region MetadataStore Implementation |
23,312 | CompletableFuture < Integer > updateBuckets ( DirectSegmentAccess segment , Collection < BucketUpdate > bucketUpdates , long firstIndexedOffset , long lastIndexedOffset , int processedCount , Duration timeout ) { UpdateInstructions update = new UpdateInstructions ( ) ; for ( BucketUpdate bucketUpdate : bucketUpdates ) ... | Determines what Segment Attribute Updates are necessary to apply the given bucket updates and executes them onto the given Segment . |
23,313 | private AttributeUpdate generateBackpointerUpdate ( long fromOffset , long toOffset ) { return new AttributeUpdate ( getBackpointerAttributeKey ( fromOffset ) , AttributeUpdateType . Replace , toOffset ) ; } | Generates an AttributeUpdate that creates a new or updates an existing Backpointer . |
23,314 | private AttributeUpdate generateBackpointerRemoval ( long fromOffset ) { return new AttributeUpdate ( getBackpointerAttributeKey ( fromOffset ) , AttributeUpdateType . Replace , Attributes . NULL_ATTRIBUTE_VALUE ) ; } | Generates an AttributeUpdate that removes a Backpointer whether it exists or not . |
23,315 | @ SneakyThrows ( Exception . class ) private void tryInit ( ) { if ( ! zkInit ) { ZKUtils . createPathIfNotExists ( zkClient , zkPath , HostContainerMap . EMPTY . toBytes ( ) ) ; hostContainerMapNode . getListenable ( ) . addListener ( this :: updateMap ) ; hostContainerMapNode . start ( true ) ; updateMap ( ) ; zkInit... | Ensure required zk node is present in zookeeper . |
23,316 | protected void complete ( ReadResultEntryContents readResultEntryContents ) { Preconditions . checkState ( ! this . contents . isDone ( ) , "ReadResultEntry has already had its result set." ) ; CompletionConsumer callback = this . completionCallback ; if ( callback != null ) { callback . accept ( readResultEntryContent... | Completes the Future of this ReadResultEntry by setting the given content . |
23,317 | protected void fail ( Throwable exception ) { Preconditions . checkState ( ! this . contents . isDone ( ) , "ReadResultEntry has already had its result set." ) ; this . contents . completeExceptionally ( exception ) ; } | Fails the Future of this ReadResultEntry with the given exception . |
23,318 | public DurableDataLog . ReadItem getNext ( ) throws DurableDataLogException { Exceptions . checkNotClosed ( this . closed . get ( ) , this ) ; if ( this . currentLedger == null ) { openNextLedger ( this . metadata . getNextAddress ( this . metadata . getTruncationAddress ( ) , Long . MAX_VALUE ) ) ; } while ( this . cu... | region CloseableIterator Implementation |
23,319 | public static int writeShort ( ArrayView target , int offset , short value ) { return writeShort ( target . array ( ) , target . arrayOffset ( ) + offset , value ) ; } | Writes the given 16 - bit Short to the given ArrayView at the given offset . |
23,320 | public static int writeShort ( byte [ ] target , int offset , short value ) { target [ offset ] = ( byte ) ( value >>> 8 & 255 ) ; target [ offset + 1 ] = ( byte ) ( value & 255 ) ; return Short . BYTES ; } | Writes the given 16 - bit Short to the given byte array at the given offset . |
23,321 | public static int writeInt ( ArrayView target , int offset , int value ) { return writeInt ( target . array ( ) , target . arrayOffset ( ) + offset , value ) ; } | Writes the given 32 - bit Integer to the given ArrayView at the given offset . |
23,322 | public static int writeInt ( byte [ ] target , int offset , int value ) { target [ offset ] = ( byte ) ( value >>> 24 ) ; target [ offset + 1 ] = ( byte ) ( value >>> 16 ) ; target [ offset + 2 ] = ( byte ) ( value >>> 8 ) ; target [ offset + 3 ] = ( byte ) value ; return Integer . BYTES ; } | Writes the given 32 - bit Integer to the given byte array at the given offset . |
23,323 | public static int writeInt ( OutputStream target , int value ) throws IOException { target . write ( value >>> 24 ) ; target . write ( value >>> 16 ) ; target . write ( value >>> 8 ) ; target . write ( value ) ; return Integer . BYTES ; } | Writes the given 32 - bit Integer to the given OutputStream . |
23,324 | public static short readShort ( ArrayView source , int position ) { return ( short ) ( ( source . get ( position ) & 0xFF ) << 8 | ( source . get ( position + 1 ) & 0xFF ) ) ; } | Reads a 16 - bit Short from the given ArrayView starting at the given position . |
23,325 | public static int readInt ( byte [ ] source , int position ) { return ( source [ position ] & 0xFF ) << 24 | ( source [ position + 1 ] & 0xFF ) << 16 | ( source [ position + 2 ] & 0xFF ) << 8 | ( source [ position + 3 ] & 0xFF ) ; } | Reads a 32 - bit integer from the given byte array starting at the given position . |
23,326 | public static int readInt ( ArrayView source , int position ) { return ( source . get ( position ) & 0xFF ) << 24 | ( source . get ( position + 1 ) & 0xFF ) << 16 | ( source . get ( position + 2 ) & 0xFF ) << 8 | ( source . get ( position + 3 ) & 0xFF ) ; } | Reads a 32 - bit integer from the given ArrayView starting at the given position . |
23,327 | public static int readInt ( InputStream source ) throws IOException { int b1 = source . read ( ) ; int b2 = source . read ( ) ; int b3 = source . read ( ) ; int b4 = source . read ( ) ; if ( ( b1 | b2 | b3 | b4 ) < 0 ) { throw new EOFException ( ) ; } else { return ( b1 << 24 ) + ( b2 << 16 ) + ( b3 << 8 ) + b4 ; } } | Reads a 32 - bit integer from the given InputStream that was encoded using BitConverter . writeInt . |
23,328 | public static int writeLong ( ArrayView target , int offset , long value ) { return writeLong ( target . array ( ) , target . arrayOffset ( ) + offset , value ) ; } | Writes the given 64 - bit Long to the given ArrayView at the given offset . |
23,329 | public static int writeLong ( byte [ ] target , int offset , long value ) { target [ offset ] = ( byte ) ( value >>> 56 ) ; target [ offset + 1 ] = ( byte ) ( value >>> 48 ) ; target [ offset + 2 ] = ( byte ) ( value >>> 40 ) ; target [ offset + 3 ] = ( byte ) ( value >>> 32 ) ; target [ offset + 4 ] = ( byte ) ( value... | Writes the given 64 - bit Long to the given byte array at the given offset . |
23,330 | public static int writeUUID ( byte [ ] target , int offset , UUID value ) { writeLong ( target , offset , value . getMostSignificantBits ( ) ) ; writeLong ( target , offset + Long . BYTES , value . getLeastSignificantBits ( ) ) ; return 2 * Long . BYTES ; } | Writes the given 128 - bit UUID to the given byte array at the given offset . |
23,331 | public static UUID readUUID ( ArrayView source , int position ) { long msb = readLong ( source , position ) ; long lsb = readLong ( source , position + Long . BYTES ) ; return new UUID ( msb , lsb ) ; } | Reads a 128 - bit UUID from the given ArrayView starting at the given position . |
23,332 | public static long readLong ( ArrayView source , int position ) { return ( long ) ( source . get ( position ) & 0xFF ) << 56 | ( long ) ( source . get ( position + 1 ) & 0xFF ) << 48 | ( long ) ( source . get ( position + 2 ) & 0xFF ) << 40 | ( long ) ( source . get ( position + 3 ) & 0xFF ) << 32 | ( long ) ( source .... | Reads a 64 - bit long from the given ArrayView starting at the given position . |
23,333 | public static long readLong ( byte [ ] source , int position ) { return ( long ) ( source [ position ] & 0xFF ) << 56 | ( long ) ( source [ position + 1 ] & 0xFF ) << 48 | ( long ) ( source [ position + 2 ] & 0xFF ) << 40 | ( long ) ( source [ position + 3 ] & 0xFF ) << 32 | ( long ) ( source [ position + 4 ] & 0xFF ) ... | Reads a 64 - bit long from the given byte array starting at the given position . |
23,334 | public static long readLong ( InputStream source ) throws IOException { int b1 = source . read ( ) ; int b2 = source . read ( ) ; int b3 = source . read ( ) ; int b4 = source . read ( ) ; int b5 = source . read ( ) ; int b6 = source . read ( ) ; int b7 = source . read ( ) ; int b8 = source . read ( ) ; if ( ( b1 | b2 |... | Reads a 64 - bit long from the given InputStream that was encoded using BitConverter . writeLong . |
23,335 | LogMetadata addLedger ( long ledgerId ) { Preconditions . checkState ( this . enabled , "Log is not enabled. Cannot perform any modifications on it." ) ; List < LedgerMetadata > newLedgers = new ArrayList < > ( this . ledgers . size ( ) + 1 ) ; newLedgers . addAll ( this . ledgers ) ; int sequence = this . ledgers . si... | Creates a new instance of the LogMetadata class which contains an additional ledger . |
23,336 | LogMetadata removeEmptyLedgers ( int skipCountFromEnd ) { val newLedgers = new ArrayList < LedgerMetadata > ( ) ; int cutoffIndex = this . ledgers . size ( ) - skipCountFromEnd ; for ( int i = 0 ; i < cutoffIndex ; i ++ ) { LedgerMetadata lm = this . ledgers . get ( i ) ; if ( lm . getStatus ( ) != LedgerMetadata . Sta... | Removes LedgerMetadata instances for those Ledgers that are known to be empty . |
23,337 | LogMetadata updateLedgerStatus ( Map < Long , Long > lastAddConfirmed ) { if ( lastAddConfirmed . isEmpty ( ) ) { return this ; } val newLedgers = this . ledgers . stream ( ) . map ( lm -> { long lac = lastAddConfirmed . getOrDefault ( lm . getLedgerId ( ) , Long . MIN_VALUE ) ; if ( lm . getStatus ( ) == LedgerMetadat... | Updates the LastAddConfirmed on individual LedgerMetadata instances based on the provided argument . |
23,338 | LogMetadata withUpdateVersion ( int value ) { Preconditions . checkArgument ( value >= this . updateVersion . get ( ) , "versions must increase" ) ; this . updateVersion . set ( value ) ; return this ; } | Updates the current version of the metadata . |
23,339 | LogMetadata asEnabled ( ) { return this . enabled ? this : new LogMetadata ( this . epoch , true , this . ledgers , this . truncationAddress , this . updateVersion . get ( ) ) ; } | Returns a LogMetadata class with the exact contents of this instance but the enabled flag set to true . No changes are performed on this instance . |
23,340 | LogMetadata asDisabled ( ) { return this . enabled ? new LogMetadata ( this . epoch , false , this . ledgers , this . truncationAddress , this . updateVersion . get ( ) ) : this ; } | Returns a LogMetadata class with the exact contents of this instance but the enabled flag set to false . No changes are performed on this instance . |
23,341 | LedgerMetadata getLedger ( long ledgerId ) { int index = getLedgerMetadataIndex ( ledgerId ) ; if ( index >= 0 ) { return this . ledgers . get ( index ) ; } return null ; } | Gets the LedgerMetadata for the ledger with given ledger Id . |
23,342 | LedgerAddress getNextAddress ( LedgerAddress address , long lastEntryId ) { if ( this . ledgers . size ( ) == 0 ) { return null ; } LedgerAddress result = null ; LedgerMetadata firstLedger = this . ledgers . get ( 0 ) ; if ( address . getLedgerSequence ( ) < firstLedger . getSequence ( ) ) { result = new LedgerAddress ... | Gets the Ledger Address immediately following the given address . |
23,343 | synchronized void remove ( PageWrapper page ) { super . remove ( page ) ; if ( this . incompleteNewPageOffset == page . getOffset ( ) ) { this . incompleteNewPageOffset = PagePointer . NO_OFFSET ; } this . deletedPageOffsets . add ( page . getOffset ( ) ) ; page . setOffset ( PagePointer . NO_OFFSET ) ; } | Removes the given PageWrapper from this PageCollection . |
23,344 | synchronized void complete ( PageWrapper page ) { Preconditions . checkArgument ( this . pageByOffset . containsKey ( page . getOffset ( ) ) , "Given page is not registered." ) ; Preconditions . checkArgument ( this . incompleteNewPageOffset == PagePointer . NO_OFFSET || this . incompleteNewPageOffset == page . getOffs... | Indicates that any modifications to the given PageWrapper have completed . |
23,345 | synchronized void collectPages ( Collection < Long > offsets , Collection < PageWrapper > target ) { offsets . forEach ( offset -> { PageWrapper p = this . pageByOffset . getOrDefault ( offset , null ) ; if ( p != null ) { target . add ( p ) ; } } ) ; } | Collects the PageWrappers with given offsets into the given Collection . |
23,346 | synchronized List < PageWrapper > getPagesSortedByOffset ( ) { return this . pageByOffset . values ( ) . stream ( ) . sorted ( Comparator . comparingLong ( PageWrapper :: getOffset ) ) . collect ( Collectors . toList ( ) ) ; } | Gets a new List containing all the PageWrappers in this PageCollection ordered by their offset . |
23,347 | public < ReturnType > CompletableFuture < ReturnType > add ( Supplier < CompletableFuture < ? extends ReturnType > > toRun ) { CompletableFuture < ReturnType > result = new CompletableFuture < > ( ) ; CompletableFuture < ? > existingTask ; synchronized ( this . lock ) { Exceptions . checkNotClosed ( this . closed , thi... | Queues up a new task to execute . |
23,348 | public Collection < WriterSegmentProcessor > createWriterSegmentProcessors ( UpdateableSegmentMetadata metadata ) { Exceptions . checkNotClosed ( this . closed . get ( ) , this ) ; if ( ! metadata . getAttributes ( ) . containsKey ( TableAttributes . INDEX_OFFSET ) ) { return Collections . emptyList ( ) ; } return Coll... | region ContainerTableExtension Implementation |
23,349 | public void registerAndRunReleaser ( Runnable willCallRelease , CompletableFuture < T > toNotify ) { boolean run = false ; boolean complete = false ; T result = null ; Throwable e = null ; synchronized ( lock ) { if ( released ) { complete = true ; result = this . result ; e = this . e ; } else { waitingFutures . add (... | If the latch is released completes the provided future without invoking the provided runnable . If the latch is not released it will add the provided future to the list to be notified and runs the provided runnable if there is not already one running . |
23,350 | public ServiceBuilder withDataLogFactory ( Function < ComponentSetup , DurableDataLogFactory > dataLogFactoryCreator ) { Preconditions . checkNotNull ( dataLogFactoryCreator , "dataLogFactoryCreator" ) ; this . dataLogFactoryCreator = dataLogFactoryCreator ; return this ; } | Attaches the given DurableDataLogFactory creator to this ServiceBuilder . The given Function will only not be invoked right away ; it will be called when needed . |
23,351 | public ServiceBuilder withStorageFactory ( Function < ComponentSetup , StorageFactory > storageFactoryCreator ) { Preconditions . checkNotNull ( storageFactoryCreator , "storageFactoryCreator" ) ; this . storageFactoryCreator = storageFactoryCreator ; return this ; } | Attaches the given StorageFactory creator to this ServiceBuilder . The given Function will only not be invoked right away ; it will be called when needed . |
23,352 | public ServiceBuilder withContainerManager ( Function < ComponentSetup , SegmentContainerManager > segmentContainerManagerCreator ) { Preconditions . checkNotNull ( segmentContainerManagerCreator , "segmentContainerManagerCreator" ) ; this . segmentContainerManagerCreator = segmentContainerManagerCreator ; return this ... | Attaches the given SegmentContainerManager creator to this ServiceBuilder . The given Function will only not be invoked right away ; it will be called when needed . |
23,353 | public ServiceBuilder withCacheFactory ( Function < ComponentSetup , CacheFactory > cacheFactoryCreator ) { Preconditions . checkNotNull ( cacheFactoryCreator , "cacheFactoryCreator" ) ; this . cacheFactoryCreator = cacheFactoryCreator ; return this ; } | Attaches the given CacheFactory creator to this ServiceBuilder . The given Function will only not be invoked right away ; it will be called when needed . |
23,354 | public ServiceBuilder withStreamSegmentStore ( Function < ComponentSetup , StreamSegmentStore > streamSegmentStoreCreator ) { Preconditions . checkNotNull ( streamSegmentStoreCreator , "streamSegmentStoreCreator" ) ; this . streamSegmentStoreCreator = streamSegmentStoreCreator ; return this ; } | Attaches the given StreamSegmentStore creator to this ServiceBuilder . The given Function will not be invoked right away ; it will be called when needed . |
23,355 | public TableStore createTableStoreService ( ) { return getSingleton ( this . tableStoreService , setup -> new TableService ( setup . getContainerRegistry ( ) , setup . getSegmentToContainerMapper ( ) ) ) ; } | Creates a new instance of TableStore using the components generated by this class . |
23,356 | public void initialize ( ) throws DurableDataLogException { this . cacheManager . startAsync ( ) . awaitRunning ( ) ; getSingleton ( this . dataLogFactory , this . dataLogFactoryCreator ) . initialize ( ) ; getSingleton ( this . containerManager , this . segmentContainerManagerCreator ) . initialize ( ) ; } | Initializes the ServiceBuilder . |
23,357 | public static ServiceBuilder newInMemoryBuilder ( ServiceBuilderConfig builderConfig , ExecutorBuilder executorBuilder ) { ServiceConfig serviceConfig = builderConfig . getConfig ( ServiceConfig :: builder ) ; ServiceBuilder builder ; if ( serviceConfig . isReadOnlySegmentStore ( ) ) { builder = new ReadOnlyServiceBuil... | Creates a new instance of the ServiceBuilder class which is contained in memory . Any data added to this service will be lost when the object is garbage collected or the process terminates . |
23,358 | public < T extends Notification > void removeListener ( final String type , final Listener < T > listener ) { map . get ( type ) . removeIf ( e -> e . getListener ( ) . equals ( listener ) ) ; } | Remove Listener of a given notification type . |
23,359 | private < R > CompletableFuture < R > supplyAsync ( Callable < R > operation , String ... segmentNames ) { Exceptions . checkNotClosed ( this . closed . get ( ) , this ) ; return this . taskProcessor . add ( Arrays . asList ( segmentNames ) , ( ) -> execute ( operation ) ) ; } | Executes the given Callable asynchronously and returns a CompletableFuture that will be completed with the result . |
23,360 | private CompletableFuture < Void > runAsync ( RunnableWithException operation , String ... segmentNames ) { return supplyAsync ( ( ) -> { operation . run ( ) ; return null ; } , segmentNames ) ; } | Executes the given RunnableWithException asynchronously and returns a CompletableFuture that will be completed when the Runnable completes . |
23,361 | private < R > CompletableFuture < R > execute ( Callable < R > operation ) { return CompletableFuture . supplyAsync ( ( ) -> { try { return operation . call ( ) ; } catch ( Exception ex ) { throw new CompletionException ( ex ) ; } } , this . executor ) ; } | Executes the given Callable synchronously and invokes cleanup when done . |
23,362 | public static String ofStreamInScope ( String scopeName , String streamName ) { Exceptions . checkNotNullOrEmpty ( streamName , "streamName" ) ; return String . format ( "%s/%s" , ofStreamsInScope ( scopeName ) , streamName ) ; } | Creates a resource representation for use in authorization of actions pertaining to the specified stream within the specified scope . |
23,363 | public static String ofReaderGroupInScope ( String scopeName , String readerGroupName ) { Exceptions . checkNotNullOrEmpty ( readerGroupName , "readerGroupName" ) ; return String . format ( "%s/%s" , ofReaderGroupsInScope ( scopeName ) , readerGroupName ) ; } | Creates a resource representation for use in authorization of actions pertaining to the specified reader group within the specified scope . |
23,364 | public static Throwable unwrap ( Throwable ex ) { if ( canInspectCause ( ex ) ) { Throwable cause = ex . getCause ( ) ; if ( cause != null ) { return unwrap ( cause ) ; } } return ex ; } | If the provided exception is a CompletionException or ExecutionException which need be unwrapped . |
23,365 | public static boolean shouldUnwrap ( Class < ? extends Exception > c ) { return c . equals ( CompletionException . class ) || c . equals ( ExecutionException . class ) ; } | Returns true if the provided class is CompletionException or ExecutionException which need to be unwrapped . |
23,366 | public static String checkNotNullOrEmpty ( String arg , String argName ) throws NullPointerException , IllegalArgumentException { Preconditions . checkNotNull ( arg , argName ) ; checkArgument ( arg . length ( ) > 0 , argName , "Cannot be an empty string." ) ; return arg ; } | Throws a NullPointerException if the arg argument is null . Throws an IllegalArgumentException if the String arg argument has a length of zero . |
23,367 | public static < T , V extends Collection < T > > V checkNotNullOrEmpty ( V arg , String argName ) throws NullPointerException , IllegalArgumentException { Preconditions . checkNotNull ( arg , argName ) ; checkArgument ( ! arg . isEmpty ( ) , argName , "Cannot be an empty collection." ) ; return arg ; } | Throws a NullPointerException if the arg argument is null . Throws an IllegalArgumentException if the Collections arg argument has a size of zero . |
23,368 | public static < K , V > Map < K , V > checkNotNullOrEmpty ( Map < K , V > arg , String argName ) throws NullPointerException , IllegalArgumentException { Preconditions . checkNotNull ( arg , argName ) ; checkArgument ( ! arg . isEmpty ( ) , argName , "Cannot be an empty map." ) ; return arg ; } | Throws a NullPointerException if the arg argument is null . Throws an IllegalArgumentException if the Map arg argument has a size of zero . |
23,369 | public static void checkArgument ( boolean validCondition , String argName , String message , Object ... args ) throws IllegalArgumentException { if ( ! validCondition ) { throw new IllegalArgumentException ( badArgumentMessage ( argName , message , args ) ) ; } } | Throws an IllegalArgumentException if the validCondition argument is false . |
23,370 | public static void checkArrayRange ( long startIndex , int length , long arrayLength , String startIndexArgName , String lengthArgName ) throws ArrayIndexOutOfBoundsException , IllegalArgumentException { if ( length < 0 ) { throw new IllegalArgumentException ( badArgumentMessage ( lengthArgName , "length must be a non-... | Throws an appropriate exception if the given range is not included in the given array interval . |
23,371 | CompletableFuture < Void > removeEntities ( String scope , String stream , Collection < Long > entities ) { Set < Integer > collections = entities . stream ( ) . collect ( Collectors . groupingBy ( x -> new Position ( x ) . collectionNumber ) ) . keySet ( ) ; return Futures . allOf ( entities . stream ( ) . map ( entit... | Method to remove entities from the ordered set . Entities are referred to by their position pointer . |
23,372 | private CompletableFuture < Void > tryDeleteSealedCollection ( String scope , String stream , Integer collectionNum ) { return getLatestCollection ( scope , stream ) . thenCompose ( latestcollectionNum -> storeHelper . getChildren ( getEntitiesPath ( scope , stream , collectionNum ) ) . thenCompose ( entitiesPos -> { S... | Collection should be sealed while calling this method |
23,373 | void preProcessOperation ( StreamSegmentAppendOperation operation ) throws StreamSegmentSealedException , StreamSegmentMergedException , BadOffsetException , BadAttributeUpdateException { ensureSegmentId ( operation ) ; if ( this . merged ) { throw new StreamSegmentMergedException ( this . name ) ; } if ( this . sealed... | Pre - processes a StreamSegmentAppendOperation . After this method returns the given operation will have its SegmentOffset property set to the current SegmentLength and all AttributeUpdates will be set to the current values . |
23,374 | void preProcessOperation ( UpdateAttributesOperation operation ) throws StreamSegmentSealedException , StreamSegmentMergedException , BadAttributeUpdateException { ensureSegmentId ( operation ) ; if ( this . merged ) { throw new StreamSegmentMergedException ( this . name ) ; } if ( this . sealed ) { throw new StreamSeg... | Pre - processes a UpdateAttributesOperation . After this method returns the given operation will have its AttributeUpdates set to the current values of those attributes . |
23,375 | void preProcessOperation ( StreamSegmentSealOperation operation ) throws StreamSegmentSealedException , StreamSegmentMergedException { ensureSegmentId ( operation ) ; if ( this . merged ) { throw new StreamSegmentMergedException ( this . name ) ; } if ( this . sealed ) { throw new StreamSegmentSealedException ( this . ... | Pre - processes a StreamSegmentSealOperation . After this method returns the operation will have its SegmentLength property set to the current length of the Segment . |
23,376 | void preProcessOperation ( StreamSegmentTruncateOperation operation ) throws BadOffsetException { ensureSegmentId ( operation ) ; if ( operation . getStreamSegmentOffset ( ) < this . startOffset || operation . getStreamSegmentOffset ( ) > this . length ) { String msg = String . format ( "Truncation Offset must be at le... | Pre - processes a StreamSegmentTruncateOperation . |
23,377 | void preProcessAsSourceSegment ( MergeSegmentOperation operation ) throws StreamSegmentNotSealedException , StreamSegmentMergedException , StreamSegmentTruncatedException { Exceptions . checkArgument ( this . id == operation . getSourceSegmentId ( ) , "operation" , "Invalid Operation Source Segment Id." ) ; if ( this .... | Pre - processes the given operation as a Source Segment . |
23,378 | void acceptOperation ( StreamSegmentAppendOperation operation ) throws MetadataUpdateException { ensureSegmentId ( operation ) ; if ( operation . getStreamSegmentOffset ( ) != this . length ) { throw new MetadataUpdateException ( this . containerId , String . format ( "SegmentAppendOperation offset mismatch. Expected %... | Accepts a StreamSegmentAppendOperation in the metadata . |
23,379 | void acceptOperation ( UpdateAttributesOperation operation ) { ensureSegmentId ( operation ) ; acceptAttributes ( operation . getAttributeUpdates ( ) ) ; this . isChanged = true ; } | Accepts an UpdateAttributesOperation in the metadata . |
23,380 | void acceptOperation ( StreamSegmentSealOperation operation ) throws MetadataUpdateException { ensureSegmentId ( operation ) ; if ( operation . getStreamSegmentOffset ( ) < 0 ) { throw new MetadataUpdateException ( containerId , "StreamSegmentSealOperation cannot be accepted if it hasn't been pre-processed: " + operati... | Accepts a StreamSegmentSealOperation in the metadata . |
23,381 | void acceptOperation ( StreamSegmentTruncateOperation operation ) { ensureSegmentId ( operation ) ; this . startOffset = operation . getStreamSegmentOffset ( ) ; this . isChanged = true ; } | Accepts a StreamSegmentTruncateOperation in the metadata . |
23,382 | void acceptAsSourceSegment ( MergeSegmentOperation operation ) { Exceptions . checkArgument ( this . id == operation . getSourceSegmentId ( ) , "operation" , "Invalid Operation Source Segment Id." ) ; this . sealed = true ; this . merged = true ; this . isChanged = true ; } | Accepts the given operation as a Source Segment . |
23,383 | private void acceptAttributes ( Collection < AttributeUpdate > attributeUpdates ) { if ( attributeUpdates == null ) { return ; } for ( AttributeUpdate au : attributeUpdates ) { this . attributeUpdates . put ( au . getAttributeId ( ) , au . getValue ( ) ) ; } } | Accepts a collection of AttributeUpdates in the metadata . |
23,384 | void updateStorageState ( long storageLength , boolean storageSealed , boolean deleted , boolean storageDeleted ) { this . storageLength = storageLength ; this . sealedInStorage = storageSealed ; this . deleted = deleted ; this . deletedInStorage = storageDeleted ; this . isChanged = true ; } | Updates the transaction with the given state of the segment in storage . |
23,385 | void apply ( UpdateableSegmentMetadata target ) { if ( ! this . isChanged ) { return ; } Preconditions . checkArgument ( target . getId ( ) == this . id , "Target Segment Id mismatch. Expected %s, given %s." , this . id , target . getId ( ) ) ; Preconditions . checkArgument ( target . getName ( ) . equals ( this . name... | Applies all the outstanding changes to the base SegmentMetadata object . |
23,386 | public CompletableFuture < CreateScopeStatus > createScope ( final String scopeName ) { return getScope ( scopeName ) . createScope ( ) . handle ( ( result , ex ) -> { if ( ex == null ) { return CreateScopeStatus . newBuilder ( ) . setStatus ( CreateScopeStatus . Status . SUCCESS ) . build ( ) ; } if ( ex instanceof St... | Create a scope with given name . |
23,387 | public CompletableFuture < DeleteScopeStatus > deleteScope ( final String scopeName ) { return getScope ( scopeName ) . deleteScope ( ) . handle ( ( result , e ) -> { Throwable ex = Exceptions . unwrap ( e ) ; if ( ex == null ) { return DeleteScopeStatus . newBuilder ( ) . setStatus ( DeleteScopeStatus . Status . SUCCE... | Delete a scope with given name . |
23,388 | public CompletableFuture < Boolean > sealSegment ( final String scope , final String stream , final long segmentId , String delegationToken , final long clientRequestId ) { final Controller . NodeUri uri = getSegmentUri ( scope , stream , segmentId ) ; final String qualifiedName = getQualifiedStreamSegmentName ( scope ... | This method sends segment sealed message for the specified segment . |
23,389 | public CompletableFuture < Boolean > createTableSegment ( final String tableName , String delegationToken , final long clientRequestId ) { final CompletableFuture < Boolean > result = new CompletableFuture < > ( ) ; final Controller . NodeUri uri = getTableUri ( tableName ) ; final WireCommandType type = WireCommandTyp... | This method sends a WireCommand to create a table segment . |
23,390 | public CompletableFuture < Boolean > deleteTableSegment ( final String tableName , final boolean mustBeEmpty , String delegationToken , final long clientRequestId ) { final CompletableFuture < Boolean > result = new CompletableFuture < > ( ) ; final Controller . NodeUri uri = getTableUri ( tableName ) ; final WireComma... | This method sends a WireCommand to delete a table segment . |
23,391 | public CompletableFuture < TableSegment . IteratorItem < TableKey < byte [ ] > > > readTableKeys ( final String tableName , final int suggestedKeyCount , final IteratorState state , final String delegationToken , final long clientRequestId ) { final Controller . NodeUri uri = getTableUri ( tableName ) ; final WireComma... | The method sends a WireCommand to iterate over table keys . |
23,392 | private void sendRequestAsync ( final WireCommand request , final ReplyProcessor replyProcessor , final CompletableFuture < ? > resultFuture , final PravegaNodeUri uri ) { try { CompletableFuture < ConnectionWrapper > connectionFuture = connectionManager . getConnection ( uri , replyProcessor ) ; connectionFuture . whe... | This method takes a new connection from the pool and associates replyProcessor with that connection and sends the supplied request over that connection . It takes a resultFuture that is completed when the response from the store is processed successfully . If there is a failure in establishing connection or sending the... |
23,393 | private void connectionCompleteCallback ( WireCommand request , CompletableFuture < ? > resultFuture , ConnectionWrapper connection , Throwable e ) { if ( connection == null || e != null ) { ConnectionFailedException cause = e != null ? new ConnectionFailedException ( e ) : new ConnectionFailedException ( ) ; resultFut... | Connection completion callback method . This is invoked when the future returned by the connection pool completes . If it succeeded we will have a connection object where send the request . If it failed the resultFuture is failed with ConnectionFailedException . |
23,394 | private void requestCompleteCallback ( CompletableFuture < ConnectionWrapper > connectionFuture , Throwable e ) { if ( e != null ) { Throwable unwrap = Exceptions . unwrap ( e ) ; if ( hasConnectionFailed ( unwrap ) ) { connectionFuture . thenAccept ( connectionObject -> { connectionObject . failConnection ( ) ; connec... | Request Complete callback is invoked when the request is complete either by sending and receiving a response from segment store or by way of failure of connection . This is responsible for returning the connection back to the connection pool . |
23,395 | public static ThreadFactory getThreadFactory ( String groupName ) { return new ThreadFactory ( ) { final AtomicInteger threadCount = new AtomicInteger ( ) ; public Thread newThread ( Runnable r ) { Thread thread = new Thread ( r , groupName + "-" + threadCount . incrementAndGet ( ) ) ; thread . setDaemon ( true ) ; ret... | Creates and returns a thread factory that will create threads with the given name prefix . |
23,396 | public static ScheduledExecutorService newScheduledThreadPool ( int size , String poolName ) { ScheduledThreadPoolExecutor result = new ScheduledThreadPoolExecutor ( size , getThreadFactory ( poolName ) , new CallerRuns ( ) ) ; result . setContinueExistingPeriodicTasksAfterShutdownPolicy ( false ) ; result . setExecute... | Creates a new ScheduledExecutorService that will use daemon threads with appropriate names the threads . |
23,397 | public static Snapshot getSnapshot ( ExecutorService service ) { Preconditions . checkNotNull ( service , "service" ) ; if ( service instanceof ThreadPoolExecutor ) { val tpe = ( ThreadPoolExecutor ) service ; return new Snapshot ( tpe . getQueue ( ) . size ( ) , tpe . getActiveCount ( ) , tpe . getPoolSize ( ) ) ; } e... | Gets a snapshot of the given ExecutorService . |
23,398 | public static ThreadPoolExecutor getShrinkingExecutor ( int maxThreadCount , int threadTimeout , String poolName ) { return new ThreadPoolExecutor ( 0 , maxThreadCount , threadTimeout , TimeUnit . MILLISECONDS , new LinkedBlockingQueue < > ( ) , getThreadFactory ( poolName ) , new CallerRuns ( ) ) ; } | Operates like Executors . cachedThreadPool but with a custom thread timeout and pool name . |
23,399 | public static void execute ( RunnableWithException task , Consumer < Throwable > exceptionHandler , Runnable runFinally , Executor executor ) { Preconditions . checkNotNull ( task , "task" ) ; Preconditions . checkNotNull ( exceptionHandler , "exceptionHandler" ) ; Preconditions . checkNotNull ( runFinally , "runFinall... | Executes the given task on the given Executor . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.