use of org.apache.gobblin.metastore.FsStateStore in project incubator-gobblin by apache.
the class GobblinHelixTaskTest method testPrepareTask.
@Test
public void testPrepareTask() throws IOException {
// Serialize the JobState that will be read later in GobblinHelixTask
Path jobStateFilePath = new Path(appWorkDir, TestHelper.TEST_JOB_ID + "." + AbstractJobLauncher.JOB_STATE_FILE_NAME);
JobState jobState = new JobState();
jobState.setJobName(TestHelper.TEST_JOB_NAME);
jobState.setJobId(TestHelper.TEST_JOB_ID);
SerializationUtils.serializeState(this.localFs, jobStateFilePath, jobState);
// Prepare the WorkUnit
WorkUnit workUnit = WorkUnit.createEmpty();
prepareWorkUnit(workUnit);
// Prepare the source Json file
File sourceJsonFile = new File(this.appWorkDir.toString(), TestHelper.TEST_JOB_NAME + ".json");
TestHelper.createSourceJsonFile(sourceJsonFile);
workUnit.setProp(SimpleJsonSource.SOURCE_FILE_KEY, sourceJsonFile.getAbsolutePath());
// Serialize the WorkUnit into a file
// expected path is appWorkDir/_workunits/job_id/job_id.wu
Path workUnitDirPath = new Path(this.appWorkDir, GobblinClusterConfigurationKeys.INPUT_WORK_UNIT_DIR_NAME);
FsStateStore<WorkUnit> wuStateStore = new FsStateStore<>(this.localFs, workUnitDirPath.toString(), WorkUnit.class);
Path workUnitFilePath = new Path(new Path(workUnitDirPath, TestHelper.TEST_JOB_ID), TestHelper.TEST_JOB_NAME + ".wu");
wuStateStore.put(TestHelper.TEST_JOB_ID, TestHelper.TEST_JOB_NAME + ".wu", workUnit);
Assert.assertTrue(this.localFs.exists(workUnitFilePath));
// Prepare the GobblinHelixTask
Map<String, String> taskConfigMap = Maps.newHashMap();
taskConfigMap.put(GobblinClusterConfigurationKeys.WORK_UNIT_FILE_PATH, workUnitFilePath.toString());
taskConfigMap.put(ConfigurationKeys.JOB_NAME_KEY, TestHelper.TEST_JOB_NAME);
taskConfigMap.put(ConfigurationKeys.JOB_ID_KEY, TestHelper.TEST_JOB_ID);
taskConfigMap.put(ConfigurationKeys.TASK_KEY_KEY, Long.toString(Id.parse(TestHelper.TEST_JOB_ID).getSequence()));
TaskConfig taskConfig = new TaskConfig("", taskConfigMap, true);
TaskCallbackContext taskCallbackContext = Mockito.mock(TaskCallbackContext.class);
Mockito.when(taskCallbackContext.getTaskConfig()).thenReturn(taskConfig);
Mockito.when(taskCallbackContext.getManager()).thenReturn(this.helixManager);
GobblinHelixTaskFactory gobblinHelixTaskFactory = new GobblinHelixTaskFactory(Optional.<ContainerMetrics>absent(), this.taskExecutor, this.taskStateTracker, this.localFs, this.appWorkDir, ConfigFactory.empty(), this.helixManager);
this.gobblinHelixTask = (GobblinHelixTask) gobblinHelixTaskFactory.createNewTask(taskCallbackContext);
}
use of org.apache.gobblin.metastore.FsStateStore in project incubator-gobblin by apache.
the class MRJobLauncherTest method startUp.
@BeforeClass
public void startUp() throws Exception {
this.testLogger.info("startUp: in");
testMetastoreDatabase = TestMetastoreDatabaseFactory.get();
this.launcherProps = new Properties();
try (InputStream propsReader = getClass().getClassLoader().getResourceAsStream("gobblin.mr-test.properties")) {
this.launcherProps.load(propsReader);
}
this.launcherProps.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_ENABLED_KEY, "true");
this.launcherProps.setProperty(ConfigurationKeys.METRICS_ENABLED_KEY, "true");
this.launcherProps.setProperty(ConfigurationKeys.METRICS_REPORTING_FILE_ENABLED_KEY, "false");
this.launcherProps.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_URL_KEY, testMetastoreDatabase.getJdbcUrl());
StateStore<JobState.DatasetState> datasetStateStore = new FsStateStore<>(this.launcherProps.getProperty(ConfigurationKeys.STATE_STORE_FS_URI_KEY), this.launcherProps.getProperty(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY), JobState.DatasetState.class);
this.jobLauncherTestHelper = new JobLauncherTestHelper(this.launcherProps, datasetStateStore);
// Other tests may not clean up properly, clean up outputDir and stagingDir or some of these tests might fail.
String outputDir = this.launcherProps.getProperty(ConfigurationKeys.WRITER_OUTPUT_DIR);
String stagingDir = this.launcherProps.getProperty(ConfigurationKeys.WRITER_STAGING_DIR);
FileUtils.deleteDirectory(new File(outputDir));
FileUtils.deleteDirectory(new File(stagingDir));
this.testLogger.info("startUp: out");
}
use of org.apache.gobblin.metastore.FsStateStore in project incubator-gobblin by apache.
the class LocalJobLauncherTest method startUp.
@BeforeClass
public void startUp() throws Exception {
testMetastoreDatabase = TestMetastoreDatabaseFactory.get();
this.launcherProps = new Properties();
this.launcherProps.load(new FileReader("gobblin-test/resource/gobblin.test.properties"));
this.launcherProps.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_ENABLED_KEY, "true");
this.launcherProps.setProperty(ConfigurationKeys.METRICS_ENABLED_KEY, "true");
this.launcherProps.setProperty(ConfigurationKeys.METRICS_REPORTING_FILE_ENABLED_KEY, "false");
this.launcherProps.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_URL_KEY, testMetastoreDatabase.getJdbcUrl());
StateStore<JobState.DatasetState> datasetStateStore = new FsStateStore<>(this.launcherProps.getProperty(ConfigurationKeys.STATE_STORE_FS_URI_KEY), this.launcherProps.getProperty(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY), JobState.DatasetState.class);
this.jobLauncherTestHelper = new JobLauncherTestHelper(this.launcherProps, datasetStateStore);
}
Aggregations