use of org.apache.servicecomb.foundation.common.net.IpPort in project incubator-servicecomb-java-chassis by apache.
the class IpPortManager method getNextAvailableAddress.
public IpPort getNextAvailableAddress(IpPort failedIpPort) {
int currentIndex = currentAvailableIndex.get();
IpPort current = getAvailableAddress(currentIndex);
if (current.equals(failedIpPort)) {
currentAvailableIndex.compareAndSet(currentIndex, currentIndex + 1);
current = getAvailableAddress();
}
LOGGER.info("Change service center address from {} to {}", failedIpPort.toString(), current.toString());
return current;
}
use of org.apache.servicecomb.foundation.common.net.IpPort in project incubator-servicecomb-java-chassis by apache.
the class ServiceRegistryConfig method getIpPort.
public ArrayList<IpPort> getIpPort() {
DynamicStringProperty property = DynamicPropertyFactory.getInstance().getStringProperty("cse.service.registry.address", "https://127.0.0.1:30100");
List<String> uriList = Arrays.asList(property.get().split(","));
ArrayList<IpPort> ipPortList = new ArrayList<>();
uriList.forEach(anUriList -> {
try {
URI uri = new URI(anUriList);
StringBuilder sb = new StringBuilder(uri.getHost());
sb.append(':').append(uri.getPort() < 0 ? PROTOCOL_HTTP_PORT : uri.getPort());
this.ssl = uri.getScheme().startsWith("https");
ipPortList.add(NetUtils.parseIpPort(sb.toString()));
} catch (Exception e) {
LOGGER.error("cse.service.registry.address invalid : {}", anUriList, e);
}
});
return ipPortList;
}
use of org.apache.servicecomb.foundation.common.net.IpPort in project incubator-servicecomb-java-chassis by apache.
the class MockForRestServerVerticle method mockRestServerVerticle.
public void mockRestServerVerticle() {
final HttpServer server = Mockito.mock(HttpServer.class);
new MockUp<RestServerVerticle>() {
@Mock
private void startListen(HttpServer server, IpPort ipPort, Future<Void> startFuture) {
}
@Mock
private HttpServer createHttpServer(boolean isHttp_2) {
return server;
}
};
}
use of org.apache.servicecomb.foundation.common.net.IpPort in project incubator-servicecomb-java-chassis by apache.
the class RestUtilsTest method defaultHeadersContainServiceRegistryAndAuthentication.
@Test
public void defaultHeadersContainServiceRegistryAndAuthentication() throws Exception {
MultiMap headers = RestUtils.getDefaultHeaders();
headers.addAll(RestUtils.getSignAuthHeaders(RestUtils.createSignRequest(HttpMethod.GET.toString(), new IpPort("127.0.0.1", 443), new RequestParam().addQueryParam("testParam", "test"), "test", new HashMap<>())));
assertThat(headers.get("Content-Type"), is("application/json"));
assertThat(headers.get("User-Agent"), is("cse-serviceregistry-client/1.0.0"));
assertThat(headers.get("x-domain-name"), is("default"));
assertThat(headers.get("X-Service-AK"), is("blah..."));
}
use of org.apache.servicecomb.foundation.common.net.IpPort in project incubator-servicecomb-java-chassis by apache.
the class TestClientHttp method testRequestContext.
@Test
public void testRequestContext() {
RequestContext oContext = new RequestContext();
oContext.setUri("//test");
oContext.setMethod(io.vertx.core.http.HttpMethod.POST);
oContext.setIpPort(new IpPort("145.0.0.1", 8080));
oContext.setParams(null);
Assert.assertEquals("//test", oContext.getUri());
Assert.assertEquals(io.vertx.core.http.HttpMethod.POST, oContext.getMethod());
Assert.assertEquals(8080, oContext.getIpPort().getPort());
Assert.assertEquals(null, oContext.getParams());
RestResponse oResponse = new RestResponse(null, null);
oResponse.setRequestContext(oContext);
Assert.assertEquals(oContext, oResponse.getRequestContext());
Assert.assertEquals(null, oResponse.getResponse());
}
Aggregations