use of org.infinispan.server.core.transport.Transport in project infinispan by infinispan.
the class ServerStateManagerImpl method updateIpFilters.
private CompletionStage<Void> updateIpFilters(String connector, Collection<IpFilterRule> rules) {
ProtocolServer protocolServer = server.getProtocolServers().get(connector);
if (rules.isEmpty()) {
protocolServer.getConfiguration().ipFilter().rules(Collections.emptyList());
Server.log.connectorIpFilterCleared(connector);
return CompletableFutures.completedNull();
} else {
List<IpSubnetFilterRule> localRules = new ArrayList<>(rules.size());
for (IpFilterRule rule : rules) {
localRules.add(new IpSubnetFilterRule(rule.cidr, IpFilterRuleType.valueOf(rule.type)));
}
protocolServer.getConfiguration().ipFilter().rules(localRules);
Transport transport = getTransport(protocolServer);
CompositeChannelMatcher matcher = new CompositeChannelMatcher(protocolServer.getChannelMatcher(), new IpFilterRuleChannelMatcher(localRules));
return transport.closeChannels(matcher).thenApply(v -> {
Server.log.connectorIpFilterSet(connector, localRules);
return v;
});
}
}
use of org.infinispan.server.core.transport.Transport in project infinispan by infinispan.
the class ServerResource method connectorStatus.
private CompletionStage<RestResponse> connectorStatus(RestRequest restRequest) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder();
String connectorName = restRequest.variables().get("connector");
ProtocolServer connector = getProtocolServer(restRequest);
if (connector == null)
return completedFuture(builder.status(NOT_FOUND).build());
ServerStateManager serverStateManager = invocationHelper.getServer().getServerStateManager();
Json info = Json.object().set("name", connectorName).set("ip-filter-rules", ipFilterRulesAsJson(connector));
Transport transport = connector.getTransport();
if (transport != null) {
info.set("host", transport.getHostName()).set("port", transport.getPort()).set("local-connections", transport.getNumberOfLocalConnections()).set("global-connections", transport.getNumberOfGlobalConnections()).set("io-threads", transport.getNumberIOThreads()).set("pending-tasks", transport.getPendingTasks()).set("total-bytes-read", transport.getTotalBytesRead()).set("total-bytes-written", transport.getTotalBytesWritten()).set("send-buffer-size", transport.getSendBufferSize()).set("receive-buffer-size", transport.getReceiveBufferSize());
}
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<RestResponse>>) () -> serverStateManager.connectorStatus(connectorName).thenApply(b -> builder.contentType(APPLICATION_JSON).entity(info.set("enabled", b)).build()));
}
Aggregations