idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
118,700
public static Map < String , String > getClusterNameTags ( Configuration conf ) { ImmutableMap . Builder < String , String > tagMap = ImmutableMap . builder ( ) ; String clusterIdentifierTag = ClustersNames . getInstance ( ) . getClusterName ( conf ) ; if ( ! Strings . isNullOrEmpty ( clusterIdentifierTag ) ) { tagMap ...
Gets all useful Hadoop cluster metrics .
118,701
public static FlowSpec . Builder builder ( URI catalogURI , Properties flowProps ) { String name = flowProps . getProperty ( ConfigurationKeys . FLOW_NAME_KEY ) ; String group = flowProps . getProperty ( ConfigurationKeys . FLOW_GROUP_KEY , "default" ) ; try { URI flowURI = new URI ( catalogURI . getScheme ( ) , catalo...
Creates a builder for the FlowSpec based on values in a flow properties config .
118,702
protected boolean folderWithinAllowedPeriod ( Path inputFolder , DateTime folderTime ) { DateTime currentTime = new DateTime ( this . timeZone ) ; PeriodFormatter periodFormatter = getPeriodFormatter ( ) ; DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime ( currentTime , periodFormatter ) ; DateTime lat...
Return true iff input folder time is between compaction . timebased . min . time . ago and compaction . timebased . max . time . ago .
118,703
public Result verify ( FileSystemDataset dataset ) { Map < String , Double > thresholdMap = RecompactionConditionBasedOnRatio . getDatasetRegexAndRecompactThreshold ( state . getProp ( MRCompactor . COMPACTION_LATEDATA_THRESHOLD_FOR_RECOMPACT_PER_DATASET , StringUtils . EMPTY ) ) ; CompactionPathParser . CompactionPars...
There are two record count we are comparing here 1 ) The new record count in the input folder 2 ) The record count we compacted previously from last run Calculate two numbers difference and compare with a predefined threshold .
118,704
protected Collection < FileSystemDatasetVersion > listQualifiedRawFileSystemDatasetVersions ( Collection < FileSystemDatasetVersion > allVersions ) { return Lists . newArrayList ( Collections2 . filter ( allVersions , new Predicate < FileSystemDatasetVersion > ( ) { public boolean apply ( FileSystemDatasetVersion versi...
A raw dataset version is qualified to be deleted iff the corresponding refined paths exist and the latest mod time of all files is in the raw dataset is earlier than the latest mod time of all files in the refined paths .
118,705
public JdbcEntrySchema convertSchema ( Schema inputSchema , WorkUnitState workUnit ) throws SchemaConversionException { LOG . info ( "Converting schema " + inputSchema ) ; Preconditions . checkArgument ( Type . RECORD . equals ( inputSchema . getType ( ) ) , "%s is expected for the first level element in Avro schema %s...
Converts Avro schema to JdbcEntrySchema .
118,706
private String tryConvertAvroColNameToJdbcColName ( String avroColName ) { if ( ! avroToJdbcColPairs . isPresent ( ) ) { String converted = avroColName . replaceAll ( AVRO_NESTED_COLUMN_DELIMITER_REGEX_COMPATIBLE , JDBC_FLATTENED_COLUMN_DELIMITER ) ; jdbcToAvroColPairs . put ( converted , avroColName ) ; return convert...
Convert Avro column name to JDBC column name . If name mapping is defined follow it . Otherwise just return avro column name while replacing nested column delimiter dot to underscore . This method also updates mapping from JDBC column name to Avro column name for reverse look up .
118,707
public RecordEnvelope < D > readRecordEnvelopeImpl ( ) throws DataRecordException , IOException { if ( ! _isStarted . get ( ) ) { throw new IOException ( "Streaming extractor has not been started." ) ; } while ( ( _records == null ) || ( ! _records . hasNext ( ) ) ) { synchronized ( _consumer ) { if ( _close . get ( ) ...
Return the next record when available . Will never time out since this is a streaming source .
118,708
public void onFileDelete ( Path rawPath ) { URI jobSpecUri = this . converter . computeURI ( rawPath ) ; listeners . onDeleteJob ( jobSpecUri , null ) ; }
For already deleted job configuration file the only identifier is path it doesn t make sense to loadJobConfig Here .
118,709
public Future < ? > scheduleJobImmediately ( Properties jobProps , JobListener jobListener , JobLauncher jobLauncher ) { Callable < Void > callable = new Callable < Void > ( ) { public Void call ( ) throws JobException { try { runJob ( jobProps , jobListener , jobLauncher ) ; } catch ( JobException je ) { LOG . error (...
Schedule a job immediately .
118,710
public void unscheduleJob ( String jobName ) throws JobException { if ( this . scheduledJobs . containsKey ( jobName ) ) { try { this . scheduler . getScheduler ( ) . deleteJob ( this . scheduledJobs . remove ( jobName ) ) ; } catch ( SchedulerException se ) { LOG . error ( "Failed to unschedule and delete job " + jobN...
Unschedule and delete a job .
118,711
private void scheduleGeneralConfiguredJobs ( ) throws ConfigurationException , JobException , IOException { LOG . info ( "Scheduling configured jobs" ) ; for ( Properties jobProps : loadGeneralJobConfigs ( ) ) { if ( ! jobProps . containsKey ( ConfigurationKeys . JOB_SCHEDULE_KEY ) ) { jobProps . setProperty ( Configur...
Schedule Gobblin jobs in general position
118,712
private void startGeneralJobConfigFileMonitor ( ) throws Exception { SchedulerUtils . addPathAlterationObserver ( this . pathAlterationDetector , this . listener , jobConfigFileDirPath ) ; this . pathAlterationDetector . start ( ) ; this . closer . register ( new Closeable ( ) { public void close ( ) throws IOException...
Start the job configuration file monitor using generic file system API .
118,713
public Collection < DbAndTable > getTables ( ) throws IOException { List < DbAndTable > tables = Lists . newArrayList ( ) ; try ( AutoReturnableObject < IMetaStoreClient > client = this . clientPool . getClient ( ) ) { Iterable < String > databases = Iterables . filter ( client . get ( ) . getAllDatabases ( ) , new Pre...
Get all tables in db with given table pattern .
118,714
protected static Set < URI > getValidDatasetURIsHelper ( Collection < URI > allDatasetURIs , Set < URI > disabledURISet , Path datasetCommonRoot ) { if ( allDatasetURIs == null || allDatasetURIs . isEmpty ( ) ) { return ImmutableSet . of ( ) ; } Comparator < URI > pathLengthComparator = new Comparator < URI > ( ) { pub...
Extended signature for testing convenience .
118,715
public long getRecordCount ( Path filepath ) { String filename = filepath . getName ( ) ; Preconditions . checkArgument ( filename . startsWith ( M_OUTPUT_FILE_PREFIX ) || filename . startsWith ( MR_OUTPUT_FILE_PREFIX ) , String . format ( "%s is not a supported filename, which should start with %s, or %s." , filename ...
Get the record count through filename .
118,716
private void findPath ( Map < Spec , SpecExecutor > specExecutorInstanceMap , Spec spec ) { inMemoryWeightGraphGenerator ( ) ; FlowSpec flowSpec = ( FlowSpec ) spec ; if ( optionalUserSpecifiedPath . isPresent ( ) ) { log . info ( "Starting to evaluate user's specified path ... " ) ; if ( userSpecifiedPathVerificator (...
that a topologySpec not being reflected in findPath .
118,717
protected void populateEdgeTemplateMap ( ) { if ( templateCatalog . isPresent ( ) ) { for ( FlowEdge flowEdge : this . weightedGraph . edgeSet ( ) ) { edgeTemplateMap . put ( flowEdge . getEdgeIdentity ( ) , templateCatalog . get ( ) . getAllTemplates ( ) . stream ( ) . map ( jobTemplate -> jobTemplate . getUri ( ) ) ....
As the base implementation here all templates will be considered for each edge .
118,718
private boolean userSpecifiedPathVerificator ( Map < Spec , SpecExecutor > specExecutorInstanceMap , FlowSpec flowSpec ) { Map < Spec , SpecExecutor > tmpSpecExecutorInstanceMap = new HashMap < > ( ) ; List < String > userSpecfiedPath = Arrays . asList ( optionalUserSpecifiedPath . get ( ) . split ( "," ) ) ; for ( int...
else return true .
118,719
private void weightGraphGenerateHelper ( TopologySpec topologySpec ) { try { Map < ServiceNode , ServiceNode > capabilities = topologySpec . getSpecExecutor ( ) . getCapabilities ( ) . get ( ) ; for ( Map . Entry < ServiceNode , ServiceNode > capability : capabilities . entrySet ( ) ) { BaseServiceNodeImpl sourceNode =...
Helper function for transform TopologySpecMap into a weightedDirectedGraph .
118,720
private JobSpec convertHopToJobSpec ( ServiceNode sourceNode , ServiceNode targetNode , FlowSpec flowSpec ) { FlowEdge flowEdge = weightedGraph . getAllEdges ( sourceNode , targetNode ) . iterator ( ) . next ( ) ; URI templateURI = getTemplateURI ( sourceNode , targetNode , flowSpec , flowEdge ) ; return buildJobSpec (...
A naive implementation of resolving templates in each JobSpec among Multi - hop FlowSpec . Handle the case when edge is not specified . Always select the first available template .
118,721
public URI jobSpecURIGenerator ( Object ... objects ) { FlowSpec flowSpec = ( FlowSpec ) objects [ 0 ] ; ServiceNode sourceNode = ( ServiceNode ) objects [ 1 ] ; ServiceNode targetNode = ( ServiceNode ) objects [ 2 ] ; try { return new URI ( JobSpec . Builder . DEFAULT_JOB_CATALOG_SCHEME , flowSpec . getUri ( ) . getAu...
A naive implementation of generating a jobSpec s URI within a multi - hop logical Flow .
118,722
private PathFilter getFileFilter ( ) { final String extension = ( this . expectedExtension . startsWith ( "." ) ) ? this . expectedExtension : "." + this . expectedExtension ; return new PathFilter ( ) { public boolean accept ( Path path ) { return path . getName ( ) . endsWith ( extension ) && ! ( schemaInSourceDir &&...
This method is to filter out files that don t need to be processed by extension
118,723
private static Deserializer getDeserializer ( HiveRegistrationUnit unit ) { Optional < String > serdeClass = unit . getSerDeType ( ) ; if ( ! serdeClass . isPresent ( ) ) { return null ; } String serde = serdeClass . get ( ) ; HiveConf hiveConf ; Deserializer deserializer ; try { hiveConf = SharedResourcesBrokerFactory...
Returns a Deserializer from HiveRegistrationUnit if present and successfully initialized . Else returns null .
118,724
public synchronized List < JobSpec > getJobs ( ) { return Lists . transform ( Lists . newArrayList ( loader . loadPullFilesRecursively ( loader . getRootDirectory ( ) , this . sysConfig , shouldLoadGlobalConf ( ) ) ) , this . converter ) ; }
Fetch all the job files under the jobConfDirPath
118,725
public synchronized JobSpec getJobSpec ( URI uri ) throws JobSpecNotFoundException { try { Path targetJobSpecFullPath = getPathForURI ( this . jobConfDirPath , uri ) ; return this . converter . apply ( loader . loadPullFile ( targetJobSpecFullPath , this . sysConfig , shouldLoadGlobalConf ( ) ) ) ; } catch ( FileNotFou...
Fetch single job file based on its URI return null requested URI not existed
118,726
private void readPrevAvgRecordMillis ( SourceState state ) { Map < String , List < Double > > prevAvgMillis = Maps . newHashMap ( ) ; for ( WorkUnitState workUnitState : state . getPreviousWorkUnitStates ( ) ) { List < KafkaPartition > partitions = KafkaUtils . getPartitions ( workUnitState ) ; for ( KafkaPartition par...
Get avg time to pull a record in the previous run for all topics each of which is the geometric mean of the avg time to pull a record of all partitions of the topic .
118,727
private Optional < DataFileVersionStrategy > initDataFileVersionStrategy ( EndPoint endPoint , ReplicationConfiguration rc , Properties props ) { if ( ! ( endPoint instanceof HadoopFsEndPoint ) ) { log . warn ( "Data file version currently only handle the Hadoop Fs EndPoint replication" ) ; return Optional . absent ( )...
Get the version strategy that can retrieve the data file version from the end point .
118,728
public void closeCurrentFile ( ) { try { this . closer . close ( ) ; } catch ( IOException e ) { if ( this . currentFile != null ) { LOG . error ( "Failed to close file: " + this . currentFile , e ) ; } } }
Closes the current file being read .
118,729
private boolean ensureHiveTableExistenceBeforeAlternation ( String tableName , String dbName , IMetaStoreClient client , Table table , HiveSpec spec ) throws TException { try ( AutoCloseableLock lock = this . locks . getTableLock ( dbName , tableName ) ) { try { try ( Timer . Context context = this . metricContext . ti...
If table existed on Hive side will return false ; Or will create the table thru . RPC and return retVal from remote MetaStore .
118,730
private boolean ensureHiveDbExistence ( String hiveDbName , IMetaStoreClient client ) throws IOException { try ( AutoCloseableLock lock = this . locks . getDbLock ( hiveDbName ) ) { Database db = new Database ( ) ; db . setName ( hiveDbName ) ; try { try ( Timer . Context context = this . metricContext . timer ( GET_HI...
If databse existed on Hive side will return false ; Or will create the table thru . RPC and return retVal from remote MetaStore .
118,731
public boolean isCompleted ( ) { WorkingState state = getWorkingState ( ) ; return state == WorkingState . SUCCESSFUL || state == WorkingState . COMMITTED || state == WorkingState . FAILED ; }
Return whether the task has completed running or not .
118,732
public synchronized void updateByteMetrics ( long bytesWritten , int branchIndex ) { TaskMetrics metrics = TaskMetrics . get ( this ) ; String forkBranchId = TaskMetrics . taskInstanceRemoved ( this . taskId ) ; Counter taskByteCounter = metrics . getCounter ( MetricGroup . TASK . name ( ) , forkBranchId , BYTES ) ; lo...
Collect byte - level metrics .
118,733
public void adjustJobMetricsOnRetry ( int branches ) { TaskMetrics metrics = TaskMetrics . get ( this ) ; for ( int i = 0 ; i < branches ; i ++ ) { String forkBranchId = ForkOperatorUtils . getForkId ( this . taskId , i ) ; long recordsWritten = metrics . getCounter ( MetricGroup . TASK . name ( ) , forkBranchId , RECO...
Adjust job - level metrics when the task gets retried .
118,734
public static String getFullEventName ( State state ) { return Joiner . on ( '.' ) . join ( LineageEventBuilder . LIENAGE_EVENT_NAMESPACE , state . getProp ( getKey ( NAME_KEY ) ) ) ; }
Get the full lineage event name from a state
118,735
static double [ ] addVector ( double [ ] x , double [ ] y , double c , double [ ] reuse ) { if ( reuse == null ) { reuse = new double [ x . length ] ; } for ( int i = 0 ; i < x . length ; i ++ ) { reuse [ i ] = x [ i ] + c * y [ i ] ; } return reuse ; }
Performs x + cy
118,736
public static long getProcessedCount ( List < TaskState > taskStates ) { long value = 0 ; for ( TaskState taskState : taskStates ) { value += taskState . getPropAsLong ( ConfigurationKeys . WRITER_RECORDS_WRITTEN , 0 ) ; } return value ; }
Get the number of records written by all the writers
118,737
public static String getTaskFailureExceptions ( List < TaskState > taskStates ) { StringBuffer sb = new StringBuffer ( ) ; appendTaskStateValues ( taskStates , sb , TASK_FAILURE_MESSAGE_KEY ) ; appendTaskStateValues ( taskStates , sb , ConfigurationKeys . TASK_FAILURE_EXCEPTION_KEY ) ; return sb . toString ( ) ; }
Get failure messages
118,738
public void commit ( ) throws IOException { if ( ! this . actualProcessedCopyableFile . isPresent ( ) ) { return ; } CopyableFile copyableFile = this . actualProcessedCopyableFile . get ( ) ; Path stagingFilePath = getStagingFilePath ( copyableFile ) ; Path outputFilePath = getSplitOutputFilePath ( copyableFile , this ...
Moves the file from task staging to task output . Each task has its own staging directory but all the tasks share the same task output directory .
118,739
public long getGap ( MultiLongWatermark highWatermark ) { Preconditions . checkNotNull ( highWatermark ) ; Preconditions . checkArgument ( this . values . size ( ) == highWatermark . values . size ( ) ) ; long diff = 0 ; for ( int i = 0 ; i < this . values . size ( ) ; i ++ ) { Preconditions . checkArgument ( this . va...
Get the number of records that need to be pulled given the high watermark .
118,740
public static KafkaWrapper create ( State state ) { Preconditions . checkNotNull ( state . getProp ( ConfigurationKeys . KAFKA_BROKERS ) , "Need to specify at least one Kafka broker." ) ; KafkaWrapper . Builder builder = new KafkaWrapper . Builder ( ) ; if ( state . getPropAsBoolean ( USE_NEW_KAFKA_API , DEFAULT_USE_NE...
Create a KafkaWrapper based on the given type of Kafka API and list of Kafka brokers .
118,741
protected void addWriterOutputToExistingDir ( Path writerOutput , Path publisherOutput , WorkUnitState workUnitState , int branchId , ParallelRunner parallelRunner ) throws IOException { for ( FileStatus status : FileListUtils . listFilesRecursively ( this . writerFileSystemByBranches . get ( branchId ) , writerOutput ...
This method needs to be overridden for TimePartitionedDataPublisher since the output folder structure contains timestamp we have to move the files recursively .
118,742
public static void sendEmail ( State state , String subject , String message ) throws EmailException { Email email = new SimpleEmail ( ) ; email . setHostName ( state . getProp ( ConfigurationKeys . EMAIL_HOST_KEY , ConfigurationKeys . DEFAULT_EMAIL_HOST ) ) ; if ( state . contains ( ConfigurationKeys . EMAIL_SMTP_PORT...
A general method for sending emails .
118,743
public static void sendJobCompletionEmail ( String jobId , String message , String state , State jobState ) throws EmailException { sendEmail ( jobState , String . format ( "Gobblin notification: job %s has completed with state %s" , jobId , state ) , message ) ; }
Send a job completion notification email .
118,744
public static void sendJobCancellationEmail ( String jobId , String message , State jobState ) throws EmailException { sendEmail ( jobState , String . format ( "Gobblin notification: job %s has been cancelled" , jobId ) , message ) ; }
Send a job cancellation notification email .
118,745
public static void sendJobFailureAlertEmail ( String jobName , String message , int failures , State jobState ) throws EmailException { sendEmail ( jobState , String . format ( "Gobblin alert: job %s has failed %d %s consecutively in the past" , jobName , failures , failures > 1 ? "times" : "time" ) , message ) ; }
Send a job failure alert email .
118,746
public boolean isRecompactionNeeded ( DatasetHelper helper ) { if ( recompactionConditions . isEmpty ( ) ) return false ; if ( operation == CombineOperation . OR ) { for ( RecompactionCondition c : recompactionConditions ) { if ( c . isRecompactionNeeded ( helper ) ) { return true ; } } return false ; } else { for ( Re...
For OR combination return true iff one of conditions return true For AND combination return true iff all of conditions return true Other cases return false
118,747
public void open ( Path errFilePath ) throws IOException { this . fs . mkdirs ( errFilePath . getParent ( ) ) ; OutputStream os = this . closer . register ( this . fs . exists ( errFilePath ) ? this . fs . append ( errFilePath ) : this . fs . create ( errFilePath ) ) ; this . writer = this . closer . register ( new Buf...
Open a BufferedWriter
118,748
public Partition getGlobalPartition ( long previousWatermark ) { ExtractType extractType = ExtractType . valueOf ( state . getProp ( ConfigurationKeys . SOURCE_QUERYBASED_EXTRACT_TYPE ) . toUpperCase ( ) ) ; WatermarkType watermarkType = WatermarkType . valueOf ( state . getProp ( ConfigurationKeys . SOURCE_QUERYBASED_...
Get the global partition of the whole data set which has the global low and high watermarks
118,749
public HashMap < Long , Long > getPartitions ( long previousWatermark ) { HashMap < Long , Long > defaultPartition = Maps . newHashMap ( ) ; if ( ! isWatermarkExists ( ) ) { defaultPartition . put ( ConfigurationKeys . DEFAULT_WATERMARK_VALUE , ConfigurationKeys . DEFAULT_WATERMARK_VALUE ) ; LOG . info ( "Watermark col...
Get partitions with low and high water marks
118,750
public List < Partition > getPartitionList ( long previousWatermark ) { if ( state . getPropAsBoolean ( HAS_USER_SPECIFIED_PARTITIONS ) ) { return createUserSpecifiedPartitions ( ) ; } List < Partition > partitions = new ArrayList < > ( ) ; HashMap < Long , Long > partitionMap = getPartitions ( previousWatermark ) ; if...
Get an unordered list of partition with lowWatermark highWatermark and hasUserSpecifiedHighWatermark .
118,751
private List < Partition > createUserSpecifiedPartitions ( ) { List < Partition > partitions = new ArrayList < > ( ) ; List < String > watermarkPoints = state . getPropAsList ( USER_SPECIFIED_PARTITIONS ) ; boolean isEarlyStopped = state . getPropAsBoolean ( IS_EARLY_STOPPED ) ; if ( watermarkPoints == null || watermar...
Generate the partitions based on the lists specified by the user in job config
118,752
private static long adjustWatermark ( String baseWatermark , WatermarkType watermarkType ) { long result = ConfigurationKeys . DEFAULT_WATERMARK_VALUE ; switch ( watermarkType ) { case SIMPLE : result = SimpleWatermark . adjustWatermark ( baseWatermark , 0 ) ; break ; case DATE : result = DateWatermark . adjustWatermar...
Adjust a watermark based on watermark type
118,753
private static int getUpdatedInterval ( int inputInterval , ExtractType extractType , WatermarkType watermarkType ) { LOG . debug ( "Getting updated interval" ) ; if ( ( extractType == ExtractType . SNAPSHOT && watermarkType == WatermarkType . DATE ) ) { return inputInterval * 24 ; } else if ( extractType == ExtractTyp...
Calculate interval in hours with the given interval
118,754
private long getSnapshotLowWatermark ( WatermarkType watermarkType , long previousWatermark , int deltaForNextWatermark ) { LOG . debug ( "Getting snapshot low water mark" ) ; String timeZone = this . state . getProp ( ConfigurationKeys . SOURCE_TIMEZONE , ConfigurationKeys . DEFAULT_SOURCE_TIMEZONE ) ; if ( isPrevious...
Get low water mark
118,755
protected long getHighWatermark ( ExtractType extractType , WatermarkType watermarkType ) { LOG . debug ( "Getting high watermark" ) ; String timeZone = this . state . getProp ( ConfigurationKeys . SOURCE_TIMEZONE ) ; long highWatermark = ConfigurationKeys . DEFAULT_WATERMARK_VALUE ; if ( this . isWatermarkOverride ( )...
Get high water mark
118,756
private long getSnapshotHighWatermark ( WatermarkType watermarkType ) { LOG . debug ( "Getting snapshot high water mark" ) ; if ( isSimpleWatermark ( watermarkType ) ) { return ConfigurationKeys . DEFAULT_WATERMARK_VALUE ; } String timeZone = this . state . getProp ( ConfigurationKeys . SOURCE_TIMEZONE ) ; return Long ...
Get snapshot high water mark
118,757
private long getAppendHighWatermark ( ExtractType extractType ) { LOG . debug ( "Getting append high water mark" ) ; if ( this . isFullDump ( ) ) { LOG . info ( "Overriding high water mark with end value:" + ConfigurationKeys . SOURCE_QUERYBASED_END_VALUE ) ; long highWatermark = this . state . getPropAsLong ( Configur...
Get append high water mark
118,758
private long getAppendWatermarkCutoff ( ExtractType extractType ) { LOG . debug ( "Getting append water mark cutoff" ) ; long highWatermark = ConfigurationKeys . DEFAULT_WATERMARK_VALUE ; String timeZone = this . state . getProp ( ConfigurationKeys . SOURCE_TIMEZONE ) ; AppendMaxLimitType limitType = getAppendLimitType...
Get cutoff for high water mark
118,759
private static AppendMaxLimitType getAppendLimitType ( ExtractType extractType , String maxLimit ) { LOG . debug ( "Getting append limit type" ) ; AppendMaxLimitType limitType ; switch ( extractType ) { case APPEND_DAILY : limitType = AppendMaxLimitType . CURRENTDATE ; break ; case APPEND_HOURLY : limitType = AppendMax...
Get append max limit type from the input
118,760
private static int getAppendLimitDelta ( String maxLimit ) { LOG . debug ( "Getting append limit delta" ) ; int limitDelta = 0 ; if ( ! Strings . isNullOrEmpty ( maxLimit ) ) { String [ ] limitParams = maxLimit . split ( "-" ) ; if ( limitParams . length >= 2 ) { limitDelta = Integer . parseInt ( limitParams [ 1 ] ) ; ...
Get append max limit delta num
118,761
private boolean isWatermarkExists ( ) { if ( ! Strings . isNullOrEmpty ( this . state . getProp ( ConfigurationKeys . EXTRACT_DELTA_FIELDS_KEY ) ) && ! Strings . isNullOrEmpty ( this . state . getProp ( ConfigurationKeys . SOURCE_QUERYBASED_WATERMARK_TYPE ) ) ) { return true ; } return false ; }
true if water mark columns and water mark type provided
118,762
public static Map < String , Object > getConfigForBranch ( EntityType entityType , WorkUnitState workUnitState ) { return getConfigForBranch ( entityType , null , workUnitState ) ; }
Retrieve encryption configuration for the branch the WorKUnitState represents
118,763
public static Map < String , Object > getConfigForBranch ( EntityType entityType , State taskState , int numBranches , int branch ) { return getConfigForBranch ( taskState , entityType . getConfigPrefix ( ) , ForkOperatorUtils . getPropertyNameForBranch ( "" , numBranches , branch ) ) ; }
Retrieve encryption config for a given branch of a task
118,764
public static String getKeystoreType ( Map < String , Object > parameters ) { String type = ( String ) parameters . get ( ENCRYPTION_KEYSTORE_TYPE_KEY ) ; if ( type == null ) { type = ENCRYPTION_KEYSTORE_TYPE_KEY_DEFAULT ; } return type ; }
Get the type of keystore to instantiate
118,765
public static String getCipher ( Map < String , Object > parameters ) { return ( String ) parameters . get ( ENCRYPTION_CIPHER_KEY ) ; }
Get the underlying cipher name
118,766
private static Map < String , Object > extractPropertiesForBranch ( Properties properties , String prefix , String branchSuffix ) { Map < String , Object > ret = new HashMap < > ( ) ; for ( Map . Entry < Object , Object > prop : properties . entrySet ( ) ) { String key = ( String ) prop . getKey ( ) ; if ( key . starts...
Extract a set of properties for a given branch stripping out the prefix and branch suffix .
118,767
private boolean isRestorable ( HivePartitionDataset dataset , HivePartitionVersion version ) throws IOException { if ( version . getLocation ( ) . toString ( ) . equalsIgnoreCase ( dataset . getLocation ( ) . toString ( ) ) ) { return false ; } FileSystem fs = ProxyUtils . getOwnerFs ( new State ( this . state ) , vers...
A version is called restorable if it can be used to restore dataset .
118,768
public static void createGobblinHelixCluster ( String zkConnectionString , String clusterName , boolean overwrite ) { ClusterSetup clusterSetup = new ClusterSetup ( zkConnectionString ) ; clusterSetup . addCluster ( clusterName , overwrite ) ; String autoJoinConfig = ZKHelixManager . ALLOW_PARTICIPANT_AUTO_JOIN + "=tru...
Create a Helix cluster for the Gobblin Cluster application .
118,769
public static void submitJobToQueue ( JobConfig . Builder jobConfigBuilder , String queueName , String jobName , TaskDriver helixTaskDriver , HelixManager helixManager , long jobQueueDeleteTimeoutSeconds ) throws Exception { submitJobToWorkFlow ( jobConfigBuilder , queueName , jobName , helixTaskDriver , helixManager ,...
We have switched from Helix JobQueue to WorkFlow based job execution .
118,770
private static void deleteStoppedHelixJob ( HelixManager helixManager , String workFlowName , String jobName ) throws InterruptedException { WorkflowContext workflowContext = TaskDriver . getWorkflowContext ( helixManager , workFlowName ) ; while ( workflowContext . getJobState ( TaskUtil . getNamespacedJobName ( workF...
Deletes the stopped Helix Workflow . Caller should stop the Workflow before calling this method .
118,771
public boolean copyPartitionParams ( String completeSourcePartitionName , String completeDestPartitionName , List < String > whitelist , List < String > blacklist ) { Optional < Partition > sourcePartitionOptional = getPartitionObject ( completeSourcePartitionName ) ; Optional < Partition > destPartitionOptional = getP...
Method to copy partition parameters from source partition to destination partition
118,772
public static Set < String > findFullPrefixKeys ( Properties properties , Optional < String > keyPrefix ) { TreeSet < String > propNames = new TreeSet < > ( ) ; for ( Map . Entry < Object , Object > entry : properties . entrySet ( ) ) { String entryKey = entry . getKey ( ) . toString ( ) ; if ( StringUtils . startsWith...
Finds a list of properties whose keys are complete prefix of other keys . This function is meant to be used during conversion from Properties to typesafe Config as the latter does not support this scenario .
118,773
private static Map < String , Object > guessPropertiesTypes ( Map < Object , Object > srcProperties ) { Map < String , Object > res = new HashMap < > ( ) ; for ( Map . Entry < Object , Object > prop : srcProperties . entrySet ( ) ) { Object value = prop . getValue ( ) ; if ( null != value && value instanceof String && ...
Attempts to guess type types of a Properties . By default typesafe will make all property values Strings . This implementation will try to recognize booleans and numbers . All keys are treated as strings .
118,774
public static boolean verifySubset ( Config superConfig , Config subConfig ) { for ( Map . Entry < String , ConfigValue > entry : subConfig . entrySet ( ) ) { if ( ! superConfig . hasPath ( entry . getKey ( ) ) || ! superConfig . getValue ( entry . getKey ( ) ) . unwrapped ( ) . equals ( entry . getValue ( ) . unwrappe...
Check that every key - value in superConfig is in subConfig
118,775
public static boolean checkReaderWriterCompatibility ( Schema readerSchema , Schema writerSchema , boolean ignoreNamespace ) { if ( ignoreNamespace ) { List < Schema . Field > fields = deepCopySchemaFields ( readerSchema ) ; readerSchema = Schema . createRecord ( writerSchema . getName ( ) , writerSchema . getDoc ( ) ,...
Validates that the provided reader schema can be used to decode avro data written with the provided writer schema .
118,776
public static Optional < Field > getField ( Schema schema , String fieldLocation ) { Preconditions . checkNotNull ( schema ) ; Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( fieldLocation ) ) ; Splitter splitter = Splitter . on ( FIELD_LOCATION_DELIMITER ) . omitEmptyStrings ( ) . trimResults ( ) ; List < ...
Given a GenericRecord this method will return the field specified by the path parameter . The fieldLocation parameter is an ordered string specifying the location of the nested field to retrieve . For example field1 . nestedField1 takes field field1 and retrieves nestedField1 from it .
118,777
public static Optional < Object > getFieldValue ( GenericRecord record , String fieldLocation ) { Map < String , Object > ret = getMultiFieldValue ( record , fieldLocation ) ; return Optional . fromNullable ( ret . get ( fieldLocation ) ) ; }
Given a GenericRecord this method will return the field specified by the path parameter . The fieldLocation parameter is an ordered string specifying the location of the nested field to retrieve . For example field1 . nestedField1 takes the the value of the field field1 and retrieves the field nestedField1 from it .
118,778
private static Object getObjectFromMap ( Map map , String key ) { Utf8 utf8Key = new Utf8 ( key ) ; return map . get ( utf8Key ) ; }
This method is to get object from map given a key as string . Avro persists string as Utf8
118,779
public static GenericRecord convertRecordSchema ( GenericRecord record , Schema newSchema ) throws IOException { if ( record . getSchema ( ) . equals ( newSchema ) ) { return record ; } try { BinaryDecoder decoder = new DecoderFactory ( ) . binaryDecoder ( recordToByteArray ( record ) , null ) ; DatumReader < GenericRe...
Change the schema of an Avro record .
118,780
public static byte [ ] recordToByteArray ( GenericRecord record ) throws IOException { try ( ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ) { Encoder encoder = EncoderFactory . get ( ) . directBinaryEncoder ( out , null ) ; DatumWriter < GenericRecord > writer = new GenericDatumWriter < > ( record . getSch...
Convert a GenericRecord to a byte array .
118,781
public static Schema getSchemaFromDataFile ( Path dataFile , FileSystem fs ) throws IOException { try ( SeekableInput sin = new FsInput ( dataFile , fs . getConf ( ) ) ; DataFileReader < GenericRecord > reader = new DataFileReader < > ( sin , new GenericDatumReader < GenericRecord > ( ) ) ) { return reader . getSchema ...
Get Avro schema from an Avro data file .
118,782
public static Schema parseSchemaFromFile ( Path filePath , FileSystem fs ) throws IOException { Preconditions . checkArgument ( fs . exists ( filePath ) , filePath + " does not exist" ) ; try ( FSDataInputStream in = fs . open ( filePath ) ) { return new Schema . Parser ( ) . parse ( in ) ; } }
Parse Avro schema from a schema file .
118,783
public static void writeSchemaToFile ( Schema schema , Path filePath , Path tempFilePath , FileSystem fs , boolean overwrite , FsPermission perm ) throws IOException { boolean fileExists = fs . exists ( filePath ) ; if ( ! overwrite ) { Preconditions . checkState ( ! fileExists , filePath + " already exists" ) ; } else...
Write a schema to a file
118,784
public static Schema nullifyFieldsForSchemaMerge ( Schema oldSchema , Schema newSchema ) { if ( oldSchema == null ) { LOG . warn ( "No previous schema available, use the new schema instead." ) ; return newSchema ; } if ( ! ( oldSchema . getType ( ) . equals ( Type . RECORD ) && newSchema . getType ( ) . equals ( Type ....
Merge oldSchema and newSchame . Set a field default value to null if this field exists in the old schema but not in the new schema .
118,785
public static Optional < Schema > removeUncomparableFields ( Schema schema ) { return removeUncomparableFields ( schema , Sets . < Schema > newHashSet ( ) ) ; }
Remove map array enum fields as well as union fields that contain map array or enum from an Avro schema . A schema with these fields cannot be used as Mapper key in a MapReduce job .
118,786
public Collection < Spec > getAllVersionsOfSpec ( URI specUri ) { Preconditions . checkArgument ( null != specUri , "Spec URI should not be null" ) ; Path specPath = getPathForURI ( this . fsSpecStoreDirPath , specUri , FlowSpec . Builder . DEFAULT_VERSION ) ; return getAllVersionsOfSpec ( specPath ) ; }
Returns all versions of the spec defined by specUri . Currently multiple versions are not supported so this should return exactly one spec .
118,787
protected Path getPathForURI ( Path fsSpecStoreDirPath , URI uri , String version ) { return PathUtils . addExtension ( PathUtils . mergePaths ( fsSpecStoreDirPath , new Path ( uri ) ) , version ) ; }
Construct a file path given URI and version of a spec .
118,788
public static JsonElementConverter getConverter ( JsonSchema schema , boolean repeated ) { InputType fieldType = schema . getInputType ( ) ; switch ( fieldType ) { case INT : return new IntConverter ( schema , repeated ) ; case LONG : return new LongConverter ( schema , repeated ) ; case FLOAT : return new FloatConvert...
Use to create a converter for a single field from a parquetSchema .
118,789
private Config loadConfigFileWithFlowNameOverrides ( Path configFilePath ) throws IOException { Config flowConfig = this . pullFileLoader . loadPullFile ( configFilePath , emptyConfig , false ) ; String flowName = FSSpecStore . getSpecName ( configFilePath ) ; String flowGroup = FSSpecStore . getSpecGroup ( configFileP...
Load the config file and override the flow name and flow path properties with the names from the file path
118,790
public static URI buildURI ( String urlTemplate , Map < String , String > keys , Map < String , String > queryParams ) { String url = urlTemplate ; if ( keys != null && keys . size ( ) != 0 ) { url = StrSubstitutor . replace ( urlTemplate , keys ) ; } try { URIBuilder uriBuilder = new URIBuilder ( url ) ; if ( queryPar...
Given a url template interpolate with keys and build the URI after adding query parameters
118,791
public static Set < String > getErrorCodeWhitelist ( Config config ) { String list = config . getString ( HttpConstants . ERROR_CODE_WHITELIST ) . toLowerCase ( ) ; return new HashSet < > ( getStringList ( list ) ) ; }
Get the error code whitelist from a config
118,792
public static Map < String , Object > toMap ( String jsonString ) { Map < String , Object > map = new HashMap < > ( ) ; return GSON . fromJson ( jsonString , map . getClass ( ) ) ; }
Convert a json encoded string to a Map
118,793
public static String createR2ClientLimiterKey ( Config config ) { String urlTemplate = config . getString ( HttpConstants . URL_TEMPLATE ) ; try { String escaped = URIUtil . encodeQuery ( urlTemplate ) ; URI uri = new URI ( escaped ) ; if ( uri . getHost ( ) == null ) throw new RuntimeException ( "Cannot get host part ...
Convert D2 URL template into a string used for throttling limiter
118,794
public void onSuccessfulWrite ( long startTimeNanos ) { Instrumented . updateTimer ( this . dataWriterTimer , System . nanoTime ( ) - startTimeNanos , TimeUnit . NANOSECONDS ) ; Instrumented . markMeter ( this . successfulWritesMeter ) ; }
Called after a successful write of a record .
118,795
public String convertSchema ( Schema inputSchema , WorkUnitState workUnit ) throws SchemaConversionException { return EnvelopeSchemaConverter . class . getName ( ) ; }
Do nothing actual schema must be obtained from records .
118,796
public Iterable < GenericRecord > convertRecord ( String outputSchema , GenericRecord inputRecord , WorkUnitState workUnit ) throws DataConversionException { try { String schemaIdField = workUnit . contains ( PAYLOAD_SCHEMA_ID_FIELD ) ? workUnit . getProp ( PAYLOAD_SCHEMA_ID_FIELD ) : DEFAULT_PAYLOAD_SCHEMA_ID_FIELD ; ...
Get actual schema from registry and deserialize payload using it .
118,797
public byte [ ] getPayload ( GenericRecord inputRecord , String payloadFieldName ) { ByteBuffer bb = ( ByteBuffer ) inputRecord . get ( payloadFieldName ) ; byte [ ] payloadBytes ; if ( bb . hasArray ( ) ) { payloadBytes = bb . array ( ) ; } else { payloadBytes = new byte [ bb . remaining ( ) ] ; bb . get ( payloadByte...
Get payload field from GenericRecord and convert to byte array
118,798
public GenericRecord deserializePayload ( byte [ ] payload , Schema payloadSchema ) throws IOException , ExecutionException { Decoder decoder = this . decoderFactory . binaryDecoder ( payload , null ) ; GenericDatumReader < GenericRecord > reader = this . readers . get ( payloadSchema ) ; return reader . read ( null , ...
Deserialize payload using payload schema
118,799
private void deleteStateStore ( URI jobSpecUri ) throws IOException { int EXPECTED_NUM_URI_TOKENS = 3 ; String [ ] uriTokens = jobSpecUri . getPath ( ) . split ( "/" ) ; if ( null == this . datasetStateStore ) { log . warn ( "Job state store deletion failed as datasetstore is not initialized." ) ; return ; } if ( uriTo...
It fetches the job name from the given jobSpecUri and deletes its corresponding state store