-
Notifications
You must be signed in to change notification settings - Fork 440
TEZ-4014: Allow DAGAppMaster to read configuration from plaintext (1/3) #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import java.io.FileInputStream; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.lang.management.ManagementFactory; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
|
|
@@ -45,8 +46,10 @@ | |
| import org.apache.hadoop.yarn.api.records.ApplicationId; | ||
| import org.apache.log4j.Appender; | ||
| import org.apache.log4j.PatternLayout; | ||
| import org.apache.tez.client.TezClientUtils; | ||
| import org.apache.tez.common.io.NonSyncByteArrayOutputStream; | ||
| import org.apache.tez.dag.api.DagTypeConverters; | ||
| import org.apache.tez.dag.api.TezConfiguration; | ||
| import org.apache.tez.dag.api.TezConstants; | ||
| import org.apache.tez.dag.api.TezUncheckedException; | ||
| import org.apache.tez.dag.api.records.DAGProtos; | ||
|
|
@@ -57,6 +60,7 @@ | |
| import org.apache.tez.dag.records.TezTaskAttemptID; | ||
| import org.apache.tez.dag.records.TezVertexID; | ||
| import org.apache.tez.hadoop.shim.HadoopShim; | ||
| import org.apache.tez.serviceplugins.api.ServicePluginsDescriptor; | ||
| import org.apache.tez.serviceplugins.api.TaskAttemptEndReason; | ||
| import org.apache.tez.util.StopWatch; | ||
|
|
||
|
|
@@ -74,14 +78,36 @@ public final class TezUtilsInternal { | |
|
|
||
| private TezUtilsInternal() {} | ||
|
|
||
| public static ConfigurationProto readUserSpecifiedTezConfiguration(String baseDir) throws | ||
| IOException { | ||
| public static ConfigurationProto readUserSpecifiedTezConfiguration(String baseDir) throws IOException { | ||
| File confPBFile = new File(baseDir, TezConstants.TEZ_PB_BINARY_CONF_NAME); | ||
| try (FileInputStream fis = new FileInputStream(confPBFile)) { | ||
| return ConfigurationProto.parseFrom(fis); | ||
| } | ||
| } | ||
|
|
||
| public static Configuration readTezConfigurationXml(InputStream is) throws IOException { | ||
| Configuration configuration = new Configuration(); | ||
| if (is != null) { | ||
| configuration.addResource(is); | ||
| } | ||
| return configuration; | ||
| } | ||
|
|
||
| public static ConfigurationProto loadConfProtoFromText() throws IOException { | ||
|
||
| try (InputStream cis = ClassLoader.getSystemResourceAsStream(TezConfiguration.TEZ_SITE_XML); | ||
| InputStream sis = ClassLoader.getSystemResourceAsStream(TezConstants.SERVICE_PLUGINS_DESCRIPTOR_JSON)) { | ||
| Configuration confFromXml = TezUtilsInternal.readTezConfigurationXml(cis); | ||
| for (String confFile : confFromXml.getTrimmedStringCollection(TezConfiguration.TEZ_AM_STANDALONE_CONFS)) { | ||
| try (InputStream additionalInput = ClassLoader.getSystemResourceAsStream(confFile)) { | ||
| Configuration additionalConfFromXml = TezUtilsInternal.readTezConfigurationXml(additionalInput); | ||
| confFromXml.addResource(additionalConfFromXml); | ||
| } | ||
| } | ||
| ServicePluginsDescriptor pluginsDescriptor = TezClientUtils.createPluginsDescriptorFromJSON(sis); | ||
| return TezClientUtils.createFinalConfProtoForApp(confFromXml, pluginsDescriptor); | ||
| } | ||
| } | ||
|
|
||
| public static void addUserSpecifiedTezConfiguration(Configuration conf, | ||
| List<PlanKeyValuePair> kvPairList) { | ||
| if (kvPairList != null && !kvPairList.isEmpty()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,28 @@ | |
|
|
||
| package org.apache.tez.common; | ||
|
|
||
| import static org.junit.Assert.assertArrayEquals; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.util.BitSet; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Random; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.tez.client.TezClientUtils; | ||
| import org.apache.tez.dag.api.TezConfiguration; | ||
| import org.apache.tez.dag.api.TezConstants; | ||
| import org.apache.tez.dag.api.UserPayload; | ||
| import org.apache.tez.dag.api.records.DAGProtos; | ||
| import org.apache.tez.serviceplugins.api.ContainerLauncherDescriptor; | ||
| import org.apache.tez.serviceplugins.api.ServicePluginsDescriptor; | ||
| import org.apache.tez.serviceplugins.api.TaskCommunicatorDescriptor; | ||
| import org.apache.tez.serviceplugins.api.TaskSchedulerDescriptor; | ||
|
|
||
| import com.google.protobuf.ByteString; | ||
|
|
||
|
|
@@ -291,4 +301,30 @@ public void testPopulateConfProtoFromEntries() { | |
| assertEquals(confBuilder.getConfKeyValuesList().size(), 1); | ||
| } | ||
|
|
||
| @Test(timeout = 5000) | ||
| public void testReadTezConfigurationXmlFromClasspath() throws IOException { | ||
| InputStream is = ClassLoader.getSystemResourceAsStream(TezConfiguration.TEZ_SITE_XML); | ||
| Configuration conf = TezUtilsInternal.readTezConfigurationXml(is); | ||
| assertEquals(conf.get("tez.lib.uris"), "tez.tar.gz"); | ||
| } | ||
|
|
||
| @Test(timeout = 5000) | ||
| public void testPluginsDescriptorFromJSON() throws IOException { | ||
| InputStream is = ClassLoader.getSystemResourceAsStream(TezConstants.SERVICE_PLUGINS_DESCRIPTOR_JSON); | ||
| ServicePluginsDescriptor spd = TezClientUtils.createPluginsDescriptorFromJSON(is); | ||
| TaskSchedulerDescriptor tsd = spd.getTaskSchedulerDescriptors()[0]; | ||
| ContainerLauncherDescriptor cld = spd.getContainerLauncherDescriptors()[0]; | ||
| TaskCommunicatorDescriptor tcd = spd.getTaskCommunicatorDescriptors()[0]; | ||
|
|
||
| assertFalse(spd.areContainersEnabled()); | ||
| assertTrue(spd.isUberEnabled()); | ||
| assertEquals(tsd.getClassName(), "testScheduler0_class"); | ||
| assertEquals(tsd.getEntityName(), "testScheduler0"); | ||
| assertEquals(cld.getClassName(), "testLauncher0_class"); | ||
| assertEquals(cld.getEntityName(), "testLauncher0"); | ||
| assertEquals(tcd.getClassName(), "testComm0_class"); | ||
| assertEquals(tcd.getEntityName(), "testComm0"); | ||
| assertEquals(tcd.getUserPayload().getVersion(), 1); | ||
| assertArrayEquals(tcd.getUserPayload().deepCopyAsArray(), new byte[] {0, 0, 0, 1}); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "taskSchedulerDescriptors": [ | ||
| { | ||
| "className": "testScheduler0_class", | ||
| "entityName": "testScheduler0" | ||
| } | ||
| ], | ||
| "containerLauncherDescriptors": [ | ||
| { | ||
| "className": "testLauncher0_class", | ||
| "entityName": "testLauncher0" | ||
| } | ||
| ], | ||
| "taskCommunicatorDescriptors": [ | ||
| { | ||
| "userPayload": { | ||
| "payload": "AAAAAQ==", | ||
| "version": 1 | ||
| }, | ||
| "className": "testComm0_class", | ||
| "entityName": "testComm0" | ||
| } | ||
| ], | ||
| "enableContainers": false, | ||
| "enableUber": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
| <!-- | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. See accompanying LICENSE file. | ||
| --> | ||
|
|
||
| <configuration> | ||
| <property> | ||
| <name>tez.lib.uris</name> | ||
| <value>tez.tar.gz</value> | ||
| </property> | ||
| </configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't throw IOE