use of org.apache.samza.rest.proxy.installation.InstallationRecord in project samza by apache.
the class ScriptJobProxy method getScriptPath.
/**
* Constructs the path to the specified script within the job installation.
*
* @param jobInstance the instance of the job.
* @param scriptName the name of the script.
* @return the full path to the script.
* @throws FileNotFoundException if the job installation path doesn't exist.
*/
public String getScriptPath(JobInstance jobInstance, String scriptName) throws FileNotFoundException {
String scriptPath;
InstallationRecord jobInstallation = getInstallationFinder().getAllInstalledJobs().get(jobInstance);
scriptPath = Paths.get(jobInstallation.getScriptFilePath(), scriptName).toString();
File scriptFile = new File(scriptPath);
if (!scriptFile.exists()) {
throw new FileNotFoundException("Script does not exist: " + scriptPath);
}
return scriptPath;
}
use of org.apache.samza.rest.proxy.installation.InstallationRecord in project samza by apache.
the class SamzaTaskProxy method getCoordinatorSystemConfig.
/**
* Builds coordinator system config for the {@param jobInstance}.
* @param jobInstance the job instance to get the jobModel for.
* @return the constructed coordinator system config.
*/
private Config getCoordinatorSystemConfig(JobInstance jobInstance) {
try {
InstallationRecord record = installFinder.getAllInstalledJobs().get(jobInstance);
ConfigFactory configFactory = ClassLoaderHelper.fromClassName(taskResourceConfig.getJobConfigFactory());
Config config = configFactory.getConfig(new URI(String.format("file://%s", record.getConfigFilePath())));
Map<String, String> configMap = ImmutableMap.of(JobConfig.JOB_ID(), jobInstance.getJobId(), JobConfig.JOB_NAME(), jobInstance.getJobName());
return Util.buildCoordinatorStreamConfig(new MapConfig(ImmutableList.of(config, configMap)));
} catch (Exception e) {
LOG.error(String.format("Failed to get coordinator stream config for job : %s", jobInstance), e);
throw new SamzaException(e);
}
}
Aggregations