Architecture

The Auto Configuration Server (ACS) measures the devices. The FCC Service owns the campaigns and the verdicts.

Why the ACS link is queues only

The ACS and the FCC Service do not know each other. There is no SOAP client and no REST call between them. Neither configuration holds the address of the other. The only channel is a fixed set of five Hazelcast queues. See Hazelcast queues.

This design gives three benefits:

Independent releases: each side ships on its own schedule. The queue message is the only coupling.

One contract: every queue has exactly one message shape. The shape is defined once and copied into both repositories.

No impact on Group Update: the FCC code in the ACS is a separate module. The old fcc code and Update Group stay untouched.

The design has a real cost. There is no immediate accept or reject. The service puts an ACTIVATE command on a queue. At that moment it cannot know whether the ACS will ever read the command.

Three rules compensate:

  • Every command carries an acknowledgement. The service matches it by idempotencyKey and commandSeq. See How an acknowledgement is matched.

  • A missing acknowledgement triggers republication with a growing delay. The timeout is ft.fcc.command-ack-timeout, 60 seconds by default.

  • Hazelcast is a hard dependency for both sides. Without the cluster no campaign moves forward. The service also cannot tell a cluster outage from an ACS outage.

No authentication of its own

The FCC Service has no authentication. It has no user store and no tokens. Two rules protect it instead:

  1. The service port stays inside the Docker network. Nothing maps it to the host or to an ingress.

  2. The portal reaches the service only through the UI Backend. The UI Backend authenticates the user, resolves the domain scope and adds the identity headers.

The service trusts those headers without a check. A request without the X-FT-Domain-Scope header is refused with HTTP 403. The service never falls back to a default scope. See Identity contract.

FCC diagnostics has no role model. Access means one thing: the FCC menu item is visible in the portal. Inside the service the domain scope is the only further limit.

Why the service keeps an audit trail

Every caller may create, activate, stop, pause and delete any campaign in a visible domain. No permission can prevent an action, so the service records who acted and when.

The four audit columns on each table are not enough. They show the last writer of a row, and a deleted campaign leaves no row. Lifecycle actions therefore go to a separate append-only trail. See fcc_audit.

An empty user_id means the service acted by itself. The scheduled-campaign poller and the daily reactivation create runs without a user request.

Schema ownership

The service uses four schemas under four different rules.

Schema Access Rule

ftfcc

Read and write

Owned by this service. Liquibase migrates it, and nothing else does. See ftfcc schema.

ftacs

Read-only

Owned by the ACS. A dedicated account holds SELECT rights on a fixed table list. The service reads those tables and writes nothing.

ClickHouse ftacs_qoe_ui_data

Shared

Quality of Experience (QoE) monitoring already owns diag_speed_test and diag_ip_ping there. This service owns fcc_result_speed and fcc_result_latency. Flyway migrates them under its own history table flyway_schema_history_fcc. See ClickHouse schema.

iotw

Read-only, optional

Owned by the UI Backend. The service reads two tables for the saved device conditions. The pool is lazy and has no transaction manager. Without this grant the service starts and refuses only one device source. See The iotw grant.

Liquibase cannot run on the ftacs schema. Liquibase needs to create and lock its own two tables, and the read-only account has no such rights. The service checks the schema at startup instead. One catalog query per database vendor confirms every table and column. See Startup checks.

The same check runs for the two iotw tables. There it only warns, because a missing grant costs one device source and not the service. See The iotw grant check.

Campaign states

The portal shows the state of every campaign.

State Meaning

Not active

The campaign is idle. It never ran, or an operator stopped it. You can activate it again.

Scheduled

An operator booked a start time. The campaign waits for that time.

Running

A run is live on the fleet.

Scheduled for reactivation

A daily campaign finished one run and waits for the next day.

Paused

An operator paused the campaign and means to come back to it. The live run is already stopped.

Stopped

The ACS or an outage ended the run. Nobody asked for it.

Completed

Every planned run finished.

Error

The run failed. The ACS refused the command, or it reported a failure.

Archived

The campaign comes from the legacy FCC import. You cannot run, schedule or edit it.

