idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
37,500
public ImmutableList < InstanceInfo > getRoleInstances ( String roleName ) { return getRoleInstancesWithMetadataImpl ( roleName , Collections . < String , String > emptyMap ( ) ) ; }
Retrieve information about instances of a particular role from the Conqueso Server .
37,501
protected final void checkNotNull ( final ConversionStringency stringency , final Logger logger ) { if ( stringency == null ) { throw new NullPointerException ( "stringency must not be null" ) ; } if ( logger == null ) { throw new NullPointerException ( "logger must not be null" ) ; } }
Check the specified conversion stringency and logger are not null .
37,502
protected final void warnOrThrow ( final S source , final String message , final Throwable cause , final ConversionStringency stringency , final Logger logger ) throws ConversionException { checkNotNull ( stringency , logger ) ; if ( stringency . isLenient ( ) ) { if ( cause != null ) { logger . warn ( String . format ...
If the conversion stringency is lenient log a warning with the specified message or if the conversion stringency is strict throw a ConversionException with the specified message and cause .
37,503
public static String buildJDBCString ( final String sJdbcURL , final Map < EMySQLConnectionProperty , String > aConnectionProperties ) { ValueEnforcer . notEmpty ( sJdbcURL , "JDBC URL" ) ; ValueEnforcer . isTrue ( sJdbcURL . startsWith ( CJDBC_MySQL . CONNECTION_PREFIX ) , "The JDBC URL '" + sJdbcURL + "' does not see...
Build the final connection string from the base JDBC URL and an optional set of connection properties .
37,504
public Pattern updatePattern ( final Collection < String > prefixes ) { final String XML_PREFIX = prefixes . stream ( ) . map ( s -> Pattern . quote ( s + "/" ) ) . collect ( Collectors . joining ( "|" ) ) ; return XML_PATH_PATTERN = Pattern . compile ( "^/?(?:" + XML_PREFIX + ")?(?:" + IDX_PREFIX + ")?(?<fieldPath>[^/...
We have to do it this way to break the circular dependency between the FieldsInfo deserializer and this .
37,505
public static String resolveTitle ( final String title , final String reference ) { if ( StringUtils . isBlank ( title ) && ! StringUtils . isBlank ( reference ) ) { final String [ ] splitReference = PATH_SEPARATOR_REGEX . split ( reference ) ; final String lastPart = splitReference [ splitReference . length - 1 ] ; re...
Determine a title to use for a document given it s title and reference fields .
37,506
public static int getJDBCTypeFromClass ( final Class < ? > aClass ) { ValueEnforcer . notNull ( aClass , "Class" ) ; if ( ! ClassHelper . isArrayClass ( aClass ) ) { if ( aClass . equals ( String . class ) ) return Types . VARCHAR ; if ( aClass . equals ( BigDecimal . class ) ) return Types . NUMERIC ; if ( aClass . eq...
Determine the JDBC type from the passed class .
37,507
public final ESuccess dumpDatabase ( final OutputStream aOS ) { ValueEnforcer . notNull ( aOS , "OutputStream" ) ; try { LOGGER . info ( "Dumping database '" + getDatabaseName ( ) + "' to OutputStream" ) ; try ( final PrintWriter aPrintWriter = new PrintWriter ( new NonBlockingBufferedWriter ( StreamHelper . createWrit...
Dump the database to the passed output stream and closed the passed output stream .
37,508
public final ESuccess createBackup ( final File fDestFile ) { ValueEnforcer . notNull ( fDestFile , "DestFile" ) ; LOGGER . info ( "Backing up database '" + getDatabaseName ( ) + "' to " + fDestFile ) ; final DBExecutor aExecutor = new DBExecutor ( this ) ; return aExecutor . executeStatement ( "BACKUP TO '" + fDestFil...
Create a backup file . The file is a ZIP file .
37,509
private HodSearchResult addDomain ( final Iterable < ResourceName > indexIdentifiers , final HodSearchResult document ) { final String index = document . getIndex ( ) ; String domain = null ; for ( final ResourceName indexIdentifier : indexIdentifiers ) { if ( index . equals ( indexIdentifier . getName ( ) ) ) { domain...
Add a domain to a FindDocument given the collection of indexes which were queried against to return it from HOD
37,510
List < String > splitEffects ( final String s ) { return Splitter . on ( "&" ) . omitEmptyStrings ( ) . splitToList ( s ) ; }
Split the specified string into a list of effects .
37,511
List < VariantAnnotationMessage > splitMessages ( final String s , final ConversionStringency stringency , final Logger logger ) throws ConversionException { return Splitter . on ( "&" ) . omitEmptyStrings ( ) . splitToList ( s ) . stream ( ) . map ( m -> variantAnnotationMessageConverter . convert ( m , stringency , l...
Split the specified string into a list of variant annotation messages .
37,512
static Integer emptyToNullInteger ( final String s ) { return "" . equals ( s ) ? null : Integer . parseInt ( s ) ; }
Parse the specified string into an integer returning null if the string is empty .
37,513
static Integer numerator ( final String s ) { if ( "" . equals ( s ) ) { return null ; } String [ ] tokens = s . split ( "/" ) ; return emptyToNullInteger ( tokens [ 0 ] ) ; }
Parse the specified string as a fraction and return the numerator if any .
37,514
static Integer denominator ( final String s ) { if ( "" . equals ( s ) ) { return null ; } String [ ] tokens = s . split ( "/" ) ; return ( tokens . length < 2 ) ? null : emptyToNullInteger ( tokens [ 1 ] ) ; }
Parse the specified string as a fraction and return the denominator if any .
37,515
public static < T > JPAExecutionResult < T > createSuccess ( final T aObj ) { return new JPAExecutionResult < > ( ESuccess . SUCCESS , aObj , null ) ; }
Create a new success object .
37,516
public static < T > JPAExecutionResult < T > createFailure ( final Exception ex ) { return new JPAExecutionResult < > ( ESuccess . FAILURE , null , ex ) ; }
Create a new failure object .
37,517
public static void doOnMainThread ( final OnMainThreadJob onMainThreadJob ) { uiHandler . post ( new Runnable ( ) { public void run ( ) { onMainThreadJob . doInUIThread ( ) ; } } ) ; }
Executes the provided code immediately on the UI Thread
37,518
public static void doInBackground ( final OnBackgroundJob onBackgroundJob ) { new Thread ( new Runnable ( ) { public void run ( ) { onBackgroundJob . doOnBackground ( ) ; } } ) . start ( ) ; }
Executes the provided code immediately on a background thread
37,519
public static FutureTask doInBackground ( final OnBackgroundJob onBackgroundJob , ExecutorService executor ) { FutureTask task = ( FutureTask ) executor . submit ( new Runnable ( ) { public void run ( ) { onBackgroundJob . doOnBackground ( ) ; } } ) ; return task ; }
Executes the provided code immediately on a background thread that will be submitted to the provided ExecutorService
37,520
public void start ( ) { if ( actionInBackground != null ) { Runnable jobToRun = new Runnable ( ) { public void run ( ) { result = ( JobResult ) actionInBackground . doAsync ( ) ; onResult ( ) ; } } ; if ( getExecutorService ( ) != null ) { asyncFutureTask = ( FutureTask ) getExecutorService ( ) . submit ( jobToRun ) ; ...
Begins the background execution providing a result similar to an AsyncTask . It will execute it on a new Thread or using the provided ExecutorService
37,521
public void cancel ( ) { if ( actionInBackground != null ) { if ( executorService != null ) { asyncFutureTask . cancel ( true ) ; } else { asyncThread . interrupt ( ) ; } } }
Cancels the AsyncJob interrupting the inner thread .
37,522
public static String replacePathParam ( final String url , final String param , final String value ) throws EncoderException { final String pathParam = param . startsWith ( "{" ) ? param : "{" + param + "}" ; final String encodedValue = encode ( value ) ; return StringUtils . replace ( url , pathParam , encodedValue ) ...
Replaces path param in uri to a valid encoded value
37,523
public static List < String > extractPathParams ( final String url ) { final List < String > pathParams = new ArrayList < > ( ) ; int index = url . indexOf ( '{' ) ; while ( index >= 0 ) { final int endIndex = url . indexOf ( '}' , index ) ; final String pathParam = url . substring ( index + 1 , endIndex ) ; pathParams...
Extracts all path params in url
37,524
private void prepareRequestBody ( ) throws IOException { if ( bodyByteArray != null ) { setByteArrayBody ( ) ; } else if ( bodyString != null ) { setStringBody ( ) ; } else if ( bodyObject != null ) { setTypedBody ( ) ; } }
Prepares the request body - setting the body charset and content length by body type
37,525
public Observable < String > helloUserStream ( final String name , final int repeats ) { return interval ( 100 , TimeUnit . MILLISECONDS ) . map ( i -> "Hello, " + name + "! (#" + i + ")" ) . take ( repeats ) ; }
Endpoint which receives username and repeats number and returns stream of messages limited by the repeat number size
37,526
public static < T , R > Observable < List < R > > batchToStream ( final List < T > elements , final int batchSize , final FutureSuccessHandler < T , R > producer ) { return Observable . create ( subscriber -> batchToStream ( elements , batchSize , 0 , subscriber , producer ) ) ; }
Execute the producer on each element in the list in batches and return a stream of batch results . Every batch is executed in parallel and the next batch begins only after the previous one ended . The result of each batch is the next element in the stream . An error in one of the futures produced by the producer will e...
37,527
public static < T > ComposableFuture < T > submit ( final Callable < T > task ) { return submit ( false , task ) ; }
sends a callable task to the default thread pool and returns a ComposableFuture that represent the result .
37,528
public static < T > ComposableFuture < T > buildLazy ( final Producer < T > producer ) { return LazyComposableFuture . build ( producer ) ; }
builds a lazy future from a producer . the producer itself is cached and used afresh on every consumption .
37,529
public static < T > ComposableFuture < T > withTimeout ( final ComposableFuture < T > future , final long duration , final TimeUnit unit ) { return future . withTimeout ( SchedulerServiceHolder . INSTANCE , duration , unit ) ; }
adds a time cap to the provided future . if response do not arrive after the specified time a TimeoutException is returned from the returned future .
37,530
public static < T > ComposableFuture < T > retry ( final int retries , final long duration , final TimeUnit unit , final FutureAction < T > action ) { return action . execute ( ) . withTimeout ( duration , unit ) . recoverWith ( error -> { if ( retries < 1 ) { return ComposableFutures . fromError ( error ) ; } return r...
reties an eager future on failure retries times . each try is time capped with the specified time limit .
37,531
public static < T > ComposableFuture < T > doubleDispatch ( final long duration , final TimeUnit unit , final FutureAction < T > action ) { return EagerComposableFuture . doubleDispatch ( action , duration , unit , getScheduler ( ) ) ; }
creates a future that fires the first future immediately and a second one after a specified time period if result hasn t arrived yet . should be used with eager futures .
37,532
public static < T > Observable < T > toColdObservable ( final List < ComposableFuture < T > > futures , final boolean failOnError ) { return Observable . create ( subscriber -> { final AtomicInteger counter = new AtomicInteger ( futures . size ( ) ) ; final AtomicBoolean errorTrigger = new AtomicBoolean ( false ) ; for...
translate a list of lazy futures to a cold Observable stream
37,533
public static < T > Observable < T > toColdObservable ( final RecursiveFutureProvider < T > futureProvider ) { return Observable . create ( new Observable . OnSubscribe < T > ( ) { public void call ( final Subscriber < ? super T > subscriber ) { recursiveChain ( subscriber , futureProvider . createStopCriteria ( ) ) ; ...
creates new cold observable given future provider on each subscribe will consume the provided future and repeat until stop criteria will exists each result will be emitted to the stream
37,534
public static < T > Observable < T > toHotObservable ( final List < ComposableFuture < T > > futures , final boolean failOnError ) { final ReplaySubject < T > subject = ReplaySubject . create ( futures . size ( ) ) ; final AtomicInteger counter = new AtomicInteger ( futures . size ( ) ) ; final AtomicBoolean errorTrigg...
translate a list of eager futures into a hot Observable stream the results of the futures will be stored in the stream for any future subscriber .
37,535
public static < T > Observable < T > toObservable ( final FutureProvider < T > provider ) { return Observable . create ( new FutureProviderToStreamHandler < > ( provider ) ) ; }
creates new observable given future provider translating the future results into stream . the sequence will be evaluated on subscribe .
37,536
public static AuthenticationCookie fromDelimitedString ( final String delimitedString ) { Preconditions . checkArgument ( delimitedString != null && delimitedString . length ( ) > 0 , "delimitedString cannot be empty" ) ; final String [ ] cookieElements = delimitedString . split ( DELIMITER ) ; Preconditions . checkArg...
Converted the given delimited string into an Authentication cookie . Expected a string in the format username ; creationTime ; appId ; authenticatorId
37,537
public RequestBuilder get ( final String url ) { checkNotNull ( url , "url may not be null" ) ; final AsyncHttpClient . BoundRequestBuilder ningRequestBuilder = asyncHttpClient . prepareGet ( url ) ; return createNewRequestBuilder ( url , ningRequestBuilder ) ; }
Http get request
37,538
public RequestBuilder post ( final String url ) { checkNotNull ( url , "url may not be null" ) ; final AsyncHttpClient . BoundRequestBuilder ningRequestBuilder = asyncHttpClient . preparePost ( url ) ; return createNewRequestBuilder ( url , ningRequestBuilder ) ; }
Http post request
37,539
public RequestBuilder put ( final String url ) { checkNotNull ( url , "url may not be null" ) ; final AsyncHttpClient . BoundRequestBuilder ningRequestBuilder = asyncHttpClient . preparePut ( url ) ; return createNewRequestBuilder ( url , ningRequestBuilder ) ; }
Http put request
37,540
public RequestBuilder delete ( final String url ) { checkNotNull ( url , "url may not be null" ) ; final AsyncHttpClient . BoundRequestBuilder ningRequestBuilder = asyncHttpClient . prepareDelete ( url ) ; return createNewRequestBuilder ( url , ningRequestBuilder ) ; }
Http delete request
37,541
public RequestBuilder head ( final String url ) { checkNotNull ( url , "url may not be null" ) ; final AsyncHttpClient . BoundRequestBuilder ningRequestBuilder = asyncHttpClient . prepareHead ( url ) ; return createNewRequestBuilder ( url , ningRequestBuilder ) ; }
Http head request
37,542
public boolean acceptInboundMessage ( final Object msg ) throws Exception { if ( ! ( msg instanceof FullHttpRequest ) ) return false ; final FullHttpRequest request = ( FullHttpRequest ) msg ; final String uri = request . getUri ( ) ; return pathResolver . isStaticPath ( uri ) ; }
here to make sure that the message is not released twice by the dispatcherHandler and by this handler
37,543
private static void setDateHeader ( final FullHttpResponse response ) { final SimpleDateFormat dateFormatter = new SimpleDateFormat ( HTTP_DATE_FORMAT , Locale . US ) ; dateFormatter . setTimeZone ( TimeZone . getTimeZone ( HTTP_DATE_GMT_TIMEZONE ) ) ; final Calendar time = new GregorianCalendar ( ) ; response . header...
Sets the Date header for the HTTP response
37,544
public static boolean isResolved ( Type type ) { if ( type instanceof GenericArrayType ) { return isResolved ( ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ) ; } if ( type instanceof ParameterizedType ) { for ( Type t : ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) ) { if ( ! isResolved ( t...
Checks if the given type is fully resolved .
37,545
public static void visit ( Object instance , TypeToken < ? > inspectType , Visitor firstVisitor , Visitor ... moreVisitors ) { try { List < Visitor > visitors = ImmutableList . < Visitor > builder ( ) . add ( firstVisitor ) . add ( moreVisitors ) . build ( ) ; for ( TypeToken < ? > type : inspectType . getTypes ( ) . c...
Inspect all members in the given type . Fields and Methods that are given to Visitor are always having accessible flag being set .
37,546
public static byte [ ] getQueueRowPrefix ( QueueName queueName ) { if ( queueName . isStream ( ) ) { return Bytes . EMPTY_BYTE_ARRAY ; } String flowlet = queueName . getThirdComponent ( ) ; String output = queueName . getSimpleName ( ) ; byte [ ] idWithinFlow = ( flowlet + "/" + output ) . getBytes ( Charsets . US_ASCI...
Returns a byte array representing prefix of a queue . The prefix is formed by first two bytes of MD5 of the queue name followed by the queue name .
37,547
private static byte [ ] getQueueRowPrefix ( byte [ ] queueIdWithinFlow ) { byte [ ] bytes = new byte [ queueIdWithinFlow . length + 1 ] ; Hashing . md5 ( ) . hashBytes ( queueIdWithinFlow ) . writeBytesTo ( bytes , 0 , 1 ) ; System . arraycopy ( queueIdWithinFlow , 0 , bytes , 1 , queueIdWithinFlow . length ) ; return ...
Returns a byte array representing prefix of a queue . The prefix is formed by first byte of MD5 of the queue name followed by the queue name .
37,548
public static boolean isCommittedProcessed ( byte [ ] stateBytes , Transaction tx ) { long writePointer = Bytes . toLong ( stateBytes , 0 , Longs . BYTES ) ; if ( ! tx . isVisible ( writePointer ) ) { return false ; } byte state = stateBytes [ Longs . BYTES + Ints . BYTES ] ; return state == ConsumerEntryState . PROCES...
For a queue entry consumer state serialized to byte array return whether it is processed and committed .
37,549
private String [ ] getAlternateNames ( String name ) { String oldName , altNames [ ] = null ; DeprecatedKeyInfo keyInfo = deprecatedKeyMap . get ( name ) ; if ( keyInfo == null ) { altNames = ( reverseDeprecatedKeyMap . get ( name ) != null ) ? new String [ ] { reverseDeprecatedKeyMap . get ( name ) } : null ; if ( alt...
Returns the alternate name for a key if the property name is deprecated or if deprecates a property name .
37,550
public IntegerRanges getRange ( String name ) { String valueString = get ( name ) ; Preconditions . checkNotNull ( valueString ) ; return new IntegerRanges ( valueString ) ; }
Parse the given attribute as a set of integer ranges .
37,551
public Map < String , String > getValByRegex ( String regex ) { Pattern p = Pattern . compile ( regex ) ; Map < String , String > result = new HashMap < String , String > ( ) ; Matcher m ; for ( Map . Entry < Object , Object > item : getProps ( ) . entrySet ( ) ) { if ( item . getKey ( ) instanceof String && item . get...
get keys matching the the regex .
37,552
protected final < V > void error ( Throwable t , SettableFuture < V > future ) { state . set ( State . ERROR ) ; if ( future != null ) { future . setException ( t ) ; } caller . error ( t ) ; }
Force this controller into error state .
37,553
protected final void started ( ) { if ( ! state . compareAndSet ( State . STARTING , State . ALIVE ) ) { LOG . info ( "Program already started {} {}" , programName , runId ) ; return ; } LOG . info ( "Program started: {} {}" , programName , runId ) ; executor ( State . ALIVE ) . execute ( new Runnable ( ) { public void...
Children call this method to signal the program is started .
37,554
private Arguments createProgramArguments ( TwillContext context , Map < String , String > configs ) { Map < String , String > args = ImmutableMap . < String , String > builder ( ) . put ( ProgramOptionConstants . INSTANCE_ID , Integer . toString ( context . getInstanceId ( ) ) ) . put ( ProgramOptionConstants . INSTANC...
Creates program arguments . It includes all configurations from the specification excluding hConf and cConf .
37,555
@ SuppressWarnings ( "unchecked" ) protected final Schema doGenerate ( TypeToken < ? > typeToken , Set < String > knownRecords , boolean acceptRecursion ) throws UnsupportedTypeException { Type type = typeToken . getType ( ) ; Class < ? > rawType = typeToken . getRawType ( ) ; if ( SIMPLE_SCHEMAS . containsKey ( rawTyp...
Actual schema generation . It recursively resolves container types .
37,556
void open ( int groupSize ) { try { close ( ) ; ConsumerConfig config = consumerConfig ; if ( groupSize != config . getGroupSize ( ) ) { config = new ConsumerConfig ( consumerConfig . getGroupId ( ) , consumerConfig . getInstanceId ( ) , groupSize , consumerConfig . getDequeueStrategy ( ) , consumerConfig . getHashKey ...
Updates number of instances for the consumer group that this instance belongs to . It ll close existing consumer and create a new one with the new group size .
37,557
public void close ( ) throws IOException { try { if ( consumer != null && consumer instanceof Closeable ) { TransactionContext txContext = dataFabricFacade . createTransactionManager ( ) ; txContext . start ( ) ; try { ( ( Closeable ) consumer ) . close ( ) ; txContext . finish ( ) ; } catch ( TransactionFailureExcepti...
Close the current consumer if there is one .
37,558
public boolean isCompatible ( Schema target ) { if ( equals ( target ) ) { return true ; } Multimap < String , String > recordCompared = HashMultimap . create ( ) ; return checkCompatible ( target , recordCompared ) ; }
Checks if the given target schema is compatible with this schema meaning datum being written with this schema could be projected correctly into the given target schema .
37,559
private < V > BiMap < V , Integer > createIndex ( Set < V > values ) { if ( values == null ) { return null ; } ImmutableBiMap . Builder < V , Integer > builder = ImmutableBiMap . builder ( ) ; int idx = 0 ; for ( V value : values ) { builder . put ( value , idx ++ ) ; } return builder . build ( ) ; }
Creates a map of indexes based on the iteration order of the given set .
37,560
private Map < String , Field > populateRecordFields ( Map < String , Field > fields ) { if ( fields == null ) { return null ; } Map < String , Schema > knownRecordSchemas = Maps . newHashMap ( ) ; knownRecordSchemas . put ( recordName , this ) ; ImmutableMap . Builder < String , Field > builder = ImmutableMap . builder...
Resolves all field schemas .
37,561
private Schema resolveSchema ( final Schema schema , final Map < String , Schema > knownRecordSchemas ) { switch ( schema . getType ( ) ) { case ARRAY : Schema componentSchema = resolveSchema ( schema . getComponentSchema ( ) , knownRecordSchemas ) ; return ( componentSchema == schema . getComponentSchema ( ) ) ? schem...
This method is to recursively resolves all name only record schema in the given schema .
37,562
private String buildString ( ) { if ( type . isSimpleType ( ) ) { return '"' + type . name ( ) . toLowerCase ( ) + '"' ; } StringBuilder builder = new StringBuilder ( ) ; JsonWriter writer = new JsonWriter ( CharStreams . asWriter ( builder ) ) ; try { new SchemaTypeAdapter ( ) . write ( writer , this ) ; writer . clos...
Helper method to encode this schema into json string .
37,563
private void waitForInstances ( String flowletId , int expectedInstances ) throws InterruptedException , TimeoutException { int numRunningFlowlets = getNumberOfProvisionedInstances ( flowletId ) ; int secondsWaited = 0 ; while ( numRunningFlowlets != expectedInstances ) { LOG . debug ( "waiting for {} instances of {} b...
it cannot change instances without being in the suspended state .
37,564
private void setDefaultConfiguration ( HTableDescriptor tableDescriptor , Configuration conf ) { String compression = conf . get ( CFG_HBASE_TABLE_COMPRESSION , DEFAULT_COMPRESSION_TYPE . name ( ) ) ; CompressionType compressionAlgo = CompressionType . valueOf ( compression ) ; for ( HColumnDescriptor hcd : tableDescri...
which doesn t support certain compression type
37,565
public static Map < String , CoprocessorInfo > getCoprocessorInfo ( HTableDescriptor tableDescriptor ) { Map < String , CoprocessorInfo > info = Maps . newHashMap ( ) ; for ( Map . Entry < ImmutableBytesWritable , ImmutableBytesWritable > entry : tableDescriptor . getValues ( ) . entrySet ( ) ) { String key = Bytes . t...
Returns information for all coprocessor configured for the table .
37,566
private void invoke ( Method method , Object event , InputContext inputContext ) throws Exception { if ( needContext ) { method . invoke ( flowlet , event , inputContext ) ; } else { method . invoke ( flowlet , event ) ; } }
Calls the user process method .
37,567
public static CConfiguration create ( ) { CConfiguration conf = new CConfiguration ( ) ; conf . addResource ( "tigon-default.xml" ) ; conf . addResource ( "tigon-site.xml" ) ; return conf ; }
Creates an instance of configuration .
37,568
protected void upgradeTable ( String tableNameStr ) throws IOException { byte [ ] tableName = Bytes . toBytes ( tableNameStr ) ; HTableDescriptor tableDescriptor = getAdmin ( ) . getTableDescriptor ( tableName ) ; boolean needUpgrade = upgradeTable ( tableDescriptor ) ; ProjectInfo . Version version = new ProjectInfo ....
Performs upgrade on a given HBase table .
37,569
public static void mkdirsIfNotExists ( Location location ) throws IOException { if ( ! location . isDirectory ( ) && ! location . mkdirs ( ) && ! location . isDirectory ( ) ) { throw new IOException ( "Failed to create directory at " + location . toURI ( ) ) ; } }
Create the directory represented by the location if not exists .
37,570
public static Manifest getManifest ( Location jarLocation ) throws IOException { URI uri = jarLocation . toURI ( ) ; if ( "file" . equals ( uri . getScheme ( ) ) ) { JarFile jarFile = new JarFile ( new File ( uri ) ) ; try { return jarFile . getManifest ( ) ; } finally { jarFile . close ( ) ; } } JarInputStream is = ne...
Load the manifest inside the given jar .
37,571
protected int persist ( Iterable < QueueEntry > entries , Transaction transaction ) throws IOException { long writePointer = transaction . getWritePointer ( ) ; byte [ ] rowKeyPrefix = Bytes . add ( queueRowPrefix , Bytes . toBytes ( writePointer ) ) ; int count = 0 ; List < Put > puts = Lists . newArrayList ( ) ; int ...
Persist queue entries into HBase .
37,572
public static Credentials obtainToken ( Configuration hConf , Credentials credentials ) { if ( ! User . isHBaseSecurityEnabled ( hConf ) ) { return credentials ; } try { Class c = Class . forName ( "org.apache.hadoop.hbase.security.token.TokenUtil" ) ; Method method = c . getMethod ( "obtainToken" , Configuration . cla...
Gets a HBase delegation token and stores it in the given Credentials .
37,573
public void suspend ( ) { if ( suspension . compareAndSet ( null , new CountDownLatch ( 1 ) ) ) { try { suspendBarrier . await ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } catch ( BrokenBarrierException e ) { LOG . error ( "Exception during suspend: " + flowletContext , e ) ...
Suspend the running of flowlet . This method will block until the flowlet running thread actually suspended .
37,574
public void resume ( ) { CountDownLatch latch = suspension . getAndSet ( null ) ; if ( latch != null ) { suspendBarrier . reset ( ) ; latch . countDown ( ) ; } }
Resume the running of flowlet .
37,575
private void postProcess ( ProcessMethodCallback callback , TransactionContext txContext , InputDatum input , ProcessMethod . ProcessResult result ) { InputContext inputContext = input . getInputContext ( ) ; Throwable failureCause = null ; FailureReason . Type failureType = FailureReason . Type . IO_ERROR ; try { if (...
Process the process result . This method never throws .
37,576
public static int putBytes ( byte [ ] tgtBytes , int tgtOffset , byte [ ] srcBytes , int srcOffset , int srcLength ) { System . arraycopy ( srcBytes , srcOffset , tgtBytes , tgtOffset , srcLength ) ; return tgtOffset + srcLength ; }
Put bytes at the specified byte array position .
37,577
public static byte [ ] toBytes ( ByteBuffer bb ) { int length = bb . limit ( ) ; byte [ ] result = new byte [ length ] ; System . arraycopy ( bb . array ( ) , bb . arrayOffset ( ) , result , 0 , length ) ; return result ; }
Returns a new byte array copied from the passed ByteBuffer .
37,578
public static String toStringBinary ( ByteBuffer buf ) { if ( buf == null ) { return "null" ; } return toStringBinary ( buf . array ( ) , buf . arrayOffset ( ) , buf . limit ( ) ) ; }
Converts the given byte buffer from its array offset to its limit to a string . The position and the mark are ignored .
37,579
public static long toLong ( byte [ ] bytes , int offset , final int length ) { if ( length != SIZEOF_LONG || offset + length > bytes . length ) { throw explainWrongLengthOrOffset ( bytes , offset , length , SIZEOF_LONG ) ; } long l = 0 ; for ( int i = offset ; i < offset + length ; i ++ ) { l <<= 8 ; l ^= bytes [ i ] &...
Converts a byte array to a long value .
37,580
public static int putLong ( byte [ ] bytes , int offset , long val ) { if ( bytes . length - offset < SIZEOF_LONG ) { throw new IllegalArgumentException ( "Not enough room to put a long at" + " offset " + offset + " in a " + bytes . length + " byte array" ) ; } for ( int i = offset + 7 ; i > offset ; i -- ) { bytes [ i...
Put a long value out to the specified byte array position .
37,581
public static int putFloat ( byte [ ] bytes , int offset , float f ) { return putInt ( bytes , offset , Float . floatToRawIntBits ( f ) ) ; }
Put a float value out to the specified byte array position .
37,582
public static int putDouble ( byte [ ] bytes , int offset , double d ) { return putLong ( bytes , offset , Double . doubleToLongBits ( d ) ) ; }
Put a double value out to the specified byte array position .
37,583
public static byte [ ] toBytes ( int val ) { byte [ ] b = new byte [ 4 ] ; for ( int i = 3 ; i > 0 ; i -- ) { b [ i ] = ( byte ) val ; val >>>= 8 ; } b [ 0 ] = ( byte ) val ; return b ; }
Convert an int value to a byte array .
37,584
public static int putInt ( byte [ ] bytes , int offset , int val ) { if ( bytes . length - offset < SIZEOF_INT ) { throw new IllegalArgumentException ( "Not enough room to put an int at" + " offset " + offset + " in a " + bytes . length + " byte array" ) ; } for ( int i = offset + 3 ; i > offset ; i -- ) { bytes [ i ] ...
Put an int value out to the specified byte array position .
37,585
public static short toShort ( byte [ ] bytes , int offset , final int length ) { if ( length != SIZEOF_SHORT || offset + length > bytes . length ) { throw explainWrongLengthOrOffset ( bytes , offset , length , SIZEOF_SHORT ) ; } short n = 0 ; n ^= bytes [ offset ] & 0xFF ; n <<= 8 ; n ^= bytes [ offset + 1 ] & 0xFF ; r...
Converts a byte array to a short value .
37,586
public static byte [ ] getBytes ( ByteBuffer buf ) { int savedPos = buf . position ( ) ; byte [ ] newBytes = new byte [ buf . remaining ( ) ] ; buf . get ( newBytes ) ; buf . position ( savedPos ) ; return newBytes ; }
This method will get a sequence of bytes from pos - > limit but will restore pos after .
37,587
public static int putShort ( byte [ ] bytes , int offset , short val ) { if ( bytes . length - offset < SIZEOF_SHORT ) { throw new IllegalArgumentException ( "Not enough room to put a short at" + " offset " + offset + " in a " + bytes . length + " byte array" ) ; } bytes [ offset + 1 ] = ( byte ) val ; val >>= 8 ; byte...
Put a short value out to the specified byte array position .
37,588
public static byte [ ] toBytes ( BigDecimal val ) { byte [ ] valueBytes = val . unscaledValue ( ) . toByteArray ( ) ; byte [ ] result = new byte [ valueBytes . length + SIZEOF_INT ] ; int offset = putInt ( result , 0 , val . scale ( ) ) ; putBytes ( result , offset , valueBytes , 0 , valueBytes . length ) ; return resu...
Convert a BigDecimal value to a byte array .
37,589
public static BigDecimal toBigDecimal ( byte [ ] bytes , int offset , final int length ) { if ( bytes == null || length < SIZEOF_INT + 1 || ( offset + length > bytes . length ) ) { return null ; } int scale = toInt ( bytes , offset ) ; byte [ ] tcBytes = new byte [ length - SIZEOF_INT ] ; System . arraycopy ( bytes , o...
Converts a byte array to a BigDecimal value .
37,590
public static int putBigDecimal ( byte [ ] bytes , int offset , BigDecimal val ) { if ( bytes == null ) { return offset ; } byte [ ] valueBytes = val . unscaledValue ( ) . toByteArray ( ) ; byte [ ] result = new byte [ valueBytes . length + SIZEOF_INT ] ; offset = putInt ( result , offset , val . scale ( ) ) ; return p...
Put a BigDecimal value out to the specified byte array position .
37,591
public static boolean startsWith ( byte [ ] bytes , byte [ ] prefix ) { return bytes != null && prefix != null && bytes . length >= prefix . length && LexicographicalComparerHolder . BEST_COMPARER . compareTo ( bytes , 0 , prefix . length , prefix , 0 , prefix . length ) == 0 ; }
Return true if the byte array on the right is a prefix of the byte array on the left .
37,592
public static int hashBytes ( byte [ ] bytes , int offset , int length ) { int hash = 1 ; for ( int i = offset ; i < offset + length ; i ++ ) { hash = ( 31 * hash ) + bytes [ i ] ; } return hash ; }
Compute hash for binary data .
37,593
public static byte [ ] add ( final byte [ ] a , final byte [ ] b , final byte [ ] c ) { byte [ ] result = new byte [ a . length + b . length + c . length ] ; System . arraycopy ( a , 0 , result , 0 , a . length ) ; System . arraycopy ( b , 0 , result , a . length , b . length ) ; System . arraycopy ( c , 0 , result , a...
Concatenate three byte arrays .
37,594
public static byte [ ] [ ] split ( final byte [ ] a , final byte [ ] b , boolean inclusive , final int num ) { byte [ ] [ ] ret = new byte [ num + 2 ] [ ] ; int i = 0 ; Iterable < byte [ ] > iter = iterateOnSplits ( a , b , inclusive , num ) ; if ( iter == null ) { return null ; } for ( byte [ ] elem : iter ) { ret [ i...
Split passed range . Expensive operation relatively . Uses BigInteger math . Useful splitting ranges for MapReduce jobs .
37,595
public static Iterable < byte [ ] > iterateOnSplits ( final byte [ ] a , final byte [ ] b , final int num ) { return iterateOnSplits ( a , b , false , num ) ; }
Iterate over keys within the passed range splitting at an [ a b ) boundary .
37,596
public static Iterable < byte [ ] > iterateOnSplits ( final byte [ ] a , final byte [ ] b , boolean inclusive , final int num ) { byte [ ] aPadded ; byte [ ] bPadded ; if ( a . length < b . length ) { aPadded = padTail ( a , b . length - a . length ) ; bPadded = b ; } else if ( b . length < a . length ) { aPadded = a ;...
Iterate over keys within the passed range .
37,597
public static byte [ ] [ ] toByteArrays ( final String [ ] t ) { byte [ ] [ ] result = new byte [ t . length ] [ ] ; for ( int i = 0 ; i < t . length ; i ++ ) { result [ i ] = Bytes . toBytes ( t [ i ] ) ; } return result ; }
Returns an array of byte arrays made from passed array of Text .
37,598
public static void writeStringFixedSize ( final DataOutput out , String s , int size ) throws IOException { byte [ ] b = toBytes ( s ) ; if ( b . length > size ) { throw new IOException ( "Trying to write " + b . length + " bytes (" + toStringBinary ( b ) + ") into a field of length " + size ) ; } out . writeBytes ( s ...
Writes a string as a fixed - size field padded with zeros .
37,599
private Filter createFilter ( ) { return new FilterList ( FilterList . Operator . MUST_PASS_ONE , processedStateFilter , new SingleColumnValueFilter ( QueueEntryRow . COLUMN_FAMILY , stateColumnName , CompareFilter . CompareOp . GREATER , new BinaryPrefixComparator ( Bytes . toBytes ( transaction . getReadPointer ( ) )...
Creates a HBase filter that will filter out rows that that has committed state = PROCESSED .