forked from apache/gobblin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the part of task flow within forked branches into a new class Fork
Also added support to allow using converters, quality checkers, and task publishers in forks. This is the first step to support having separate config files for each forked branch and allowing a richer sets of operations within a fork. Signed-off-by: Yinan Li <[email protected]>
- Loading branch information
1 parent
0bc4115
commit 1cc44ae
Showing
31 changed files
with
669 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
common-api/src/main/java/com/linkedin/uif/converter/BaseAvroForkOperator.java
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
common-api/src/main/java/com/linkedin/uif/converter/ForkOperator.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
common-api/src/main/java/com/linkedin/uif/fork/CopyNotSupportedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.linkedin.uif.fork; | ||
|
||
/** | ||
* A type of {@link java.lang.Exception}s thrown when copying is not supported. | ||
* | ||
* @author ynli | ||
*/ | ||
public class CopyNotSupportedException extends Exception { | ||
|
||
public CopyNotSupportedException(String message) { | ||
super(message); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
common-api/src/main/java/com/linkedin/uif/fork/Copyable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.linkedin.uif.fork; | ||
|
||
/** | ||
* An interface for classes that supports making copies of their instances. | ||
* | ||
* @author ynli | ||
*/ | ||
public interface Copyable<T> { | ||
|
||
/** | ||
* Make a new copy of this instance. | ||
* | ||
* @return new copy of this instance | ||
*/ | ||
public T copy() throws CopyNotSupportedException; | ||
} |
29 changes: 29 additions & 0 deletions
29
common-api/src/main/java/com/linkedin/uif/fork/CopyableGenericRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.linkedin.uif.fork; | ||
|
||
import org.apache.avro.generic.GenericData; | ||
import org.apache.avro.generic.GenericRecord; | ||
|
||
/** | ||
* A wrapper class for {@link org.apache.avro.generic.GenericRecord} | ||
* that is also {@link Copyable}. | ||
* | ||
* @author ynli | ||
*/ | ||
public class CopyableGenericRecord implements Copyable<GenericRecord> { | ||
|
||
private final GenericRecord record; | ||
|
||
public CopyableGenericRecord(GenericRecord record) { | ||
this.record = record; | ||
} | ||
|
||
@Override | ||
public GenericRecord copy() throws CopyNotSupportedException { | ||
if (!(this.record instanceof GenericData.Record)) { | ||
throw new CopyNotSupportedException( | ||
"The record to make copy is not an instance of " + GenericData.Record.class.getName()); | ||
} | ||
// Make a deep copy of the original record | ||
return new GenericData.Record((GenericData.Record) this.record, true); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
common-api/src/main/java/com/linkedin/uif/fork/CopyableSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.linkedin.uif.fork; | ||
|
||
import org.apache.avro.Schema; | ||
|
||
/** | ||
* A wrapper class for {@link org.apache.avro.Schema} that is also {@link Copyable}. | ||
* | ||
* @author ynli | ||
*/ | ||
public class CopyableSchema implements Copyable<Schema> { | ||
|
||
private final Schema schema; | ||
|
||
public CopyableSchema(Schema schema) { | ||
this.schema = schema; | ||
} | ||
|
||
@Override | ||
public Schema copy() throws CopyNotSupportedException { | ||
return new Schema.Parser().parse(this.schema.toString()); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
common-api/src/main/java/com/linkedin/uif/fork/ForkOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.linkedin.uif.fork; | ||
|
||
import java.io.Closeable; | ||
import java.util.List; | ||
|
||
import com.linkedin.uif.configuration.WorkUnitState; | ||
|
||
/** | ||
* An interface for fork operators that convert one input data record into multiple | ||
* records. So essentially this operator forks one input data stream into multiple | ||
* data streams. This interface allows user to plugin their fork logic. | ||
* | ||
* @author ynli | ||
* | ||
* @param <S> schema data type | ||
* @param <D> data record data type | ||
*/ | ||
public interface ForkOperator<S, D> extends Closeable { | ||
|
||
/** | ||
* Initialize this {@link ForkOperator}. | ||
* | ||
* @param workUnitState {@link WorkUnitState} carrying the configuration | ||
*/ | ||
public void init(WorkUnitState workUnitState) throws Exception; | ||
|
||
/** | ||
* Get the number of branches after the fork. | ||
* | ||
* @param workUnitState {@link WorkUnitState} carrying the configuration | ||
* @return number of branches after the fork | ||
*/ | ||
public int getBranches(WorkUnitState workUnitState); | ||
|
||
/** | ||
* Get a list of {@link java.lang.Boolean}s indicating if the schema should go to each branch. | ||
* | ||
* @param workUnitState {@link WorkUnitState} carrying the configuration | ||
* @param input input schema | ||
* @return list of {@link java.lang.Boolean}s | ||
*/ | ||
public List<Boolean> forkSchema(WorkUnitState workUnitState, S input); | ||
|
||
/** | ||
* Get a list of {@link java.lang.Boolean}s indicating if the record should go to each branch. | ||
* | ||
* @param workUnitState {@link WorkUnitState} carrying the configuration | ||
* @param input input data record | ||
* @return list of {@link java.lang.Boolean}s | ||
*/ | ||
public List<Boolean> forkDataRecord(WorkUnitState workUnitState, D input); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.