Two states look similar and are not:

Not active: the operator stopped the campaign.

Stopped: something else stopped it.

A stop and a pause do the same work on the fleet. Both clear the booked time, stop the live run and cancel the planned runs. A pause differs in one point only: it records that the operator means to return. Neither state keeps a position, so a new activation always starts a new run.

Run states

A run is one execution of a campaign. The portal reports a run state per run.

State Meaning

Planned

The service created the run for a future day. It sent no command yet.

Dispatching

The command is on the queue. The service waits for the acknowledgement of the ACS.

Running

The ACS measures the fleet.

Stopping

A stop is sent. Measurements from devices in flight still arrive.

Stopped

The run ended after a stop.

Finished

The run completed its window.

Failed

The ACS refused the command, or it reported a failure.

A stopped run never reopens. A finished run never reopens. Late reports from the ACS are logged and dropped. Reports from a closed run must not change a regulatory report.

Component view

fcc-architecture-components

One thread reads each inbound queue: fccCommandAck, fccResultQueue, fccDeviceStateQueue and fccActivationEventQueue. See Messaging for the full queue specification.

State transitions

Every change of a campaign state and of a run state follows one of the two tables below. Any combination outside a table is refused.

A refusal is a normal outcome and not a failure. A Hazelcast queue delivers every message at least once. Two producers share no order. A republished command therefore produces a second acknowledgement. An ACS after a failover reports a run this service closed minutes ago.

A refused queue message is logged and dropped. A refused user request answers HTTP 409 and names the state.

What a transition writes

A transition writes more than the state column. The table below names every further write. The service performs the write in the same transaction as the state change.

Table Effect What the service writes

fcc_test

CLEAR_SCHEDULED_AT

Sets fcc_test.scheduled_at to null. A leftover instant would let the scheduled poller claim the campaign a second time.

fcc_test

SET_SCHEDULED_AT

Writes the requested instant. The instant always comes from the request.

fcc_test

PLAN_REACTIVATION

Creates the next run as a PLANNED row with no command. The service plans a run only while the campaign still owes one.

fcc_test

STOP_ACTIVE_ACTIVATION

Stops the run the campaign owns now. The service finds that run by a query, so it may differ from the run of the current event.

fcc_activation

SET_STARTED_AT

Writes started_at once. The acknowledgement and the start event travel on different queues in any order. The measurement window is anchored on this column.

fcc_activation

RECOMPUTE_WINDOW_END

Sets window_end_at from the real started_at plus total_duration_h. A command delayed in the outbox still gets a full window. See ACTIVATE.

fcc_activation

SET_STOPPED_AT

Writes stopped_at once. The stop grace runs from this column. A repeated write would postpone the deadline forever.

fcc_activation

SET_FINISHED_AT

Writes finished_at. Every transition with this effect ends in a terminal state.

fcc_activation

PUBLISH_STOP_COMMAND

Writes a STOP into fcc_acs_outbox with a fresh idempotency key and a fresh command_seq. This is a new command and never a republication.

Campaign transition table

The table below is the specification. Any combination outside it is refused.

From Event To Effects

NOT_ACTIVE, STOPPED, COMPLETED, ERROR

ACTIVATE_IMMEDIATELY

RUNNING

CLEAR_SCHEDULED_AT

ACTIVATE_SCHEDULED

SCHEDULED

SET_SCHEDULED_AT

PAUSED

ACTIVATE_IMMEDIATELY

RUNNING

CLEAR_SCHEDULED_AT

ACTIVATE_SCHEDULED

SCHEDULED

SET_SCHEDULED_AT

USER_STOP

NOT_ACTIVE

CLEAR_SCHEDULED_AT

SCHEDULED

ACTIVATE_IMMEDIATELY

RUNNING

CLEAR_SCHEDULED_AT

ACTIVATE_SCHEDULED

SCHEDULED

SET_SCHEDULED_AT

SCHEDULE_DUE

RUNNING

CLEAR_SCHEDULED_AT

USER_STOP

NOT_ACTIVE

CLEAR_SCHEDULED_AT

