From f75f9e8d72841dc5c0c49b4e855cdb42fe669025 Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Mon, 2 May 2016 18:22:40 -0300 Subject: [PATCH 1/6] added eureka retrival code --- hystrix-dashboard/build.gradle | 6 ++- .../dashboard/eureka/EurekaService.java | 11 ++++ .../dashboard/eureka/EurekaServiceInfo.java | 44 +++++++++++++++ .../dashboard/eureka/pojos/Application.java | 28 ++++++++++ .../dashboard/eureka/pojos/Applications.java | 54 +++++++++++++++++++ .../eureka/EurekaServiceInfoTest.java | 24 +++++++++ 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java create mode 100644 hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java diff --git a/hystrix-dashboard/build.gradle b/hystrix-dashboard/build.gradle index fbd5292eb..b44ee7c17 100644 --- a/hystrix-dashboard/build.gradle +++ b/hystrix-dashboard/build.gradle @@ -6,8 +6,12 @@ dependencies { compile 'org.apache.httpcomponents:httpclient:4.2.1' compile 'log4j:log4j:1.2.17' compile 'org.slf4j:slf4j-log4j12:1.7.0' + compile 'com.squareup.retrofit:retrofit:2.0.2' + compile 'com.squareup.retrofit2:converter-simplexml:2.0.2' + compile 'com.squareup.retrofit2:converter-jackson:2.0.2' + testCompile 'junit:junit:4.12' } jettyRun { - httpPort = 7979 + httpPort = 7979 } diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java new file mode 100644 index 000000000..72ba44908 --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java @@ -0,0 +1,11 @@ +package com.netflix.hystrix.dashboard.eureka; + +import com.netflix.hystrix.dashboard.eureka.pojos.Applications; + +import retrofit2.Call; +import retrofit2.http.GET; + +public interface EurekaService { + @GET("v2/apps/") + Call listApps(); +} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java new file mode 100644 index 000000000..72dd2ed5f --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java @@ -0,0 +1,44 @@ +package com.netflix.hystrix.dashboard.eureka; + +import java.util.ArrayList; +import java.util.List; + +import com.netflix.hystrix.dashboard.eureka.pojos.Application; +import com.netflix.hystrix.dashboard.eureka.pojos.Applications; + +import retrofit2.Call; +import retrofit2.Retrofit; +import retrofit2.converter.simplexml.SimpleXmlConverterFactory; + +public class EurekaServiceInfo { + + public Applications retrieveApps() { + try{ + Retrofit retrofit = new Retrofit. + Builder(). + baseUrl("http://127.0.0.1:8080/eureka/"). + addConverterFactory(SimpleXmlConverterFactory.create()). + build(); + + EurekaService service = retrofit.create(EurekaService.class); + Call apps = service.listApps(); + return apps.execute().body(); + + }catch(Exception e){ + throw new RuntimeException(e); + } + } + + public List retrieveAllAplications(){ + + List applications = new ArrayList(); + Applications apps = retrieveApps(); + if (apps==null) return applications; + + for(Application a: apps.getApplication()){ + applications.add(a.getName()); + } + return applications; + } + +} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java new file mode 100644 index 000000000..d3faf7ee3 --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java @@ -0,0 +1,28 @@ +package com.netflix.hystrix.dashboard.eureka.pojos; + +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Root; + +@Root(strict = false) +public class Application { + + @Element(required=false) + private String name; + + public Application() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Application [name=" + name + "]"; + } + +} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java new file mode 100644 index 000000000..d32149889 --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java @@ -0,0 +1,54 @@ +package com.netflix.hystrix.dashboard.eureka.pojos; + +import java.util.ArrayList; + +import org.simpleframework.xml.Element; +import org.simpleframework.xml.ElementList; +import org.simpleframework.xml.Root; + +@Root(strict = false) +public class Applications { + + @Element + private String versions__delta; + + @Element + private String apps__hashcode; + + @ElementList(inline=true) + private ArrayList application; + + public Applications() { + } + + public String getVersions__delta() { + return versions__delta; + } + + public void setVersions__delta(String versions__delta) { + this.versions__delta = versions__delta; + } + + public String getApps__hashcode() { + return apps__hashcode; + } + + public void setApps__hashcode(String apps__hashcode) { + this.apps__hashcode = apps__hashcode; + } + + public ArrayList getApplication() { + return application; + } + + public void setApplication(ArrayList application) { + this.application = application; + } + + @Override + public String toString() { + return "Applications [versions__delta=" + versions__delta + ", apps__hashcode=" + apps__hashcode + + ", application=" + application + "]"; + } + +} diff --git a/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java b/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java new file mode 100644 index 000000000..4c4eb16d5 --- /dev/null +++ b/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java @@ -0,0 +1,24 @@ +package com.netflix.hytrix.dashboard.eureka; + +import org.junit.Assert; +import org.junit.Test; + +import com.netflix.hystrix.dashboard.eureka.EurekaServiceInfo; + +public class EurekaServiceInfoTest { + + @Test + public void testRetrieveAppNames() { + EurekaServiceInfo esi = new EurekaServiceInfo(); + Assert.assertNotNull(esi); + } + + @Test + public void TestRetrieveAllAplications() { + EurekaServiceInfo esi = new EurekaServiceInfo(); + Object r = esi.retrieveAllAplications(); + Assert.assertNotNull(r); + System.out.println(r); + } + +} From bfe4ecb2dba210e265bf6395d0c25a5ba70cf9ff Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Mon, 2 May 2016 20:01:21 -0300 Subject: [PATCH 2/6] add right lib and added jquery --- hystrix-dashboard/build.gradle | 2 +- hystrix-dashboard/src/main/webapp/index.html | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hystrix-dashboard/build.gradle b/hystrix-dashboard/build.gradle index b44ee7c17..a4e45b0cd 100644 --- a/hystrix-dashboard/build.gradle +++ b/hystrix-dashboard/build.gradle @@ -6,7 +6,7 @@ dependencies { compile 'org.apache.httpcomponents:httpclient:4.2.1' compile 'log4j:log4j:1.2.17' compile 'org.slf4j:slf4j-log4j12:1.7.0' - compile 'com.squareup.retrofit:retrofit:2.0.2' + compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.squareup.retrofit2:converter-simplexml:2.0.2' compile 'com.squareup.retrofit2:converter-jackson:2.0.2' testCompile 'junit:junit:4.12' diff --git a/hystrix-dashboard/src/main/webapp/index.html b/hystrix-dashboard/src/main/webapp/index.html index 1a4ea9ea3..38e7698d9 100644 --- a/hystrix-dashboard/src/main/webapp/index.html +++ b/hystrix-dashboard/src/main/webapp/index.html @@ -46,6 +46,22 @@ } }); }); + + $.get( "http://127.0.0.1:8080/eureka/v2/apps", function( data ) { + $.each(data, function(i, item){ + $('#eurekaApp').append($("") + .attr("value",item.name) + .text(item.name)); + + $('#repos').bind('change',function(item){ + var $this = $(this), + $value = $this.val(); + $('#eurekaApp').text($value) + }); + + }); + }); + @@ -57,6 +73,7 @@

Hystrix Dashboard

+

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream From 225844455730d55591d13c50d59d025e65c5912f Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Tue, 3 May 2016 16:37:07 -0300 Subject: [PATCH 3/6] hack to list eureka apps --- hystrix-dashboard/src/main/webapp/index.html | 37 ++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/hystrix-dashboard/src/main/webapp/index.html b/hystrix-dashboard/src/main/webapp/index.html index 38e7698d9..ac893ce86 100644 --- a/hystrix-dashboard/src/main/webapp/index.html +++ b/hystrix-dashboard/src/main/webapp/index.html @@ -46,21 +46,30 @@ } }); }); - - $.get( "http://127.0.0.1:8080/eureka/v2/apps", function( data ) { - $.each(data, function(i, item){ - $('#eurekaApp').append($("") - .attr("value",item.name) - .text(item.name)); - $('#repos').bind('change',function(item){ - var $this = $(this), - $value = $this.val(); - $('#eurekaApp').text($value) - }); + $.get("http://127.0.0.1:8080/eureka/v2/apps/", function( data ) { - }); - }); + app = $(data.children).find("application").each(function(index,item){ + appName = $(item).find("name")[0].innerHTML + + ip = null; + $($(item).find("instance")).each(function(i,d){ + ip = $(d).find("ipAddr")[0].innerHTML; + }); + + $('#eurekaApp').append($("") + .attr("value",ip) + .text(appName)); + + $('#eurekaApp').bind('change',function(item){ + var $this = $(this), + $value = $this.val(); + $('#stream').val("http://" + $value + ":7001/turbine.stream?cluster=default"); + }); + + }); + + }); @@ -73,7 +82,7 @@

