cameronlee314 commented on a change in pull request #1278: SAMZA-2458: Update
ProcessJobFactory and ThreadJobFactory to load full job config
URL: https://github.com/apache/samza/pull/1278#discussion_r379694087
##########
File path:
samza-core/src/main/scala/org/apache/samza/job/local/ProcessJobFactory.scala
##########
@@ -22,25 +22,48 @@ package org.apache.samza.job.local
import java.util
import org.apache.samza.SamzaException
+import org.apache.samza.application.ApplicationUtil
+import org.apache.samza.application.descriptors.ApplicationDescriptorUtil
import org.apache.samza.config.{Config, JobConfig, TaskConfig}
import org.apache.samza.container.TaskName
import org.apache.samza.coordinator.metadatastore.{CoordinatorStreamStore,
NamespaceAwareCoordinatorStreamStore}
import org.apache.samza.coordinator.stream.messages.SetChangelogMapping
import org.apache.samza.coordinator.{JobModelManager, MetadataResourceUtil}
+import org.apache.samza.execution.RemoteJobPlanner
import org.apache.samza.job.model.JobModelUtil
import org.apache.samza.job.{CommandBuilder, ShellCommandBuilder, StreamJob,
StreamJobFactory}
import org.apache.samza.metrics.MetricsRegistryMap
import org.apache.samza.startpoint.StartpointManager
import org.apache.samza.storage.ChangelogStreamManager
-import org.apache.samza.util.{CoordinatorStreamUtil, Logging, ReflectionUtil}
+import org.apache.samza.util.{ConfigUtil, CoordinatorStreamUtil,
DiagnosticsUtil, Logging, ReflectionUtil}
import scala.collection.JavaConversions._
/**
- * Creates a stand alone ProcessJob with the specified config.
+ * Creates a ProcessJob with the specified config.
*/
class ProcessJobFactory extends StreamJobFactory with Logging {
- def getJob(config: Config): StreamJob = {
+ def getJob(submissionConfig: Config): StreamJob = {
+ var config = submissionConfig
+
+ if (new JobConfig(submissionConfig).getConfigLoaderFactory.isPresent) {
+ val originalConfig = ConfigUtil.loadConfig(submissionConfig)
+
+ // Execute planning
+ val planner = new
RemoteJobPlanner(ApplicationDescriptorUtil.getAppDescriptor(ApplicationUtil.fromConfig(originalConfig),
originalConfig))
+ val jobConfigs = planner.prepareJobs
+
+ if (jobConfigs.size != 1) {
+ throw new SamzaException("Only single process job is supported.")
+ }
+
+ // This is the full job config
+ config = jobConfigs.get(0)
+ // This needs to be consistent with RemoteApplicationRunner#run where
JobRunner#submit to be called instead of JobRunner#run
+ CoordinatorStreamUtil.writeConfigToCoordinatorStream(config)
+ DiagnosticsUtil.createDiagnosticsStream(config)
Review comment:
Similar to above: does this only need to be consistent with
`RemoteApplicationRunner`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services