Skip to content

feat(client): implement lifecycle operations and support reconnecting to existing sessions#24

Merged
camory merged 2 commits intomainfrom
client_session_lifecycle
Nov 19, 2025
Merged

feat(client): implement lifecycle operations and support reconnecting to existing sessions#24
camory merged 2 commits intomainfrom
client_session_lifecycle

Conversation

@camory
Copy link
Copy Markdown
Collaborator

@camory camory commented Nov 17, 2025

Pull Request Description

Summary

This PR introduces complete support for session retrieval and lifecycle management .
It expands the SessionHandle API, enhances the underlying gRPC mapping layer,.

This feature aligns the Java SDK with the full lifecycle exposed by the Sessions service (Create, Get, Pause, Resume, Cancel, Close, Purge, Delete).


Motivation

Sessions in ArmoniK are long-lived entities and can be reused across client restarts.
Until now, the Java SDK only supported:

  • openSession()
  • Task submission

But not:

  • reconnecting to an existing session
  • performing lifecycle actions from the SDK
  • obtaining structured lifecycle information (SessionState)

This PR completes the feature set and makes the Java SDK consistent with the official session lifecycle defined in ArmoniK.


Changes

✔️ Public API

New in SessionHandle

All lifecycle operations are now available:

  • cancel()
  • pause()
  • resume()
  • close()
  • purge()
  • delete()

Each method:

  • calls the matching gRPC RPC (CancelSession, PauseSession, etc.)
  • returns a CompletionStage<SessionState>
  • uses the new unified SessionState record

ArmoniKClient

  • Added getSession(SessionId) and getSession(SessionId, BlobCompletionListener)
  • Added deleteSession(SessionId) as a convenience API

SessionState

  • New public record representing the complete state of a session:
    • status, submission flags, partition IDs
    • task configuration defaults
    • timestamps (created, cancelled, paused, closed, purged, deleted)
    • duration

Full Javadoc added.


✔️ Testing

Mapping tests

Added SessionMapperTest to ensure correct mapping of:

  • timestamps
  • duration
  • partition IDs
  • task configuration
  • null-handling

Wiring tests

Extended SessionHandleTest to cover all lifecycle RPCs with minimal, high-value assertions:

  • verifies correct RPC invoked
  • verifies correct sessionId passed
  • verifies CompletionStage completes without exception
    (no redundant state assertions—mapping is already tested)

Backward compatibility

This PR is fully backward compatible:

  • No existing public APIs are changed
  • All new APIs are purely additive
  • Existing behavior of openSession() and task submission untouched

* @see SessionHandle#delete()
* @see SessionState
*/
public CompletionStage<SessionState> deleteSession(SessionId sessionId) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the delete here ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have replaced it by closeSession()

@camory camory force-pushed the client_session_lifecycle branch from 5f74847 to 00f0373 Compare November 18, 2025 14:26
@camory camory requested a review from aneojgurhem November 18, 2025 15:26
aneojgurhem
aneojgurhem previously approved these changes Nov 18, 2025
@camory camory merged commit 5c97172 into main Nov 19, 2025
3 checks passed
@camory camory deleted the client_session_lifecycle branch November 19, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants