Class CanaryDeployment

java.lang.Object
org.j7m.middleware.cluster.CanaryDeployment
All Implemented Interfaces:
AutoCloseable

public final class CanaryDeployment extends Object implements AutoCloseable
Quorum-backed canary traffic controller invoking real managed application endpoints. Each policy is CAS-versioned in the authenticated resource scope. Readiness is obtained through the lifecycle's live inspection. Missing/stale observations cause HOLD and cannot raise exposure. Bad candidate observations atomically disable candidate admission before lifecycle rollback/drain. Completion timeout is UNKNOWN: this class never retries an application invocation automatically. Metrics count calls made through this instance; restarting requires fresh minimum samples. Instances are thread-safe; close stops evaluation, not application effects or durable policies.
  • Constructor Details

    • CanaryDeployment

      public CanaryDeployment(String scope, org.j7m.middleware.distributed.ResourceEndpoint resources, ClusterLifecycle lifecycle, Map<String, ManagedInvocation> endpoints)
      Creates an automatically evaluated controller using measured local invocation outcomes.
      Parameters:
      scope - authenticated policy namespace, bounded deployment identity
      resources - scope-bound durable CAS endpoint
      lifecycle - concrete remote cluster lifecycle
      endpoints - actual managed invocation clients by node identity, 1..64
      Throws:
      IllegalArgumentException - for invalid scope or endpoint capacity
    • CanaryDeployment

      public CanaryDeployment(String scope, org.j7m.middleware.distributed.ResourceEndpoint resources, ClusterLifecycle lifecycle, Map<String, ManagedInvocation> endpoints, CanaryDeployment.ProbeReader probes)
      Creates a controller with an optional external observation adapter. The adapter must authenticate its source and return measurements for the supplied revision.
      Parameters:
      scope - authenticated namespace
      resources - durable CAS endpoint
      lifecycle - concrete cluster lifecycle
      endpoints - managed invocation clients by node
      probes - external probe reader, or null for local measured calls
      Throws:
      IllegalArgumentException - for invalid scope or endpoint capacity
  • Method Details

    • configure

      public CanaryDeployment.Status configure(String request, long expectedVersion, CanaryPolicy policy, Instant deadline) throws IOException
      Installs an increasing revision after fresh readiness/probe checks; retries use the same request ID.
      Parameters:
      request - stable authorized operation identity
      expectedVersion - expected resource version, zero for initial creation
      policy - new explicit traffic/threshold policy
      deadline - absolute deadline
      Returns:
      committed policy state
      Throws:
      IOException - for missing probes, readiness, CAS conflict or unknown commit
    • invoke

      public byte[] invoke(String requestId, String contract, byte[] payload, Instant deadline) throws IOException
      Invokes one actual managed endpoint selected by the durable policy and request identity. No fallback invocation follows an ambiguous error; applications must reconcile by request ID.
      Parameters:
      requestId - stable application request identity
      contract - exported application contract
      payload - application bytes passed unchanged
      deadline - absolute deadline
      Returns:
      managed application response
      Throws:
      IOException - on unavailable policy/owner or unknown application outcome
    • evaluate

      public CanaryDeployment.Status evaluate(Instant deadline) throws IOException
      Evaluates fresh readiness and measured error/mean-latency thresholds, resuming durable rollback.
      Parameters:
      deadline - absolute deadline for quorum/lifecycle operations
      Returns:
      latest durable state, or null before configuration
      Throws:
      IOException - for unavailable quorum or unknown lifecycle outcome
    • status

      public CanaryDeployment.Status status(Instant deadline) throws IOException
      Reads the current quorum-authoritative policy.
      Parameters:
      deadline - absolute deadline
      Returns:
      durable policy state, or null
      Throws:
      IOException - on unavailable quorum or unsupported encoding
    • metrics

      public Map<String,Long> metrics()
      Returns bounded identity-free controller counters.
      Returns:
      counts of hold observations and completed rollback evaluations
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable