idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
155,100
private boolean watchNextLowerNode ( ) throws KeeperException , InterruptedException { List < String > children = zk . getChildren ( dir , false ) ; Collections . sort ( children ) ; ListIterator < String > iter = children . listIterator ( ) ; String me = null ; while ( iter . hasNext ( ) ) { me = ZKUtil . joinZKPath (...
Set a watch on the node that comes before the specified node in the directory .
155,101
public CharEscaperBuilder addEscape ( char c , String r ) { map . put ( c , checkNotNull ( r ) ) ; if ( c > max ) { max = c ; } return this ; }
Add a new mapping from an index to an object to the escaping .
155,102
public CharEscaperBuilder addEscapes ( char [ ] cs , String r ) { checkNotNull ( r ) ; for ( char c : cs ) { addEscape ( c , r ) ; } return this ; }
Add multiple mappings at once for a particular index .
155,103
private void deliverReadyTxns ( ) { VoltMessage m = m_replaySequencer . poll ( ) ; while ( m != null ) { deliver ( m ) ; m = m_replaySequencer . poll ( ) ; } m = m_replaySequencer . drain ( ) ; while ( m != null ) { if ( m instanceof Iv2InitiateTaskMessage ) { Iv2InitiateTaskMessage task = ( Iv2InitiateTaskMessage ) m ...
Poll the replay sequencer and process the messages until it returns null
155,104
public boolean sequenceForReplay ( VoltMessage message ) { boolean canDeliver = false ; long sequenceWithUniqueId = Long . MIN_VALUE ; boolean commandLog = ( message instanceof TransactionInfoBaseMessage && ( ( ( TransactionInfoBaseMessage ) message ) . isForReplay ( ) ) ) ; boolean sentinel = message instanceof MultiP...
Sequence the message for replay if it s for CL or DR .
155,105
private void doLocalInitiateOffer ( Iv2InitiateTaskMessage msg ) { final VoltTrace . TraceEventBatch traceLog = VoltTrace . log ( VoltTrace . Category . SPI ) ; if ( traceLog != null ) { final String threadName = Thread . currentThread ( ) . getName ( ) ; traceLog . add ( ( ) -> VoltTrace . meta ( "process_name" , "nam...
Do the work necessary to turn the Iv2InitiateTaskMessage into a TransactionTask which can be queued to the TransactionTaskQueue . This is reused by both the normal message handling path and the repair path and assumes that the caller has dealt with or ensured that the necessary ID SpHandles and replication issues are r...
155,106
private void handleBorrowTaskMessage ( BorrowTaskMessage message ) { long newSpHandle = getMaxScheduledTxnSpHandle ( ) ; Iv2Trace . logFragmentTaskMessage ( message . getFragmentTaskMessage ( ) , m_mailbox . getHSId ( ) , newSpHandle , true ) ; final VoltTrace . TraceEventBatch traceLog = VoltTrace . log ( VoltTrace . ...
to perform replicated reads or aggregation fragment work .
155,107
void handleFragmentTaskMessage ( FragmentTaskMessage message ) { FragmentTaskMessage msg = message ; long newSpHandle ; if ( ! message . isForReplica ( ) && ( m_isLeader || message . isExecutedOnPreviousLeader ( ) ) ) { msg = new FragmentTaskMessage ( message . getInitiatorHSId ( ) , message . getCoordinatorHSId ( ) , ...
doesn t matter it isn t going to be used for anything .
155,108
public void offerPendingMPTasks ( long txnId ) { Queue < TransactionTask > pendingTasks = m_mpsPendingDurability . get ( txnId ) ; if ( pendingTasks != null ) { for ( TransactionTask task : pendingTasks ) { if ( task instanceof SpProcedureTask ) { final VoltTrace . TraceEventBatch traceLog = VoltTrace . log ( VoltTrace...
Offer all fragment tasks and complete transaction tasks queued for durability for the given MP transaction and remove the entry from the pending map so that future ones won t be queued .
155,109
private void queueOrOfferMPTask ( TransactionTask task ) { Queue < TransactionTask > pendingTasks = m_mpsPendingDurability . get ( task . getTxnId ( ) ) ; if ( pendingTasks != null ) { pendingTasks . offer ( task ) ; } else { m_pendingTasks . offer ( task ) ; } }
Check if the MP task has to be queued because the first fragment is still being logged synchronously to the command log . If not offer it to the transaction task queue .
155,110
private void handleIv2LogFaultMessage ( Iv2LogFaultMessage message ) { SettableFuture < Boolean > written = writeIv2ViableReplayEntryInternal ( message . getSpHandle ( ) ) ; blockFaultLogWriteStatus ( written ) ; setMaxSeenTxnId ( message . getSpHandle ( ) ) ; m_uniqueIdGenerator . updateMostRecentlyGeneratedUniqueId (...
Should only receive these messages at replicas when told by the leader
155,111
private void blockFaultLogWriteStatus ( SettableFuture < Boolean > written ) { boolean logWritten = false ; if ( written != null ) { try { logWritten = written . get ( ) ; } catch ( InterruptedException e ) { } catch ( ExecutionException e ) { if ( tmLog . isDebugEnabled ( ) ) { tmLog . debug ( "Could not determine fau...
Wait to get the status of a fault log write
155,112
SettableFuture < Boolean > writeIv2ViableReplayEntryInternal ( long spHandle ) { SettableFuture < Boolean > written = null ; if ( m_replayComplete ) { written = m_cl . logIv2Fault ( m_mailbox . getHSId ( ) , new HashSet < Long > ( m_replicaHSIds ) , m_partitionId , spHandle ) ; } return written ; }
Write the viable replay set to the command log with the provided SP Handle . Pass back the future that is set after the fault log is written to disk .
155,113
public void updateReplicasFromMigrationLeaderFailedHost ( int failedHostId ) { List < Long > replicas = new ArrayList < > ( ) ; for ( long hsid : m_replicaHSIds ) { if ( failedHostId != CoreUtils . getHostIdFromHSId ( hsid ) ) { replicas . add ( hsid ) ; } } ( ( InitiatorMailbox ) m_mailbox ) . updateReplicas ( replica...
update the duplicated counters after the host failure .
155,114
public void forwardPendingTaskToRejoinNode ( long [ ] replicasAdded , long snapshotSpHandle ) { if ( tmLog . isDebugEnabled ( ) ) { tmLog . debug ( "Forward pending tasks in backlog to rejoin node: " + Arrays . toString ( replicasAdded ) ) ; } if ( replicasAdded . length == 0 ) { return ; } boolean sentAny = false ; fo...
first fragment of stream snapshot and site runs the first fragment .
155,115
public void cleanupTransactionBacklogOnRepair ( ) { if ( m_isLeader && m_sendToHSIds . length > 0 ) { m_mailbox . send ( m_sendToHSIds , new MPBacklogFlushMessage ( ) ) ; } Iterator < Entry < Long , TransactionState > > iter = m_outstandingTxns . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Entry < Long...
site leaders also forward the message to its replicas .
155,116
synchronized void reset ( ) { schemaMap . clear ( ) ; sqlLookup . clear ( ) ; csidMap . clear ( ) ; sessionUseMap . clear ( ) ; useMap . clear ( ) ; next_cs_id = 0 ; }
Clears all internal data structures removing any references to compiled statements .
155,117
synchronized void resetStatements ( ) { Iterator it = csidMap . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Statement cs = ( Statement ) it . next ( ) ; cs . clearVariables ( ) ; } }
Used after a DDL change that could impact the compiled statements . Clears references to CompiledStatement objects while keeping the counts and references to the sql strings .
155,118
private long getStatementID ( HsqlName schema , String sql ) { LongValueHashMap sqlMap = ( LongValueHashMap ) schemaMap . get ( schema . hashCode ( ) ) ; if ( sqlMap == null ) { return - 1 ; } return sqlMap . get ( sql , - 1 ) ; }
Retrieves the registered compiled statement identifier associated with the specified SQL String or a value less than zero if no such statement has been registered .
155,119
public synchronized Statement getStatement ( Session session , long csid ) { Statement cs = ( Statement ) csidMap . get ( csid ) ; if ( cs == null ) { return null ; } if ( ! cs . isValid ( ) ) { String sql = ( String ) sqlLookup . get ( csid ) ; try { Session sys = database . sessionManager . getSysSession ( session . ...
Returns an existing CompiledStatement object with the given statement identifier . Returns null if the CompiledStatement object has been invalidated and cannot be recompiled
155,120
private void linkSession ( long csid , long sessionID ) { LongKeyIntValueHashMap scsMap ; scsMap = ( LongKeyIntValueHashMap ) sessionUseMap . get ( sessionID ) ; if ( scsMap == null ) { scsMap = new LongKeyIntValueHashMap ( ) ; sessionUseMap . put ( sessionID , scsMap ) ; } int count = scsMap . get ( csid , 0 ) ; scsMa...
Links a session with a registered compiled statement . If this session has not already been linked with the given statement then the statement use count is incremented .
155,121
private long registerStatement ( long csid , Statement cs ) { if ( csid < 0 ) { csid = nextID ( ) ; int schemaid = cs . getSchemaName ( ) . hashCode ( ) ; LongValueHashMap sqlMap = ( LongValueHashMap ) schemaMap . get ( schemaid ) ; if ( sqlMap == null ) { sqlMap = new LongValueHashMap ( ) ; schemaMap . put ( schemaid ...
Registers a compiled statement to be managed .
155,122
synchronized void removeSession ( long sessionID ) { LongKeyIntValueHashMap scsMap ; long csid ; Iterator i ; scsMap = ( LongKeyIntValueHashMap ) sessionUseMap . remove ( sessionID ) ; if ( scsMap == null ) { return ; } i = scsMap . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { csid = i . nextLong ( ) ; int u...
Releases the link betwen the session and all compiled statement objects it is linked to . If any such statement is not linked with any other session it is removed from management .
155,123
synchronized Statement compile ( Session session , Result cmd ) throws Throwable { String sql = cmd . getMainString ( ) ; long csid = getStatementID ( session . currentSchema , sql ) ; Statement cs = ( Statement ) csidMap . get ( csid ) ; if ( cs == null || ! cs . isValid ( ) || ! session . isAdmin ( ) ) { Session sys ...
Compiles an SQL statement and returns a CompiledStatement Object
155,124
private void startupInstance ( ) throws IOException { assert ( m_blockPathMap . isEmpty ( ) ) ; try { clearSwapDir ( ) ; } catch ( Exception e ) { throw new IOException ( "Unable to clear large query swap directory: " + e . getMessage ( ) ) ; } }
On startup clear out the large query swap directory .
155,125
void storeBlock ( BlockId blockId , ByteBuffer block ) throws IOException { synchronized ( m_accessLock ) { if ( m_blockPathMap . containsKey ( blockId ) ) { throw new IllegalArgumentException ( "Request to store block that is already stored: " + blockId . toString ( ) ) ; } int origPosition = block . position ( ) ; bl...
Store the given block with the given ID to disk .
155,126
void loadBlock ( BlockId blockId , ByteBuffer block ) throws IOException { synchronized ( m_accessLock ) { if ( ! m_blockPathMap . containsKey ( blockId ) ) { throw new IllegalArgumentException ( "Request to load block that is not stored: " + blockId ) ; } int origPosition = block . position ( ) ; block . position ( 0 ...
Read the block with the given ID into the given byte buffer .
155,127
void releaseBlock ( BlockId blockId ) throws IOException { synchronized ( m_accessLock ) { if ( ! m_blockPathMap . containsKey ( blockId ) ) { throw new IllegalArgumentException ( "Request to release block that is not stored: " + blockId ) ; } Path blockPath = m_blockPathMap . get ( blockId ) ; Files . delete ( blockPa...
The block with the given site id and block counter is no longer needed so delete it from disk .
155,128
private void releaseAllBlocks ( ) throws IOException { synchronized ( m_accessLock ) { Set < Map . Entry < BlockId , Path > > entries = m_blockPathMap . entrySet ( ) ; while ( ! entries . isEmpty ( ) ) { Map . Entry < BlockId , Path > entry = entries . iterator ( ) . next ( ) ; Files . delete ( entry . getValue ( ) ) ;...
Release all the blocks that are on disk and delete them from the map that tracks them .
155,129
Path makeBlockPath ( BlockId id ) { String filename = id . fileNameString ( ) ; return m_largeQuerySwapPath . resolve ( filename ) ; }
Given package visibility for unit testing purposes .
155,130
public static List < Shard > discoverShards ( String regionName , String streamName , String accessKey , String secretKey , String appName ) { try { Region region = RegionUtils . getRegion ( regionName ) ; if ( region != null ) { final AWSCredentials credentials = new BasicAWSCredentials ( accessKey , secretKey ) ; Ama...
connect to kinesis stream to discover the shards on the stream
155,131
public static String getProperty ( Properties props , String propertyName , String defaultValue ) { String value = props . getProperty ( propertyName , defaultValue ) . trim ( ) ; if ( value . isEmpty ( ) ) { throw new IllegalArgumentException ( "Property " + propertyName + " is missing in Kinesis importer configuratio...
get property value . If no value is available throw IllegalArgumentException
155,132
public static long getPropertyAsLong ( Properties props , String propertyName , long defaultValue ) { String value = props . getProperty ( propertyName , "" ) . trim ( ) ; if ( value . isEmpty ( ) ) { return defaultValue ; } try { long val = Long . parseLong ( value ) ; if ( val <= 0 ) { throw new IllegalArgumentExcept...
get property value as long .
155,133
public synchronized boolean addChild ( String child ) { if ( children == null ) { children = new HashSet < String > ( 8 ) ; } return children . add ( child ) ; }
Method that inserts a child into the children set
155,134
protected String getHostHeader ( ) { if ( m_hostHeader != null ) { return m_hostHeader ; } if ( ! httpAdminListener . m_publicIntf . isEmpty ( ) ) { m_hostHeader = httpAdminListener . m_publicIntf ; return m_hostHeader ; } InetAddress addr = null ; int httpPort = VoltDB . DEFAULT_HTTP_PORT ; try { String localMetadata ...
like behind a NATed network .
155,135
void handleReportPage ( HttpServletRequest request , HttpServletResponse response ) { try { String report = ReportMaker . liveReport ( ) ; response . setContentType ( HTML_CONTENT_TYPE ) ; response . setStatus ( HttpServletResponse . SC_OK ) ; response . getWriter ( ) . print ( report ) ; } catch ( IOException ex ) { m...
Draw the catalog report page mostly by pulling it from the JAR .
155,136
public int getIntegerProperty ( String key , int defaultValue , int [ ] values ) { String prop = getProperty ( key ) ; int value = defaultValue ; try { if ( prop != null ) { value = Integer . parseInt ( prop ) ; } } catch ( NumberFormatException e ) { } if ( ArrayUtil . find ( values , value ) == - 1 ) { return default...
Choice limited to values list defaultValue must be in the values list .
155,137
public void save ( ) throws Exception { if ( fileName == null || fileName . length ( ) == 0 ) { throw new java . io . FileNotFoundException ( Error . getMessage ( ErrorCode . M_HsqlProperties_load ) ) ; } String filestring = fileName + ".properties" ; save ( filestring ) ; }
Saves the properties .
155,138
public void save ( String fileString ) throws Exception { fa . createParentDirs ( fileString ) ; OutputStream fos = fa . openOutputStreamElement ( fileString ) ; FileAccess . FileSync outDescriptor = fa . getFileSync ( fos ) ; JavaSystem . saveProperties ( stringProps , HsqlDatabaseProperties . PRODUCT_NAME + " " + Hsq...
Saves the properties using JDK2 method if present otherwise JDK1 .
155,139
private void addError ( int code , String key ) { errorCodes = ( int [ ] ) ArrayUtil . resizeArray ( errorCodes , errorCodes . length + 1 ) ; errorKeys = ( String [ ] ) ArrayUtil . resizeArray ( errorKeys , errorKeys . length + 1 ) ; errorCodes [ errorCodes . length - 1 ] = code ; errorKeys [ errorKeys . length - 1 ] =...
Adds the error code and the key to the list of errors . This list is populated during construction or addition of elements and is used outside this class to act upon the errors .
155,140
public void checkPassword ( String value ) { if ( ! value . equals ( password ) ) { throw Error . error ( ErrorCode . X_28000 ) ; } }
Checks if this object s password attibute equals specified argument else throws .
155,141
public String getCreateUserSQL ( ) { StringBuffer sb = new StringBuffer ( 64 ) ; sb . append ( Tokens . T_CREATE ) . append ( ' ' ) ; sb . append ( Tokens . T_USER ) . append ( ' ' ) ; sb . append ( getStatementName ( ) ) . append ( ' ' ) ; sb . append ( Tokens . T_PASSWORD ) . append ( ' ' ) ; sb . append ( StringConv...
Returns the DDL string sequence that creates this user .
155,142
public String getConnectUserSQL ( ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( Tokens . T_SET ) . append ( ' ' ) ; sb . append ( Tokens . T_SESSION ) . append ( ' ' ) ; sb . append ( Tokens . T_AUTHORIZATION ) . append ( ' ' ) ; sb . append ( StringConverter . toQuotedString ( getNameString ( ) , '\'' , t...
Retrieves the redo log character sequence for connecting this user
155,143
static ImmutableMap < String , PublicSuffixType > parseTrie ( CharSequence encoded ) { ImmutableMap . Builder < String , PublicSuffixType > builder = ImmutableMap . builder ( ) ; int encodedLen = encoded . length ( ) ; int idx = 0 ; while ( idx < encodedLen ) { idx += doParseTrieToBuilder ( Lists . < CharSequence > new...
Parses a serialized trie representation of a map of reversed public suffixes into an immutable map of public suffixes .
155,144
private static int doParseTrieToBuilder ( List < CharSequence > stack , CharSequence encoded , ImmutableMap . Builder < String , PublicSuffixType > builder ) { int encodedLen = encoded . length ( ) ; int idx = 0 ; char c = '\0' ; for ( ; idx < encodedLen ; idx ++ ) { c = encoded . charAt ( idx ) ; if ( c == '&' || c ==...
Parses a trie node and returns the number of characters consumed .
155,145
public static synchronized void initialize ( int myHostId , CatalogContext catalogContext , boolean isRejoin , boolean forceCreate , HostMessenger messenger , List < Pair < Integer , Integer > > partitions ) throws ExportManager . SetupException { ExportManager em = new ExportManager ( myHostId , catalogContext , messe...
FIXME - this synchronizes on the ExportManager class but everyone else synchronizes on the instance .
155,146
private void initialize ( CatalogContext catalogContext , List < Pair < Integer , Integer > > localPartitionsToSites , boolean isRejoin ) { try { CatalogMap < Connector > connectors = CatalogUtil . getConnectors ( catalogContext ) ; if ( exportLog . isDebugEnabled ( ) ) { exportLog . debug ( "initialize for " + connect...
Creates the initial export processor if export is enabled
155,147
private void swapWithNewProcessor ( final CatalogContext catalogContext , ExportGeneration generation , CatalogMap < Connector > connectors , List < Pair < Integer , Integer > > partitions , Map < String , Pair < Properties , Set < String > > > config ) { ExportDataProcessor oldProcessor = m_processor . get ( ) ; if ( ...
remove and install new processor
155,148
public String calculateContentDeterminismMessage ( ) { String ans = getContentDeterminismMessage ( ) ; if ( ans != null ) { return ans ; } if ( m_subquery != null ) { updateContentDeterminismMessage ( m_subquery . calculateContentDeterminismMessage ( ) ) ; return getContentDeterminismMessage ( ) ; } if ( m_columns != n...
Return the content determinism string of the subquery if there is one .
155,149
public int getSortIndexOfOrderByExpression ( AbstractExpression partitionByExpression ) { for ( int idx = 0 ; idx < m_orderByExpressions . size ( ) ; ++ idx ) { if ( m_orderByExpressions . get ( idx ) . equals ( partitionByExpression ) ) { return idx ; } } return - 1 ; }
Return the index of the given partition by expression in the order by list . This is used when trying to rationalize partition by and order by expressions .
155,150
private boolean rewriteSelectStmt ( ) { if ( m_mvi != null ) { final Table view = m_mvi . getDest ( ) ; final String viewName = view . getTypeName ( ) ; m_selectStmt . getFinalProjectionSchema ( ) . resetTableName ( viewName , viewName ) . toTVEAndFixColumns ( m_QueryColumnNameAndIndx_to_MVColumnNameAndIndx . entrySet ...
Try to rewrite SELECT stmt if there is a matching materialized view .
155,151
private static boolean rewriteTableAlias ( StmtSubqueryScan scan ) { final AbstractParsedStmt stmt = scan . getSubqueryStmt ( ) ; return stmt instanceof ParsedSelectStmt && ( new MVQueryRewriter ( ( ParsedSelectStmt ) stmt ) ) . rewrite ( ) ; }
Checks for any opportunity to rewrite sub - queries
155,152
private static List < Integer > extractTVEIndices ( AbstractExpression e , List < Integer > accum ) { if ( e != null ) { if ( e instanceof TupleValueExpression ) { accum . add ( ( ( TupleValueExpression ) e ) . getColumnIndex ( ) ) ; } else { extractTVEIndices ( e . getRight ( ) , extractTVEIndices ( e . getLeft ( ) , ...
Helper method to extract all TVE column indices from an expression .
155,153
private Map < Pair < String , Integer > , Pair < String , Integer > > gbyMatches ( MaterializedViewInfo mv ) { final FilterMatcher filter = new FilterMatcher ( m_selectStmt . m_joinTree . getJoinExpression ( ) , predicate_of ( mv ) ) ; if ( filter . match ( ) && gbyTablesEqual ( mv ) && gbyColumnsMatch ( mv ) ) { retur...
Apply matching rules of SELECT stmt against a materialized view and gives back column relationship between the two .
155,154
private static Map < MaterializedViewInfo , Table > getMviAndViews ( List < Table > tbls ) { return tbls . stream ( ) . flatMap ( tbl -> StreamSupport . stream ( ( ( Iterable < MaterializedViewInfo > ) ( ) -> tbl . getViews ( ) . iterator ( ) ) . spliterator ( ) , false ) . map ( mv -> Pair . of ( mv , mv . getDest ( )...
returns all materialized view info = > view table from table list
155,155
private static AbstractExpression transformExpressionRidofPVE ( AbstractExpression src ) { AbstractExpression left = src . getLeft ( ) , right = src . getRight ( ) ; if ( left != null ) { left = transformExpressionRidofPVE ( left ) ; } if ( right != null ) { right = transformExpressionRidofPVE ( right ) ; } final Abstr...
For scope of ENG - 2878 caching would not cause this trouble because parameter
155,156
private static List < AbstractExpression > getGbyExpressions ( MaterializedViewInfo mv ) { try { return AbstractExpression . fromJSONArrayString ( mv . getGroupbyexpressionsjson ( ) , null ) ; } catch ( JSONException e ) { return new ArrayList < > ( ) ; } }
Get group - by expression
155,157
private boolean isNpTxn ( Iv2InitiateTaskMessage msg ) { return msg . getStoredProcedureName ( ) . startsWith ( "@" ) && msg . getStoredProcedureName ( ) . equalsIgnoreCase ( "@BalancePartitions" ) && ( byte ) msg . getParameters ( ) [ 1 ] != 1 ; }
Hacky way to only run
155,158
private Set < Integer > getBalancePartitions ( Iv2InitiateTaskMessage msg ) { try { JSONObject jsObj = new JSONObject ( ( String ) msg . getParameters ( ) [ 0 ] ) ; BalancePartitionsRequest request = new BalancePartitionsRequest ( jsObj ) ; return Sets . newHashSet ( request . partitionPairs . get ( 0 ) . srcPartition ...
Extract the two involved partitions from the
155,159
public void handleInitiateResponseMessage ( InitiateResponseMessage message ) { final VoltTrace . TraceEventBatch traceLog = VoltTrace . log ( VoltTrace . Category . MPI ) ; if ( traceLog != null ) { traceLog . add ( ( ) -> VoltTrace . endAsync ( "initmp" , message . getTxnId ( ) ) ) ; } DuplicateCounter counter = m_du...
see all of these messages and control their transmission .
155,160
public void handleEOLMessage ( ) { Iv2EndOfLogMessage msg = new Iv2EndOfLogMessage ( m_partitionId ) ; MPIEndOfLogTransactionState txnState = new MPIEndOfLogTransactionState ( msg ) ; MPIEndOfLogTask task = new MPIEndOfLogTask ( m_mailbox , m_pendingTasks , txnState , m_iv2Masters ) ; m_pendingTasks . offer ( task ) ; ...
Inject a task into the transaction task queue to flush it . When it executes it will send out MPI end of log messages to all partition initiators .
155,161
private static ProClass < MpProcedureTask > loadNpProcedureTaskClass ( ) { return ProClass . < MpProcedureTask > load ( "org.voltdb.iv2.NpProcedureTask" , "N-Partition" , MiscUtils . isPro ( ) ? ProClass . HANDLER_LOG : ProClass . HANDLER_IGNORE ) . errorHandler ( tmLog :: error ) . useConstructorFor ( Mailbox . class ...
Load the pro class for n - partition transactions .
155,162
void safeAddToDuplicateCounterMap ( long dpKey , DuplicateCounter counter ) { DuplicateCounter existingDC = m_duplicateCounters . get ( dpKey ) ; if ( existingDC != null ) { existingDC . logWithCollidingDuplicateCounters ( counter ) ; VoltDB . crashGlobalVoltDB ( "DUPLICATE COUNTER MISMATCH: two duplicate counter keys ...
Just using put on the dup counter map is unsafe . It won t detect the case where keys collide from two different transactions .
155,163
Table ADMINISTRABLE_ROLE_AUTHORIZATIONS ( ) { Table t = sysTables [ ADMINISTRABLE_ROLE_AUTHORIZATIONS ] ; if ( t == null ) { t = createBlankTable ( sysTableHsqlNames [ ADMINISTRABLE_ROLE_AUTHORIZATIONS ] ) ; addColumn ( t , "GRANTEE" , SQL_IDENTIFIER ) ; addColumn ( t , "ROLE_NAME" , SQL_IDENTIFIER ) ; addColumn ( t , ...
Returns roles that are grantable by an admin user which means all the roles
155,164
Table ROUTINE_ROUTINE_USAGE ( ) { Table t = sysTables [ ROUTINE_ROUTINE_USAGE ] ; if ( t == null ) { t = createBlankTable ( sysTableHsqlNames [ ROUTINE_ROUTINE_USAGE ] ) ; addColumn ( t , "SPECIFIC_CATALOG" , SQL_IDENTIFIER ) ; addColumn ( t , "SPECIFIC_SCHEMA" , SQL_IDENTIFIER ) ; addColumn ( t , "SPECIFIC_NAME" , SQL...
needs to provide list of specific referenced routines
155,165
public ListenableFuture < ? > closeAndDelete ( ) { m_closed = true ; m_ackMailboxRefs . set ( null ) ; m_mastershipAccepted . set ( false ) ; try { if ( m_pollTask != null ) { m_pollTask . setFuture ( null ) ; } } catch ( RejectedExecutionException reex ) { } m_pollTask = null ; return m_es . submit ( new Runnable ( ) ...
This is called on updateCatalog when an exporting stream is dropped .
155,166
public void setPendingContainer ( AckingContainer container ) { Preconditions . checkNotNull ( m_pendingContainer . get ( ) != null , "Pending container must be null." ) ; if ( m_closed ) { exportLog . info ( "Discarding stale pending container" ) ; container . internalDiscard ( ) ; } else { m_pendingContainer . set ( ...
Needs to be thread - safe EDS executor export decoder and site thread both touch m_pendingContainer .
155,167
public void remoteAck ( final long seq ) { m_es . execute ( new Runnable ( ) { public void run ( ) { try { if ( ! m_es . isShutdown ( ) && ! m_mastershipAccepted . get ( ) ) { setCommittedSeqNo ( seq ) ; ackImpl ( seq ) ; } } catch ( Exception e ) { exportLog . error ( "Error acking export buffer" , e ) ; } catch ( Err...
Entry point for receiving acknowledgments from remote entities .
155,168
private void handleDrainedSource ( ) throws IOException { if ( ! inCatalog ( ) && m_committedBuffers . isEmpty ( ) ) { try { if ( m_pollTask != null ) { m_pollTask . setFuture ( null ) ; } } catch ( RejectedExecutionException reex ) { } m_pollTask = null ; m_generation . onSourceDrained ( m_partitionId , m_tableName ) ...
Notify the generation when source is drained on an unused partition .
155,169
public synchronized void acceptMastership ( ) { if ( m_onMastership == null ) { if ( exportLog . isDebugEnabled ( ) ) { exportLog . debug ( "Mastership Runnable not yet set for table " + getTableName ( ) + " partition " + getPartitionId ( ) ) ; } return ; } if ( m_mastershipAccepted . get ( ) ) { if ( exportLog . isDeb...
Trigger an execution of the mastership runnable by the associated executor service
155,170
public void setOnMastership ( Runnable toBeRunOnMastership ) { Preconditions . checkNotNull ( toBeRunOnMastership , "mastership runnable is null" ) ; m_onMastership = toBeRunOnMastership ; if ( m_runEveryWhere ) { m_ackMailboxRefs . set ( null ) ; acceptMastership ( ) ; } }
set the runnable task that is to be executed on mastership designation
155,171
public void handleQueryMessage ( final long senderHSId , long requestId , long gapStart ) { m_es . execute ( new Runnable ( ) { public void run ( ) { long lastSeq = Long . MIN_VALUE ; Pair < Long , Long > range = m_gapTracker . getRangeContaining ( gapStart ) ; if ( range != null ) { lastSeq = range . getSecond ( ) ; }...
Query whether a master exists for the given partition if not try to promote the local data source .
155,172
private void resetStateInRejoinOrRecover ( long initialSequenceNumber , boolean isRejoin ) { if ( isRejoin ) { if ( ! m_gapTracker . isEmpty ( ) ) { m_lastReleasedSeqNo = Math . max ( m_lastReleasedSeqNo , m_gapTracker . getFirstSeqNo ( ) - 1 ) ; } } else { m_lastReleasedSeqNo = Math . max ( m_lastReleasedSeqNo , initi...
current master to tell us where to poll next buffer .
155,173
public static Date getDateFromTransactionId ( long txnId ) { long time = txnId >> ( COUNTER_BITS + INITIATORID_BITS ) ; time += VOLT_EPOCH ; return new Date ( time ) ; }
Given a transaction id return the time of its creation by examining the embedded timestamp .
155,174
private AbstractTopology recoverPartitions ( AbstractTopology topology , String haGroup , Set < Integer > recoverPartitions ) { long version = topology . version ; if ( ! recoverPartitions . isEmpty ( ) ) { if ( Collections . max ( recoverPartitions ) > Collections . max ( m_cartographer . getPartitions ( ) ) ) { recov...
recover the partition assignment from one of lost hosts in the same placement group for rejoin Use the placement group of the recovering host to find a matched host from the lost nodes in the topology If the partition count from the lost node is the same as the site count of the recovering host The partitions on the lo...
155,175
private boolean stopRejoiningHost ( ) { try { m_meshDeterminationLatch . await ( ) ; } catch ( InterruptedException e ) { } if ( m_rejoining ) { VoltDB . crashLocalVoltDB ( "Another node failed before this node could finish rejoining. " + "As a result, the rejoin operation has been canceled. Please try again." ) ; retu...
If the current node hasn t finished rejoin when another node fails fail this node to prevent locking up .
155,176
private void checkExportStreamMastership ( ) { for ( Initiator initiator : m_iv2Initiators . values ( ) ) { if ( initiator . getPartitionId ( ) != MpInitiator . MP_INIT_PID ) { SpInitiator spInitiator = ( SpInitiator ) initiator ; if ( spInitiator . isLeader ( ) ) { ExportManager . instance ( ) . takeMastership ( spIni...
move back to partition leader s node .
155,177
void scheduleDailyLoggingWorkInNextCheckTime ( ) { DailyRollingFileAppender dailyAppender = null ; Enumeration < ? > appenders = Logger . getRootLogger ( ) . getAllAppenders ( ) ; while ( appenders . hasMoreElements ( ) ) { Appender appender = ( Appender ) appenders . nextElement ( ) ; if ( appender instanceof DailyRol...
Get the next check time for a private member in log4j library which is not a reliable idea . It adds 30 seconds for the initial delay and uses a periodical thread to schedule the daily logging work with this delay .
155,178
private void schedulePeriodicWorks ( ) { m_periodicWorks . add ( scheduleWork ( new Runnable ( ) { public void run ( ) { if ( m_statsManager != null ) { m_statsManager . sendNotification ( ) ; } } } , 0 , StatsManager . POLL_INTERVAL , TimeUnit . MILLISECONDS ) ) ; m_periodicWorks . add ( scheduleWork ( new Runnable ( ...
Schedule all the periodic works
155,179
private boolean determineIfEligibleAsLeader ( Collection < Integer > partitions , Set < Integer > partitionGroupPeers , AbstractTopology topology ) { if ( partitions . contains ( Integer . valueOf ( 0 ) ) ) { return true ; } for ( Integer host : topology . getHostIdList ( 0 ) ) { if ( partitionGroupPeers . contains ( h...
This host can be a leader if partition 0 is on it or it is in the same partition group as a node which has partition 0 . This is because the partition group with partition 0 can never be removed by elastic remove .
155,180
public void run ( ) { if ( m_restoreAgent != null ) { m_restoreAgent . restore ( ) ; } else { onSnapshotRestoreCompletion ( ) ; onReplayCompletion ( Long . MIN_VALUE , m_iv2InitiatorStartingTxnIds ) ; } if ( m_joinCoordinator != null ) { try { m_statusTracker . set ( NodeState . REJOINING ) ; if ( ! m_joinCoordinator ....
Start all the site s event loops . That s it .
155,181
public void cleanUpTempCatalogJar ( ) { File configInfoDir = getConfigDirectory ( ) ; if ( ! configInfoDir . exists ( ) ) { return ; } File tempJar = new VoltFile ( configInfoDir . getPath ( ) , InMemoryJarfile . TMP_CATALOG_JAR_FILENAME ) ; if ( tempJar . exists ( ) ) { tempJar . delete ( ) ; } }
Clean up the temporary jar file
155,182
private void shutdownInitiators ( ) { if ( m_iv2Initiators == null ) { return ; } m_iv2Initiators . descendingMap ( ) . values ( ) . stream ( ) . forEach ( p -> p . shutdown ( ) ) ; }
to be done on SP sites kill SP sites first may risk MP site to wait forever .
155,183
public void createRuntimeReport ( PrintStream out ) { out . print ( "MIME-Version: 1.0\n" ) ; out . print ( "Content-type: multipart/mixed; boundary=\"reportsection\"" ) ; out . print ( "\n\n--reportsection\nContent-Type: text/plain\n\nClientInterface Report\n" ) ; if ( m_clientInterface != null ) { out . print ( m_cli...
Debugging function - creates a record of the current state of the system .
155,184
private void initializeDRProducer ( ) { try { if ( m_producerDRGateway != null ) { m_producerDRGateway . startAndWaitForGlobalAgreement ( ) ; for ( Initiator iv2init : m_iv2Initiators . values ( ) ) { iv2init . initDRGateway ( m_config . m_startAction , m_producerDRGateway , isLowestSiteId ( iv2init ) ) ; } m_producerD...
Initialize the DR producer so that any binary log generated on recover will be queued . This does NOT open the DR port . That will happen after command log replay finishes .
155,185
static public long computeMinimumHeapRqt ( int tableCount , int sitesPerHost , int kfactor ) { long baseRqt = 384 ; long tableRqt = 10 * tableCount ; long rejoinRqt = ( kfactor > 0 ) ? 128 * sitesPerHost : 0 ; return baseRqt + tableRqt + rejoinRqt ; }
Any changes there should get reflected here and vice versa .
155,186
synchronized void prepareCommit ( Session session ) { RowActionBase action = this ; do { if ( action . session == session && action . commitTimestamp == 0 ) { action . prepared = true ; } action = action . next ; } while ( action != null ) ; }
for two - phased pre - commit
155,187
synchronized void rollback ( Session session , long timestamp ) { RowActionBase action = this ; do { if ( action . session == session && action . commitTimestamp == 0 ) { if ( action . actionTimestamp >= timestamp || action . actionTimestamp == 0 ) { action . commitTimestamp = session . actionTimestamp ; action . rolle...
Rollback actions for a session including and after the given timestamp
155,188
synchronized int getCommitType ( long timestamp ) { RowActionBase action = this ; int type = ACTION_NONE ; do { if ( action . commitTimestamp == timestamp ) { type = action . type ; } action = action . next ; } while ( action != null ) ; return type ; }
returns type of commit performed on timestamp . ACTION_NONE if none .
155,189
synchronized boolean canCommit ( Session session , OrderedHashSet set ) { RowActionBase action ; long timestamp = session . transactionTimestamp ; long commitTimestamp = 0 ; final boolean readCommitted = session . isolationMode == SessionInterface . TX_READ_COMMITTED ; action = this ; if ( readCommitted ) { do { if ( a...
returns false if another committed session has altered the same row
155,190
synchronized void mergeRollback ( Row row ) { RowActionBase action = this ; RowActionBase head = null ; RowActionBase tail = null ; if ( type == RowActionBase . ACTION_DELETE_FINAL || type == RowActionBase . ACTION_NONE ) { return ; } do { if ( action . rolledback ) { if ( tail != null ) { tail . next = null ; } } else...
merge rolled back actions
155,191
private void adjustReplicationFactorForURI ( HttpPut httpPut ) throws URISyntaxException { String queryString = httpPut . getURI ( ) . getQuery ( ) ; if ( ! StringUtils . isEmpty ( queryString ) && queryString . contains ( "op=CREATE" ) && ( queryString . contains ( "replication=" ) || ! StringUtils . isEmpty ( m_block...
append replication factor to the URI for CREATE operation if the factor is not in URI
155,192
private List < NameValuePair > sign ( URI uri , final List < NameValuePair > params ) { Preconditions . checkNotNull ( m_secret ) ; final List < NameValuePair > sortedParams = Lists . newArrayList ( params ) ; Collections . sort ( sortedParams , new Comparator < NameValuePair > ( ) { public int compare ( NameValuePair ...
Calculate the signature of the request using the specified secret key .
155,193
public final FluentIterable < T > preOrderTraversal ( final T root ) { checkNotNull ( root ) ; return new FluentIterable < T > ( ) { public UnmodifiableIterator < T > iterator ( ) { return preOrderIterator ( root ) ; } } ; }
Returns an unmodifiable iterable over the nodes in a tree structure using pre - order traversal . That is each node s subtrees are traversed after the node itself is returned .
155,194
public final FluentIterable < T > breadthFirstTraversal ( final T root ) { checkNotNull ( root ) ; return new FluentIterable < T > ( ) { public UnmodifiableIterator < T > iterator ( ) { return new BreadthFirstIterator ( root ) ; } } ; }
Returns an unmodifiable iterable over the nodes in a tree structure using breadth - first traversal . That is all the nodes of depth 0 are returned then depth 1 then 2 and so on .
155,195
public String getUserName ( ) throws SQLException { ResultSet rs = execute ( "CALL USER()" ) ; rs . next ( ) ; String result = rs . getString ( 1 ) ; rs . close ( ) ; return result ; }
Retrieves the user name as known to this database .
155,196
public boolean isReadOnly ( ) throws SQLException { ResultSet rs = execute ( "CALL isReadOnlyDatabase()" ) ; rs . next ( ) ; boolean result = rs . getBoolean ( 1 ) ; rs . close ( ) ; return result ; }
Retrieves whether this database is in read - only mode .
155,197
private StringBuffer toQueryPrefixNoSelect ( String t ) { StringBuffer sb = new StringBuffer ( 255 ) ; return sb . append ( t ) . append ( whereTrue ) ; }
Retrieves &lt ; expression&gt ; WHERE 1 = 1 in string
155,198
public static ConstantValueExpression makeExpression ( VoltType dataType , String value ) { ConstantValueExpression constantExpr = new ConstantValueExpression ( ) ; constantExpr . setValueType ( dataType ) ; constantExpr . setValue ( value ) ; return constantExpr ; }
Create a new CVE for a given type and value
155,199
Result executeUpdateStatement ( Session session ) { int count = 0 ; Expression [ ] colExpressions = updateExpressions ; HashMappedList rowset = new HashMappedList ( ) ; Type [ ] colTypes = baseTable . getColumnTypes ( ) ; RangeIteratorBase it = RangeVariable . getIterator ( session , targetRangeVariables ) ; Expression...
Executes an UPDATE statement . It is assumed that the argument is of the correct type .