@@ -38,6 +38,9 @@ public class TonyJob extends HadoopJavaJob {
38
38
private static final String TONY_CONF_PREFIX = "tony." ;
39
39
public static final String TONY_APPLICATION_TAGS =
40
40
TONY_CONF_PREFIX + "application.tags" ;
41
+ public static final String TONY_DEFAULT_JVM_OPTS = TONY_CONF_PREFIX + "default.jvm.opts" ;
42
+ public static final String TONY_TASK_AM_JVM_OPTS = TONY_CONF_PREFIX + "task.am.jvm.opts" ;
43
+ public static final String TONY_TASK_EXECUTOR_JVM_OPTS = TONY_CONF_PREFIX + "task.executor.jvm.opts" ;
41
44
private String tonyXml ;
42
45
private File tonyConfFile ;
43
46
private final Configuration tonyConf ;
@@ -64,9 +67,37 @@ private Configuration getJobConfiguration() {
64
67
String applicationTags =
65
68
HadoopJobUtils .constructHadoopTags (getJobProps (), tagKeys );
66
69
tonyConf .set (TONY_APPLICATION_TAGS , applicationTags );
70
+
71
+ // inject default jvm options
72
+ updateDefaultTonyJvmOpts (tonyConf );
67
73
return tonyConf ;
68
74
}
69
75
76
+ private void updateDefaultTonyJvmOpts (Configuration conf ) {
77
+ String defaultTonyJvmOpts = getJobProps ().get (TONY_DEFAULT_JVM_OPTS );
78
+ if (defaultTonyJvmOpts == null ) {
79
+ return ;
80
+ }
81
+
82
+ // tony am jvm opts
83
+ String tonyTaskAmJvmOpts = conf .get (TONY_TASK_AM_JVM_OPTS , "" );
84
+ if (!tonyTaskAmJvmOpts .isEmpty ()) {
85
+ tonyTaskAmJvmOpts += " " + defaultTonyJvmOpts ;
86
+ } else {
87
+ tonyTaskAmJvmOpts += defaultTonyJvmOpts ;
88
+ }
89
+ conf .set (TONY_TASK_AM_JVM_OPTS , tonyTaskAmJvmOpts );
90
+
91
+ // tony executor jvm opts
92
+ String tonyTaskExecutorJvmOpts = conf .get (TONY_TASK_EXECUTOR_JVM_OPTS , "" );
93
+ if (!tonyTaskExecutorJvmOpts .isEmpty ()) {
94
+ tonyTaskExecutorJvmOpts += " " + defaultTonyJvmOpts ;
95
+ } else {
96
+ tonyTaskExecutorJvmOpts += defaultTonyJvmOpts ;
97
+ }
98
+ conf .set (TONY_TASK_EXECUTOR_JVM_OPTS , tonyTaskExecutorJvmOpts );
99
+ }
100
+
70
101
public Configuration getTonyJobConf () {
71
102
return tonyConf ;
72
103
}
0 commit comments