Class OperationClassifier
java.lang.Object
org.openspaces.core.multicluster.internal.OperationClassifier
Maps a
Method to the OperationKind that decides how it is routed.
An explicit table, not a guess
Classification is by method name, from a reviewed table below - not by prefix heuristics. A heuristic would quietly misfile the awkward cases, and each of them matters:countandaggregateare reads, so they go to one cluster and are never summed across clusters;asyncLoadsounds like a read but loads the space from its data source - a mutation;snapshotandprepareTemplateonly prepare a query object, so they are reads;setQuiesceTokenis a setter but is space-local, not a data mutation.
Unknown methods fail loudly
An unclassified method throwsIllegalStateException rather than defaulting to something
plausible: silently treating a new mutation as a read would send writes to one cluster and leave the
others stale. OperationClassifierCompletenessTest asserts the table covers every method of
GigaSpace and fails the build when a version upgrade adds one - which 18.0 did (four
methods over 17.2.2, three of them default).
Default methods matter here
DefaultMultiClusterGigaSpace would inherit a default
method silently, and the inherited body is not routed - so 18.0's getLastOperations() and
clear(Object, int, ClearModifiers) are overridden there and classified here like any abstract
method. DefaultMultiClusterGigaSpaceCompletenessTest fails the build if one is ever left
inherited.
Stateless and thread-safe; results are cached per Method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat to do with a method whose return value is a live handle onto a single cluster. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClassifies a method, caching the result.static OperationKindclassifyUncached(Method method) Classification without the cache; also the entry point the completeness test uses.Return types that make a method a single-cluster handle, for the completeness test.handlePolicy(Method method) The policy for a method that hands back a single-cluster handle, ornullwhen the method returns no such thing.static Map<String, OperationClassifier.HandlePolicy> The single-cluster-handle table, for the completeness test.static booleanTrue for theasyncXxxflavour of an operation, whose result is anAsyncFuturerather than a value.static StringrejectionMessage(Method method, String proxyName) Explains aOperationClassifier.HandlePolicy.REJECT, naming what to call instead.static StringrejectionMessage(String methodName, String proxyName) Explains aOperationClassifier.HandlePolicy.REJECTfor a method known by name - whatDefaultMultiClusterGigaSpacethrows from the two methods it refuses, which have noMethodto hand because they are compiled overrides rather than reflective dispatch.static Class<?> Sanity check used by the completeness test: does the table cover all ofGigaSpace?static Map<String, OperationKind> table()The names this classifier knows about, for diagnostics and tests.
-
Constructor Details
-
OperationClassifier
public OperationClassifier()
-
-
Method Details
-
classify
Classifies a method, caching the result.- Throws:
IllegalStateException- if the method belongs toGigaSpacebut is not in the table - that means a version upgrade added an operation and the router has not been taught what it does
-
classifyUncached
Classification without the cache; also the entry point the completeness test uses. -
isAsync
True for theasyncXxxflavour of an operation, whose result is anAsyncFuturerather than a value. Selection is identical to the synchronous counterpart; only result handling differs. -
handlePolicy
The policy for a method that hands back a single-cluster handle, ornullwhen the method returns no such thing. -
rejectionMessage
Explains aOperationClassifier.HandlePolicy.REJECT, naming what to call instead. -
rejectionMessage
Explains aOperationClassifier.HandlePolicy.REJECTfor a method known by name - whatDefaultMultiClusterGigaSpacethrows from the two methods it refuses, which have noMethodto hand because they are compiled overrides rather than reflective dispatch. -
table
The names this classifier knows about, for diagnostics and tests. -
handleTable
The single-cluster-handle table, for the completeness test. -
escapingReturnTypes
-
spaceInterface
Sanity check used by the completeness test: does the table cover all ofGigaSpace?
-