Package com.netflix.zuul.context
Class SessionContext
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
Object>
Represents the context between client and origin server for the duration of the dedicated connection/session
between them. But we're currently still only modelling single request/response pair per session.
NOTE: Not threadsafe, and not intended to be used concurrently.
User: Mike Smith
Date: 4/28/15
Time: 6:45 PM
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A Key is type-safe, identity-based key into the Session Context.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilterExecutionSummary
(String name, String status, long time) appends filter name and status to the filter execution history for the current requestvoid
cancel()
clone()
Makes a copy of the RequestContext.boolean
gets debugRequestboolean
boolean
boolean
<T> T
get
(SessionContext.Key<T> key) Returns the value in the context, ornull
if absent.boolean
getBoolean
(String key) Convenience method to return a boolean value for a given keyboolean
getBoolean
(String key, boolean defaultResponse) Convenience method to return a boolean value for a given keygetError()
Gets the throwable that will be use in the Error endpoint.<T> T
getOrDefault
(SessionContext.Key<T> key, T defaultValue) Returns the value in the context, ordefaultValue
if absent.int
returns the routeVIP; that is the Eureka "vip" of registered instancesgetUUID()
boolean
boolean
This can be used by filters for flagging if the server is getting overloaded, and then choose to disable/sample/rate-limit some optional features.keys()
static <T> SessionContext.Key<T>
<T> T
put
(SessionContext.Key<T> key, T value) Returns the previous value associated with key, ornull
if there was no mapping for key.<T> T
remove
(SessionContext.Key<T> key) <T> boolean
remove
(SessionContext.Key<T> key, T value) boolean
void
removes "routeHost" keyvoid
sets a key value to Boolean.TRUEvoid
puts the key, value into the map.void
setDebugRequest
(boolean bDebug) sets "debugRequest"void
setDebugRequestHeadersOnly
(boolean bHeadersOnly) sets "debugRequestHeadersOnly" to bHeadersOnlyvoid
setDebugRouting
(boolean bDebug) sets debugRoutingvoid
setEndpoint
(String endpoint) void
Sets throwable to use for generating a response in the Error endpoint.void
setErrorEndpoint
(String name) void
setErrorResponseSent
(boolean should) void
setEventProperty
(String key, Object value) void
void
setOriginReportedDuration
(int duration) void
setRouteHost
(URL routeHost) sets routeHostvoid
setRouteVIP
(String sVip) sets routeVIP; that is the Eureka "vip" of registered instancesvoid
setShouldSendErrorResponse
(boolean should) Set this to true to indicate that the Error endpoint should be applied after the end of the current filter processing phase.void
setStaticResponse
(HttpResponseMessage response) void
boolean
boolean
void
This is typically set by a filter when wanting to reject a request, and also reduce load on the server by not processing any subsequent filters for this request.Methods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
SessionContext
public SessionContext()
-
-
Method Details
-
newKey
-
get
This method exists for static analysis.
-
get
Returns the value in the context, ornull
if absent. -
getOrDefault
Returns the value in the context, ordefaultValue
if absent. -
put
This method exists for static analysis.
-
put
Returns the previous value associated with key, ornull
if there was no mapping for key. Unlikeput(String, Object)
, this will never return a null value if the key is present in the map. -
remove
This method exists for static analysis.
-
remove
-
remove
This method exists for static analysis.
-
remove
-
keys
-
clone
Makes a copy of the RequestContext. This is used for debugging. -
getString
-
getBoolean
Convenience method to return a boolean value for a given key- Returns:
- true or false depending what was set. default is false
-
getBoolean
Convenience method to return a boolean value for a given key- Returns:
- true or false depending what was set. default defaultResponse
-
set
sets a key value to Boolean.TRUE -
set
puts the key, value into the map. a null value will remove the key from the map -
getUUID
-
setUUID
-
setStaticResponse
-
getStaticResponse
-
getError
Gets the throwable that will be use in the Error endpoint. -
setError
Sets throwable to use for generating a response in the Error endpoint. -
getErrorEndpoint
-
setErrorEndpoint
-
setDebugRouting
public void setDebugRouting(boolean bDebug) sets debugRouting -
debugRouting
public boolean debugRouting()- Returns:
- "debugRouting"
-
setDebugRequestHeadersOnly
public void setDebugRequestHeadersOnly(boolean bHeadersOnly) sets "debugRequestHeadersOnly" to bHeadersOnly -
debugRequestHeadersOnly
public boolean debugRequestHeadersOnly()- Returns:
- "debugRequestHeadersOnly"
-
setDebugRequest
public void setDebugRequest(boolean bDebug) sets "debugRequest" -
debugRequest
public boolean debugRequest()gets debugRequest- Returns:
- debugRequest
-
removeRouteHost
public void removeRouteHost()removes "routeHost" key -
setRouteHost
sets routeHost- Parameters:
routeHost
- a URL
-
getRouteHost
- Returns:
- "routeHost" URL
-
addFilterExecutionSummary
appends filter name and status to the filter execution history for the current request -
getFilterExecutionSummary
- Returns:
- String that represents the filter execution history for the current request
-
shouldSendErrorResponse
public boolean shouldSendErrorResponse() -
setShouldSendErrorResponse
public void setShouldSendErrorResponse(boolean should) Set this to true to indicate that the Error endpoint should be applied after the end of the current filter processing phase. -
errorResponseSent
public boolean errorResponseSent() -
setErrorResponseSent
public void setErrorResponseSent(boolean should) -
isInBrownoutMode
public boolean isInBrownoutMode()This can be used by filters for flagging if the server is getting overloaded, and then choose to disable/sample/rate-limit some optional features. -
setInBrownoutMode
public void setInBrownoutMode() -
stopFilterProcessing
public void stopFilterProcessing()This is typically set by a filter when wanting to reject a request, and also reduce load on the server by not processing any subsequent filters for this request. -
shouldStopFilterProcessing
public boolean shouldStopFilterProcessing() -
getRouteVIP
returns the routeVIP; that is the Eureka "vip" of registered instances -
setRouteVIP
sets routeVIP; that is the Eureka "vip" of registered instances -
setEndpoint
-
getEndpoint
-
setEventProperty
-
getEventProperties
-
getFilterErrors
-
setOriginReportedDuration
public void setOriginReportedDuration(int duration) -
getOriginReportedDuration
public int getOriginReportedDuration() -
isCancelled
public boolean isCancelled() -
cancel
public void cancel()
-