SCHEDULED_FOR_REACTIVATION

REACTIVATION_DUE

RUNNING

 — 

ACTIVATE_IMMEDIATELY

RUNNING

CLEAR_SCHEDULED_AT, STOP_ACTIVE_ACTIVATION

USER_STOP

NOT_ACTIVE

STOP_ACTIVE_ACTIVATION

USER_PAUSE

PAUSED

STOP_ACTIVE_ACTIVATION

RUNNING

ACTIVATION_STARTED

RUNNING

 — 

USER_PAUSE

PAUSED

STOP_ACTIVE_ACTIVATION

USER_STOP

NOT_ACTIVE

STOP_ACTIVE_ACTIVATION

ACTIVATION_FAILED

ERROR

 — 

ACTIVATION_STOPPED

STOPPED

 — 

ACTIVATION_FINISHED, more reactivations left

SCHEDULED_FOR_REACTIVATION

PLAN_REACTIVATION

ACTIVATION_FINISHED, none left

COMPLETED

 — 

ARCHIVED

anything

denied

terminal and unreachable

Five rows carry more than the table shows.

RUNNING plus ACTIVATION_STARTED stays RUNNING on purpose. The service applies the acknowledgement first, so the start event only confirms a known fact. The confirmation may arrive twice. The service accepts the repeat instead of logging a denial.

USER_STOP leads to NOT_ACTIVE. Group Update behaves the same way: its stop returns the group to the Not active state. STOPPED is the word of the ACS, not the word of the operator.

RUNNING plus ACTIVATION_STOPPED leads to STOPPED, and only an unplanned end reaches this row. Three sources can feed the event: the run event consumer, the device state drain and the stop grace watchdog. All three skip the event after a stop or a pause by an operator. That guard also protects a pause. Without it an ACTIVATION_STOPPED would turn a pause into a stop. See Run events.

PAUSED plus USER_STOP leads to NOT_ACTIVE, and PAUSED is the only closed state with a stop. A stop of an already closed campaign answers HTTP 409 and names the state. That answer tells an operator with forty campaigns that somebody else closed one a minute earlier. A pause is different: the operator is meant to leave that state. A second USER_PAUSE stays denied, because nothing would change.

NOT_ACTIVE, PAUSED, STOPPED, ERROR and COMPLETED deny the three run events and still accept the two activate events. Re-running a closed campaign is a normal operation. Every run is its own row with its own settings snapshot.

Stopping a paused campaign carries CLEAR_SCHEDULED_AT and no STOP_ACTIVE_ACTIVATION. A pause leaves nothing on the ACS to stop. A stop and a pause run the same work on the fleet. By the time a campaign is PAUSED, every activation of the live run is closed locally or has a STOP on the ACS. Every planned reactivation is closed with it.

A run in the STOPPING state gets no second stop. Such a run drains under ft.fcc.stop-grace with its STOP already sent. A second command would burn a command sequence and repeat an instruction in progress.

Nothing can reopen the gap. PAUSED denies SCHEDULE_DUE and REACTIVATION_DUE. An activate event leaves PAUSED in the same transaction.

One consequence matters here. The draining run keeps stop_reason = USER_PAUSE, because the stop finds nothing to stamp again. The later ACTIVATION_STOPPED therefore never reaches the campaign, and a stopped campaign cannot move to STOPPED.

SCHEDULED_FOR_REACTIVATION plus ACTIVATE_IMMEDIATELY also carries STOP_ACTIVE_ACTIVATION. A campaign between daily runs already owns the next run as a PLANNED row. The operator asks for a different run now.

An abandoned row costs more than tidiness. The campaign moves to RUNNING, so RUNNING plus REACTIVATION_DUE is denied and the row stays PLANNED. The reactivation poller then claims that row on every tick forever. A row already in DISPATCHING or RUNNING is worse: it keeps measuring under a campaign on a different run.

A PLANNED row is closed locally with no command. A DISPATCHING or RUNNING row takes the normal STOP_REQUESTED path with a STOP for the ACS.

