This repository was archived by the owner on Feb 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
SLIDER-1090: Speed up SliderClient and AM by reading metainfo from su… #4
Open
shanyu
wants to merge
1
commit into
apache:develop
Choose a base branch
from
shanyu:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package org.apache.slider.providers.agent; | ||
|
|
||
| import java.io.BufferedWriter; | ||
| import java.io.File; | ||
| import java.io.FileWriter; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.slider.common.tools.SliderFileSystem; | ||
| import org.apache.slider.providers.agent.application.metadata.Metainfo; | ||
| import org.apache.slider.tools.TestUtility; | ||
| import org.junit.Assert; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class TestAgentUtils { | ||
| protected static final Logger log = | ||
| LoggerFactory.getLogger(TestAgentUtils.class); | ||
| @Rule | ||
| public TemporaryFolder folder = new TemporaryFolder(); | ||
| private static final String metainfo_str = "<metainfo>\n" | ||
| + " <schemaVersion>2.0</schemaVersion>\n" | ||
| + " <application>\n" | ||
| + " <name>MYTESTAPPLICATION</name>\n" | ||
| + " <comment>\n" | ||
| + " My Test Application\n" | ||
| + " </comment>\n" | ||
| + " <version>1.0</version>\n" | ||
| + " <type>YARN-APP</type>\n" | ||
| + " <components>\n" | ||
| + " <component>\n" | ||
| + " <name>REST</name>\n" | ||
| + " <category>MASTER</category>\n" | ||
| + " <commandScript>\n" | ||
| + " <script>scripts/rest.py</script>\n" | ||
| + " <scriptType>PYTHON</scriptType>\n" | ||
| + " <timeout>600</timeout>\n" | ||
| + " </commandScript>\n" | ||
| + " </component>\n" | ||
| + " </components>\n" | ||
| + " </application>\n" | ||
| + "</metainfo>"; | ||
|
|
||
| @Test | ||
| public void testGetApplicationMetainfo() throws Exception { | ||
| String zipFileName = TestUtility.createAppPackage( | ||
| folder, | ||
| "testpkg", | ||
| "test.zip", | ||
| "target/test-classes/org/apache/slider/common/tools/test"); | ||
| Configuration configuration = new Configuration(); | ||
| FileSystem fs = FileSystem.getLocal(configuration); | ||
| log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); | ||
| SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); | ||
|
|
||
| // Without accompany metainfo file, read metainfo from the zip file | ||
| Metainfo metainfo = AgentUtils.getApplicationMetainfo( | ||
| sliderFileSystem, zipFileName, false); | ||
| Assert.assertNotNull(metainfo.getApplication()); | ||
| Assert.assertEquals("STORM", metainfo.getApplication().getName()); | ||
|
|
||
| // With accompany metainfo file, read metainfo from the accompany file | ||
| String acompanyFileName = zipFileName + ".metainfo.xml"; | ||
| File f = new File(acompanyFileName); | ||
| try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { | ||
| writer.write(metainfo_str); | ||
| } | ||
| metainfo = AgentUtils.getApplicationMetainfo( | ||
| sliderFileSystem, zipFileName, false); | ||
| Assert.assertNotNull(metainfo.getApplication()); | ||
| Assert.assertEquals("MYTESTAPPLICATION", metainfo.getApplication().getName()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
1.s/acompany/r/summary file
2. include path.
3. add a log@debug with the stack trace