use of org.apache.gobblin.source.workunit.Extract in project incubator-gobblin by apache.
the class WriterUtilsTest method testGetDefaultWriterFilePathWithWorkUnitState.
@Test
public void testGetDefaultWriterFilePathWithWorkUnitState() {
String namespace = "gobblin.test";
String tableName = "test-table";
SourceState sourceState = new SourceState();
WorkUnit workUnit = WorkUnit.create(new Extract(sourceState, TableType.APPEND_ONLY, namespace, tableName));
WorkUnitState workUnitState = new WorkUnitState(workUnit);
Assert.assertEquals(WriterUtils.getWriterFilePath(workUnitState, 0, 0), new Path(workUnitState.getExtract().getOutputFilePath()));
Assert.assertEquals(WriterUtils.getWriterFilePath(workUnitState, 2, 0), new Path(workUnitState.getExtract().getOutputFilePath(), ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + "0"));
}
use of org.apache.gobblin.source.workunit.Extract in project incubator-gobblin by apache.
the class WriterUtilsTest method testGetDefaultWriterFilePath.
@Test
public void testGetDefaultWriterFilePath() {
String namespace = "gobblin.test";
String tableName = "test-table";
SourceState sourceState = new SourceState();
WorkUnit state = WorkUnit.create(new Extract(sourceState, TableType.APPEND_ONLY, namespace, tableName));
Assert.assertEquals(WriterUtils.getWriterFilePath(state, 0, 0), new Path(state.getExtract().getOutputFilePath()));
Assert.assertEquals(WriterUtils.getWriterFilePath(state, 2, 0), new Path(state.getExtract().getOutputFilePath(), ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + "0"));
}
use of org.apache.gobblin.source.workunit.Extract in project incubator-gobblin by apache.
the class WorstFitDecreasingBinPackingTest method getWorkUnitWithWeight.
public WorkUnit getWorkUnitWithWeight(long weight) {
WorkUnit workUnit = new WorkUnit(new Extract(Extract.TableType.APPEND_ONLY, "", ""));
workUnit.setProp(WEIGHT, Long.toString(weight));
return workUnit;
}
use of org.apache.gobblin.source.workunit.Extract in project incubator-gobblin by apache.
the class CopySourceTest method testPartitionableDataset.
@Test
public void testPartitionableDataset() throws Exception {
SourceState state = new SourceState();
state.setProp(ConfigurationKeys.SOURCE_FILEBASED_FS_URI, "file:///");
state.setProp(ConfigurationKeys.WRITER_FILE_SYSTEM_URI, "file:///");
state.setProp(ConfigurationKeys.DATA_PUBLISHER_FINAL_DIR, "/target/dir");
state.setProp(DatasetUtils.DATASET_PROFILE_CLASS_KEY, TestCopyablePartitionableDatasedFinder.class.getCanonicalName());
CopySource source = new CopySource();
List<WorkUnit> workunits = source.getWorkunits(state);
workunits = JobLauncherUtils.flattenWorkUnits(workunits);
Assert.assertEquals(workunits.size(), TestCopyableDataset.FILE_COUNT);
Extract extractAbove = null;
Extract extractBelow = null;
for (WorkUnit workUnit : workunits) {
CopyableFile copyableFile = (CopyableFile) CopySource.deserializeCopyEntity(workUnit);
Assert.assertTrue(copyableFile.getOrigin().getPath().toString().startsWith(TestCopyableDataset.ORIGIN_PREFIX));
Assert.assertEquals(copyableFile.getDestinationOwnerAndPermission(), TestCopyableDataset.OWNER_AND_PERMISSION);
if (Integer.parseInt(copyableFile.getOrigin().getPath().getName()) < TestCopyablePartitionableDataset.THRESHOLD) {
// should be in extractBelow
if (extractBelow == null) {
extractBelow = workUnit.getExtract();
}
Assert.assertEquals(workUnit.getExtract(), extractBelow);
} else {
// should be in extractAbove
if (extractAbove == null) {
extractAbove = workUnit.getExtract();
}
Assert.assertEquals(workUnit.getExtract(), extractAbove);
}
}
Assert.assertNotNull(extractAbove);
Assert.assertNotNull(extractBelow);
}
use of org.apache.gobblin.source.workunit.Extract in project incubator-gobblin by apache.
the class TaskTest method getEmptyTestTaskState.
TaskState getEmptyTestTaskState(String taskId) {
// Create a TaskState
WorkUnit workUnit = WorkUnit.create(new Extract(Extract.TableType.SNAPSHOT_ONLY, this.getClass().getName(), this.getClass().getSimpleName()));
workUnit.setProp(ConfigurationKeys.TASK_KEY_KEY, "taskKey");
TaskState taskState = new TaskState(new WorkUnitState(workUnit));
taskState.setProp(ConfigurationKeys.METRICS_ENABLED_KEY, Boolean.toString(false));
taskState.setTaskId(taskId);
taskState.setJobId("1234");
return taskState;
}
Aggregations