Search in sources :

Example 1 with InstallationRecord

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) InstallationRecord(org.apache.samza.rest.proxy.installation.InstallationRecord) File(java.io.File)

Example 2 with InstallationRecord

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);
    }
}
Also used : JobConfig(org.apache.samza.config.JobConfig) MapConfig(org.apache.samza.config.MapConfig) StorageConfig(org.apache.samza.config.StorageConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) InstallationRecord(org.apache.samza.rest.proxy.installation.InstallationRecord) URI(java.net.URI) SamzaException(org.apache.samza.SamzaException) IOException(java.io.IOException) SamzaException(org.apache.samza.SamzaException) ConfigFactory(org.apache.samza.config.ConfigFactory)

Aggregations

InstallationRecord (org.apache.samza.rest.proxy.installation.InstallationRecord)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URI (java.net.URI)1 SamzaException (org.apache.samza.SamzaException)1 Config (org.apache.samza.config.Config)1 ConfigFactory (org.apache.samza.config.ConfigFactory)1 JobConfig (org.apache.samza.config.JobConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 StorageConfig (org.apache.samza.config.StorageConfig)1