idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
136,800 | public static Message buildSyncHistory ( Zxid lastZxid ) { ZabMessage . Zxid zxid = toProtoZxid ( lastZxid ) ; ZabMessage . SyncHistory sync = ZabMessage . SyncHistory . newBuilder ( ) . setLastZxid ( zxid ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . SYNC_HISTORY ) . setSyncHistory ( sync )... | Creates a SYNC_HISTORY message . Leader will synchronize everything it has to follower after receiving this message . |
136,801 | public static Message buildSyncHistoryReply ( int timeout ) { ZabMessage . SyncHistoryReply reply = ZabMessage . SyncHistoryReply . newBuilder ( ) . setSyncTimeout ( timeout ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . SYNC_HISTORY_REPLY ) . setSyncHistoryReply ( reply ) . build ( ) ; } | Creates the SYNC_HISTORY_REPLY message . It s the first time to tell the joiner the synchronization timeout . |
136,802 | public static Message buildElectionInfo ( String vote , Zxid lastZxid , long ackEpoch , long round , boolean electing ) { ZabMessage . Zxid zxid = toProtoZxid ( lastZxid ) ; ZabMessage . ElectionInfo ei = ZabMessage . ElectionInfo . newBuilder ( ) . setVote ( vote ) . setZxid ( zxid ) . setAckEpoch ( ackEpoch ) . setIs... | Creates the ELECTION_INFO message . |
136,803 | public static Message buildSnapshotDone ( String filePath ) { ZabMessage . SnapshotDone done = ZabMessage . SnapshotDone . newBuilder ( ) . setFilePath ( filePath ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . SNAPSHOT_DONE ) . setSnapshotDone ( done ) . build ( ) ; } | Creates the SNAPSHOT_DONE message . |
136,804 | void deliverPendingFlushes ( Zxid zxid ) { if ( ! flushQueue . isEmpty ( ) ) { while ( flushQueue . peek ( ) != null ) { PendingFlush flush = flushQueue . peek ( ) ; if ( flush . getWaitZxid ( ) . compareTo ( zxid ) <= 0 ) { Tuple tp = pendings . pendingFlushes . remove ( 0 ) ; if ( tp == null ) { throw new RuntimeExce... | given zxid . |
136,805 | public void join ( String peer ) throws Exception { try { List < String > peers = new ArrayList < String > ( ) ; peers . add ( this . serverId ) ; ClusterConfiguration cnf = new ClusterConfiguration ( new Zxid ( 0 , 0 ) , peers , this . serverId ) ; persistence . setLastSeenConfig ( cnf ) ; ByteBuffer cop = cnf . toByt... | Starts from joining leader itself . |
136,806 | void waitProposedEpochFromQuorum ( ) throws InterruptedException , TimeoutException , IOException { ClusterConfiguration currentConfig = persistence . getLastSeenConfig ( ) ; long acknowledgedEpoch = persistence . getAckEpoch ( ) ; while ( this . quorumMap . size ( ) < getQuorumSize ( ) - 1 ) { MessageTuple tuple = fil... | Waits until receives the CEPOCH message from the quorum . |
136,807 | void proposeNewEpoch ( ) throws IOException { long maxEpoch = persistence . getProposedEpoch ( ) ; int maxSyncTimeoutMs = getSyncTimeoutMs ( ) ; for ( PeerHandler ph : this . quorumMap . values ( ) ) { if ( ph . getLastProposedEpoch ( ) > maxEpoch ) { maxEpoch = ph . getLastProposedEpoch ( ) ; } if ( ph . getSyncTimeou... | Finds an epoch number which is higher than any proposed epoch in quorum set and propose the epoch to them . |
136,808 | void broadcast ( Iterator < String > peers , Message message ) { transport . broadcast ( peers , message ) ; } | Broadcasts the message to all the peers . |
136,809 | void waitEpochAckFromQuorum ( ) throws InterruptedException , TimeoutException { int ackCount = 0 ; while ( ackCount < this . quorumMap . size ( ) ) { MessageTuple tuple = filter . getExpectedMessage ( MessageType . ACK_EPOCH , null , config . getTimeoutMs ( ) ) ; Message msg = tuple . getMessage ( ) ; String source = ... | Waits until the new epoch is established . |
136,810 | String selectSyncHistoryOwner ( ) throws IOException { long ackEpoch = persistence . getAckEpoch ( ) ; Zxid zxid = persistence . getLatestZxid ( ) ; String peerId = this . serverId ; Iterator < Map . Entry < String , PeerHandler > > iter ; iter = this . quorumMap . entrySet ( ) . iterator ( ) ; while ( iter . hasNext (... | Finds a server who has the largest acknowledged epoch and longest history . |
136,811 | void synchronizeFromFollower ( String peerId ) throws IOException , TimeoutException , InterruptedException { LOG . debug ( "Begins synchronizing from follower {}." , peerId ) ; Zxid lastZxid = persistence . getLatestZxid ( ) ; Message pullTxn = MessageBuilder . buildPullTxnReq ( lastZxid ) ; LOG . debug ( "Last zxid o... | Pulls the history from the server who has the best history . |
136,812 | void waitNewLeaderAckFromQuorum ( ) throws TimeoutException , InterruptedException , IOException { LOG . debug ( "Waiting for synchronization to followers complete." ) ; int completeCount = 0 ; Zxid lastZxid = persistence . getLatestZxid ( ) ; while ( completeCount < this . quorumMap . size ( ) ) { MessageTuple tuple =... | Waits for synchronization to followers complete . |
136,813 | void beginSynchronizing ( ) throws IOException { Zxid lastZxid = persistence . getLatestZxid ( ) ; ClusterConfiguration clusterConfig = persistence . getLastSeenConfig ( ) ; long proposedEpoch = persistence . getProposedEpoch ( ) ; for ( PeerHandler ph : this . quorumMap . values ( ) ) { ph . setSyncTask ( new SyncPeer... | Starts synchronizing peers in background threads . |
136,814 | void broadcasting ( ) throws TimeoutException , InterruptedException , IOException , ExecutionException { broadcastingInit ( ) ; try { while ( this . quorumMap . size ( ) >= clusterConfig . getQuorumSize ( ) ) { MessageTuple tuple = filter . getMessage ( config . getTimeoutMs ( ) ) ; Message msg = tuple . getMessage ( ... | Entering broadcasting phase leader broadcasts proposal to followers . |
136,815 | private Zxid getNextProposedZxid ( ) { if ( lastProposedZxid . getEpoch ( ) != establishedEpoch ) { lastProposedZxid = new Zxid ( establishedEpoch , - 1 ) ; } lastProposedZxid = new Zxid ( establishedEpoch , lastProposedZxid . getXid ( ) + 1 ) ; return lastProposedZxid ; } | Gets next proposed zxid for leader in broadcasting phase . |
136,816 | private static boolean isCompilationDisabledCondition ( Expression condition ) { Object conditionValue = condition . accept ( new ConditionalCompilationConditionEvaluator ( ) , null ) ; return Boolean . FALSE . equals ( conditionValue ) ; } | Is value of expression definitely false following conditional compilation rules? |
136,817 | private static void includeColumnRecursive ( List < OrcProto . Type > types , boolean [ ] result , int typeId ) { result [ typeId ] = true ; OrcProto . Type type = types . get ( typeId ) ; int children = type . getSubtypesCount ( ) ; for ( int i = 0 ; i < children ; ++ i ) { includeColumnRecursive ( types , result , ty... | Recurse down into a type subtree turning on all of the sub - columns . |
136,818 | private static boolean [ ] findIncludedColumns ( List < OrcProto . Type > types , Configuration conf ) { String includedStr = conf . get ( ColumnProjectionUtils . READ_COLUMN_IDS_CONF_STR ) ; if ( includedStr == null || includedStr . trim ( ) . length ( ) == 0 ) { return null ; } else { int numColumns = types . size ( ... | Take the configuration and figure out which columns we need to include . |
136,819 | public void shutdown ( ) throws InterruptedException { try { channel . close ( ) ; for ( Map . Entry < String , Sender > entry : senders . entrySet ( ) ) { entry . getValue ( ) . shutdown ( ) ; } senders . clear ( ) ; for ( Map . Entry < String , ChannelHandlerContext > entry : receivers . entrySet ( ) ) { entry . getV... | Destroys the transport . |
136,820 | private List < Map . Entry < StreamName , BufferedStream > > cleanUpStreams ( ) throws IOException { List < Map . Entry < StreamName , BufferedStream > > streamList = new ArrayList < Map . Entry < StreamName , BufferedStream > > ( streams . size ( ) ) ; Map < StreamName , Integer > indexMap = new HashMap < StreamName ,... | read the data . |
136,821 | public Object next ( Object previous ) throws IOException { DoubleWritable result = null ; if ( valuePresent ) { result = createWritable ( previous , readDouble ( ) ) ; } return result ; } | Give the next double as a Writable object . |
136,822 | public void fill ( byte value ) { int offset = 0 ; int length = size ; long longValue = Longs . fromBytes ( value , value , value , value , value , value , value , value ) ; while ( length >= SizeOf . SIZE_OF_LONG ) { unsafe . putLong ( base , address + offset , longValue ) ; offset += SizeOf . SIZE_OF_LONG ; length -=... | Fill the slice with the specified value ; |
136,823 | public byte [ ] getBytes ( int index , int length ) { byte [ ] bytes = new byte [ length ] ; getBytes ( index , bytes , 0 , length ) ; return bytes ; } | Returns a copy of this buffer as a byte array . |
136,824 | public Slice slice ( int index , int length ) { if ( ( index == 0 ) && ( length == length ( ) ) ) { return this ; } checkIndexLength ( index , length ) ; if ( length == 0 ) { return Slices . EMPTY_SLICE ; } return new Slice ( base , address + index , length , reference ) ; } | Returns a slice of this buffer s sub - region . Modifying the content of the returned buffer or this buffer affects each other s content . |
136,825 | @ SuppressWarnings ( "ObjectEquality" ) public int compareTo ( int offset , int length , Slice that , int otherOffset , int otherLength ) { return compareTo ( offset , length , that . base , otherOffset , otherLength ) ; } | Compares a portion of this slice with a portion of the specified slice . Equality is solely based on the contents of the slice . |
136,826 | synchronized void addWriter ( final Path path , final long requestedAllocation , final Callback callback , final long initialAllocation ) throws IOException { WriterInfo oldVal = writerList . get ( path ) ; if ( oldVal == null ) { LOG . info ( "Registering writer for path " + path . toString ( ) ) ; oldVal = new Writer... | Add a new writer s memory allocation to the pool . We use the path as a unique key to ensure that we don t get duplicates . |
136,827 | synchronized void removeWriter ( Path path ) throws IOException { WriterInfo val = writerList . get ( path ) ; if ( val != null ) { LOG . info ( "Unregeristering writer for path " + path . toString ( ) ) ; writerList . remove ( path ) ; totalAllocation -= val . allocation ; updateScale ( false ) ; } } | Remove the given writer from the pool . |
136,828 | private synchronized void notifyWriters ( ) throws IOException { LOG . debug ( "Notifying writers after " + rowsAddedSinceCheck ) ; for ( WriterInfo writer : writerList . values ( ) ) { if ( lowMemoryMode ) { if ( writer . flushedCount == 0 ) { writersForDeallocation . add ( writer ) ; } else if ( writer . flushedCount... | Notify all of the writers that they should check their memory usage . |
136,829 | protected void grow ( int index ) { if ( ( index * literalSize ) + ( literalSize - 1 ) >= data . length ( ) ) { int newSize = Math . max ( ( index * literalSize ) + defaultSize , 2 * data . length ( ) ) ; Slice newSlice = Slices . allocate ( newSize ) ; newSlice . setBytes ( 0 , data ) ; setData ( newSlice ) ; } } | Ensure that the given index is valid . |
136,830 | public static void read ( FSDataInputStream file , long fileOffset , byte [ ] array , int arrayOffset , int length ) throws IOException { file . seek ( fileOffset ) ; file . readFully ( array , arrayOffset , length ) ; } | reads at some point . |
136,831 | public static List < Method > findOverriddenMethods ( MethodDeclaration md ) { final List < Method > methods = new ArrayList < Method > ( ) ; collectOverriddenMethods ( md , methods ) ; return methods . isEmpty ( ) ? Collections . < Method > emptyList ( ) : Collections . unmodifiableList ( methods ) ; } | Returns the methods overridden by given method declaration |
136,832 | private static boolean collectOverriddenMethods ( MethodDeclaration md , List < Method > overriddenMethods ) { final MethodSymbolData sdata = md . getSymbolData ( ) ; if ( sdata == null || isStatic ( sdata . getMethod ( ) ) || isPrivate ( sdata . getMethod ( ) ) ) { return false ; } else { boolean result = false ; fina... | Returns if any of the overriddenMethods overrides an specific method declaration . |
136,833 | private short readShort ( ) throws IOException { latestRead = ( short ) SerializationUtils . readIntegerType ( input , WriterImpl . SHORT_BYTE_SIZE , true , input . useVInts ( ) ) ; return latestRead ; } | Read a short value from the stream . |
136,834 | public void broadcast ( Iterator < String > peers , Message message ) { while ( peers . hasNext ( ) ) { send ( peers . next ( ) , message ) ; } } | Broadcasts a message to a set of peers . |
136,835 | private void addPreliminaryThis ( Scope scope , Symbol symbol , TypeDeclaration type ) { Symbol < TypeDeclaration > thisSymbol = new Symbol < TypeDeclaration > ( "this" , symbol . getType ( ) , type , ReferenceType . VARIABLE ) ; thisSymbol . setInnerScope ( scope ) ; scope . addSymbol ( thisSymbol ) ; } | preliminary this to allow depth first inheritance tree scope loading |
136,836 | protected MessageTuple getMessage ( int timeoutMs ) throws InterruptedException , TimeoutException { MessageTuple tuple = messageQueue . poll ( timeoutMs , TimeUnit . MILLISECONDS ) ; if ( tuple == null ) { throw new TimeoutException ( "Timeout while waiting for the message." ) ; } if ( tuple . getMessage ( ) . getType... | Takes the filtered message from message queue . This method will be blocked until the message becomes available or timeout is detected . |
136,837 | protected MessageTuple getExpectedMessage ( MessageType type , String source , int timeoutMs ) throws TimeoutException , InterruptedException { int startTime = ( int ) ( System . nanoTime ( ) / 1000000 ) ; while ( true ) { MessageTuple tuple = getMessage ( timeoutMs ) ; String from = tuple . getServerId ( ) ; if ( tupl... | Takes the expected message from message queue . This method will be blocked until the expected message from the expected source becomes available or timeout is detected . |
136,838 | private int getSizeOfIntArrays ( ) { return ( offsets . length + hashcodes . length + nexts . length + counts . length + indexStrides . length ) * 4 ; } | Returns the size of the int arrays used by this class it s 4 times the length of the arrays |
136,839 | public void clear ( ) { memoryEstimate . decrementDictionaryMemory ( byteArray . size ( ) ) ; byteArray . clear ( ) ; memoryEstimate . incrementDictionaryMemory ( byteArray . size ( ) ) ; htDictionary . clear ( ) ; memoryEstimate . decrementTotalMemory ( getSizeOfIntArrays ( ) ) ; offsets = new int [ DynamicIntArray . ... | Reset the table to empty . |
136,840 | private void maybeIndexResource ( String relPath , URL delegate ) { if ( ! index . containsKey ( relPath ) ) { index . put ( relPath , delegate ) ; if ( relPath . endsWith ( File . separator ) ) { maybeIndexResource ( relPath . substring ( 0 , relPath . length ( ) - File . separator . length ( ) ) , delegate ) ; } } } | Callers may request the directory itself as a resource and may do so with or without trailing slashes . We do this in a while - loop in case the classpath element has multiple superfluous trailing slashes . |
136,841 | public static void writeLongToFile ( long value , File file ) throws IOException { File temp = File . createTempFile ( file . getName ( ) , null , file . getAbsoluteFile ( ) . getParentFile ( ) ) ; try ( FileOutputStream fos = new FileOutputStream ( temp ) ; OutputStreamWriter os = new OutputStreamWriter ( fos , Charse... | Atomically writes a long integer to a file . |
136,842 | public static void writePropertiesToFile ( Properties prop , File file ) throws IOException { File temp = File . createTempFile ( file . getName ( ) , null , file . getAbsoluteFile ( ) . getParentFile ( ) ) ; try ( FileOutputStream fos = new FileOutputStream ( temp ) ) { prop . store ( fos , "" ) ; fos . getChannel ( )... | Atomically writes properties to a file . |
136,843 | public static void atomicMove ( File source , File dest ) throws IOException { Files . move ( source . toPath ( ) , dest . toPath ( ) , ATOMIC_MOVE , REPLACE_EXISTING ) ; } | Atomically move one file to another file . |
136,844 | public void send ( ByteBuffer request , Object ctx ) throws InvalidPhase , TooManyPendingRequests { this . mainThread . send ( request , ctx ) ; } | Submits a request to Zab . Under the hood followers forward requests to the leader and the leader will be responsible for converting this request to idempotent transaction and broadcasting . If you send request in non - broadcasting phase the operation will fail . |
136,845 | public void flush ( ByteBuffer request , Object ctx ) throws InvalidPhase , TooManyPendingRequests { this . mainThread . flush ( request , ctx ) ; } | Flushes a request through pipeline . The flushed request will be delivered in order with other sending requests but it will not be convereted to idempotent transaction and will not be persisted in log . And it will only be delivered on the server who issued this request . The purpose of flush is to allow implementing a... |
136,846 | public void remove ( String peerId , Object ctx ) throws InvalidPhase , TooManyPendingRequests { this . mainThread . remove ( peerId , ctx ) ; } | Removes a peer from the cluster . If you send remove request in non - broadcasting phase the operation will fail . |
136,847 | protected long countNonNulls ( long rows ) throws IOException { if ( present != null ) { long result = 0 ; for ( long c = 0 ; c < rows ; ++ c ) { if ( present . next ( ) == 1 ) { result += 1 ; } } return result ; } else { return rows ; } } | in the next rows values returns the number of values which are not null |
136,848 | public boolean nextIsNull ( long currentRow ) throws IOException { if ( present != null ) { seekToPresentRow ( currentRow ) ; valuePresent = present . next ( ) == 1 ; if ( valuePresent ) { numNonNulls ++ ; } else { if ( currentRow == previousRow + 1 ) { previousRow ++ ; } } } return ! valuePresent ; } | Returns whether or not the value corresponding to currentRow is null suitable for calling from outside |
136,849 | protected void seekToPresentRow ( long currentRow ) throws IOException { if ( currentRow != previousPresentRow + 1 ) { long rowInStripe = currentRow - rowBaseInStripe - 1 ; int rowIndexEntry = computeRowIndexEntry ( currentRow ) ; if ( rowIndexEntry != computeRowIndexEntry ( previousPresentRow ) || currentRow < previou... | Shifts only the present stream so that next will return the value for currentRow |
136,850 | public Object get ( long currentRow , Object previous ) throws IOException { seekToRow ( currentRow ) ; return next ( previous ) ; } | Returns the value corresponding to currentRow suitable for calling from outside |
136,851 | protected void seek ( int rowIndexEntry , boolean backwards ) throws IOException { if ( backwards || rowIndexEntry != computeRowIndexEntry ( previousRow ) ) { previousRowIndexEntry = rowIndexEntry ; if ( present != null && ( backwards || rowIndexEntry != computeRowIndexEntry ( previousPresentRow ) ) ) { present . seek ... | Adjust all streams to the beginning of the row index entry specified backwards means that a previous value is being read and forces the index entry to be restarted otherwise has no effect if we re already in the current index entry |
136,852 | protected boolean seekToRow ( long currentRow ) throws IOException { boolean seeked = false ; if ( currentRow != previousPresentRow ) { nextIsNull ( currentRow ) ; } if ( valuePresent ) { if ( currentRow != previousRow + 1 ) { numNonNulls -- ; long rowInStripe = currentRow - rowBaseInStripe - 1 ; int rowIndexEntry = co... | Adjusts all streams so that the next value returned corresponds to the value for currentRow suitable for calling from outside |
136,853 | public int loadIndeces ( List < RowIndexEntry > rowIndexEntries , int startIndex ) { if ( present != null ) { return present . loadIndeces ( rowIndexEntries , startIndex ) ; } else { return startIndex ; } } | Read any indeces that will be needed and return a startIndex after the values that have been read . |
136,854 | public int loadIndeces ( List < RowIndexEntry > rowIndexEntries , int startIndex ) { int updatedStartIndex = input . loadIndeces ( rowIndexEntries , startIndex ) ; int numIndeces = rowIndexEntries . size ( ) ; indeces = new int [ numIndeces + 1 ] ; int i = 0 ; for ( RowIndexEntry rowIndexEntry : rowIndexEntries ) { ind... | Read in the number of bytes consumed at each index entry and store it also call loadIndeces on child stream and return the index of the next streams indexes . |
136,855 | public int add ( byte [ ] value , int valueOffset , int valueLength ) { grow ( length + valueLength ) ; data . setBytes ( length , value , valueOffset , valueLength ) ; int result = length ; length += valueLength ; return result ; } | Copy a slice of a byte array into our buffer . |
136,856 | public void readAll ( InputStream in ) throws IOException { int read = 0 ; do { grow ( length ) ; read = data . setBytes ( length , in , data . length ( ) - length ) ; if ( read > 0 ) { length += read ; } } while ( in . available ( ) > 0 ) ; } | Read the entire stream into this array . |
136,857 | public void read ( InputStream in , int lengthToRead ) throws IOException { int read = 0 ; do { grow ( length ) ; read = data . setBytes ( length , in , Math . min ( lengthToRead , data . length ( ) - length ) ) ; length += read ; lengthToRead -= read ; } while ( lengthToRead > 0 ) ; } | Read lengthToRead bytes from the input stream into this array |
136,858 | public int compare ( byte [ ] other , int otherOffset , int otherLength , int ourOffset , int ourLength ) { return 0 - data . compareTo ( ourOffset , ourLength , other , otherOffset , otherLength ) ; } | Byte compare a set of bytes against the bytes in this dynamic array . |
136,859 | public void setText ( Text result , int offset , int length ) { result . clear ( ) ; result . set ( data . getBytes ( ) , offset , length ) ; } | Set a text value from the bytes in this dynamic array . |
136,860 | public void write ( OutputStream out , int offset , int length ) throws IOException { data . getBytes ( offset , out , length ) ; } | Write out a range of this dynamic array to an output stream . |
136,861 | long getAckEpoch ( ) throws IOException { try { long ackEpoch = FileUtils . readLongFromFile ( this . fAckEpoch ) ; return ackEpoch ; } catch ( FileNotFoundException e ) { LOG . debug ( "File not exist, initialize acknowledged epoch to -1" ) ; return - 1 ; } catch ( IOException e ) { LOG . error ( "IOException encounte... | Gets the last acknowledged epoch . |
136,862 | long getProposedEpoch ( ) throws IOException { try { long pEpoch = FileUtils . readLongFromFile ( this . fProposedEpoch ) ; return pEpoch ; } catch ( FileNotFoundException e ) { LOG . debug ( "File not exist, initialize acknowledged epoch to -1" ) ; return - 1 ; } catch ( IOException e ) { LOG . error ( "IOException en... | Gets the last proposed epoch . |
136,863 | ClusterConfiguration getLastSeenConfig ( ) throws IOException { File file = getLatestFileWithPrefix ( this . rootDir , "cluster_config" ) ; if ( file == null ) { return null ; } try { Properties prop = FileUtils . readPropertiesFromFile ( file ) ; return ClusterConfiguration . fromProperties ( prop ) ; } catch ( FileNo... | Gets last seen configuration . |
136,864 | ClusterConfiguration getLastConfigWithin ( Zxid zxid ) throws IOException { String pattern = "cluster_config\\.\\d+_-?\\d+" ; String zxidFileName = "cluster_config." + zxid . toSimpleString ( ) ; String lastFileName = null ; for ( File file : this . rootDir . listFiles ( ) ) { if ( ! file . isDirectory ( ) && file . ge... | Gets the last configuration which has version equal or smaller than zxid . |
136,865 | void setLastSeenConfig ( ClusterConfiguration conf ) throws IOException { String version = conf . getVersion ( ) . toSimpleString ( ) ; File file = new File ( rootDir , String . format ( "cluster_config.%s" , version ) ) ; FileUtils . writePropertiesToFile ( conf . toProperties ( ) , file ) ; fsyncDirectory ( ) ; } | Updates the last seen configuration . |
136,866 | File setSnapshotFile ( File tempFile , Zxid zxid ) throws IOException { File snapshot = new File ( dataDir , String . format ( "snapshot.%s" , zxid . toSimpleString ( ) ) ) ; LOG . debug ( "Atomically move snapshot file to {}" , snapshot ) ; FileUtils . atomicMove ( tempFile , snapshot ) ; fsyncDirectory ( ) ; return s... | Turns a temporary snapshot file into a valid snapshot file . |
136,867 | Zxid getSnapshotZxid ( ) { File snapshot = getSnapshotFile ( ) ; if ( snapshot == null ) { return Zxid . ZXID_NOT_EXIST ; } String fileName = snapshot . getName ( ) ; String strZxid = fileName . substring ( fileName . indexOf ( '.' ) + 1 ) ; return Zxid . fromSimpleString ( strZxid ) ; } | Gets the last zxid of transaction which is guaranteed in snapshot . |
136,868 | void endStateTransfer ( ) throws IOException { File nextDir = getNextDataDir ( ) ; FileUtils . atomicMove ( this . dataDir , nextDir ) ; this . dataDir = nextDir ; this . log = createLog ( dataDir ) ; fsyncDirectory ( ) ; this . isTransferring = false ; } | Ends state transferring mode after calling this function all the txns and snapshots persisted during the transferring mode will be visible from now . |
136,869 | File getNextDataDir ( ) { File latest = getLatestDataDir ( ) ; long newID ; if ( latest == null ) { newID = 0 ; } else { newID = Long . parseLong ( latest . getName ( ) . substring ( 4 ) ) + 1 ; } String suffix = String . format ( "%015d" , newID ) ; return new File ( this . rootDir , "data" + suffix ) ; } | Gets the next data directory . |
136,870 | void cleanupClusterConfigFiles ( ) throws IOException { Zxid latestZxid = getLatestZxid ( ) ; List < File > files = getFilesWithPrefix ( this . rootDir , "cluster_config" ) ; if ( files . isEmpty ( ) ) { LOG . error ( "There's no cluster_config files in log directory." ) ; throw new RuntimeException ( "There's no clust... | cluster_config files . |
136,871 | public SymbolType withName ( String name ) { return clone ( marker , name , arrayCount , typeVariable , null , null ) ; } | Clones replacing the symbol type name . |
136,872 | public static SymbolType typeVariableOf ( final String typeVariable , final Class < Object > clazz ) { return new SymbolType ( clazz , typeVariable ) ; } | Builds a symbol for a type variable from a Java class . |
136,873 | public static SymbolType typeVariableOf ( final String typeVariable , List < SymbolType > upperBounds ) { return new SymbolType ( upperBounds , typeVariable ) ; } | Builds a symbol for a type variable from a list of upper bounds . |
136,874 | private static SymbolType typeVariableOf ( String typeVariable , final String name , final int arrayCount , final List < SymbolType > upperBounds , final List < SymbolType > lowerBounds ) { return new SymbolType ( name , arrayCount , upperBounds , lowerBounds , typeVariable ) ; } | Builds a symbol for a type variable . |
136,875 | public static SymbolType typeVariableOf ( TypeVariable < ? > typeVariable ) throws InvalidTypeException { return valueOf ( typeVariable , null ) . cloneAsTypeVariable ( typeVariable . getName ( ) ) ; } | Builds a symbol for a type variable from a TypeVariable . |
136,876 | public static SymbolType valueOf ( Type type , SymbolType arg , Map < String , SymbolType > updatedTypeMapping , Map < String , SymbolType > typeMapping ) throws InvalidTypeException { if ( typeMapping == null ) { typeMapping = Collections . emptyMap ( ) ; } SymbolType returnType = null ; if ( type instanceof Class < ?... | Builds a symbol type from a Java type . |
136,877 | public float nextFloat ( boolean readStream ) throws IOException , ValueNotPresentException { if ( ! readStream ) { return latestRead ; } if ( ! valuePresent ) { throw new ValueNotPresentException ( "Cannot materialize float.." ) ; } return readFloat ( ) ; } | Give the next float as a primitive . |
136,878 | public static List < ? extends Class < ? > > intersectRawTypes ( List < Class < ? > > classes1 , List < Class < ? > > classes2 ) { if ( classes1 . size ( ) == 1 && classes2 . size ( ) == 1 ) { return intersectRawTypes ( classes1 . get ( 0 ) , classes2 . get ( 0 ) ) ; } else { return list ( removeSubClasses ( intersecti... | Returns the intersection of raw types of classes and all super classes and interfaces . |
136,879 | public static List < ? extends Class < ? > > intersectRawTypes ( Class < ? > clazz1 , Class < ? > clazz2 ) { if ( clazz2 == null ) { clazz2 = Object . class ; } if ( clazz1 == null ) { clazz1 = Object . class ; } if ( clazz1 . isPrimitive ( ) ) { clazz1 = Types . getWrapperClass ( clazz1 . getName ( ) ) ; } if ( clazz2... | Looks for intersection of raw types of classes and all super classes and interfaces . |
136,880 | public void join ( String peer ) throws Exception { LOG . debug ( "Follower joins in." ) ; try { LOG . debug ( "Query leader from {}" , peer ) ; Message query = MessageBuilder . buildQueryLeader ( ) ; MessageTuple tuple = null ; while ( true ) { try { sendMessage ( peer , query ) ; tuple = filter . getExpectedMessage (... | Starts from joining some one who is in cluster .. |
136,881 | void sendProposedEpoch ( ) throws IOException { Message message = MessageBuilder . buildProposedEpoch ( persistence . getProposedEpoch ( ) , persistence . getAckEpoch ( ) , persistence . getLastSeenConfig ( ) , getSyncTimeoutMs ( ) ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Sends {} to leader {}" , TextFormat... | Sends CEPOCH message to its prospective leader . |
136,882 | void waitForNewEpoch ( ) throws InterruptedException , TimeoutException , IOException { MessageTuple tuple = filter . getExpectedMessage ( MessageType . NEW_EPOCH , this . electedLeader , config . getTimeoutMs ( ) ) ; Message msg = tuple . getMessage ( ) ; String source = tuple . getServerId ( ) ; ZabMessage . NewEpoch... | Waits until receives the NEWEPOCH message from leader . |
136,883 | void waitForNewLeaderMessage ( ) throws TimeoutException , InterruptedException , IOException { LOG . debug ( "Waiting for New Leader message from {}." , this . electedLeader ) ; MessageTuple tuple = filter . getExpectedMessage ( MessageType . NEW_LEADER , this . electedLeader , config . getTimeoutMs ( ) ) ; Message ms... | Waits for NEW_LEADER message and sends back ACK and update ACK epoch . |
136,884 | void waitForCommitMessage ( ) throws TimeoutException , InterruptedException , IOException { LOG . debug ( "Waiting for commit message from {}" , this . electedLeader ) ; MessageTuple tuple = filter . getExpectedMessage ( MessageType . COMMIT , this . electedLeader , config . getTimeoutMs ( ) ) ; Zxid zxid = MessageBui... | Wait for a commit message from the leader . |
136,885 | private void joinSynchronization ( ) throws IOException , TimeoutException , InterruptedException { Message sync = MessageBuilder . buildSyncHistory ( persistence . getLatestZxid ( ) ) ; sendMessage ( this . electedLeader , sync ) ; MessageTuple tuple = filter . getExpectedMessage ( MessageType . SYNC_HISTORY_REPLY , e... | depends on the length of the synchronization . |
136,886 | public static Reader createReader ( FileSystem fs , Path path , Configuration conf ) throws IOException { return new ReaderImpl ( fs , path , conf ) ; } | Create an ORC file reader . |
136,887 | public static Writer createWriter ( FileSystem fs , Path path , Configuration conf , ObjectInspector inspector , long stripeSize , CompressionKind compress , int bufferSize , int rowIndexStride ) throws IOException { return new WriterImpl ( fs , path , conf , inspector , stripeSize , compress , bufferSize , rowIndexStr... | Create an ORC file streamFactory . |
136,888 | private int compareKinds ( Kind kind1 , Kind kind2 ) { if ( kind1 == Kind . LENGTH && kind2 == Kind . DATA ) { return - 1 ; } if ( kind1 == Kind . DATA && kind2 == Kind . LENGTH ) { return 1 ; } return kind1 . compareTo ( kind2 ) ; } | stuck with it this is just a hack to work around that . |
136,889 | protected void sendMessage ( String dest , Message message ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Sends message {} to {}." , TextFormat . shortDebugString ( message ) , dest ) ; } this . transport . send ( dest , message ) ; } | Sends message to the specific destination . |
136,890 | void waitForSyncEnd ( String peerId ) throws TimeoutException , IOException , InterruptedException { MessageTuple tuple = filter . getExpectedMessage ( MessageType . SYNC_END , peerId , getSyncTimeoutMs ( ) ) ; ClusterConfiguration cnf = ClusterConfiguration . fromProto ( tuple . getMessage ( ) . getConfig ( ) , this .... | Waits for the end of the synchronization and updates last seen config file . |
136,891 | void restoreFromSnapshot ( ) throws IOException { Zxid snapshotZxid = persistence . getSnapshotZxid ( ) ; LOG . debug ( "The last applied zxid in snapshot is {}" , snapshotZxid ) ; if ( snapshotZxid != Zxid . ZXID_NOT_EXIST && lastDeliveredZxid == Zxid . ZXID_NOT_EXIST ) { File snapshot = persistence . getSnapshotFile ... | Restores the state of user s application from snapshot file . |
136,892 | void deliverUndeliveredTxns ( ) throws IOException { LOG . debug ( "Delivering all the undelivered txns after {}" , lastDeliveredZxid ) ; Zxid startZxid = new Zxid ( lastDeliveredZxid . getEpoch ( ) , lastDeliveredZxid . getXid ( ) + 1 ) ; Log log = persistence . getLog ( ) ; try ( Log . LogIterator iter = log . getIte... | Delivers all the transactions in the log after last delivered zxid . |
136,893 | protected void clearMessageQueue ( ) { MessageTuple tuple = null ; while ( ( tuple = messageQueue . poll ( ) ) != null ) { Message msg = tuple . getMessage ( ) ; if ( msg . getType ( ) == MessageType . DISCONNECTED ) { this . transport . clear ( msg . getDisconnected ( ) . getServerId ( ) ) ; } else if ( msg . getType ... | Clears all the messages in the message queue clears the peer in transport if it s the DISCONNECTED message . This function should be called only right before going back to recovery . |
136,894 | protected int incSyncTimeout ( ) { int syncTimeoutMs = getSyncTimeoutMs ( ) ; participantState . setSyncTimeoutMs ( syncTimeoutMs * 2 ) ; LOG . debug ( "Increase the sync timeout to {}" , getSyncTimeoutMs ( ) ) ; return syncTimeoutMs ; } | Doubles the synchronizing timeout . |
136,895 | protected void adjustSyncTimeout ( int timeoutMs ) { int timeoutSec = ( timeoutMs + 999 ) / 1000 ; for ( int i = 0 ; i < 32 ; ++ i ) { if ( ( 1 << i ) >= timeoutSec ) { LOG . debug ( "Adjust timeout to {} sec" , 1 << i ) ; setSyncTimeoutMs ( ( 1 << i ) * 1000 ) ; return ; } } throw new RuntimeException ( "Timeout is to... | Adjusts the synchronizing timeout based on parameter timeoutMs . The new synchronizing timeout will be smallest timeout which is power of 2 and larger than timeoutMs . |
136,896 | void initFromDir ( ) { for ( File file : this . logDir . listFiles ( ) ) { if ( ! file . isDirectory ( ) && file . getName ( ) . matches ( "transaction\\.\\d+_\\d+" ) ) { this . logFiles . add ( file ) ; } } if ( ! this . logFiles . isEmpty ( ) ) { Collections . sort ( this . logFiles ) ; } } | Initialize from the log directory . |
136,897 | int getFileIdx ( Zxid zxid ) { if ( logFiles . isEmpty ( ) || zxid . compareTo ( getZxidFromFileName ( logFiles . get ( 0 ) ) ) < 0 ) { return - 1 ; } int idx = 0 ; while ( idx < logFiles . size ( ) - 1 ) { Zxid firstZxid = getZxidFromFileName ( logFiles . get ( idx ) ) ; if ( zxid . compareTo ( firstZxid ) == 0 ) { br... | Given the zxid find out the idx of the file in list which contains the transaction with this zxid if and only if the transaction with the zxid is in RollingLog . If the zxid is smaller than the smallest zxid in log - 1 will be returned . |
136,898 | Zxid getZxidFromFileName ( File file ) { String fileName = file . getName ( ) ; String strZxid = fileName . substring ( fileName . indexOf ( '.' ) + 1 ) ; return Zxid . fromSimpleString ( strZxid ) ; } | Given the log file finds out the smallest allowed zxid for thi file . It s infered by looking at the name of the file . |
136,899 | SimpleLog getLastLog ( ) throws IOException { if ( logFiles . isEmpty ( ) ) { return null ; } return new SimpleLog ( logFiles . get ( logFiles . size ( ) - 1 ) ) ; } | Gets the last log file in the list of logs . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.