Kinesis Data Analytics
Kinesis Data Analytics V2 emulates the control plane for Managed Service for Apache Flink. It stores application configuration and status, exposes AWS-shaped operation APIs, and can start a real Flink session cluster that runs application JARs from local S3. The service also keeps snapshots and tags with the application so the resource remains manageable across emulator restarts.
System model
The service has two linked parts. KinesisAnalyticsV2Service owns the durable application resource and its state transitions. FlinkContainerManager supplies the optional executable cluster and reports Flink readiness, job state, and savepoint state back to the service.
This diagram shows how an API request becomes persisted application state and, when needed, a running Flink job.
flowchart LR
API[Kinesis Analytics API] --> Control[Application control plane]
Control --> Store[Persisted application state]
Control --> Manager[Flink container manager]
Manager --> Cluster[JobManager and TaskManager]
Cluster --> REST[Flink REST API]
Manager --> S3[Local S3 application JAR]
Control --> Poller[Readiness and snapshot poller]
Poller --> REST
The cluster is optional. In mock mode, application operations use the control-plane state without starting Flink containers. In real mode, StartApplication provisions the cluster and the poller completes the transition after Flink is ready. Container behavior follows container orchestration.
Operation APIs
KinesisAnalyticsV2JsonHandler is the AWS-shaped API boundary. It accepts Kinesis Analytics V2 actions and converts request fields into the application model, while the service applies lifecycle rules and returns application, snapshot, tag, or dashboard data.
Operation groups
The API follows the resource lifecycle from creation to removal. It also exposes the metadata and runtime controls needed to operate an application.
| Operation group | Purpose |
|---|---|
| Application control | Create, describe, list, start, stop, update, and delete applications |
| Application configuration | Set Flink code location, parallelism, environment properties, and snapshot policy |
| Resource metadata | Add, remove, and list tags |
| Snapshot control | Create, describe, list, and delete application snapshots |
| Dashboard access | Return the running Flink dashboard endpoint |
References: src/…/KinesisAnalyticsV2JsonHandler.java• L40-61 src/…/KinesisAnalyticsV2JsonHandler.java• L64-102 src/…/KinesisAnalyticsV2JsonHandler.java• L141-232
Application configuration
An application can point to a Flink JAR in local S3 and set the parallelism used to run it. It can also carry grouped environment properties and a snapshot policy. The service preserves these values in the AWS property-group shape and makes them available to the Flink processes at runtime.
Updates require the current application version. A successful update advances that version and can change the service role, code location, parallelism, or snapshot policy. A code update on a running coded application redeploys the job without replacing its cluster.
References: src/…/KinesisAnalyticsV2JsonHandler.java• L64-89 src/…/KinesisAnalyticsV2JsonHandler.java• L155-183 src/…/KinesisAnalyticsV2JsonHandler.java• L333-366 src/…/KinesisAnalyticsV2Service.java• L340-426
Application lifecycle
An application is created as a durable READY resource with version 1. Creation validates its name, runtime, execution role, and tag count. It does not start compute, so the application has no live Flink cluster until StartApplication runs.
The main lifecycle is:
stateDiagram-v2
[*] --> READY: CreateApplication
READY --> STARTING: StartApplication in real mode
READY --> RUNNING: StartApplication in mock mode
STARTING --> RUNNING: Flink REST and job ready
RUNNING --> STARTING: Code update and redeploy
RUNNING --> READY: StopApplication
STARTING --> READY: StopApplication
READY --> [*]: DeleteApplication
In real mode, a coded application remains STARTING until its Flink job reaches RUNNING. An application without code becomes a bare running cluster when its JobManager is ready. StopApplication cancels the job and removes the cluster, but preserves the savepoint storage. DeleteApplication requires the application to be stopped and removes both the resource and its savepoint storage.
The readiness poller checks all persisted applications. It retries temporary Flink health failures and persists state when a job ID or terminal status changes. This lets the control plane recover its view of a cluster without making the API request wait for the full container and job startup.
References: src/…/KinesisAnalyticsV2Service.java• L158-215 src/…/KinesisAnalyticsV2Service.java• L258-337 src/…/KinesisAnalyticsV2Service.java• L367-451 src/…/KinesisAnalyticsV2Service.java• L661-700 src/…/ApplicationStatus.java• L5-23
Version and resource identity
The application version is the concurrency guard for updates. The caller must provide the version it last read, which prevents a stale update from silently replacing newer configuration. Application lookup also uses the account, region, and application ARN so the same name can be scoped correctly.
Tags belong to the application ARN and are limited to 50 user-defined tags. The dashboard operation accepts FLINK_DASHBOARD_URL for a running application and returns the live JobManager endpoint. It is not a signed URL because the emulator does not provide an IAM-backed session proxy.
References: src/…/KinesisAnalyticsV2Service.java• L367-378 src/…/KinesisAnalyticsV2Service.java• L469-495 src/…/KinesisAnalyticsV2Service.java• L605-659
Flink cluster management
FlinkContainerManager supplies a standalone Flink session cluster for each real application. The cluster has a JobManager for the REST and dashboard endpoint. A coded application also gets a TaskManager with enough slots for its requested parallelism. The TaskManager shares the JobManager network namespace so the two processes can communicate while the cluster can still reach the emulator's Docker network.
Runtime and code delivery
The runtime catalog maps supported RuntimeEnvironment values to Apache Flink images. Operators can provide one image override for all applications. Unsupported runtimes fail validation before an application is created.
When a coded application starts, the manager reads its JAR from local S3 before creating containers. After the JobManager is ready and the TaskManager has enough slots, it uploads and runs the JAR through the Flink REST API. A bare application skips job deployment and uses the JobManager as its running cluster.
The manager writes the grouped environment properties to the standard Managed Service for Apache Flink application-properties file in both Flink containers. This gives user code the same property source on the JobManager and TaskManager. It also configures structured logs with the application ARN and version for downstream log consumers.
References: src/…/KinesisAnalyticsRuntimes.java• L25-97 src/…/FlinkContainerManager.java• L42-55 src/…/FlinkContainerManager.java• L137-259 src/…/FlinkContainerManager.java• L384-443
Cluster replacement and redeployment
Stopping an application removes the TaskManager before the JobManager because the TaskManager uses the JobManager's network namespace. Starting the application again creates fresh containers and reuses the application's named savepoint storage.
When code changes on a running coded application, the manager cancels the current job, refreshes the property file, and stages the new JAR. The readiness poller submits the replacement when slots are available. Adding code for the first time to a running bare cluster is not supported; the application must be stopped and started again.
References: src/…/FlinkContainerManager.java• L445-501 src/…/KinesisAnalyticsV2Service.java• L396-419
Flink REST coordination
FlinkRestClient separates health probes from deployment actions. REST, slot, job-state, and savepoint-status probes treat network or response errors as unavailable so the poller can retry. JAR upload, job start, and savepoint-trigger requests surface failed responses to the operation that started them.
This separation keeps a booting or briefly unavailable cluster in STARTING without hiding a real deployment or savepoint failure. A failed job submission is marked so the poller does not submit the same bad artifact on every tick.
References: src/…/FlinkRestClient.java• L17-24 src/…/FlinkRestClient.java• L35-143 src/…/FlinkRestClient.java• L145-196 src/…/FlinkContainerManager.java• L410-443
Snapshot lifecycle
An application snapshot represents a Flink savepoint and has no independent resource lifecycle. The application must be RUNNING, have a deployed job, and have snapshots enabled before it can create one.
The savepoint flow has two stages:
- The manager asks Flink to start an asynchronous savepoint and stores the returned request identity.
- The readiness poller checks the operation until Flink reports success or failure. A successful snapshot stores the savepoint location.
The savepoint files live in a named volume tied to the application. StopApplication preserves that volume so snapshots remain available after a later start. Deleting the application removes the volume. Deleting an individual completed snapshot removes its files when the JobManager is available, then removes its application metadata.
References: src/…/KinesisAnalyticsV2Service.java• L497-595 src/…/FlinkContainerManager.java• L503-599 src/…/Snapshot.java• L9-13 src/…/SnapshotStatus.java• L5-15
Change checklist
When these files or sections are changed, remember to consider these:
- If a runtime is added or removed, update runtime validation, image selection, and the configured image override as one contract.
- If application states change, keep API status output, readiness polling, container teardown, and persisted recovery behavior aligned.
- If code-location or environment-property fields change, update API parsing, application persistence, S3 loading, and the Flink property file together.
- If update behavior changes, preserve the version check and the distinction between in-place redeployment and first-time code attachment.
- If snapshot behavior changes, preserve the split between application metadata, asynchronous Flink status, and named-volume cleanup.
- If REST paths or response fields change, update readiness, deployment, job-state, and savepoint polling as one interface.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Unsupported runtime or missing or empty S3 JAR | Creation or start fails before an unusable coded cluster is left behind | Runtime validation and code loading before container creation |
| JobManager starts but TaskManager fails | The partial cluster is removed | Start rollback removes the TaskManager and JobManager |
| Flink REST is not ready or has too few slots | The application stays STARTING while the poller retries | Health probes report unavailable and readiness waits for slots |
| JAR submission fails | The same bad artifact is not submitted on every poll | Submission failure blocks retries until a new start or redeploy |
| Savepoint trigger or Flink savepoint fails | The snapshot becomes FAILED instead of usable | Trigger errors and completed savepoint failure are handled separately |
| Savepoint status probe is unavailable | The snapshot remains in progress until Flink responds | Read-only probe errors are treated as transient |
| Update uses a stale application version | The configuration change is rejected | CurrentApplicationVersionId must match the stored version |
| Application is deleted instead of stopped | The savepoint volume and its files are lost | Deletion requires READY and removes persistent storage only then |
Key files
| File | Why to read it |
|---|---|
| src/…/KinesisAnalyticsV2JsonHandler.java | API actions, request mapping, and AWS-shaped responses |
| src/…/KinesisAnalyticsV2Service.java | Application lifecycle, version checks, persistence, snapshots, tags, and readiness polling |
| src/…/FlinkContainerManager.java | Cluster provisioning, code delivery, runtime properties, savepoints, redeployment, and teardown |
| src/…/FlinkRestClient.java | Flink health checks, job operations, and asynchronous savepoint status |
| src/…/KinesisAnalyticsRuntimes.java | Supported runtime and image mapping |
| src/…/FlinkApplication.java and Snapshot.java | Durable application configuration and embedded snapshot state |
| src/…/S3Service.java | Source of application JAR bytes |