idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
118,600
public static void printAllJobs ( List < JobExecutionInfo > jobExecutionInfos , int resultsLimit ) { if ( jobExecutionInfos == null ) { System . err . println ( "No jobs found." ) ; System . exit ( 1 ) ; } List < String > labels = Arrays . asList ( "Job Name" , "State" , "Last Run Started" , "Last Run Completed" , "Sch...
Print summary information about a bunch of jobs in the system
118,601
public static void printJob ( Optional < JobExecutionInfo > jobExecutionInfoOptional ) { if ( ! jobExecutionInfoOptional . isPresent ( ) ) { System . err . println ( "Job id not found." ) ; return ; } JobExecutionInfo jobExecutionInfo = jobExecutionInfoOptional . get ( ) ; List < List < String > > data = new ArrayList ...
Print information about one specific job .
118,602
public static void printJobProperties ( Optional < JobExecutionInfo > jobExecutionInfoOptional ) { if ( ! jobExecutionInfoOptional . isPresent ( ) ) { System . err . println ( "Job not found." ) ; return ; } List < List < String > > data = new ArrayList < > ( ) ; List < String > flags = Arrays . asList ( "" , "-" ) ; L...
Print properties of a specific job
118,603
private static void printMetrics ( MetricArray metrics ) { System . out . println ( ) ; if ( metrics . size ( ) == 0 ) { System . out . println ( "No metrics found." ) ; return ; } List < List < String > > data = new ArrayList < > ( ) ; List < String > flags = Arrays . asList ( "" , "-" ) ; for ( Metric metric : metric...
Print out various metrics
118,604
@ CliObjectOption ( description = "Sets the period for which articles should be pulled in ISO time format (e.g. P2D, PT1H)" ) public EmbeddedWikipediaExample lookback ( String isoLookback ) { this . setConfiguration ( WikipediaExtractor . BOOTSTRAP_PERIOD , isoLookback ) ; return this ; }
Set bootstrap lookback i . e . oldest revision to pull .
118,605
@ CliObjectOption ( description = "Write output to Avro files. Specify the output directory as argument." ) public EmbeddedWikipediaExample avroOutput ( String outputPath ) { this . setConfiguration ( ConfigurationKeys . WRITER_BUILDER_CLASS , AvroDataWriterBuilder . class . getName ( ) ) ; this . setConfiguration ( Co...
Write output to avro files at the given input location .
118,606
protected OrcKey convertOrcStructToOrcKey ( OrcStruct struct ) { OrcKey orcKey = new OrcKey ( ) ; orcKey . key = struct ; return orcKey ; }
The output key of mapper needs to be comparable . In the scenarios that we need the orc record itself to be the output key this conversion will be necessary .
118,607
public void afterRead ( D record , long startTime ) { Instrumented . updateTimer ( this . extractorTimer , System . nanoTime ( ) - startTime , TimeUnit . NANOSECONDS ) ; if ( record != null ) { Instrumented . markMeter ( this . readRecordsMeter ) ; } }
Called after each record is read .
118,608
public void nextStage ( String name ) throws IOException { endStage ( ) ; this . currentStage = name ; this . currentStageStart = System . currentTimeMillis ( ) ; }
End the previous stage record the time spent in that stage and start the timer for a new stage .
118,609
public void endStage ( ) { if ( this . currentStage != null ) { long time = System . currentTimeMillis ( ) - this . currentStageStart ; this . timings . add ( new Stage ( this . currentStage , time ) ) ; if ( reportAsMetrics && submitter . getMetricContext ( ) . isPresent ( ) ) { String timerName = submitter . getNames...
End the previous stage and record the time spent in that stage .
118,610
public void submit ( Map < String , String > additionalMetadata ) throws IOException { if ( this . submitted ) { throw new IOException ( "MultiTimingEvent has already been submitted." ) ; } this . submitted = true ; endStage ( ) ; Map < String , String > finalMetadata = Maps . newHashMap ( ) ; finalMetadata . putAll ( ...
Ends the current stage and submits the event containing the timings of each event .
118,611
public Optional < JobExecutionInfo > queryByJobId ( String id ) throws RemoteInvocationException { JobExecutionQuery query = new JobExecutionQuery ( ) ; query . setIdType ( QueryIdTypeEnum . JOB_ID ) ; query . setId ( JobExecutionQuery . Id . create ( id ) ) ; query . setLimit ( 1 ) ; List < JobExecutionInfo > results ...
Retrieve a Gobblin job by its id .
118,612
public List < JobExecutionInfo > queryAllJobs ( QueryListType lookupType , int resultsLimit ) throws RemoteInvocationException { JobExecutionQuery query = new JobExecutionQuery ( ) ; query . setIdType ( QueryIdTypeEnum . LIST_TYPE ) ; query . setId ( JobExecutionQuery . Id . create ( lookupType ) ) ; query . setJobProp...
Retrieve all jobs
118,613
public List < JobExecutionInfo > queryByJobName ( String name , int resultsLimit ) throws RemoteInvocationException { JobExecutionQuery query = new JobExecutionQuery ( ) ; query . setIdType ( QueryIdTypeEnum . JOB_NAME ) ; query . setId ( JobExecutionQuery . Id . create ( name ) ) ; query . setIncludeTaskExecutions ( f...
Query jobs by name
118,614
private List < JobExecutionInfo > executeQuery ( JobExecutionQuery query ) throws RemoteInvocationException { JobExecutionQueryResult result = this . client . get ( query ) ; if ( result != null && result . hasJobExecutions ( ) ) { return result . getJobExecutions ( ) ; } return Collections . emptyList ( ) ; }
Execute a query and coerce the result into a java List
118,615
private boolean shouldPublishDataInTask ( ) { boolean publishDataAtJobLevel = this . taskState . getPropAsBoolean ( ConfigurationKeys . PUBLISH_DATA_AT_JOB_LEVEL , ConfigurationKeys . DEFAULT_PUBLISH_DATA_AT_JOB_LEVEL ) ; if ( publishDataAtJobLevel ) { LOG . info ( String . format ( "%s is true. Will publish data at th...
Whether the task should directly publish its output data to the final publisher output directory .
118,616
private static boolean inMultipleBranches ( List < Boolean > branches ) { int inBranches = 0 ; for ( Boolean bool : branches ) { if ( bool && ++ inBranches > 1 ) { break ; } } return inBranches > 1 ; }
Check if a schema or data record is being passed to more than one branches .
118,617
public synchronized boolean cancel ( ) { if ( this . taskFuture != null && this . taskFuture . cancel ( true ) ) { this . taskStateTracker . onTaskRunCompletion ( this ) ; this . completeShutdown ( ) ; return true ; } else { return false ; } }
return true if the task is successfully cancelled .
118,618
protected GenericRecord convertRecord ( GenericRecord record ) throws IOException { return AvroUtils . convertRecordSchema ( record , this . schema . get ( ) ) ; }
Convert the record to the output schema of this extractor
118,619
private Path getDatasetDirForKey ( ConfigKeyPath configKey ) throws VersionDoesNotExistException { return this . fs . getPath ( this . storePrefix , configKey . getAbsolutePathString ( ) ) ; }
Get path object using zipped file system and relative path
118,620
public Future < ? extends List < Pair < SpecExecutor . Verb , Spec > > > changedSpecs ( ) { List < Pair < SpecExecutor . Verb , Spec > > changesSpecs = new ArrayList < > ( ) ; try { Pair < SpecExecutor . Verb , Spec > specPair = _jobSpecQueue . take ( ) ; _metrics . jobSpecDeqCount . incrementAndGet ( ) ; do { changesS...
This method returns job specs receive from Kafka . It will block if there are no job specs .
118,621
public synchronized boolean remove ( String name ) { MetricContext metricContext = this . metricContext . get ( ) ; if ( metricContext != null ) { metricContext . removeFromMetrics ( this . contextAwareMetrics . get ( name ) . getContextAwareMetric ( ) ) ; } return this . contextAwareMetrics . remove ( name ) != null &...
Remove a metric with a given name .
118,622
private static long getInterval ( long lowWatermarkValue , long highWatermarkValue , long partitionInterval , int maxIntervals ) { if ( lowWatermarkValue > highWatermarkValue ) { LOG . info ( "lowWatermarkValue: " + lowWatermarkValue + " is greater than highWatermarkValue: " + highWatermarkValue ) ; return 0 ; } long o...
recalculate interval if total number of partitions greater than maximum number of allowed partitions
118,623
protected void report ( SortedMap < String , Gauge > gauges , SortedMap < String , Counter > counters , SortedMap < String , Histogram > histograms , SortedMap < String , Meter > meters , SortedMap < String , Timer > timers , Map < String , Object > tags , boolean isFinal ) { report ( gauges , counters , histograms , m...
Report the input metrics . The input tags apply to all input metrics .
118,624
public boolean getPermits ( long permits ) throws InterruptedException { if ( permits <= 0 ) { return true ; } long startTimeNanos = System . nanoTime ( ) ; this . permitsOutstanding . addEntryWithWeight ( permits ) ; this . lock . lock ( ) ; try { while ( true ) { if ( permits >= this . knownUnsatisfiablePermits ) { b...
Try to get a number of permits from this requester .
118,625
private void maybeSendNewPermitRequest ( ) { if ( ! this . requestSemaphore . tryAcquire ( ) ) { return ; } if ( ! this . retryStatus . canRetryNow ( ) ) { this . requestSemaphore . release ( ) ; return ; } try { long permits = computeNextPermitRequest ( ) ; if ( permits <= 0 ) { this . requestSemaphore . release ( ) ;...
Send a new permit request to the server .
118,626
public static Optional < Long > getRateIfRateControlled ( FileSystem fs ) { if ( fs instanceof Decorator ) { List < Object > lineage = DecoratorUtils . getDecoratorLineage ( fs ) ; for ( Object obj : lineage ) { if ( obj instanceof RateControlledFileSystem ) { return Optional . of ( ( ( RateControlledFileSystem ) obj )...
Determines whether the file system is rate controlled and if so returns the allowed rate in operations per second .
118,627
public static DefaultJobSpecScheduleImpl createImmediateSchedule ( JobSpec jobSpec , Runnable jobRunnable ) { return new DefaultJobSpecScheduleImpl ( jobSpec , jobRunnable , Optional . of ( System . currentTimeMillis ( ) ) ) ; }
Creates a schedule denoting that the job is to be executed immediately
118,628
public static DefaultJobSpecScheduleImpl createNoSchedule ( JobSpec jobSpec , Runnable jobRunnable ) { return new DefaultJobSpecScheduleImpl ( jobSpec , jobRunnable , Optional . < Long > absent ( ) ) ; }
Creates a schedule denoting that the job is not to be executed
118,629
Path getTargetLocation ( FileSystem sourceFs , FileSystem targetFs , Path path , Optional < Partition > partition ) throws IOException { return getTargetPathHelper ( ) . getTargetPath ( path , targetFs , partition , false ) ; }
Compute the target location for a Hive location .
118,630
public static File getIvySettingsFile ( ) throws IOException { URL settingsUrl = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( IVY_SETTINGS_FILE_NAME ) ; if ( settingsUrl == null ) { throw new IOException ( "Failed to find " + IVY_SETTINGS_FILE_NAME + " from class path" ) ; } File ivySettingsFi...
Get ivy settings file from classpath
118,631
public DataWriterBuilder < S , D > writeTo ( Destination destination ) { this . destination = destination ; log . debug ( "For destination: {}" , destination ) ; return this ; }
Tell the writer the destination to write to .
118,632
public DataWriterBuilder < S , D > withWriterId ( String writerId ) { this . writerId = writerId ; log . debug ( "withWriterId : {}" , this . writerId ) ; return this ; }
Give the writer a unique ID .
118,633
public DataWriterBuilder < S , D > withSchema ( S schema ) { this . schema = schema ; log . debug ( "withSchema : {}" , this . schema ) ; return this ; }
Tell the writer the data schema .
118,634
public DataWriterBuilder < S , D > withBranches ( int branches ) { this . branches = branches ; log . debug ( "With branches: {}" , this . branches ) ; return this ; }
Tell the writer how many branches are being used .
118,635
public DataWriterBuilder < S , D > forBranch ( int branch ) { this . branch = branch ; log . debug ( "For branch: {}" , this . branch ) ; return this ; }
Tell the writer which branch it is associated with .
118,636
public static boolean isHiveTableAvroType ( Table targetTable ) throws IOException { String serializationLib = targetTable . getTTable ( ) . getSd ( ) . getSerdeInfo ( ) . getSerializationLib ( ) ; String inputFormat = targetTable . getTTable ( ) . getSd ( ) . getInputFormat ( ) ; String outputFormat = targetTable . ge...
Tell whether a hive table is actually an Avro table
118,637
public static String getCreateTableQuery ( String completeNewTableName , String likeTableDbName , String likeTableName , String location ) { return getCreateTableQuery ( completeNewTableName , likeTableDbName , likeTableName ) + " LOCATION " + PartitionUtils . getQuotedString ( location ) ; }
If staging table doesn t exist it will create a staging table .
118,638
public static String getInsertQuery ( PurgeableHivePartitionDataset dataset ) { return "INSERT OVERWRITE" + " TABLE " + dataset . getCompleteStagingTableName ( ) + " PARTITION (" + PartitionUtils . getPartitionSpecString ( dataset . getSpec ( ) ) + ")" + " SELECT /*+MAPJOIN(b) */ " + getCommaSeparatedColumnNames ( data...
This query will create a partition in staging table and insert the datasets whose compliance id is not contained in the compliance id table .
118,639
public static List < String > getPurgeQueries ( PurgeableHivePartitionDataset dataset ) { List < String > queries = new ArrayList < > ( ) ; queries . add ( getUseDbQuery ( dataset . getStagingDb ( ) ) ) ; queries . add ( getInsertQuery ( dataset ) ) ; return queries ; }
Will return all the queries needed to populate the staging table partition . This won t include alter table partition location query .
118,640
public static List < String > getBackupQueries ( PurgeableHivePartitionDataset dataset ) { List < String > queries = new ArrayList < > ( ) ; queries . add ( getUseDbQuery ( dataset . getDbName ( ) ) ) ; queries . add ( getCreateTableQuery ( dataset . getCompleteBackupTableName ( ) , dataset . getDbName ( ) , dataset . ...
Will return all the queries needed to have a backup table partition pointing to the original partition data location
118,641
public static List < String > getAlterOriginalPartitionLocationQueries ( PurgeableHivePartitionDataset dataset ) { List < String > queries = new ArrayList < > ( ) ; queries . add ( getUseDbQuery ( dataset . getDbName ( ) ) ) ; String partitionSpecString = PartitionUtils . getPartitionSpecString ( dataset . getSpec ( ) ...
Will return all the queries needed to alter the location of the table partition . Alter table partition query doesn t work with syntax dbName . tableName
118,642
protected Field convertFieldSchema ( Schema inputSchema , Field field , WorkUnitState workUnit ) throws SchemaConversionException { if ( field . name ( ) . equals ( payloadField ) ) { return createLatestPayloadField ( field ) ; } return new Field ( field . name ( ) , field . schema ( ) , field . doc ( ) , field . defau...
Convert to the output schema of a field
118,643
protected Object convertFieldValue ( Schema outputSchema , Field field , GenericRecord inputRecord , WorkUnitState workUnit ) throws DataConversionException { if ( field . name ( ) . equals ( payloadField ) ) { return upConvertPayload ( inputRecord ) ; } return inputRecord . get ( field . name ( ) ) ; }
Convert to the output value of a field
118,644
private String convertFormat ( long watermark ) { Preconditions . checkArgument ( watermark > 0 , "Watermark should be positive number." ) ; return googleAnalyticsFormatter . print ( watermarkFormatter . parseDateTime ( Long . toString ( watermark ) ) ) ; }
Converts date format from watermark format to Google analytics format
118,645
public void submitCallable ( Callable < Void > callable , String name ) { this . futures . add ( new NamedFuture ( this . executor . submit ( callable ) , name ) ) ; }
Submit a callable to the thread pool
118,646
public void write ( byte [ ] record ) throws IOException { Preconditions . checkNotNull ( record ) ; byte [ ] toWrite = record ; if ( this . recordDelimiter . isPresent ( ) ) { toWrite = Arrays . copyOf ( record , record . length + 1 ) ; toWrite [ toWrite . length - 1 ] = this . recordDelimiter . get ( ) ; } if ( this ...
Write a source record to the staging file
118,647
public boolean moveToTrashAsUser ( Path path , final String user ) throws IOException { return getUserTrash ( user ) . moveToTrash ( path ) ; }
Move the path to trash as specified user .
118,648
public boolean moveToTrashAsOwner ( Path path ) throws IOException { String owner = this . fs . getFileStatus ( path ) . getOwner ( ) ; return moveToTrashAsUser ( path , owner ) ; }
Move the path to trash as the owner of the path .
118,649
public void run ( ) throws Exception { try { CountDownLatch countDownLatch = new CountDownLatch ( this . tasks ) ; for ( int i = 0 ; i < this . tasks ; i ++ ) { addTask ( i , countDownLatch ) ; } countDownLatch . await ( ) ; } finally { try { this . context . close ( ) ; } finally { this . executor . shutdownNow ( ) ; ...
Run the example .
118,650
private void checkSrcLogFiles ( ) throws IOException { List < FileStatus > srcLogFiles = new ArrayList < > ( ) ; for ( Path logDirPath : this . srcLogDirs ) { srcLogFiles . addAll ( FileListUtils . listFilesRecursively ( this . srcFs , logDirPath , new PathFilter ( ) { public boolean accept ( Path path ) { return LogCo...
Perform a check on new source log files and submit copy tasks for new log files .
118,651
public static void addToHadoopConfiguration ( Configuration conf ) { final String SERIALIZATION_KEY = "io.serializations" ; String existingSerializers = conf . get ( SERIALIZATION_KEY ) ; if ( existingSerializers != null ) { conf . set ( SERIALIZATION_KEY , existingSerializers + "," + WritableShimSerialization . class ...
Helper method to add this serializer to an existing Hadoop config .
118,652
public List < ? extends ProducerJob > partitionJobs ( ) { UrlTrieNode root = _jobNode . getRight ( ) ; if ( isOperatorEquals ( ) || root . getSize ( ) == 1 ) { return super . partitionJobs ( ) ; } else { if ( _groupSize <= 1 ) { throw new RuntimeException ( "This is impossible. When group size is 1, the operator must b...
The implementation here will first partition the job by pages and then by dates .
118,653
public void push ( Point point ) { BatchPoints . Builder batchPointsBuilder = BatchPoints . database ( database ) . retentionPolicy ( DEFAULT_RETENTION_POLICY ) ; batchPointsBuilder . point ( point ) ; influxDB . write ( batchPointsBuilder . build ( ) ) ; }
Push a single Point
118,654
public static long getPropAsLongFromSingleOrMultiWorkUnitState ( WorkUnitState workUnitState , String key , int partitionId ) { return Long . parseLong ( workUnitState . contains ( key ) ? workUnitState . getProp ( key ) : workUnitState . getProp ( KafkaUtils . getPartitionPropName ( key , partitionId ) , "0" ) ) ; }
Get a property as long from a work unit that may or may not be a multiworkunit . This method is needed because the SingleLevelWorkUnitPacker does not squeeze work units into a multiworkunit and thus does not append the partitionId to property keys while the BiLevelWorkUnitPacker does . Return 0 as default if key not fo...
118,655
private int computeTargetPartitionSize ( Histogram histogram , int minTargetPartitionSize , int maxPartitions ) { return Math . max ( minTargetPartitionSize , DoubleMath . roundToInt ( ( double ) histogram . totalRecordCount / maxPartitions , RoundingMode . CEILING ) ) ; }
Compute the target partition size .
118,656
private int getCountForRange ( TableCountProbingContext probingContext , StrSubstitutor sub , Map < String , String > subValues , long startTime , long endTime ) { String startTimeStr = Utils . dateToString ( new Date ( startTime ) , SalesforceExtractor . SALESFORCE_TIMESTAMP_FORMAT ) ; String endTimeStr = Utils . date...
Get the row count for a time range
118,657
private void getHistogramRecursively ( TableCountProbingContext probingContext , Histogram histogram , StrSubstitutor sub , Map < String , String > values , int count , long startEpoch , long endEpoch ) { long midpointEpoch = startEpoch + ( endEpoch - startEpoch ) / 2 ; if ( count <= probingContext . bucketSizeLimit ||...
Split a histogram bucket along the midpoint if it is larger than the bucket size limit .
118,658
private Histogram getHistogramByProbing ( TableCountProbingContext probingContext , int count , long startEpoch , long endEpoch ) { Histogram histogram = new Histogram ( ) ; Map < String , String > values = new HashMap < > ( ) ; values . put ( "table" , probingContext . entity ) ; values . put ( "column" , probingConte...
Get a histogram for the time range by probing to break down large buckets . Use count instead of querying if it is non - negative .
118,659
private Histogram getRefinedHistogram ( SalesforceConnector connector , String entity , String watermarkColumn , SourceState state , Partition partition , Histogram histogram ) { final int maxPartitions = state . getPropAsInt ( ConfigurationKeys . SOURCE_MAX_NUMBER_OF_PARTITIONS , ConfigurationKeys . DEFAULT_MAX_NUMBER...
Refine the histogram by probing to split large buckets
118,660
private Histogram getHistogramByDayBucketing ( SalesforceConnector connector , String entity , String watermarkColumn , Partition partition ) { Histogram histogram = new Histogram ( ) ; Calendar calendar = new GregorianCalendar ( ) ; Date startDate = Utils . toDate ( partition . getLowWatermark ( ) , Partitioner . WATE...
Get a histogram with day granularity buckets .
118,661
private Histogram getHistogram ( String entity , String watermarkColumn , SourceState state , Partition partition ) { SalesforceConnector connector = getConnector ( state ) ; try { if ( ! connector . connect ( ) ) { throw new RuntimeException ( "Failed to connect." ) ; } } catch ( RestApiConnectionException e ) { throw...
Generate the histogram
118,662
private Retryer < Void > buildRetryer ( State state ) { RetryerBuilder < Void > builder = null ; if ( writer instanceof Retriable ) { builder = ( ( Retriable ) writer ) . getRetryerBuilder ( ) ; } else { builder = createRetryBuilder ( state ) ; } if ( GobblinMetrics . isEnabled ( state ) ) { final Optional < Meter > re...
Build Retryer . - If Writer implements Retriable it will use the RetryerBuilder from the writer . - Otherwise it will use DEFAULT writer builder .
118,663
public static List < Partition > getPartitions ( IMetaStoreClient client , Table table , Optional < String > filter ) throws IOException { return getPartitions ( client , table , filter , Optional . < HivePartitionExtendedFilter > absent ( ) ) ; }
For backward compatibility when PathFilter is injected as a parameter .
118,664
public static Set < Path > getPaths ( InputFormat < ? , ? > inputFormat , Path location ) throws IOException { JobConf jobConf = new JobConf ( getHadoopConfiguration ( ) ) ; Set < Path > paths = Sets . newHashSet ( ) ; FileInputFormat . addInputPaths ( jobConf , location . toString ( ) ) ; InputSplit [ ] splits = input...
Get paths from a Hive location using the provided input format .
118,665
public static String getPathForBranch ( State state , String path , int numBranches , int branchId ) { Preconditions . checkNotNull ( state ) ; Preconditions . checkNotNull ( path ) ; Preconditions . checkArgument ( numBranches >= 0 , "The number of branches is expected to be non-negative" ) ; Preconditions . checkArgu...
Get a new path with the given branch name as a sub directory .
118,666
protected static long getCreateTime ( Table table ) { return TimeUnit . MILLISECONDS . convert ( table . getTTable ( ) . getCreateTime ( ) , TimeUnit . SECONDS ) ; }
Convert createTime from seconds to milliseconds
118,667
private void silenceHiveLoggers ( ) { List < String > loggers = ImmutableList . of ( "org.apache.hadoop.hive" , "org.apache.hive" , "hive.ql.parse" ) ; for ( String name : loggers ) { Logger logger = Logger . getLogger ( name ) ; if ( logger != null ) { logger . setLevel ( Level . WARN ) ; } } }
Hive logging is too verbose at INFO level . Currently hive does not have a way to set log level . This is a workaround to set log level to WARN for hive loggers only
118,668
private void commitDataset ( Collection < TaskState > taskStates , DataPublisher publisher ) { try { publisher . publish ( taskStates ) ; } catch ( Throwable t ) { log . error ( "Failed to commit dataset" , t ) ; setTaskFailureException ( taskStates , t ) ; } }
Commit the output data of a dataset .
118,669
private boolean canCommitDataset ( JobState . DatasetState datasetState ) { return this . jobContext . getJobCommitPolicy ( ) == JobCommitPolicy . COMMIT_ON_PARTIAL_SUCCESS || this . jobContext . getJobCommitPolicy ( ) == JobCommitPolicy . COMMIT_SUCCESSFUL_TASKS || ( this . jobContext . getJobCommitPolicy ( ) == JobCo...
Check if it is OK to commit the output data of a dataset .
118,670
private void persistDatasetState ( String datasetUrn , JobState . DatasetState datasetState ) throws IOException { log . info ( "Persisting dataset state for dataset " + datasetUrn ) ; this . jobContext . getDatasetStateStore ( ) . persistDatasetState ( datasetUrn , datasetState ) ; }
Persist dataset state of a given dataset identified by the dataset URN .
118,671
private Path getOrGenerateSchemaFile ( Schema schema ) throws IOException { Preconditions . checkNotNull ( schema , "Avro Schema should not be null" ) ; String hashedSchema = Hashing . sha256 ( ) . hashString ( schema . toString ( ) , StandardCharsets . UTF_8 ) . toString ( ) ; if ( ! this . schemaPaths . containsKey (...
If url for schema already exists return the url . If not create a new temporary schema file and return a the url .
118,672
public static void writeStringAsText ( DataOutput stream , String str ) throws IOException { byte [ ] utf8Encoded = str . getBytes ( StandardCharsets . UTF_8 ) ; writeVLong ( stream , utf8Encoded . length ) ; stream . write ( utf8Encoded ) ; }
Serialize a String using the same logic as a Hadoop Text object
118,673
public static String readTextAsString ( DataInput in ) throws IOException { int bufLen = ( int ) readVLong ( in ) ; byte [ ] buf = new byte [ bufLen ] ; in . readFully ( buf ) ; return new String ( buf , StandardCharsets . UTF_8 ) ; }
Deserialize a Hadoop Text object into a String
118,674
private static void writeVLong ( DataOutput stream , long i ) throws IOException { if ( i >= - 112 && i <= 127 ) { stream . writeByte ( ( byte ) i ) ; return ; } int len = - 112 ; if ( i < 0 ) { i ^= - 1L ; len = - 120 ; } long tmp = i ; while ( tmp != 0 ) { tmp = tmp >> 8 ; len -- ; } stream . writeByte ( ( byte ) len...
From org . apache . hadoop . io . WritableUtis
118,675
private static long readVLong ( DataInput stream ) throws IOException { byte firstByte = stream . readByte ( ) ; int len = decodeVIntSize ( firstByte ) ; if ( len == 1 ) { return firstByte ; } long i = 0 ; for ( int idx = 0 ; idx < len - 1 ; idx ++ ) { byte b = stream . readByte ( ) ; i = i << 8 ; i = i | ( b & 0xFF ) ...
Reads a zero - compressed encoded long from input stream and returns it .
118,676
private boolean canRun ( String flowName , String flowGroup , boolean allowConcurrentExecution ) { if ( allowConcurrentExecution ) { return true ; } else { return ! flowStatusGenerator . isFlowRunning ( flowName , flowGroup ) ; } }
Check if the flow instance is allowed to run .
118,677
private synchronized void getAllPreviousOffsetState ( SourceState state ) { if ( this . doneGettingAllPreviousOffsets ) { return ; } this . previousOffsets . clear ( ) ; this . previousLowWatermarks . clear ( ) ; this . previousExpectedHighWatermarks . clear ( ) ; this . previousOffsetFetchEpochTimes . clear ( ) ; this...
this . previousOffsetFetchEpochTimes need to be initialized once
118,678
public static String getCoalesceColumnNames ( String columnOrColumnList ) { if ( Strings . isNullOrEmpty ( columnOrColumnList ) ) { return null ; } if ( columnOrColumnList . contains ( "," ) ) { return "COALESCE(" + columnOrColumnList + ")" ; } return columnOrColumnList ; }
Get coalesce of columns if there are multiple comma - separated columns
118,679
public static String printTiming ( long start , long end ) { long totalMillis = end - start ; long mins = TimeUnit . MILLISECONDS . toMinutes ( totalMillis ) ; long secs = TimeUnit . MILLISECONDS . toSeconds ( totalMillis ) - TimeUnit . MINUTES . toSeconds ( mins ) ; long millis = TimeUnit . MILLISECONDS . toMillis ( t...
Print time difference in minutes seconds and milliseconds
118,680
public static List < String > getColumnListFromQuery ( String query ) { if ( Strings . isNullOrEmpty ( query ) ) { return null ; } String queryLowerCase = query . toLowerCase ( ) ; int startIndex = queryLowerCase . indexOf ( "select " ) + 7 ; int endIndex = queryLowerCase . indexOf ( " from " ) ; if ( startIndex < 0 ||...
get column list from the user provided query to build schema with the respective columns
118,681
public static String escapeSpecialCharacters ( String columnName , String escapeChars , String character ) { if ( Strings . isNullOrEmpty ( columnName ) ) { return null ; } if ( StringUtils . isEmpty ( escapeChars ) ) { return columnName ; } List < String > specialChars = Arrays . asList ( escapeChars . split ( "," ) )...
escape characters in column name or table name
118,682
public static long getLongWithCurrentDate ( String value , String timezone ) { if ( Strings . isNullOrEmpty ( value ) ) { return 0 ; } DateTime time = getCurrentTime ( timezone ) ; DateTimeFormatter dtFormatter = DateTimeFormat . forPattern ( CURRENT_DATE_FORMAT ) . withZone ( time . getZone ( ) ) ; if ( value . toUppe...
Helper method for getting a value containing CURRENTDAY - 1 or CURRENTHOUR - 1 in the form yyyyMMddHHmmss
118,683
public static String dateTimeToString ( DateTime input , String format , String timezone ) { String tz = StringUtils . defaultString ( timezone , ConfigurationKeys . DEFAULT_SOURCE_TIMEZONE ) ; DateTimeZone dateTimeZone = getTimeZone ( tz ) ; DateTimeFormatter outputDtFormat = DateTimeFormat . forPattern ( format ) . w...
Convert joda time to a string in the given format
118,684
public static DateTime getCurrentTime ( String timezone ) { String tz = StringUtils . defaultString ( timezone , ConfigurationKeys . DEFAULT_SOURCE_TIMEZONE ) ; DateTimeZone dateTimeZone = getTimeZone ( tz ) ; DateTime currentTime = new DateTime ( dateTimeZone ) ; return currentTime ; }
Get current time - joda
118,685
public static DateTime toDateTime ( String input , String format , String timezone ) { String tz = StringUtils . defaultString ( timezone , ConfigurationKeys . DEFAULT_SOURCE_TIMEZONE ) ; DateTimeZone dateTimeZone = getTimeZone ( tz ) ; DateTimeFormatter inputDtFormat = DateTimeFormat . forPattern ( format ) . withZone...
Convert timestamp in a string format to joda time
118,686
public static DateTime toDateTime ( long input , String format , String timezone ) { return toDateTime ( Long . toString ( input ) , format , timezone ) ; }
Convert timestamp in a long format to joda time
118,687
private static DateTimeZone getTimeZone ( String id ) { DateTimeZone zone ; try { zone = DateTimeZone . forID ( id ) ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "TimeZone " + id + " not recognized" ) ; } return zone ; }
Get time zone of time zone id
118,688
public synchronized void scheduleJob ( Properties jobProps , JobListener jobListener ) throws JobException { Map < String , Object > additionalJobDataMap = Maps . newHashMap ( ) ; additionalJobDataMap . put ( ServiceConfigKeys . GOBBLIN_SERVICE_FLOWSPEC , this . scheduledFlowSpecs . get ( jobProps . getProperty ( Confi...
Synchronize the job scheduling because the same flowSpec can be scheduled by different threads .
118,689
public static ArrayList < String > groupToPages ( Triple < String , GoogleWebmasterFilter . FilterOperator , UrlTrieNode > group ) { ArrayList < String > ret = new ArrayList < > ( ) ; if ( group . getMiddle ( ) . equals ( GoogleWebmasterFilter . FilterOperator . EQUALS ) ) { if ( group . getRight ( ) . isExist ( ) ) { ...
Get the detailed pages under this group
118,690
public static void deletePathByRegex ( FileSystem fs , final Path path , final String regex ) throws IOException { FileStatus [ ] statusList = fs . listStatus ( path , path1 -> path1 . getName ( ) . matches ( regex ) ) ; for ( final FileStatus oldJobFile : statusList ) { HadoopUtils . deletePath ( fs , oldJobFile . get...
Delete files according to the regular expression provided
118,691
public static void moveToTrash ( FileSystem fs , Path path ) throws IOException { Trash trash = new Trash ( fs , new Configuration ( ) ) ; trash . moveToTrash ( path ) ; }
Moves the object to the filesystem trash according to the file system policy .
118,692
public static boolean unsafeRenameIfNotExists ( FileSystem fs , Path from , Path to ) throws IOException { if ( ! fs . exists ( to ) ) { if ( ! fs . exists ( to . getParent ( ) ) ) { fs . mkdirs ( to . getParent ( ) ) ; } if ( ! renamePathHandleLocalFSRace ( fs , from , to ) ) { if ( ! fs . exists ( to ) ) { throw new ...
Renames from to to if to doesn t exist in a non - thread - safe way .
118,693
public static void setGroup ( FileSystem fs , Path path , String group ) throws IOException { fs . setOwner ( path , fs . getFileStatus ( path ) . getOwner ( ) , group ) ; }
Set the group associated with a given path .
118,694
public static void setPermissions ( Path location , Optional < String > owner , Optional < String > group , FileSystem fs , FsPermission permission ) { try { if ( ! owner . isPresent ( ) ) { return ; } if ( ! group . isPresent ( ) ) { return ; } fs . setOwner ( location , owner . get ( ) , group . get ( ) ) ; fs . setP...
Try to set owner and permissions for the path . Will not throw exception .
118,695
public List < String > generateQueries ( ) { ensureParentOfStagingPathExists ( ) ; List < String > hiveQueries = Lists . newArrayList ( ) ; hiveQueries . add ( "SET hive.exec.dynamic.partition.mode=nonstrict" ) ; Preconditions . checkNotNull ( this . workUnit , "Workunit must not be null" ) ; EventWorkunitUtils . setBe...
Returns hive queries to be run as a part of a hive task . This does not include publish queries .
118,696
public double setWorkUnitEstSizes ( Map < String , List < WorkUnit > > workUnitsByTopic ) { double totalEstDataSize = 0 ; for ( List < WorkUnit > workUnitsForTopic : workUnitsByTopic . values ( ) ) { for ( WorkUnit workUnit : workUnitsForTopic ) { setWorkUnitEstSize ( workUnit ) ; totalEstDataSize += getWorkUnitEstSize...
Calculate the total size of the workUnits and set the estimated size for each workUnit
118,697
public FlowStatus getFlowStatus ( FlowStatusId flowStatusId ) throws RemoteInvocationException { LOG . debug ( "getFlowConfig with groupName " + flowStatusId . getFlowGroup ( ) + " flowName " + flowStatusId . getFlowName ( ) ) ; GetRequest < FlowStatus > getRequest = _flowstatusesRequestBuilders . get ( ) . id ( new Co...
Get a flow status
118,698
private void submitJobToHelix ( JobConfig . Builder jobConfigBuilder ) throws Exception { HelixUtils . submitJobToWorkFlow ( jobConfigBuilder , this . helixWorkFlowName , this . jobContext . getJobId ( ) , this . helixTaskDriver , this . helixManager , this . workFlowExpiryTimeSeconds ) ; }
Submit a job to run .
118,699
private static List < ? extends Tag < ? > > addAdditionalMetadataTags ( Properties jobProps , List < ? extends Tag < ? > > inputTags ) { List < Tag < ? > > metadataTags = Lists . newArrayList ( inputTags ) ; String jobId ; if ( jobProps . containsKey ( ConfigurationKeys . JOB_ID_KEY ) ) { jobId = jobProps . getProperty...
Inject in some additional properties