Hystrix Dashboard

- + Eureka Application:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream From f5b201975b50b4ee1e2f498368e6bf2f094f4b4e Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Wed, 4 May 2016 10:28:57 -0300 Subject: [PATCH 4/6] added jquery that retrieves data from eureka --- hystrix-dashboard/src/main/webapp/index.html | 61 +++++++++++++------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/hystrix-dashboard/src/main/webapp/index.html b/hystrix-dashboard/src/main/webapp/index.html index ac893ce86..aeb67837d 100644 --- a/hystrix-dashboard/src/main/webapp/index.html +++ b/hystrix-dashboard/src/main/webapp/index.html @@ -46,31 +46,41 @@ } }); }); + + console.log(2); - $.get("http://127.0.0.1:8080/eureka/v2/apps/", function( data ) { + $(document).ready(function(){ - app = $(data.children).find("application").each(function(index,item){ - appName = $(item).find("name")[0].innerHTML - - ip = null; - $($(item).find("instance")).each(function(i,d){ - ip = $(d).find("ipAddr")[0].innerHTML; - }); + $('#eurekaURL').on('input',function(e){ - $('#eurekaApp').append($("") - .attr("value",ip) - .text(appName)); + $.get($('#eurekaURL').val(), function( data ) { - $('#eurekaApp').bind('change',function(item){ - var $this = $(this), - $value = $this.val(); - $('#stream').val("http://" + $value + ":7001/turbine.stream?cluster=default"); - }); + $(data.children).find("application").each(function(index,item){ + appName = $(item).find("name")[0].innerHTML + + ip = null; + $($(item).find("instance")).each(function(i,d){ + ip = $(d).find("ipAddr")[0].innerHTML; + }); - }); + $('#eurekaApp').append($("") + .attr("value",ip) + .text(appName)); + + $('#eurekaApp').on('change click',function(item){ + var $this = $(this), + $value = $this.val(); + streamType = $('input[name=streamType]:checked').val() + $('#stream').val("http://" + $value + ":8080/" + streamType + "?cluster=default"); + }); + + }); + }); + + }); + + }); - }); - @@ -82,7 +92,18 @@

