Class OperationClassifier

java.lang.Object
org.openspaces.core.multicluster.internal.OperationClassifier

public final class OperationClassifier extends Object
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:
  • count and aggregate are reads, so they go to one cluster and are never summed across clusters;
  • asyncLoad sounds like a read but loads the space from its data source - a mutation;
  • snapshot and prepareTemplate only prepare a query object, so they are reads;
  • setQuiesceToken is a setter but is space-local, not a data mutation.

Unknown methods fail loudly

An unclassified method throws IllegalStateException 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.

  • Constructor Details

    • OperationClassifier

      public OperationClassifier()
  • Method Details

    • classify

      public OperationKind classify(Method method)
      Classifies a method, caching the result.
      Throws:
      IllegalStateException - if the method belongs to GigaSpace but is not in the table - that means a version upgrade added an operation and the router has not been taught what it does
    • classifyUncached

      public static OperationKind classifyUncached(Method method)
      Classification without the cache; also the entry point the completeness test uses.
    • isAsync

      public static boolean isAsync(Method method)
      True for the asyncXxx flavour of an operation, whose result is an AsyncFuture rather than a value. Selection is identical to the synchronous counterpart; only result handling differs.
    • handlePolicy

      public static OperationClassifier.HandlePolicy handlePolicy(Method method)
      The policy for a method that hands back a single-cluster handle, or null when the method returns no such thing.
    • rejectionMessage

      public static String rejectionMessage(Method method, String proxyName)
      Explains a OperationClassifier.HandlePolicy.REJECT, naming what to call instead.
    • rejectionMessage

      public static String rejectionMessage(String methodName, String proxyName)
      Explains a OperationClassifier.HandlePolicy.REJECT for a method known by name - what DefaultMultiClusterGigaSpace throws from the two methods it refuses, which have no Method to hand because they are compiled overrides rather than reflective dispatch.
    • table

      public static Map<String, OperationKind> table()
      The names this classifier knows about, for diagnostics and tests.
    • handleTable

      public static Map<String, OperationClassifier.HandlePolicy> handleTable()
      The single-cluster-handle table, for the completeness test.
    • escapingReturnTypes

      public static Set<Class<?>> escapingReturnTypes()
      Return types that make a method a single-cluster handle, for the completeness test.
    • spaceInterface

      public static Class<?> spaceInterface()
      Sanity check used by the completeness test: does the table cover all of GigaSpace?