eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jjt...@apache.org
Subject eagle git commit: MINOR: change the rest api for testing resource manager HA
Date Thu, 16 Mar 2017 08:03:26 GMT
Repository: eagle
Updated Branches:
  refs/heads/master b31b5470e -> ec52457cd


MINOR: change the rest api for testing resource manager HA

Author: Zhao, Qingwen <qingwzhao@apache.org>

Closes #879 from qingwen220/minor.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/ec52457c
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/ec52457c
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/ec52457c

Branch: refs/heads/master
Commit: ec52457cdda61be2d26c1f08935198447bde3d86
Parents: b31b547
Author: Zhao, Qingwen <qingwzhao@apache.org>
Authored: Thu Mar 16 08:03:09 2017 +0000
Committer: r7raul1984 <tangjijun@yhd.com>
Committed: Thu Mar 16 08:03:09 2017 +0000

----------------------------------------------------------------------
 .../storm/HadoopQueueRunningExtractor.java      |  9 +++---
 .../org/apache/eagle/jpm/util/Constants.java    |  4 ++-
 .../util/resourcefetch/RMResourceFetcher.java   |  9 ++----
 .../resourcefetch/ha/HAURLSelectorImpl.java     | 31 +++++---------------
 .../url/JobListServiceURLBuilderImpl.java       | 13 +++++---
 .../url/RmActiveTestURLBuilderImpl.java         |  2 +-
 .../resourcefetch/ha/HAURLSelectorImplTest.java | 24 +++++++--------
 .../url/JobListServiceURLBuilderImplTest.java   | 22 ++++----------
 8 files changed, 45 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-hadoop-queue/src/main/java/org/apache/eagle/hadoop/queue/storm/HadoopQueueRunningExtractor.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-hadoop-queue/src/main/java/org/apache/eagle/hadoop/queue/storm/HadoopQueueRunningExtractor.java
b/eagle-jpm/eagle-hadoop-queue/src/main/java/org/apache/eagle/hadoop/queue/storm/HadoopQueueRunningExtractor.java
index 15e399e..77177d9 100644
--- a/eagle-jpm/eagle-hadoop-queue/src/main/java/org/apache/eagle/hadoop/queue/storm/HadoopQueueRunningExtractor.java
+++ b/eagle-jpm/eagle-hadoop-queue/src/main/java/org/apache/eagle/hadoop/queue/storm/HadoopQueueRunningExtractor.java
@@ -55,7 +55,7 @@ public class HadoopQueueRunningExtractor {
             throw new IllegalArgumentException(site + ".baseUrl is null");
         }
         String[] urls = urlBases.split(",");
-        urlSelector = new HAURLSelectorImpl(urls, new RmActiveTestURLBuilderImpl(), Constants.CompressionType.NONE,
null);
+        urlSelector = new HAURLSelectorImpl(urls, Constants.CompressionType.NONE);
         executorService = Executors.newFixedThreadPool(MAX_NUM_THREADS);
         this.collector = collector;
     }
@@ -66,13 +66,12 @@ public class HadoopQueueRunningExtractor {
         } catch (IOException e) {
             LOGGER.error("{}", e.getMessage(), e);
         }
-        String selectedUrl = urlSelector.getSelectedUrl();
-        LOGGER.info("Current RM base url is " + selectedUrl);
+
         List<Future<?>> futures = new ArrayList<>();
-        futures.add(executorService.submit(new ClusterMetricsCrawler(site, selectedUrl, collector)));
+        futures.add(executorService.submit(new ClusterMetricsCrawler(site, urlSelector.getSelectedUrl(),
collector)));
         // move RunningAppCrawler into MRRunningJobApp
         //futures.add(executorService.submit(new RunningAppsCrawler(site, selectedUrl, collector)));
