Skip to content

Commit 6e357a0

Browse files
authored
TEZ-4014: Allow DAGAppMaster to read configuration from plaintext (1/3) (#408) (Laszlo Bodor co-authored by Eric Wohlstadter reviewed by Ayush Saxena)
1 parent c981a94 commit 6e357a0

File tree

14 files changed

+156
-10
lines changed

14 files changed

+156
-10
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@
898898
<artifactId>apache-rat-plugin</artifactId>
899899
<configuration>
900900
<excludes>
901+
<exclude>**/*.json</exclude>
901902
<exclude>CHANGES.txt</exclude>
902903
<exclude>**/LICENSE*</exclude>
903904
<!-- IDE files -->

tez-api/src/main/java/org/apache/tez/client/TezClientUtils.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@
110110
import org.apache.tez.dag.api.records.DAGProtos.PlanKeyValuePair;
111111
import org.apache.tez.serviceplugins.api.ServicePluginsDescriptor;
112112

113+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
114+
import com.fasterxml.jackson.annotation.PropertyAccessor;
115+
import com.fasterxml.jackson.databind.ObjectMapper;
113116
import com.google.common.annotations.VisibleForTesting;
114117
import com.google.common.base.Function;
115118
import com.google.common.base.Strings;
@@ -200,6 +203,16 @@ static boolean setupTezJarsLocalResources(TezConfiguration conf,
200203
return usingTezArchive;
201204
}
202205

206+
public static ServicePluginsDescriptor createPluginsDescriptorFromJSON(InputStream is) throws IOException {
207+
ObjectMapper objectMapper = new ObjectMapper();
208+
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
209+
if (is != null) {
210+
return objectMapper.readValue(is, ServicePluginsDescriptor.class);
211+
} else {
212+
return ServicePluginsDescriptor.create(false);
213+
}
214+
}
215+
203216
private static boolean addLocalResources(Configuration conf,
204217
String[] configUris, Map<String, LocalResource> tezJarResources,
205218
Credentials credentials) throws IOException {
@@ -834,7 +847,7 @@ public static void addLog4jSystemProperties(String logLevel,
834847
}
835848
}
836849

837-
static ConfigurationProto createFinalConfProtoForApp(Configuration amConf,
850+
public static ConfigurationProto createFinalConfProtoForApp(Configuration amConf,
838851
ServicePluginsDescriptor servicePluginsDescriptor) {
839852
assert amConf != null;
840853
ConfigurationProto.Builder builder = ConfigurationProto.newBuilder();

tez-api/src/main/java/org/apache/tez/dag/api/NamedEntityDescriptor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323

2424
@SuppressWarnings("unchecked")
2525
public class NamedEntityDescriptor<T extends NamedEntityDescriptor<T>> extends EntityDescriptor<NamedEntityDescriptor<T>> {
26-
private final String entityName;
26+
27+
private String entityName;
28+
29+
/**
30+
* Public constructor to allow this descriptor to be instantiated by Jackson.
31+
*/
32+
@InterfaceAudience.Private
33+
public NamedEntityDescriptor() {}
2734

2835
@InterfaceAudience.Private
2936
public NamedEntityDescriptor(String entityName, String className) {

tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,4 +2332,11 @@ static Set<String> getPropertySet() {
23322332
@ConfigurationScope(Scope.DAG)
23332333
@ConfigurationProperty
23342334
public static final String TEZ_TASK_ATTEMPT_HOOKS = TEZ_TASK_PREFIX + "attempt.hooks";
2335+
2336+
/**
2337+
* Comma-separated list of additional hadoop config files to load from CLASSPATH in standalone mode.
2338+
*/
2339+
@ConfigurationScope(Scope.AM)
2340+
@ConfigurationProperty
2341+
public static final String TEZ_AM_STANDALONE_CONFS = TEZ_AM_PREFIX + "standalone.confs";
23352342
}

tez-api/src/main/java/org/apache/tez/dag/api/TezConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public final class TezConstants {
4949
TEZ_AM_SECURITY_SERVICE_AUTHORIZATION_CLIENT =
5050
"security.job.client.protocol.acl";
5151

52+
public static final String SERVICE_PLUGINS_DESCRIPTOR_JSON = "service_plugins_descriptor.json";
5253
public static final String TEZ_PB_BINARY_CONF_NAME = "tez-conf.pb";
5354
public static final String TEZ_PB_PLAN_BINARY_NAME = "tez-dag.pb";
5455
public static final String TEZ_PB_PLAN_TEXT_NAME = "tez-dag.pb.txt";

tez-api/src/main/java/org/apache/tez/dag/api/UserPayload.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import javax.annotation.Nullable;
2424

25-
import org.apache.hadoop.classification.InterfaceAudience.Public;
25+
import org.apache.hadoop.classification.InterfaceAudience;
2626
import org.apache.hadoop.classification.InterfaceStability;
2727

2828
import com.google.common.annotations.VisibleForTesting;
@@ -31,12 +31,17 @@
3131
* Wrapper class to hold user payloads
3232
* Provides a version to help in evolving the payloads
3333
*/
34-
@Public
34+
@InterfaceAudience.Public
3535
public final class UserPayload {
36-
private final ByteBuffer payload;
37-
private final int version;
36+
private ByteBuffer payload;
37+
private int version;
3838
private static final ByteBuffer EMPTY_BYTE = ByteBuffer.wrap(new byte[0]);
3939

40+
/**
41+
* Public constructor to allow this descriptor to be instantiated by Jackson.
42+
*/
43+
public UserPayload() {}
44+
4045
private UserPayload(@Nullable ByteBuffer payload) {
4146
this(payload, 0);
4247
}

tez-api/src/main/java/org/apache/tez/serviceplugins/api/ContainerLauncherDescriptor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
@InterfaceStability.Unstable
2323
public class ContainerLauncherDescriptor extends NamedEntityDescriptor<ContainerLauncherDescriptor> {
2424

25+
/**
26+
* Public constructor to allow this descriptor to be instantiated by Jackson.
27+
*/
28+
@InterfaceAudience.Private
29+
public ContainerLauncherDescriptor() {}
30+
2531
private ContainerLauncherDescriptor(String containerLauncherName, String containerLauncherClassname) {
2632
super(containerLauncherName, containerLauncherClassname);
2733
}

tez-api/src/main/java/org/apache/tez/serviceplugins/api/ServicePluginsDescriptor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
@InterfaceStability.Unstable
3030
public class ServicePluginsDescriptor {
3131

32-
private final boolean enableContainers;
33-
private final boolean enableUber;
32+
private boolean enableContainers;
33+
private boolean enableUber;
3434

3535
private TaskSchedulerDescriptor[] taskSchedulerDescriptors;
3636
private ContainerLauncherDescriptor[] containerLauncherDescriptors;
3737
private TaskCommunicatorDescriptor[] taskCommunicatorDescriptors;
3838

39+
@InterfaceAudience.Private
40+
public ServicePluginsDescriptor() {}
41+
3942
private ServicePluginsDescriptor(boolean enableContainers, boolean enableUber,
4043
TaskSchedulerDescriptor[] taskSchedulerDescriptors,
4144
ContainerLauncherDescriptor[] containerLauncherDescriptors,

tez-api/src/main/java/org/apache/tez/serviceplugins/api/TaskCommunicatorDescriptor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
@InterfaceStability.Unstable
2323
public class TaskCommunicatorDescriptor extends NamedEntityDescriptor<TaskCommunicatorDescriptor> {
2424

25+
/**
26+
* Public constructor to allow this descriptor to be instantiated by Jackson.
27+
*/
28+
@InterfaceAudience.Private
29+
public TaskCommunicatorDescriptor() {}
2530

2631
private TaskCommunicatorDescriptor(String taskCommName, String taskCommClassname) {
2732
super(taskCommName, taskCommClassname);

tez-api/src/main/java/org/apache/tez/serviceplugins/api/TaskSchedulerDescriptor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
@InterfaceStability.Unstable
2323
public class TaskSchedulerDescriptor extends NamedEntityDescriptor<TaskSchedulerDescriptor> {
2424

25+
/**
26+
* Public constructor to allow this descriptor to be instantiated by Jackson.
27+
*/
28+
@InterfaceAudience.Private
29+
public TaskSchedulerDescriptor() { }
30+
2531
private TaskSchedulerDescriptor(String taskSchedulerName, String schedulerClassname) {
2632
super(taskSchedulerName, schedulerClassname);
2733
}

0 commit comments

Comments
 (0)