mesosphere.marathon.client.model.v2.GetAppsResponse Java Examples
The following examples show how to use
mesosphere.marathon.client.model.v2.GetAppsResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarathonDiscoveryClient.java From spring-cloud-marathon with MIT License | 6 votes |
private List<ServiceInstance> getInstances(Map<String, String> queryMap) throws MarathonException { List<ServiceInstance> instances = new ArrayList<>(); GetAppsResponse appsResponse = queryMap == null ? client.getApps() : client.getApps(queryMap); if (appsResponse != null && appsResponse.getApps() != null) { List<VersionedApp> apps = appsResponse.getApps(); log.debug("Discovered {} service{}{}", apps.size(), apps.size() == 1 ? "" : "s", queryMap == null ? "" : String.format(" with ids that contain [%s]", queryMap.get("id"))); for (App app : apps) { // Fetch data for this specific service id, to collect task information GetAppResponse response = client.getApp(app.getId()); if (response != null && response.getApp() != null) { instances.addAll(extractServiceInstances(response.getApp())); } } } return instances; }
Example #2
Source File: MarathonEndpointTests.java From spring-cloud-marathon with MIT License | 5 votes |
@Bean public Marathon marathonClient(MarathonProperties properties) throws MarathonException { Marathon client = mock(Marathon.class); when(client.getServerInfo()).thenReturn(new GetServerInfoResponse()); GetAppsResponse appsResponse = new GetAppsResponse(); VersionedApp app = new VersionedApp(); app.setId("test-app"); appsResponse.setApps(Collections.singletonList(app)); when(client.getApps()).thenReturn(appsResponse); return client; }
Example #3
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("GET /v2/apps") @Headers(HeaderUtils.MARATHON_API_SOURCE_HEADER) GetAppsResponse getApps() throws MarathonException;
Example #4
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("GET /v2/apps") @Headers(HeaderUtils.MARATHON_API_SOURCE_HEADER) GetAppsResponse getApps(@QueryMap Map<String, String> queryMap) throws MarathonException;
Example #5
Source File: MarathonServerListByLabelTests.java From spring-cloud-marathon with MIT License | 4 votes |
@Before public void setup() throws MarathonException { serverList = new MarathonServerList( marathonClient, new MarathonDiscoveryProperties() ); IClientConfig config = mock(IClientConfig.class); when(config.getClientName()).thenReturn("service1"); LinkedHashMap<String, Object> properties = new LinkedHashMap<>(); properties.put("IgnoreServiceId",true); properties.put("MetaDataFilter.A","A"); properties.put("MetaDataFilter.B","in(V1,V2,V3)"); properties.put("MetaDataFilter.C","!=X"); properties.put("MetaDataFilter.D","==Y"); properties.put("MetaDataFilter.E","notin(1,2,3)"); when(config.getProperties()).thenReturn(properties); serverList.initWithNiwsConfig(config); GetAppResponse appResponse = new GetAppResponse(); when(marathonClient.getApp("/service1")) .thenReturn(appResponse); GetAppsResponse appsResponse = new GetAppsResponse(); Map<String,String> queryMap = new HashMap<>(); queryMap.put("label","A==A,B in(V1,V2,V3),C!=X,D==Y,E notin(1,2,3)"); when(marathonClient.getApps(queryMap)) .thenReturn(appsResponse); VersionedApp app = new VersionedApp(); appResponse.setApp(app); app.setId("/service1"); app.setTasks(IntStream.of(1,2) .mapToObj(index -> { Task task = new Task(); task.setHost("host" + index); task.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); task.setHealthCheckResults(Collections.emptyList()); return task; }).collect(Collectors.toList()) ); Task withNullHealthChecks = new Task(); withNullHealthChecks.setHost("host3"); withNullHealthChecks.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); app.getTasks().add(withNullHealthChecks); List<VersionedApp> apps = new ArrayList<>(); apps.add(app); appsResponse.setApps(apps); }
Example #6
Source File: MarathonServerListFetchZoneTests.java From spring-cloud-marathon with MIT License | 4 votes |
@Before public void setup() throws MarathonException { serverList = new MarathonServerList( marathonClient, new MarathonDiscoveryProperties() ); IClientConfig config = mock(IClientConfig.class); when(config.getClientName()).thenReturn("service1"); Map<String, Object> properties = new HashMap<>(); properties.put("ZonePattern",".+\\.(.+)"); when(config.getProperties()).thenReturn(properties); serverList.initWithNiwsConfig(config); GetAppResponse appResponse = new GetAppResponse(); when(marathonClient.getApp("/service1")) .thenReturn(appResponse); GetAppsResponse appsResponse = new GetAppsResponse(); when(marathonClient.getApps()) .thenReturn(appsResponse); VersionedApp app = new VersionedApp(); appResponse.setApp(app); app.setId("/service1"); app.setTasks(IntStream.of(1,2) .mapToObj(index -> { Task task = new Task(); task.setHost("host" + index + ".dc1"); task.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); task.setHealthCheckResults(Collections.emptyList()); return task; }).collect(Collectors.toList()) ); Task withNullHealthChecks = new Task(); withNullHealthChecks.setHost("host1.dc2"); withNullHealthChecks.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); app.getTasks().add(withNullHealthChecks); List<VersionedApp> apps = new ArrayList<>(); apps.add(app); appsResponse.setApps(apps); }
Example #7
Source File: MarathonServerListIgnoreServiceIdTests.java From spring-cloud-marathon with MIT License | 4 votes |
@Before public void setup() throws MarathonException { serverList = new MarathonServerList( marathonClient, new MarathonDiscoveryProperties() ); IClientConfig config = mock(IClientConfig.class); when(config.getClientName()).thenReturn("service1"); Map<String, Object> properties = new HashMap<>(); properties.put("IgnoreServiceId",true); when(config.getProperties()).thenReturn(properties); serverList.initWithNiwsConfig(config); GetAppResponse appResponse = new GetAppResponse(); when(marathonClient.getApp("/service1")) .thenReturn(appResponse); GetAppsResponse appsResponse = new GetAppsResponse(); Map<String,String> queryMap = new HashMap<>(); when(marathonClient.getApps(queryMap)) .thenReturn(appsResponse); VersionedApp app = new VersionedApp(); appResponse.setApp(app); app.setId("/service1"); app.setTasks(IntStream.of(1,2) .mapToObj(index -> { Task task = new Task(); task.setHost("host" + index); task.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); task.setHealthCheckResults(Collections.emptyList()); return task; }).collect(Collectors.toList()) ); Task withNullHealthChecks = new Task(); withNullHealthChecks.setHost("host3"); withNullHealthChecks.setPorts(IntStream.of(9090, 9091) .boxed() .collect(Collectors.toList())); app.getTasks().add(withNullHealthChecks); List<VersionedApp> apps = new ArrayList<>(); apps.add(app); appsResponse.setApps(apps); }
Example #8
Source File: MarathonDiscoveryClientTests.java From spring-cloud-marathon with MIT License | 4 votes |
@Test public void test_list_of_servers() throws MarathonException { GetAppsResponse appsResponse = new GetAppsResponse(); when(marathonClient.getApps()) .thenReturn(appsResponse); appsResponse.setApps(new ArrayList<>()); ReflectionAssert.assertReflectionEquals( "should be no one element", Collections.emptyList(), discoveryClient.getServices(), ReflectionComparatorMode.LENIENT_ORDER ); //add first application VersionedApp app1 = new VersionedApp(); app1.setId("app1"); appsResponse.getApps().add(app1); ReflectionAssert.assertReflectionEquals( "should be only one element", Collections.singletonList("app1"), discoveryClient.getServices(), ReflectionComparatorMode.LENIENT_ORDER ); //add another application VersionedApp app2 = new VersionedApp(); app2.setId("app2"); appsResponse.getApps().add(app2); ReflectionAssert.assertReflectionEquals( "should be two elements", IntStream.of(1,2) .mapToObj(index -> "app" + index) .collect(Collectors.toList()), discoveryClient.getServices(), ReflectionComparatorMode.LENIENT_ORDER ); }
Example #9
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("GET /v2/apps") GetAppsResponse getApps();