Class ProxiedResource
java.lang.Object
org.graylog2.shared.rest.resources.RestResource
org.graylog2.shared.rest.resources.ProxiedResource
- Direct Known Subclasses:
ClusterDeflectorResource
,ClusterInputStatesResource
,ClusterJournalResource
,ClusterLoadBalancerStatusResource
,ClusterLoggersResource
,ClusterLookupTableResource
,ClusterMetricsResource
,ClusterNodeMetricsResource
,ClusterProcessingStatusResource
,ClusterSystemJobResource
,ClusterSystemPluginResource
,ClusterSystemProcessingResource
,ClusterSystemResource
,ClusterSystemShutdownResource
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This wrapper is intended to provide additional server error information if something went wrong beyond the actual API HTTP call.static class
Deprecated.static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final NodeService
protected final RemoteInterfaceProvider
Fields inherited from class org.graylog2.shared.rest.resources.RestResource
configuration, userService
-
Constructor Summary
ModifierConstructorDescriptionprotected
ProxiedResource
(javax.ws.rs.core.HttpHeaders httpHeaders, NodeService nodeService, RemoteInterfaceProvider remoteInterfaceProvider, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
authenticationToken
(javax.ws.rs.core.HttpHeaders httpHeaders) createRemoteInterfaceProvider
(Class<RemoteInterfaceType> interfaceClass) protected String
Gets an authentication token to be used in an Authorization header of forwarded requests by extracting authentication information from the original request.getForAllNodes
(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider) Deprecated.protected <RemoteInterfaceType,
FinalResponseType, RemoteCallResponseType>
Map<String,Optional<FinalResponseType>> getForAllNodes
(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Function<RemoteCallResponseType, FinalResponseType> transformer) Deprecated.protected <RemoteInterfaceType,
RemoteCallResponseType>
Map<String,ProxiedResource.CallResult<RemoteCallResponseType>> requestOnAllNodes
(Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn) protected <RemoteInterfaceType,
RemoteCallResponseType, FinalResponseType>
Map<String,ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes
(Function<String, Optional<RemoteInterfaceType>> remoteInterfaceProvider, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer) This method concurrently performs an API call on all active nodes.protected <RemoteInterfaceType,
RemoteCallResponseType>
ProxiedResource.NodeResponse<RemoteCallResponseType>requestOnLeader
(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<String, Optional<RemoteInterfaceType>> remoteInterfaceProvider) Execute the given remote interface function on the leader node.protected <RemoteInterfaceType,
RemoteCallResponseType>
ProxiedResource.MasterResponse<RemoteCallResponseType>requestOnMaster
(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<String, Optional<RemoteInterfaceType>> remoteInterfaceProvider) Deprecated.UserequestOnLeader(Function, Function)
instead.Methods inherited from class org.graylog2.shared.rest.resources.RestResource
checkAnyPermission, checkPermission, checkPermission, getCurrentUser, getIndexSet, getSubject, getUriBuilderToSelf, isAnyPermitted, isAnyPermitted, isPermitted, isPermitted, setPrettyPrint
-
Field Details
-
nodeService
-
remoteInterfaceProvider
-
-
Constructor Details
-
ProxiedResource
protected ProxiedResource(@Context javax.ws.rs.core.HttpHeaders httpHeaders, NodeService nodeService, RemoteInterfaceProvider remoteInterfaceProvider, ExecutorService executorService)
-
-
Method Details
-
authenticationToken
-
getAuthenticationToken
Gets an authentication token to be used in an Authorization header of forwarded requests by extracting authentication information from the original request.- Returns:
- An authentication token if one could be extracted from the original requeest. Null otherwise.
- Throws:
javax.ws.rs.NotAuthorizedException
- if the original request was authenticated, but no authentication token could be created from the request headers.
-
getForAllNodes
@Deprecated protected <RemoteInterfaceType,RemoteCallResponseType> Map<String,Optional<RemoteCallResponseType>> getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider) Deprecated.Prefer usingrequestOnAllNodes(Function, Function)
instead. The new method properly handles the case of `No-Content` response and provides detailed report per each node API call. -
getForAllNodes
@Deprecated protected <RemoteInterfaceType,FinalResponseType, Map<String,RemoteCallResponseType> Optional<FinalResponseType>> getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Function<RemoteCallResponseType, FinalResponseType> transformer) Deprecated.Prefer usingrequestOnAllNodes(Function, Function, Function)
instead. The new method properly handles the case of `No-Content` response and provides detailed report per each node API call. -
createRemoteInterfaceProvider
-
requestOnAllNodes
-
requestOnAllNodes
protected <RemoteInterfaceType,RemoteCallResponseType, Map<String,FinalResponseType> ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes(Function<String, Optional<RemoteInterfaceType>> remoteInterfaceProvider, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer) This method concurrently performs an API call on all active nodes.- Type Parameters:
RemoteInterfaceType
- Type of the Retrofit HTTP clientRemoteCallResponseType
- Type of the API call response bodyFinalResponseType
- Type after applying the transformations- Parameters:
remoteInterfaceProvider
- provides an instance of Retrofit HTTP client for the target APIremoteInterfaceCallProvider
- provides an invocation of a Retrofit method for the intended API call.responseTransformer
- applies transformations to HTTP response body- Returns:
- Detailed report on call results per each active node.
-
requestOnMaster
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.MasterResponse<RemoteCallResponseType> requestOnMaster(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<String, throws IOExceptionOptional<RemoteInterfaceType>> remoteInterfaceProvider) Deprecated.UserequestOnLeader(Function, Function)
instead.- Throws:
IOException
-
requestOnLeader
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.NodeResponse<RemoteCallResponseType> requestOnLeader(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<String, throws IOExceptionOptional<RemoteInterfaceType>> remoteInterfaceProvider) Execute the given remote interface function on the leader node.This is used to forward an API request to the leader node. It is useful in situations where an API call can only be executed on the leader node.
The returned
ProxiedResource.NodeResponse
object is constructed from the remote response's status code and body.- Throws:
IOException
-
ProxiedResource.NodeResponse
instead.