Two details of that stop matter.

  • It happens before fcc_test.command_seq is raised for the new run. The STOP must take the lower sequence number. Otherwise the ACS discards the new ACTIVATE as stale.

  • The reason is USER_STOP and not ERROR. An operator ended the old run, and nothing failed. That reason also keeps the later ACTIVATION_STOPPED away from the campaign.

ARCHIVED is unreachable in both directions. Only the legacy import writes it, for campaigns finished years ago in the old product. Nothing leads to ARCHIVED and nothing leads out of it.

Run transition table

A dash in the Stop reason column means null. Null means leave stop_reason unchanged, not clear it.

From Event To Stop reason Effects

PLANNED

DISPATCH

DISPATCHING

 — 

 — 

PLANNED, DISPATCHING

ACK_ACCEPTED

RUNNING

 — 

SET_STARTED_AT, RECOMPUTE_WINDOW_END

ACK_REJECTED

FAILED

ERROR

SET_FINISHED_AT

GIVE_UP

FAILED

ACS_UNAVAILABLE

SET_FINISHED_AT, PUBLISH_STOP_COMMAND

EVENT_STARTED

RUNNING

 — 

SET_STARTED_AT, RECOMPUTE_WINDOW_END

RUNNING

EVENT_STARTED

RUNNING

 — 

 — 

EVENT_FINISHED

FINISHED

 — 

SET_FINISHED_AT

EVENT_FAILED

FAILED

ERROR

SET_FINISHED_AT

WINDOW_EXPIRED

FINISHED

WATCHDOG

SET_FINISHED_AT

PLANNED, DISPATCHING, RUNNING

STOP_REQUESTED

STOPPING

from the context

SET_STOPPED_AT, PUBLISH_STOP_COMMAND

RUNNING, STOPPING

EVENT_STOPPED, in flight null or above 0

STOPPING

 — 

SET_STOPPED_AT

EVENT_STOPPED, in flight 0

STOPPED

 — 

SET_STOPPED_AT, SET_FINISHED_AT

STOPPING

IN_FLIGHT_DRAINED, STOP_GRACE_EXPIRED, EVENT_FINISHED, WINDOW_EXPIRED

STOPPED

 — 

SET_FINISHED_AT

STOPPED, FINISHED, FAILED

anything

denied

terminal

Four rows carry more than the table shows.

PLANNED or DISPATCHING plus EVENT_STARTED leads to RUNNING. The acknowledgement and the start event travel on different queues without a shared order. The ACS can start measuring and report it before this service applies the acknowledgement. A denial would strand a live run in DISPATCHING until the watchdog closed it.

EVENT_STOPPED splits on the in-flight count of the ACS. A positive count or an absent count keeps the run in STOPPING, because those devices still produce measurements. Only a count of zero closes the run at once. An absent count counts as positive on purpose: a wait costs time, and an early close costs measurements.

STOPPING plus EVENT_FINISHED leads to STOPPED, not to FINISHED. The decision of the operator is what the run history must show.

STOPPED, FINISHED and FAILED are terminal. No late event and no second watchdog tick leaves them.

A stop of a PLANNED run diverges from the table on purpose. Such a run has no command on the ACS, and its command_seq is still the placeholder 0. A STOP for it would consume a sequence number and name an unknown run. The service closes the row locally as STOPPED with no command. The endpoint then answers commandPublished: false. See POST /FCC/stop.

State diagrams

fcc-state-machine-test
fcc-state-machine-activation

Scheduled work

Five pollers drive the scheduled work of the service: the outbox dispatcher, the acknowledgement timeout poller, two due-work passes and two closing passes. See The five pollers for every cadence.

Each poller claims its due rows and holds the claim until it commits. Two instances therefore never dispatch the same campaign, and no distributed lock is needed. Poller state lives in the business row, for example fcc_test.state, fcc_activation.window_end_at and fcc_acs_outbox.next_attempt_at. After a crash there is no separate job store to reconcile. See ftfcc schema for the index behind each claim.

Each pass is its own transaction. A backlog of due campaigns and a backlog of due reactivations are independent. A failure inside a pass applies nothing, and the next tick claims the rows again.