Class FilibusterClientInstrumentor
- java.lang.Object
-
- cloud.filibuster.instrumentation.instrumentors.FilibusterClientInstrumentor
-
public final class FilibusterClientInstrumentor extends java.lang.Object
Client instrumentor for Filibuster.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
overrideRequestId
-
Constructor Summary
Constructors Constructor Description FilibusterClientInstrumentor(java.lang.String serviceName, boolean shouldCommunicateWithServer, ContextStorage contextStorage, Callsite callsite)
Create an instance of a Filibuster client instrumentor for controlling fault injection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties)
Invoked after a remote call has been completed if the remote call completed successfully.void
afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties, boolean isUpdate, java.lang.Object returnValue)
void
afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties, boolean isUpdate, java.lang.Object returnValue, com.google.protobuf.GeneratedMessageV3 responseMessage)
Invoked after a remote call has been completed if the remote call completed successfully.void
afterInvocationWithException(java.lang.String exceptionName, java.lang.String exceptionCause, java.util.Map<java.lang.String,java.lang.String> additionalMetadata)
void
afterInvocationWithException(java.lang.String exceptionName, java.lang.String exceptionCause, java.util.Map<java.lang.String,java.lang.String> additionalMetadata, java.lang.Object exceptionDetails)
Invoked after a remote call has been completed if the remote call threw an exception.void
afterInvocationWithException(java.lang.Throwable throwable)
Invoked after a remote call has been completed if the remote call threw an exception.void
afterInvocationWithException(java.lang.Throwable throwable, java.util.Map<java.lang.String,java.lang.String> additionalMetadata)
Invoked after a remote call has been completed if the remote call threw an exception.void
afterInvocationWithTransformerFault(java.lang.String value, java.lang.String type, Accumulator<?,?> accumulator)
Invoked after a remote call has been completed if the remote call injects a transformer value.void
beforeInvocation()
Invoked directly before a remote call is issued.static void
clearDistributedExecutionIndexForRequestId()
Reset execution index mapping.static void
clearDistributedExecutionIndexForRequestId(java.lang.String serviceName)
Reset the execution index request mapping.static void
clearVectorClockForRequestId()
Reset vector clock mapping.static void
clearVectorClockForRequestId(java.lang.String serviceName)
Reset the vector clock request mapping.Callsite
getCallsite()
Return the current callsite.DistributedExecutionIndex
getDistributedExecutionIndex()
Return the execution index associated with this instrumentation call.static java.util.Map<java.lang.String,java.util.Map<java.lang.String,DistributedExecutionIndex>>
getDistributedExecutionIndexByRequest()
Get the execution index request mapping.static DistributedExecutionIndex
getDistributedExecutionIndexForServiceNameAndRequestId(java.lang.String serviceName, java.lang.String requestId, DistributedExecutionIndex defaultExecutionIndex)
Return the current execution index for a given request id.org.json.JSONObject
getFailureMetadata()
Return failure that needs to be injected.java.lang.String
getFilibusterHost()
Return the host of the Filibuster instrumentation server.int
getFilibusterPort()
Return the port of the Filibuster instrumentation server.org.json.JSONObject
getForcedException()
Return exception fault that needs to be injected.int
getGeneratedId()
Return the generated identifier for the request (as assigned by the Filibuster server.) This value will be null until the Filibuster server has been contacted for this request.VectorClock
getOriginVectorClock()
Return the origin vector clock associated with this instrumentation call.java.lang.String
getOutgoingRequestId()
Get outgoing request id.DistributedExecutionIndex
getPreliminaryDistributedExecutionIndex()
Get the value of the preliminary execution index.java.lang.String
getRequestId()
Return the Filibuster request identifier associated with this instrumentation call.org.json.JSONObject
getTransformerFault()
Return transformer fault that needs to be injected.VectorClock
getVectorClock()
Return the vector clock associated with this instrumentation call.static VectorClock
getVectorClockForServiceNameAndRequestId(java.lang.String serviceName, java.lang.String requestId, VectorClock defaultVectorClock)
Return the current vector clock for a given request id.static java.util.Map<java.lang.String,java.util.Map<java.lang.String,VectorClock>>
getVectorClocksByRequest()
Get the vector clock request mapping.void
prepareForInvocation()
Invoked before the remote call is handled to set up internal state of the instrumentor.void
prepareForInvocation(com.google.protobuf.GeneratedMessageV3 message)
static void
setDistributedExecutionIndexForRequestId(java.lang.String serviceName, java.lang.String requestId, DistributedExecutionIndex distributedExecutionIndex)
Set the current execution index for a given request id.void
setPreliminaryDistributedExecutionIndex(DistributedExecutionIndex preliminaryDistributedExecutionIndex)
Set the value of the preliminary execution index.void
setRequestId(java.lang.String requestId)
Set the request identifier.void
setRpcType(RpcType rpcType)
static void
setVectorClockForRequestId(java.lang.String serviceName, java.lang.String requestId, VectorClock vectorClock)
Set the current vector clock for a given request id.boolean
shouldAbort()
Should this request be allowed to reach the remote service or should it be skipped?boolean
shouldResetClocks()
Determine if the client instrumentor should reset the service's vector clock.void
updateCallsite(Callsite callsite)
Allow re-specification of the callsite.static boolean
vectorClockForRequestIdExists(java.lang.String serviceName, java.lang.String requestId)
Does an entry exist in the vector clock request mapping for a particular request id?
-
-
-
Constructor Detail
-
FilibusterClientInstrumentor
public FilibusterClientInstrumentor(java.lang.String serviceName, boolean shouldCommunicateWithServer, ContextStorage contextStorage, Callsite callsite)
Create an instance of a Filibuster client instrumentor for controlling fault injection.- Parameters:
serviceName
- the name of the service being instrumented.shouldCommunicateWithServer
- whether the system should communicate with the Filibuster server.contextStorage
- context storage.
-
-
Method Detail
-
getVectorClocksByRequest
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,VectorClock>> getVectorClocksByRequest()
Get the vector clock request mapping.- Returns:
- vector clock request map.
-
getDistributedExecutionIndexByRequest
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,DistributedExecutionIndex>> getDistributedExecutionIndexByRequest()
Get the execution index request mapping.- Returns:
- execution index request map.
-
setVectorClockForRequestId
public static void setVectorClockForRequestId(java.lang.String serviceName, java.lang.String requestId, VectorClock vectorClock)
Set the current vector clock for a given request id.- Parameters:
requestId
- request identifier.vectorClock
- vector clock.
-
vectorClockForRequestIdExists
public static boolean vectorClockForRequestIdExists(java.lang.String serviceName, java.lang.String requestId)
Does an entry exist in the vector clock request mapping for a particular request id?- Parameters:
serviceName
- the service name.requestId
- the request identifier.- Returns:
- whether a mapping exists.
-
clearVectorClockForRequestId
public static void clearVectorClockForRequestId(java.lang.String serviceName)
Reset the vector clock request mapping.- Parameters:
serviceName
- the service name.
-
clearVectorClockForRequestId
public static void clearVectorClockForRequestId()
Reset vector clock mapping.
-
clearDistributedExecutionIndexForRequestId
public static void clearDistributedExecutionIndexForRequestId(java.lang.String serviceName)
Reset the execution index request mapping.- Parameters:
serviceName
- the service name.
-
clearDistributedExecutionIndexForRequestId
public static void clearDistributedExecutionIndexForRequestId()
Reset execution index mapping.
-
setDistributedExecutionIndexForRequestId
public static void setDistributedExecutionIndexForRequestId(java.lang.String serviceName, java.lang.String requestId, DistributedExecutionIndex distributedExecutionIndex)
Set the current execution index for a given request id.- Parameters:
requestId
- request identifier.distributedExecutionIndex
- execution index.
-
getVectorClockForServiceNameAndRequestId
public static VectorClock getVectorClockForServiceNameAndRequestId(java.lang.String serviceName, java.lang.String requestId, VectorClock defaultVectorClock)
Return the current vector clock for a given request id.- Parameters:
requestId
- request identifier.- Returns:
- vector clock.
-
getDistributedExecutionIndexForServiceNameAndRequestId
public static DistributedExecutionIndex getDistributedExecutionIndexForServiceNameAndRequestId(java.lang.String serviceName, java.lang.String requestId, DistributedExecutionIndex defaultExecutionIndex)
Return the current execution index for a given request id.- Parameters:
requestId
- request identifier.- Returns:
- execution index.
-
setPreliminaryDistributedExecutionIndex
public void setPreliminaryDistributedExecutionIndex(DistributedExecutionIndex preliminaryDistributedExecutionIndex)
Set the value of the preliminary execution index.- Parameters:
preliminaryDistributedExecutionIndex
- execution index.
-
getPreliminaryDistributedExecutionIndex
public DistributedExecutionIndex getPreliminaryDistributedExecutionIndex()
Get the value of the preliminary execution index.- Returns:
- execution index.
-
updateCallsite
public void updateCallsite(Callsite callsite)
Allow re-specification of the callsite.- Parameters:
callsite
- callsite
-
setRpcType
public void setRpcType(@Nullable RpcType rpcType)
-
getCallsite
public Callsite getCallsite()
Return the current callsite.- Returns:
- callsite
-
getFilibusterHost
public java.lang.String getFilibusterHost()
Return the host of the Filibuster instrumentation server.- Returns:
- host.
-
getFilibusterPort
public int getFilibusterPort()
Return the port of the Filibuster instrumentation server.- Returns:
- port number.
-
getRequestId
public java.lang.String getRequestId()
Return the Filibuster request identifier associated with this instrumentation call. This will return null until the invocation has been prepared, unless it has been provided by the caller in the constructor.- Returns:
- request identifier.
-
getOutgoingRequestId
public java.lang.String getOutgoingRequestId()
Get outgoing request id.- Returns:
- request identifier.
-
setRequestId
public void setRequestId(java.lang.String requestId)
Set the request identifier.- Parameters:
requestId
- a request identifier.
-
getVectorClock
public VectorClock getVectorClock()
Return the vector clock associated with this instrumentation call. This will return null until the invocation has been prepared.- Returns:
- vector clock.
-
getDistributedExecutionIndex
public DistributedExecutionIndex getDistributedExecutionIndex()
Return the execution index associated with this instrumentation call. This will return null until the invocation has been prepared.- Returns:
- execution index.
-
getOriginVectorClock
public VectorClock getOriginVectorClock()
Return the origin vector clock associated with this instrumentation call. This value is provided by the caller in the constructor.- Returns:
- vector clock.
-
getGeneratedId
public int getGeneratedId()
Return the generated identifier for the request (as assigned by the Filibuster server.) This value will be null until the Filibuster server has been contacted for this request.- Returns:
- generated id.
-
getForcedException
public org.json.JSONObject getForcedException()
Return exception fault that needs to be injected. This value will be null until the Filibuster server has been contacted for this request.- Returns:
- JSON object containing exception to inject.
-
getFailureMetadata
public org.json.JSONObject getFailureMetadata()
Return failure that needs to be injected. This value will be null until the Filibuster server has been contacted for this request.- Returns:
- JSON object containing failure to inject.
-
getTransformerFault
public org.json.JSONObject getTransformerFault()
Return transformer fault that needs to be injected. This value will be null until the Filibuster server has been contacted for this request.- Returns:
- JSON object containing failure to inject.
-
shouldAbort
public boolean shouldAbort()
Should this request be allowed to reach the remote service or should it be skipped?- Returns:
- whether it should be aborted or not.
-
shouldResetClocks
public boolean shouldResetClocks()
Determine if the client instrumentor should reset the service's vector clock. Used by the testing infrastructure for a soft reset.- Returns:
- whether the service's vector clock should be reset.
-
prepareForInvocation
public void prepareForInvocation(com.google.protobuf.GeneratedMessageV3 message)
-
prepareForInvocation
public void prepareForInvocation()
Invoked before the remote call is handled to set up internal state of the instrumentor.
-
beforeInvocation
public void beforeInvocation()
Invoked directly before a remote call is issued.Notifies Filibuster of the remote call that is about to occur and determines if the remote call should instead, return a fault.
-
afterInvocationWithException
public void afterInvocationWithException(java.lang.Throwable throwable)
Invoked after a remote call has been completed if the remote call threw an exception.- Parameters:
throwable
- the exception thrown.
-
afterInvocationWithException
public void afterInvocationWithException(java.lang.Throwable throwable, java.util.Map<java.lang.String,java.lang.String> additionalMetadata)
Invoked after a remote call has been completed if the remote call threw an exception.- Parameters:
throwable
- the exception thrown.additionalMetadata
- any additional metadata that should be provided, such as if the request was aborted.
-
afterInvocationWithException
public void afterInvocationWithException(java.lang.String exceptionName, java.lang.String exceptionCause, java.util.Map<java.lang.String,java.lang.String> additionalMetadata)
-
afterInvocationWithException
public void afterInvocationWithException(java.lang.String exceptionName, java.lang.String exceptionCause, java.util.Map<java.lang.String,java.lang.String> additionalMetadata, @Nullable java.lang.Object exceptionDetails)
Invoked after a remote call has been completed if the remote call threw an exception.- Parameters:
exceptionName
- the fully qualified name of the exception thrown.exceptionCause
- the fully qualified name of the cause (an exception), if provided.additionalMetadata
- any additional metadata that should be provided, such as if the request was aborted.
-
afterInvocationWithTransformerFault
public void afterInvocationWithTransformerFault(java.lang.String value, java.lang.String type, Accumulator<?,?> accumulator)
Invoked after a remote call has been completed if the remote call injects a transformer value.- Parameters:
value
- the transformer value that was injected.type
- type of the injected transformer value (e.g., String).accumulator
- containing any additional information that should be communicated to the server and used in subsequent transformer faults (e.g., original value before mutation and idx of mutated char in case of a transformer string transformation).
-
afterInvocationComplete
public void afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties)
Invoked after a remote call has been completed if the remote call completed successfully.- Parameters:
className
- the fully qualified name of the response class.returnValueProperties
- any properties of the response that make the response unique.
-
afterInvocationComplete
public void afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties, boolean isUpdate, @Nullable java.lang.Object returnValue)
-
afterInvocationComplete
public void afterInvocationComplete(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> returnValueProperties, boolean isUpdate, @Nullable java.lang.Object returnValue, @Nullable com.google.protobuf.GeneratedMessageV3 responseMessage)
Invoked after a remote call has been completed if the remote call completed successfully.- Parameters:
className
- the fully qualified name of the response class.returnValueProperties
- any properties of the response that make the response unique.returnValue
- the actual return value after invocation.
-
-