Class ProxiedResource
- Direct Known Subclasses:
ClusterDeflectorResource,ClusterInputStatesResource,ClusterJournalResource,ClusterLoadBalancerStatusResource,ClusterLoggersResource,ClusterLookupTableResource,ClusterMetricsResource,ClusterNodeMetricsResource,ClusterProcessingStatusResource,ClusterSystemJobResource,ClusterSystemPluginResource,ClusterSystemProcessingResource,ClusterSystemResource,ClusterSystemShutdownResource,SearchJobsStatusResource,SupportBundleClusterResource
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis wrapper is intended to provide additional server error information if something went wrong beyond the actual API HTTP call.static classDeprecated.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final NodeServiceprotected final RemoteInterfaceProviderFields inherited from class org.graylog2.shared.rest.resources.RestResource
configuration, userService -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProxiedResource(jakarta.ws.rs.core.HttpHeaders httpHeaders, NodeService nodeService, RemoteInterfaceProvider remoteInterfaceProvider, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringauthenticationToken(jakarta.ws.rs.core.HttpHeaders httpHeaders) createRemoteInterface(Class<RemoteInterfaceType> interfaceClass, Duration timeout) protected <RemoteInterfaceType,RemoteCallResponseType, FinalResponseType>
ProxiedResource.NodeResponse<FinalResponseType>doNodeApiCall(String nodeId, Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<RemoteCallResponseType, FinalResponseType> transformer, Duration timeout) protected StringGets an authentication token to be used in an Authorization header of forwarded requests.protected DurationgetForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider) Deprecated.getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Duration timeout) 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,FinalResponseType, RemoteCallResponseType>
Map<String,Optional<FinalResponseType>> getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Function<RemoteCallResponseType, FinalResponseType> transformer, Duration timeout) Deprecated.protected voidprocessAsync(jakarta.ws.rs.container.AsyncResponse asyncResponse, Supplier<Object> responseSupplier) protected <RemoteInterfaceType,RemoteCallResponseType>
Map<String,ProxiedResource.CallResult<RemoteCallResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn) protected <RemoteInterfaceType,RemoteCallResponseType>
Map<String,ProxiedResource.CallResult<RemoteCallResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Duration timeout) protected <RemoteInterfaceType,RemoteCallResponseType, FinalResponseType>
Map<String,ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer) protected <RemoteInterfaceType,RemoteCallResponseType, FinalResponseType>
Map<String,ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer, Duration timeout) This method concurrently performs an API call on all active nodes.protected <RemoteInterfaceType,RemoteCallResponseType>
ProxiedResource.NodeResponse<RemoteCallResponseType>requestOnLeader(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass) Execute the given remote interface function on the leader node.protected <RemoteInterfaceType,RemoteCallResponseType>
ProxiedResource.NodeResponse<RemoteCallResponseType>requestOnLeader(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass, Duration timeout) Execute the given remote interface function on the leader node.protected <RemoteInterfaceType,RemoteCallResponseType>
ProxiedResource.NodeResponse<RemoteCallResponseType>requestOnNode(String nodeId, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass) Execute the given remote interface function on the given node.protected <RemoteInterfaceType,RemoteCallResponseType>
ProxiedResource.NodeResponse<RemoteCallResponseType>requestOnNode(String nodeId, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass, Duration timeout) Execute the given remote interface function on the given node.stripCallResult(Map<String, ProxiedResource.CallResult<T>> input) Helper function to remove theProxiedResource.CallResultwrapperMethods 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 jakarta.ws.rs.core.HttpHeaders httpHeaders, NodeService nodeService, RemoteInterfaceProvider remoteInterfaceProvider, ExecutorService executorService)
-
-
Method Details
-
getDefaultProxyCallTimeout
-
processAsync
-
authenticationToken
-
getAuthenticationToken
Gets an authentication token to be used in an Authorization header of forwarded requests. It was extracted from the authentication information of the original request.- Returns:
- An authentication token if the request was authenticated and one could be extracted from the original
-
getForAllNodes
@Deprecated protected <RemoteInterfaceType,RemoteCallResponseType> Map<String,Optional<RemoteCallResponseType>> getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider) Deprecated.Prefer usingrequestOnAllNodes(Class, 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,RemoteCallResponseType> Map<String,Optional<RemoteCallResponseType>> getForAllNodes(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn, Function<String, Optional<RemoteInterfaceType>> interfaceProvider, Duration timeout) Deprecated.Prefer usingrequestOnAllNodes(Class, Function, Duration)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(Class, 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, Duration timeout) Deprecated.Prefer usingrequestOnAllNodes(Class, Function, Function, Duration)instead. The new method properly handles the case of `No-Content` response and provides detailed report per each node API call. -
createRemoteInterface
-
requestOnAllNodes
protected <RemoteInterfaceType,RemoteCallResponseType> Map<String,ProxiedResource.CallResult<RemoteCallResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> fn) -
requestOnAllNodes
-
requestOnAllNodes
protected <RemoteInterfaceType,RemoteCallResponseType, Map<String,FinalResponseType> ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer) -
requestOnAllNodes
protected <RemoteInterfaceType,RemoteCallResponseType, Map<String,FinalResponseType> ProxiedResource.CallResult<FinalResponseType>> requestOnAllNodes(Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceCallProvider, Function<RemoteCallResponseType, FinalResponseType> responseTransformer, @Nullable Duration timeout) 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:
interfaceClass- The class of the Retrotfit interface for this callremoteInterfaceCallProvider- 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.
-
requestOnLeader
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.NodeResponse<RemoteCallResponseType> requestOnLeader(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass, Duration timeout) throws IOExceptionExecute 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.NodeResponseobject is constructed from the remote response's status code and body.- Throws:
IOException
-
requestOnLeader
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.NodeResponse<RemoteCallResponseType> requestOnLeader(Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass) throws IOExceptionExecute 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.NodeResponseobject is constructed from the remote response's status code and body.- Throws:
IOException
-
requestOnNode
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.NodeResponse<RemoteCallResponseType> requestOnNode(String nodeId, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass, Duration timeout) throws IOExceptionExecute the given remote interface function on the given node.This is used to forward an API request to the given node. It is useful in situations where an API call has to be executed on a particular, chosen node.
The returned
ProxiedResource.NodeResponseobject is constructed from the remote response's status code and body.- Throws:
IOException
-
requestOnNode
protected <RemoteInterfaceType,RemoteCallResponseType> ProxiedResource.NodeResponse<RemoteCallResponseType> requestOnNode(String nodeId, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Class<RemoteInterfaceType> interfaceClass) throws IOExceptionExecute the given remote interface function on the given node.This is used to forward an API request to the given node. It is useful in situations where an API call has to be executed on a particular, chosen node.
The returned
ProxiedResource.NodeResponseobject is constructed from the remote response's status code and body.- Throws:
IOException
-
doNodeApiCall
protected <RemoteInterfaceType,RemoteCallResponseType, ProxiedResource.NodeResponse<FinalResponseType> doNodeApiCallFinalResponseType> (String nodeId, Class<RemoteInterfaceType> interfaceClass, Function<RemoteInterfaceType, retrofit2.Call<RemoteCallResponseType>> remoteInterfaceFunction, Function<RemoteCallResponseType, throws IOExceptionFinalResponseType> transformer, @Nullable Duration timeout) - Throws:
IOException
-
stripCallResult
protected <T> Map<String,Optional<T>> stripCallResult(Map<String, ProxiedResource.CallResult<T>> input) Helper function to remove theProxiedResource.CallResultwrapper- Parameters:
input- responses that are wrapped with aProxiedResource.CallResult- Returns:
- the response in the legacy format of
Map<String, Optional<T>>
-
ProxiedResource.NodeResponseinstead.