use of org.infinispan.server.core.ProtocolServer in project infinispan by infinispan.
the class ServerResource method connectorIpFilterClear.
private CompletionStage<RestResponse> connectorIpFilterClear(RestRequest restRequest) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder().status(NO_CONTENT);
String connectorName = restRequest.variables().get("connector");
ProtocolServer connector = invocationHelper.getServer().getProtocolServers().get(connectorName);
if (connector == null)
return completedFuture(builder.status(NOT_FOUND).build());
ServerStateManager serverStateManager = invocationHelper.getServer().getServerStateManager();
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<RestResponse>>) () -> serverStateManager.clearConnectorIpFilterRules(connectorName).thenApply(r -> builder.build()));
}
use of org.infinispan.server.core.ProtocolServer in project infinispan by infinispan.
the class ServerResource method connectorIpFilterList.
private CompletionStage<RestResponse> connectorIpFilterList(RestRequest restRequest) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder();
ProtocolServer connector = getProtocolServer(restRequest);
if (connector == null)
return completedFuture(builder.status(NOT_FOUND).build());
return completedFuture(addEntityAsJson(ipFilterRulesAsJson(connector), builder).build());
}
use of org.infinispan.server.core.ProtocolServer in project infinispan by infinispan.
the class ServerResource method connectorStartStop.
private CompletionStage<RestResponse> connectorStartStop(RestRequest restRequest) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder().status(NO_CONTENT);
String connectorName = restRequest.variables().get("connector");
ProtocolServer connector = invocationHelper.getServer().getProtocolServers().get(connectorName);
if (connector == null)
return completedFuture(builder.status(NOT_FOUND).build());
ServerStateManager serverStateManager = invocationHelper.getServer().getServerStateManager();
switch(restRequest.getAction()) {
case "start":
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<RestResponse>>) () -> serverStateManager.connectorStart(connectorName).thenApply(r -> builder.build()));
case "stop":
if (connector.equals(invocationHelper.getProtocolServer()) || connector.equals(invocationHelper.getProtocolServer().getEnclosingProtocolServer())) {
return completedFuture(builder.status(CONFLICT).entity(Messages.MSG.connectorMatchesRequest(connectorName)).build());
} else {
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<RestResponse>>) () -> serverStateManager.connectorStop(connectorName).thenApply(r -> builder.build()));
}
}
return completedFuture(builder.status(BAD_REQUEST).build());
}
use of org.infinispan.server.core.ProtocolServer 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