Host adapter cache

  • Trace adapter-chain lookups and compare refresh-in-place with validated replacement of an entire cache generation.
Diagram phase
100%

Component responsibilities

Request path · one host classloaderConfiguration refreshChannel and service select the host adapter chainRequest / lookupControl / decisionFailure handlingRead / supplyselectkeyrunreadbuildclear + refillno matchPre-executionvalidationChain lookupLocal adapter mapOrderedadaptersAdapter configin OraclePeriodic loaderReplacemententriesMissing / emptychainselectkeyrunreadbuildclear + refillno match

Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.

  • An adapter chain is an ordered list of checks selected by channel, service and category. The Oracle configuration feeds a separate in-memory lookup on each serving member.
  • A request arriving between clearing and refilling a chain can see an empty mapping. That matters most when the missing adapter enforces a required check.
  • The lookup key joins channel, executing service and category. Multiple adapters under that key execute in sequence.
  • A timer reloads the classloader-local map. A reload can race with a request even when individual map operations are synchronized by the writer.
Host adapter selection

Host adapter selection

LCM host pre-execution policy · proposed refresh contract

Locate the hot read in the request path

  • A host policy runs mandatory validation, then selects the adapter chain for the channel, executing service and category.
  • ChannelServiceAdapterSingleton groups entries by the composite key. The getter sorts configured sequence numbers, then the policy runner invokes the selected adapters. An empty result yields no adapters from this lookup. Mandatory validation has its own execution boundary.
  • The loader reads channel/service adapter configuration, builds a replacement map and refreshes the singleton on a ten-minute timer. Each classloader owns its own copy.
  • Allowance and utilization use business data. Recheck them in the transaction accepting the operation. An adapter lookup can select which checks to run; the cached chain cannot reserve the customer’s remaining amount.

Walk a policy edit while two members serve

Event Effect in the current mechanism Failure to test
Commit a changed adapter sequence Two timers may pick up the revision on different cycles Same request class can select different sequences on A and B.
Reader overlaps refill Writer clears and refills the shared map under a lock; the getter does not acquire that lock A getter can see an absent or incomplete chain between clear and refill.
Database read fails A failed read can reach population without rows Distinguish a failed fetch from an intentional empty policy before replacing working rules.
New member loads under pressure Its initial load and periodic task consume JDBC/CPU while ready peers may already have usable copies Measure startup, reload skew and resource use per member.
  • Ten minutes is the periodic scheduling interval. Query failure, slow loading and a member restart affect how long a generation can be used.

Publish a validated generation through one reference

  • Preserve the local hot read. Have one writer per member build a fresh key-to-ordered-chain map from a consistent committed version. Deep-freeze the lists as well as the enclosing map.
  • For each key, validate sequence order and adapter availability. Represent an intentionally empty optional mapping explicitly. For a required chain, a missing key yields a controlled refusal.
  • Replace the active reference in one atomic operation. A request takes that reference once; concurrent requests see either the old complete chain or the new complete chain.
  • Keep a minimum allowed version for revocations/mandatory policy. On failed reload, retain last-known-good only when that version meets the route contract. Without an acceptable generation, reject that route and alert its owner.
  • A committed change hint may speed refresh. Retain periodic version reconciliation for missed hints; fence late results against the highest committed version known to that member.
  • For a revocation that must apply immediately, the request needs a trusted current minimum version, or traffic must pause until every eligible member acknowledges it. A member that missed a hint cannot infer a newer minimum from its own old copy.
Illustrative channel/service adapter release contractjson
{
  "purpose": "Illustrative acceptance cases for an immutable host adapter-policy generation",
  "policyKey": {"channel": "sample-channel", "service": "offer-operation", "category": "sample-category"},
  "committedVersion": 8,
  "requiredMinimumVersion": 8,
  "orderedChain": [{"sequence": 1, "adapter": "validate-input"}, {"sequence": 2, "adapter": "check-operation-policy"}],
  "cases": [
    {"input": "Complete version 8 after validating every required adapter", "expect": "Publish one immutable generation"},
    {"input": "Version 7 builder completes late", "expect": "Keep version 8 active"},
    {"input": "Query fails while 8 is required and only 7 is available", "expect": "Reject this required route; do not install empty configuration"},
    {"input": "Successful version 9 explicitly disables an optional route chain", "expect": "Install intentional empty optional mapping; keep mandatory validation"},
    {"input": "Member B misses the commit notification", "expect": "Polling eventually detects the new version; urgent revocation requires an authoritative minimum or a traffic hold until every serving member acknowledges it"}
  ]
}

Prove policy behavior before replacing the loader

  • Warm A and B, make the database read fail for A, and commit V8 removing a revoked adapter while B reloads. Capture selected chain/version for synthetic requests.
  • Force a slow V7 refresh to finish after V8, then restart one member with the config database unavailable. Test required, optional and unknown keys independently.
  • Compare selection latency, refresh duration, allowed staleness and heap at peak build time. Holding active and candidate generations uses additional memory.
  • Retain a compatible version through rollback; replay the versioned configuration and keep revocations enforced. Introduce replicated cache infrastructure only if a measured requirement justifies its consistency and outage dependencies.