-        futures.add(executorService.submit(new SchedulerInfoCrawler(site, selectedUrl, collector)));
+        futures.add(executorService.submit(new SchedulerInfoCrawler(site, urlSelector.getSelectedUrl(),
collector)));
         futures.forEach(future -> {
             try {
                 future.get(MAX_WAIT_TIME * 1000, TimeUnit.MILLISECONDS);

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/Constants.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/Constants.java
b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/Constants.java
index d7f9f3f..fee0425 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/Constants.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/Constants.java
@@ -38,11 +38,13 @@ public class Constants {
     public static final String RUNNING_SPARK_EXECUTOR_SERVICE_ENDPOINT_NAME = "RunningSparkExecutorService";
     public static final String APPLICATION_PREFIX = "application";
     public static final String JOB_PREFIX = "job";
-    public static final String V2_APPS_URL = "ws/v1/cluster/apps";
+
     public static final String ANONYMOUS_PARAMETER = "anonymous=true";
 
+    public static final String V2_APPS_URL = "ws/v1/cluster/apps";
     public static final String V2_APPS_RUNNING_URL = "ws/v1/cluster/apps?state=RUNNING";
     public static final String V2_APPS_COMPLETED_URL = "ws/v1/cluster/apps?state=FINISHED";
+    public static final String V2_CLUSTER_INFO_URL = "ws/v1/cluster";
 
     public static final String SPARK_MASTER_KEY = "spark.master";
     public static final String SPARK_EXECUTOR_MEMORY_KEY = "spark.executor.memory";

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
index 266c6b1..5b4e39a 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
@@ -58,10 +58,7 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo>
{
     public RMResourceFetcher(String[] rmBasePaths) {
         //this.jobListServiceURLBuilder = new JobListServiceURLBuilderImpl();
         //this.sparkCompleteJobServiceURLBuilder = new SparkCompleteJobServiceURLBuilderImpl();
-        this.selector = new HAURLSelectorImpl(
-                rmBasePaths,
-                new RmActiveTestURLBuilderImpl(),
-                Constants.CompressionType.NONE, null);
+        this.selector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.NONE);
     }
 
     public HAURLSelector getSelector() {
@@ -72,14 +69,14 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo>
{
         List<AppInfo> result = new ArrayList<>();
         InputStream is = null;
         try {
-            LOG.info("Going to query cluster applications list: " + urlString);
+            LOG.info("Going to query {}", urlString);
             is = InputStreamUtils.getInputStream(urlString, null, compressionType);
             final AppsWrapper appWrapper = OBJ_MAPPER.readValue(is, AppsWrapper.class);
             if (appWrapper != null && appWrapper.getApps() != null
                 && appWrapper.getApps().getApp() != null) {
                 result = appWrapper.getApps().getApp();
             }
-            LOG.info("Successfully fetched {} AppInfos from url {}", result.size(), urlString);
+            LOG.info("Successfully fetched {} AppInfos from {}", result.size(), urlString);
         } catch (Exception e) {
             LOG.error("Fail to query {} due to {}", urlString, e.getMessage());
         } finally {

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImpl.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImpl.java
b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImpl.java
index ca1df25..fff7a1b 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImpl.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImpl.java
@@ -18,6 +18,7 @@ package org.apache.eagle.jpm.util.resourcefetch.ha;
 
 import org.apache.eagle.jpm.util.Constants;
 import org.apache.eagle.jpm.util.resourcefetch.connection.InputStreamUtils;
+import org.apache.eagle.jpm.util.resourcefetch.url.RmActiveTestURLBuilderImpl;
 import org.apache.eagle.jpm.util.resourcefetch.url.ServiceURLBuilder;
 import org.apache.hadoop.util.StringUtils;
 import org.slf4j.Logger;
@@ -32,36 +33,20 @@ public class HAURLSelectorImpl implements HAURLSelector {
     private final String[] urls;
     private volatile String selectedUrl;
     private final ServiceURLBuilder builder;
-    private final Constants.JobState jobState;
 
     private volatile boolean reselectInProgress;
     private final Constants.CompressionType compressionType;
     private static final long MAX_RETRY_TIME = 2;
     private static final Logger LOG = LoggerFactory.getLogger(HAURLSelectorImpl.class);
 
-    public HAURLSelectorImpl(String[] urls, ServiceURLBuilder builder, Constants.CompressionType
compressionType, Constants.JobState jobState) {
+    public HAURLSelectorImpl(String[] urls, Constants.CompressionType compressionType) {
         this.urls = urls;
         this.compressionType = compressionType;
-        this.builder = builder;
-        this.jobState = jobState;
-    }
-
-    private String convertRestApi(Constants.JobState jobState) {
-        if (jobState == null) {
-            return null;
-        }
-        switch (jobState) {
-            case RUNNING : return Constants.V2_APPS_RUNNING_URL;
-            case FINISHED : return Constants.V2_APPS_COMPLETED_URL;
-            case ALL : return Constants.V2_APPS_URL;
-            default :
-                LOG.error("Unsupported JobState={}", jobState);
-                return null;
-        }
+        this.builder = new RmActiveTestURLBuilderImpl();
     }
 
     public void checkUrl() throws IOException {
-        if (!checkUrl(builder.build(getSelectedUrl(), convertRestApi(jobState)))) {
+        if (!checkUrl(builder.build(getSelectedUrl()))) {
             reSelectUrl();
         }
     }
@@ -69,9 +54,10 @@ public class HAURLSelectorImpl implements HAURLSelector {
     public boolean checkUrl(String urlString) {
         InputStream is = null;
         try {
+            LOG.info("checking resource manager HA by {}", urlString);
             is = InputStreamUtils.getInputStream(urlString, null, compressionType);
         } catch (Exception ex) {
-            LOG.info("get inputStream from url: " + urlString + " failed. ");
+            LOG.info("fail to get inputStream from {}", urlString);
             return false;
         } finally {
             if (is != null) {
@@ -106,14 +92,13 @@ public class HAURLSelectorImpl implements HAURLSelector {
                 LOG.info("Going to reselect url");
                 for (int i = 0; i < urls.length; i++) {
                     String urlToCheck = urls[i];
-                    LOG.info("Going to try url :" + urlToCheck);
                     for (int time = 0; time < MAX_RETRY_TIME; time++) {
-                        if (checkUrl(builder.build(urlToCheck, convertRestApi(jobState))))
{
+                        if (checkUrl(builder.build(urlToCheck))) {
                             selectedUrl = urls[i];
                             LOG.info("Successfully switch to new url : " + selectedUrl);
                             return;
                         }
-                        LOG.info("try url " + urlToCheck + "fail for " + (time + 1) + " times,
sleep 5 seconds before try again. ");
+                        LOG.info("try {} failed for {} times, sleep 5 seconds before try
again. ", urlToCheck, time + 1);
                         try {
                             Thread.sleep(1000);
                         } catch (InterruptedException ex) {

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImpl.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImpl.java
b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImpl.java
index e5994aa..38a53e5 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImpl.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImpl.java
@@ -29,11 +29,16 @@ public class JobListServiceURLBuilderImpl implements ServiceURLBuilder
{
          */
         String rmUrl = URLUtil.removeTrailingSlash(url);
 
-        String restApi = parameters[0];
-
-        if (restApi == null) {
-            return null;
+        String restApi = Constants.V2_APPS_URL;
+        if (parameters != null && parameters.length > 0) {
+            String jobState = parameters[0];
+            if (jobState.equalsIgnoreCase(Constants.JobState.RUNNING.toString())) {
+                restApi = Constants.V2_APPS_RUNNING_URL;
+            } else if (jobState.equalsIgnoreCase(Constants.JobState.FINISHED.toString()))
{
+                restApi = Constants.V2_APPS_COMPLETED_URL;
+            }
         }
+
         // "/ws/v1/cluster/apps?state=RUNNING"
         StringBuilder sb = new StringBuilder();
         sb.append(rmUrl).append("/").append(restApi);

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/RmActiveTestURLBuilderImpl.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/RmActiveTestURLBuilderImpl.java
b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/RmActiveTestURLBuilderImpl.java
index f0b963b..619f32e 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/RmActiveTestURLBuilderImpl.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/url/RmActiveTestURLBuilderImpl.java
@@ -23,6 +23,6 @@ public class RmActiveTestURLBuilderImpl implements ServiceURLBuilder {
     @Override
     public String build(String url, String... parameters) {
         String rmUrl = URLUtil.removeTrailingSlash(url);
-        return String.format("%s/%s&limit=1&%s", rmUrl, Constants.V2_APPS_COMPLETED_URL,
Constants.ANONYMOUS_PARAMETER);
+        return String.format("%s/%s?%s", rmUrl, Constants.V2_CLUSTER_INFO_URL, Constants.ANONYMOUS_PARAMETER);
     }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImplTest.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImplTest.java
b/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImplTest.java
index 9d1f73c..8d056eb 100644
--- a/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImplTest.java
+++ b/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/ha/HAURLSelectorImplTest.java
@@ -44,7 +44,7 @@ public class HAURLSelectorImplTest {
     @Test
     public void testCheckUrl() throws Exception {
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         mockStatic(InputStreamUtils.class);
         when(InputStreamUtils.getInputStream("http://www.xxx.com:8088", null, Constants.CompressionType.GZIP)).thenReturn(null);
         Assert.assertTrue(haurlSelector.checkUrl("http://www.xxx.com:8088"));
@@ -53,7 +53,7 @@ public class HAURLSelectorImplTest {
     @Test
     public void testCheckUrl1() throws Exception {
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         mockStatic(InputStreamUtils.class);
         when(InputStreamUtils.getInputStream("http://www.xxx.com:8088", null, Constants.CompressionType.GZIP)).thenThrow(new
Exception());
         Assert.assertFalse(haurlSelector.checkUrl("http://www.xxx.com:8088"));
@@ -62,17 +62,17 @@ public class HAURLSelectorImplTest {
     @Test
     public void testGetSelectedUrl() {
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         Assert.assertEquals(rmBasePaths[0], haurlSelector.getSelectedUrl());
     }
 
     @Test
     public void testReSelectUrl() throws Exception {
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         mockStatic(InputStreamUtils.class);
-        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
-        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenReturn(null);
+        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
+        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenReturn(null);
         haurlSelector.checkUrl();
         Assert.assertEquals(rmBasePaths[1], haurlSelector.getSelectedUrl());
     }
@@ -80,10 +80,10 @@ public class HAURLSelectorImplTest {
     @Test
     public void testReSelectUrl1() throws Exception {
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         mockStatic(InputStreamUtils.class);
-        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenReturn(null);
-        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
+        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenReturn(null);
+        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
         haurlSelector.checkUrl();
         Assert.assertEquals(rmBasePaths[0], haurlSelector.getSelectedUrl());
     }
@@ -93,10 +93,10 @@ public class HAURLSelectorImplTest {
     public void testReSelectUrl2() throws Exception {
         thrown.expect(IOException.class);
         String[] rmBasePaths = new String[]{"http://www.xxx.com:8088", "http://www.yyy.com:8088"};
-        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, new JobListServiceURLBuilderImpl(),
Constants.CompressionType.GZIP, Constants.JobState.RUNNING);
+        HAURLSelectorImpl haurlSelector = new HAURLSelectorImpl(rmBasePaths, Constants.CompressionType.GZIP);
         mockStatic(InputStreamUtils.class);
-        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
-        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
+        when(InputStreamUtils.getInputStream("http://www.xxx.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
+        when(InputStreamUtils.getInputStream("http://www.yyy.com:8088/ws/v1/cluster?anonymous=true",
null, Constants.CompressionType.GZIP)).thenThrow(new Exception());
         haurlSelector.checkUrl();
     }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/ec52457c/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImplTest.java
b/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImplTest.java
index 81d9309..846dc87 100644
--- a/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImplTest.java
+++ b/eagle-jpm/eagle-jpm-util/src/test/java/org/apache/eagle/jpm/util/resourcefetch/url/JobListServiceURLBuilderImplTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.eagle.jpm.util.resourcefetch.url;
 
-import org.apache.eagle.jpm.util.Constants;
 import org.apache.eagle.jpm.util.Constants.JobState;
 import org.junit.Assert;
 import org.junit.Test;
@@ -26,25 +25,14 @@ public class JobListServiceURLBuilderImplTest {
     @Test
     public void testBuild() {
         JobListServiceURLBuilderImpl jobListServiceURLBuilderImpl = new JobListServiceURLBuilderImpl();
-        String finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/",
convertRestApi(JobState.RUNNING));
+        String finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/",
JobState.RUNNING.toString());
         Assert.assertEquals("http://www.xxx.com:8088/ws/v1/cluster/apps?state=RUNNING&anonymous=true",
finalUrl);
-        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", convertRestApi(JobState.FINISHED));
+        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", JobState.FINISHED.toString());
         Assert.assertEquals("http://www.xxx.com:8088/ws/v1/cluster/apps?state=FINISHED&anonymous=true",
finalUrl);
-        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", convertRestApi(JobState.ALL));
+        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", JobState.ALL.toString());
+        Assert.assertEquals("http://www.xxx.com:8088/ws/v1/cluster/apps&anonymous=true",
finalUrl);
+        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", null);
         Assert.assertEquals("http://www.xxx.com:8088/ws/v1/cluster/apps&anonymous=true",
finalUrl);
-        finalUrl = jobListServiceURLBuilderImpl.build("http://www.xxx.com:8088/", convertRestApi(null));
-        Assert.assertEquals(null, finalUrl);
     }
 
-    private String convertRestApi(Constants.JobState jobState) {
-        if (jobState == null) {
-            return null;
-        }
-        switch (jobState) {
-            case RUNNING : return Constants.V2_APPS_RUNNING_URL;
-            case FINISHED : return Constants.V2_APPS_COMPLETED_URL;
-            case ALL : return Constants.V2_APPS_URL;
-            default : return null;
-        }
-    }
 }


Mime
View raw message