Hystrix Dashboard

- Eureka Application: + + Eureka URL:
+ + Eureka Application: + + + Stream Type: + Hystrix + Turbine

+

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream From 0d9d1b6c96fe12ed95ddb15877438ac51ee3e7ec Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Wed, 4 May 2016 11:40:12 -0300 Subject: [PATCH 5/6] Hack Hystrix Dashbaord to have a select which loads eureka apps so you dont need to type it --- hystrix-dashboard/build.gradle | 4 +- .../dashboard/eureka/EurekaService.java | 11 ---- .../dashboard/eureka/EurekaServiceInfo.java | 44 --------------- .../dashboard/eureka/pojos/Application.java | 28 ---------- .../dashboard/eureka/pojos/Applications.java | 54 ------------------- .../dashboard/stream/EurekaInfoServlet.java | 37 +++++++++++++ .../hystrix/dashboard/stream/UrlUtils.java | 32 +++++++++++ .../dashboard/stream/UrlUtilsTest.java | 23 ++++++++ .../eureka/EurekaServiceInfoTest.java | 24 --------- .../src/main/webapp/WEB-INF/web.xml | 11 ++++ hystrix-dashboard/src/main/webapp/index.html | 6 +-- 11 files changed, 106 insertions(+), 168 deletions(-) delete mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java delete mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java delete mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java delete mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java create mode 100644 hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java create mode 100644 hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java delete mode 100644 hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java diff --git a/hystrix-dashboard/build.gradle b/hystrix-dashboard/build.gradle index a4e45b0cd..7ed03753e 100644 --- a/hystrix-dashboard/build.gradle +++ b/hystrix-dashboard/build.gradle @@ -6,9 +6,7 @@ dependencies { compile 'org.apache.httpcomponents:httpclient:4.2.1' compile 'log4j:log4j:1.2.17' compile 'org.slf4j:slf4j-log4j12:1.7.0' - compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' - compile 'com.squareup.retrofit2:converter-simplexml:2.0.2' - compile 'com.squareup.retrofit2:converter-jackson:2.0.2' + compile 'commons-io:commons-io:2.5' testCompile 'junit:junit:4.12' } diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java deleted file mode 100644 index 72ba44908..000000000 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.netflix.hystrix.dashboard.eureka; - -import com.netflix.hystrix.dashboard.eureka.pojos.Applications; - -import retrofit2.Call; -import retrofit2.http.GET; - -public interface EurekaService { - @GET("v2/apps/") - Call listApps(); -} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java deleted file mode 100644 index 72dd2ed5f..000000000 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/EurekaServiceInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.netflix.hystrix.dashboard.eureka; - -import java.util.ArrayList; -import java.util.List; - -import com.netflix.hystrix.dashboard.eureka.pojos.Application; -import com.netflix.hystrix.dashboard.eureka.pojos.Applications; - -import retrofit2.Call; -import retrofit2.Retrofit; -import retrofit2.converter.simplexml.SimpleXmlConverterFactory; - -public class EurekaServiceInfo { - - public Applications retrieveApps() { - try{ - Retrofit retrofit = new Retrofit. - Builder(). - baseUrl("http://127.0.0.1:8080/eureka/"). - addConverterFactory(SimpleXmlConverterFactory.create()). - build(); - - EurekaService service = retrofit.create(EurekaService.class); - Call apps = service.listApps(); - return apps.execute().body(); - - }catch(Exception e){ - throw new RuntimeException(e); - } - } - - public List retrieveAllAplications(){ - - List applications = new ArrayList(); - Applications apps = retrieveApps(); - if (apps==null) return applications; - - for(Application a: apps.getApplication()){ - applications.add(a.getName()); - } - return applications; - } - -} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java deleted file mode 100644 index d3faf7ee3..000000000 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Application.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.netflix.hystrix.dashboard.eureka.pojos; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -@Root(strict = false) -public class Application { - - @Element(required=false) - private String name; - - public Application() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String toString() { - return "Application [name=" + name + "]"; - } - -} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java deleted file mode 100644 index d32149889..000000000 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/eureka/pojos/Applications.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.netflix.hystrix.dashboard.eureka.pojos; - -import java.util.ArrayList; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -@Root(strict = false) -public class Applications { - - @Element - private String versions__delta; - - @Element - private String apps__hashcode; - - @ElementList(inline=true) - private ArrayList application; - - public Applications() { - } - - public String getVersions__delta() { - return versions__delta; - } - - public void setVersions__delta(String versions__delta) { - this.versions__delta = versions__delta; - } - - public String getApps__hashcode() { - return apps__hashcode; - } - - public void setApps__hashcode(String apps__hashcode) { - this.apps__hashcode = apps__hashcode; - } - - public ArrayList getApplication() { - return application; - } - - public void setApplication(ArrayList application) { - this.application = application; - } - - @Override - public String toString() { - return "Applications [versions__delta=" + versions__delta + ", apps__hashcode=" + apps__hashcode - + ", application=" + application + "]"; - } - -} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java new file mode 100644 index 000000000..58ab49f26 --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java @@ -0,0 +1,37 @@ +package com.netflix.hystrix.dashboard.stream; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.IOUtils; + +/** + * Servlet that calls eureka REST api in order to get instances information.
+ * You need provide a url parameter. i.e: eureka?url=http://127.0.0.1:8080/eureka/v2/apps + * + * @author diegopacheco + * + */ +public class EurekaInfoServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String uri = request.getParameter("url"); + if (uri==null || "".equals(uri)) response.getOutputStream().write("Error. You need supply a valid eureka URL ".getBytes()); + + try{ + response.setContentType("application/xml"); + response.setHeader("Content-Encoding", "gzip"); + IOUtils.copy( UrlUtils.readXmlInputStream(uri) ,response.getOutputStream()); + }catch(Exception e){ + response.getOutputStream().write(("Error. You need supply a valid eureka URL. Ex: " + e + "").getBytes()); + } + + } +} diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java new file mode 100644 index 000000000..a6afa5c0e --- /dev/null +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java @@ -0,0 +1,32 @@ +package com.netflix.hystrix.dashboard.stream; + +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * Utility class to work with InputStreams + * + * @author diegopacheco + * + */ +public class UrlUtils { + + public static InputStream readXmlInputStream(String uri){ + + if (uri==null || "".equals(uri)) throw new IllegalArgumentException("Invalid uri. URI cannot be null or blank. "); + + try{ + URL url = new URL(uri); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.setRequestProperty("Accept", "application/xml"); + + return connection.getInputStream(); + + }catch(Exception e){ + throw new RuntimeException(e); + } + } + +} diff --git a/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java b/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java new file mode 100644 index 000000000..559ab9364 --- /dev/null +++ b/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java @@ -0,0 +1,23 @@ +package com.netflix.hystrix.dashboard.stream; + +import org.junit.Test; + +/** + * UrlUtilsTest unit tests + * + * @author diegopacheco + * + */ +public class UrlUtilsTest { + + @Test(expected=IllegalArgumentException.class) + public void testReadXmlInputStreamWithNull() { + UrlUtils.readXmlInputStream(null); + } + + @Test(expected=IllegalArgumentException.class) + public void testReadXmlInputStreamWithBlank() { + UrlUtils.readXmlInputStream(""); + } + +} diff --git a/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java b/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java deleted file mode 100644 index 4c4eb16d5..000000000 --- a/hystrix-dashboard/src/main/test/com/netflix/hytrix/dashboard/eureka/EurekaServiceInfoTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.netflix.hytrix.dashboard.eureka; - -import org.junit.Assert; -import org.junit.Test; - -import com.netflix.hystrix.dashboard.eureka.EurekaServiceInfo; - -public class EurekaServiceInfoTest { - - @Test - public void testRetrieveAppNames() { - EurekaServiceInfo esi = new EurekaServiceInfo(); - Assert.assertNotNull(esi); - } - - @Test - public void TestRetrieveAllAplications() { - EurekaServiceInfo esi = new EurekaServiceInfo(); - Object r = esi.retrieveAllAplications(); - Assert.assertNotNull(r); - System.out.println(r); - } - -} diff --git a/hystrix-dashboard/src/main/webapp/WEB-INF/web.xml b/hystrix-dashboard/src/main/webapp/WEB-INF/web.xml index c10100f65..7550f341e 100644 --- a/hystrix-dashboard/src/main/webapp/WEB-INF/web.xml +++ b/hystrix-dashboard/src/main/webapp/WEB-INF/web.xml @@ -26,5 +26,16 @@ ProxyStreamServlet /proxy.stream + + + + EurekaInfoServlet + EurekaInfoServlet + com.netflix.hystrix.dashboard.stream.EurekaInfoServlet + + + EurekaInfoServlet + /eureka + diff --git a/hystrix-dashboard/src/main/webapp/index.html b/hystrix-dashboard/src/main/webapp/index.html index aeb67837d..f7288893d 100644 --- a/hystrix-dashboard/src/main/webapp/index.html +++ b/hystrix-dashboard/src/main/webapp/index.html @@ -46,14 +46,12 @@ } }); }); - - console.log(2); $(document).ready(function(){ $('#eurekaURL').on('input',function(e){ - - $.get($('#eurekaURL').val(), function( data ) { + url = window.location.pathname + "eureka?url=" + $('#eurekaURL').val() + $.get(url,function( data ) { $(data.children).find("application").each(function(index,item){ appName = $(item).find("name")[0].innerHTML From fe82af9866e9fa3a8b7305ec5f19fb5229d754fb Mon Sep 17 00:00:00 2001 From: Diego Pacheco Date: Wed, 4 May 2016 11:46:35 -0300 Subject: [PATCH 6/6] added license --- .../dashboard/stream/EurekaInfoServlet.java | 16 ++++++++++++++++ .../hystrix/dashboard/stream/UrlUtils.java | 15 +++++++++++++++ .../hystrix/dashboard/stream/UrlUtilsTest.java | 15 +++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java index 58ab49f26..f43a12faf 100644 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/EurekaInfoServlet.java @@ -9,6 +9,22 @@ import org.apache.commons.io.IOUtils; +/** + * Copyright 2013 Netflix, Inc. + * + * 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. + */ + /** * Servlet that calls eureka REST api in order to get instances information.
* You need provide a url parameter. i.e: eureka?url=http://127.0.0.1:8080/eureka/v2/apps diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java index a6afa5c0e..2b8eb402d 100644 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/UrlUtils.java @@ -4,6 +4,21 @@ import java.net.HttpURLConnection; import java.net.URL; +/** + * Copyright 2013 Netflix, Inc. + * + * 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. + */ /** * Utility class to work with InputStreams * diff --git a/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java b/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java index 559ab9364..900a24780 100644 --- a/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java +++ b/hystrix-dashboard/src/main/test/com/netflix/hystrix/dashboard/stream/UrlUtilsTest.java @@ -2,6 +2,21 @@ import org.junit.Test; +/** + * Copyright 2013 Netflix, Inc. + * + * 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. + */ /** * UrlUtilsTest unit tests *