本文整理汇总了Java中io.vertx.core.net.SocketAddress类的典型用法代码示例。如果您正苦于以下问题:Java SocketAddress类的具体用法?Java SocketAddress怎么用?Java SocketAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketAddress类属于io.vertx.core.net包,在下文中一共展示了SocketAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFormattedElement
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public String getFormattedElement(AccessLogParam accessLogParam) {
HttpServerRequest request = accessLogParam.getRoutingContext().request();
if (null == request) {
return EMPTY_RESULT;
}
SocketAddress remoteAddress = request.remoteAddress();
if (null == remoteAddress) {
return EMPTY_RESULT;
}
String remoteHost = remoteAddress.host();
if (StringUtils.isEmpty(remoteHost)) {
return EMPTY_RESULT;
}
return remoteHost;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:RemoteHostElement.java
示例2: getFormattedElement
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public String getFormattedElement(AccessLogParam accessLogParam) {
HttpServerRequest request = accessLogParam.getRoutingContext().request();
if (null == request) {
return EMPTY_RESULT;
}
SocketAddress localAddress = request.localAddress();
if (null == localAddress) {
return EMPTY_RESULT;
}
String localHost = localAddress.host();
if (StringUtils.isEmpty(localHost)) {
return EMPTY_RESULT;
}
return localHost;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:LocalHostElement.java
示例3: getFormattedElement
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElement() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.port()).thenReturn(8080);
String result = new LocalPortElement().getFormattedElement(param);
assertEquals("8080", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:LocalPortElementTest.java
示例4: getFormattedElement
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElement() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
String localHost = "testHost";
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).thenReturn(localHost);
String result = ELEMENT.getFormattedElement(param);
assertEquals(localHost, result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:LocalHostElementTest.java
示例5: getFormattedElementOnHostIsNull
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElementOnHostIsNull() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).thenReturn(null);
String result = ELEMENT.getFormattedElement(param);
assertEquals("-", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:LocalHostElementTest.java
示例6: getFormattedElementIsEmpty
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElementIsEmpty() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
String localHost = "";
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).thenReturn(localHost);
String result = ELEMENT.getFormattedElement(param);
assertEquals("-", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:LocalHostElementTest.java
示例7: getFormattedElement
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElement() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress address = Mockito.mock(SocketAddress.class);
String remoteHost = "remoteHost";
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.remoteAddress()).thenReturn(address);
Mockito.when(address.host()).thenReturn(remoteHost);
String result = ELEMENT.getFormattedElement(param);
assertEquals(remoteHost, result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:RemoteHostElementTest.java
示例8: getFormattedElementOnHostIsNull
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElementOnHostIsNull() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress address = Mockito.mock(SocketAddress.class);
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.remoteAddress()).thenReturn(address);
Mockito.when(address.host()).thenReturn(null);
String result = ELEMENT.getFormattedElement(param);
assertEquals("-", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:RemoteHostElementTest.java
示例9: getFormattedElementOnHostIsEmpty
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void getFormattedElementOnHostIsEmpty() {
AccessLogParam param = new AccessLogParam();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress address = Mockito.mock(SocketAddress.class);
String remoteHost = "";
param.setRoutingContext(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.remoteAddress()).thenReturn(address);
Mockito.when(address.host()).thenReturn(remoteHost);
String result = ELEMENT.getFormattedElement(param);
assertEquals("-", result);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:RemoteHostElementTest.java
示例10: requestBegin
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public Map<HttpClientMetrics, ?> requestBegin(Map<HttpClientMetrics, ?> endpointMetric,
Map<HttpClientMetrics, ?> socketMetric,
SocketAddress localAddress, SocketAddress remoteAddress,
HttpClientRequest request) {
return null;
}
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:8,代码来源:DispatchingHttpClientMetrics.java
示例11: fromJson
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public FdfsClientOptions fromJson(JsonObject json) {
super.fromJson(json);
JsonArray array = json.getJsonArray(TRACKERS);
if (array != null && array.size() > 0) {
array.forEach(object -> {
if (object instanceof JsonObject) {
JsonObject tracker = (JsonObject) object;
String host = tracker.getString(HOST, "");
int port = tracker.getInteger(PORT, -1);
if (!host.isEmpty() && port != -1) {
trackers.add(SocketAddress.inetSocketAddress(port, host));
}
}
});
}
return this;
}
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:25,代码来源:FdfsClientOptions.java
示例12: parseStorage
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
private Future<FdfsStorageOptions> parseStorage(Buffer bodyBuffer, String charset, boolean hasPathIndex) {
try {
FdfsStorageOptions storageOptions = new FdfsStorageOptions(options);
String group = FdfsUtils
.fdfsTrim(bodyBuffer.getString(0, FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN, options.getCharset()));
String ip = FdfsUtils.fdfsTrim(bodyBuffer.getString(FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN,
FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN + FdfsProtocol.FDFS_IPADDR_SIZE - 1, options.getCharset()));
long port = bodyBuffer.getLong(FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN + FdfsProtocol.FDFS_IPADDR_SIZE - 1);
storageOptions.setGroup(group).setAddress(SocketAddress.inetSocketAddress((int) port, ip));
if (hasPathIndex && bodyBuffer.length() > FdfsProtocol.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) {
byte storePathIndex = bodyBuffer.getByte(FdfsProtocol.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN);
storageOptions.setStorePathIndex(storePathIndex);
}
return Future.succeededFuture(storageOptions);
} catch (Exception e) {
return Future.failedFuture(e);
}
}
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:23,代码来源:FdfsTrackerImpl.java
示例13: requestBegin
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
/**
* Only requests that contain a tracking tag will be tracked
*/
@Override
@Nullable
public HttpRequestMetrics requestBegin(final Void endpointMetric,
final SocketAddress socketMetric,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final HttpClientRequest request) {
// extract request tag to identify the metric and confirm that we want to track it
String requestTag = request.headers().get(Tags.TRACK_HEADER.toString());
HttpRequestMetrics metric = null;
if (requestTag != null) {
// Remove tracking header to avoid it propagating to clients
request.headers().remove(Tags.TRACK_HEADER.toString());
// Create client request metric
metric = new HttpRequestMetrics(requestTag, remoteAddress, request.method());
metric.start();
}
return metric;
}
开发者ID:statful,项目名称:statful-client-vertx,代码行数:28,代码来源:HttpClientMetricsImpl.java
示例14: testUntaggedRequest
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void testUntaggedRequest() {
SocketAddress socketMetric = mock(SocketAddress.class);
SocketAddress localAddress = mock(SocketAddress.class);
SocketAddress remoteAddress = mock(SocketAddress.class);
HttpClientRequest request = mock(HttpClientRequest.class);
MultiMap headers = mock(MultiMap.class);
when(headers.get(eq(Tags.TRACK_HEADER.toString()))).thenReturn(null);
when(request.headers()).thenReturn(headers);
HttpRequestMetrics metrics = victim.requestBegin(null, socketMetric, localAddress, remoteAddress, request);
assertNull(metrics);
}
开发者ID:statful,项目名称:statful-client-vertx,代码行数:17,代码来源:HttpClientMetricsImplTest.java
示例15: testRequestBegin
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Test
public void testRequestBegin() {
SocketAddress socketMetric = mock(SocketAddress.class);
SocketAddress localAddress = mock(SocketAddress.class);
SocketAddress remoteAddress = mock(SocketAddress.class);
HttpClientRequest request = mock(HttpClientRequest.class);
MultiMap headers = mock(MultiMap.class);
when(headers.get(eq(Tags.TRACK_HEADER.toString()))).thenReturn("tag");
when(request.headers()).thenReturn(headers);
HttpRequestMetrics metrics = victim.requestBegin(null, socketMetric, localAddress, remoteAddress, request);
assertNotNull(metrics);
assertEquals(remoteAddress, metrics.getAddress());
}
开发者ID:statful,项目名称:statful-client-vertx,代码行数:18,代码来源:HttpClientMetricsImplTest.java
示例16: collect
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public List<DataPoint> collect() {
long timestamp = System.currentTimeMillis();
Map<SocketAddress, Long> connections = new HashMap<>();
Map<SocketAddress, Long> bytesReceived = new HashMap<>();
Map<SocketAddress, Long> bytesSent = new HashMap<>();
Map<SocketAddress, Long> errorCount = new HashMap<>();
for (NetServerMetricsImpl netServerMetrics : metricsSet) {
SocketAddress serverAddress = netServerMetrics.getServerAddress();
merge(connections, serverAddress, netServerMetrics.getConnections());
merge(bytesReceived, serverAddress, netServerMetrics.getBytesReceived());
merge(bytesSent, serverAddress, netServerMetrics.getBytesSent());
merge(errorCount, serverAddress, netServerMetrics.getErrorCount());
}
List<DataPoint> res = new ArrayList<>();
res.addAll(gauges("connections", timestamp, connections));
res.addAll(counters("bytesReceived", timestamp, bytesReceived));
res.addAll(counters("bytesSent", timestamp, bytesSent));
res.addAll(counters("errorCount", timestamp, errorCount));
return res;
}
开发者ID:vert-x3,项目名称:vertx-hawkular-metrics,代码行数:26,代码来源:NetServerMetricsSupplier.java
示例17: collect
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public List<DataPoint> collect() {
long timestamp = System.currentTimeMillis();
Map<SocketAddress, Snapshot> values = new HashMap<>();
for (NetClientMetricsImpl netClientMetrics : metricsSet) {
netClientMetrics.getMeasurementsSnapshot().forEach((address, snapshot) -> {
values.merge(address, snapshot, Snapshot::merge);
});
}
List<DataPoint> res = new ArrayList<>();
values.forEach((address, snapshot) -> {
String addressId = address.host() + ":" + address.port();
res.add(new GaugePoint(baseName + addressId + ".connections", timestamp, snapshot.getConnections()));
res.add(new CounterPoint(baseName + addressId + ".bytesReceived", timestamp, snapshot.getBytesReceived()));
res.add(new CounterPoint(baseName + addressId + ".bytesSent", timestamp, snapshot.getBytesSent()));
res.add(new CounterPoint(baseName + addressId + ".errorCount", timestamp, snapshot.getErrorCount()));
});
return res;
}
开发者ID:vert-x3,项目名称:vertx-hawkular-metrics,代码行数:24,代码来源:NetClientMetricsSupplier.java
示例18: HttpMetricsImpl
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
public HttpMetricsImpl(MetricRegistry registry, String baseName, SocketAddress localAddress) {
super(registry, baseName);
openWebSockets = counter("open-websockets");
requests = throughputTimer("requests");
responses = new ThroughputMeter[]{
throughputMeter("responses-1xx"),
throughputMeter("responses-2xx"),
throughputMeter("responses-3xx"),
throughputMeter("responses-4xx"),
throughputMeter("responses-5xx")
};
methodRequests = new EnumMap<>(HttpMethod.class);
for (HttpMethod method : HttpMethod.values()) {
methodRequests.put(method, throughputTimer(method.toString().toLowerCase() + "-requests"));
}
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:17,代码来源:HttpMetricsImpl.java
示例19: connected
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public Long connected(SocketAddress remoteAddress, String remoteName) {
// Connection metrics
openConnections.inc();
// On network outage the remoteAddress can be null.
// Do not report the open-connections when it's null
if (remoteAddress != null) {
// Remote address connection metrics
counter("open-connections", remoteAddress.host()).inc();
}
// A little clunky, but it's possible we got here after closed has been called
if (closed) {
removeAll();
}
return System.nanoTime();
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:21,代码来源:TCPMetricsImpl.java
示例20: disconnected
import io.vertx.core.net.SocketAddress; //导入依赖的package包/类
@Override
public void disconnected(Long ctx, SocketAddress remoteAddress) {
openConnections.dec();
connections.update(System.nanoTime() - ctx, TimeUnit.NANOSECONDS);
// On network outage the remoteAddress can be null.
// Do not report the open-connections when it's null
if (remoteAddress != null) {
// Remote address connection metrics
Counter counter = counter("open-connections", remoteAddress.host());
counter.dec();
if (counter.getCount() == 0) {
remove("open-connections", remoteAddress.host());
}
}
// A little clunky, but it's possible we got here after closed has been called
if (closed) {
removeAll();
}
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:22,代码来源:TCPMetricsImpl.java
注:本文中的io.vertx.core.net.SocketAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论