Class RestApiServer

java.lang.Object
com.loomcache.server.rest.RestApiServer
All Implemented Interfaces:
AutoCloseable

@Deprecated(since="1.0", forRemoval=false) public class RestApiServer extends Object implements AutoCloseable
Deprecated.
REST ingress is de-scoped pending proper authentication and Raft consensus integration. Do not enable in production.
Experimental REST API server using Java's built-in HttpServer.

STATUS: INTENTIONALLY DISABLED / DE-SCOPED

This REST ingress layer is not production-ready and is intentionally disabled. Both start() and startUnsafeDirectApi() throw IllegalStateException because the current implementation bypasses two critical safety paths:

  1. Authentication -- direct registry access has no mTLS certificate validation or CN-based permission checks.
  2. Raft consensus -- mutations go straight to the local DataStructureRegistry without being proposed through the Raft log, breaking linearizability and replication guarantees.

The handler methods and router logic are retained so they can be wired into a proper auth + Raft pipeline in a future release. Until then, the only supported ingress path is the custom binary protocol via TcpServer.

Endpoint groups (for future reference):

  • Map operations: GET/PUT/DELETE/LIST/QUERY
  • Queue operations: OFFER/POLL/SIZE
  • Set operations: ADD/REMOVE/MEMBERS
  • Topic operations: PUBLISH/SUBSCRIBE (SSE)
  • Cluster operations: INFO/MEMBERS/HEALTH
See Also:
  • Constructor Details

    • RestApiServer

      public RestApiServer(int port, DataStructureRegistry registry)
      Deprecated.
      Create a REST API server bound to loopback (127.0.0.1) by default.
      Parameters:
      port - the port to listen on
      registry - the data structure registry
    • RestApiServer

      public RestApiServer(int port, String bindAddress, DataStructureRegistry registry)
      Deprecated.
      Create a REST API server bound to a specific address.
      Parameters:
      port - the port to listen on
      bindAddress - the address to bind to (e.g., "127.0.0.1" or "0.0.0.0")
      registry - the data structure registry
  • Method Details

    • start

      @Deprecated(since="1.0", forRemoval=false) public void start() throws IOException
      Deprecated.
      REST ingress is de-scoped. Use the binary protocol via TcpServer.
      Start the REST API server.

      Intentionally disabled. Always throws IllegalStateException because the current implementation bypasses authentication and Raft consensus. This method will be re-enabled once REST ingress is wired through the proper auth + Raft pipeline.

      Throws:
      IllegalStateException - always -- REST ingress is de-scoped
      IOException
    • startUnsafeDirectApi

      @Deprecated(since="1.0", forRemoval=false) public void startUnsafeDirectApi()
      Deprecated.
      REST ingress is de-scoped. Use the binary protocol via TcpServer.
      Legacy startup path retained only to preserve binary compatibility for callers that still instantiate the server directly.

      Intentionally disabled. Always throws IllegalStateException because direct registry-backed REST bypasses authentication and Raft consensus.

      Throws:
      IllegalStateException - always -- REST ingress is de-scoped
    • stop

      public void stop()
      Deprecated.
      Stop the REST API server.
    • setClusterInfoSuppliers

      public void setClusterInfoSuppliers(Map<String,Object> suppliers)
      Deprecated.
      Set cluster info suppliers (called from CacheNode to expose cluster state).
    • handleMapGet

      public void handleMapGet(HttpExchange exchange, String mapName, String key) throws IOException
      Deprecated.
      Handle GET /api/v1/maps/{mapName}/{key}
      Throws:
      IOException
    • handleMapPut

      public void handleMapPut(HttpExchange exchange, String mapName, String key) throws IOException
      Deprecated.
      Handle PUT /api/v1/maps/{mapName}/{key}
      Throws:
      IOException
    • handleMapDelete

      public void handleMapDelete(HttpExchange exchange, String mapName, String key) throws IOException
      Deprecated.
      Handle DELETE /api/v1/maps/{mapName}/{key}
      Throws:
      IOException
    • handleMapList

      public void handleMapList(HttpExchange exchange, String mapName, Map<String,String> queryParams) throws IOException
      Deprecated.
      Handle GET /api/v1/maps/{mapName} — list all keys with pagination
      Throws:
      IOException
    • handleMapQuery

      public void handleMapQuery(HttpExchange exchange, String mapName) throws IOException
      Deprecated.
      Handle POST /api/v1/maps/{mapName}/query — SQL query
      Throws:
      IOException
    • handleQueueOffer

      public void handleQueueOffer(HttpExchange exchange, String queueName) throws IOException
      Deprecated.
      Handle POST /api/v1/queues/{queueName}/offer
      Throws:
      IOException
    • handleQueuePoll

      public void handleQueuePoll(HttpExchange exchange, String queueName) throws IOException
      Deprecated.
      Handle POST /api/v1/queues/{queueName}/poll
      Throws:
      IOException
    • handleQueueSize

      public void handleQueueSize(HttpExchange exchange, String queueName) throws IOException
      Deprecated.
      Handle GET /api/v1/queues/{queueName}/size
      Throws:
      IOException
    • handleSetAdd

      public void handleSetAdd(HttpExchange exchange, String setName) throws IOException
      Deprecated.
      Handle POST /api/v1/sets/{setName}/add
      Throws:
      IOException
    • handleSetRemove

      public void handleSetRemove(HttpExchange exchange, String setName, String element) throws IOException
      Deprecated.
      Handle DELETE /api/v1/sets/{setName}/{element}
      Throws:
      IOException
    • handleSetMembers

      public void handleSetMembers(HttpExchange exchange, String setName) throws IOException
      Deprecated.
      Handle GET /api/v1/sets/{setName}/members
      Throws:
      IOException
    • handleTopicPublish

      public void handleTopicPublish(HttpExchange exchange, String topicName) throws IOException
      Deprecated.
      Handle POST /api/v1/topics/{name}/publish
      Throws:
      IOException
    • handleTopicSubscribe

      public void handleTopicSubscribe(HttpExchange exchange, String topicName)
      Deprecated.
      Handle GET /api/v1/topics/{name}/subscribe (Server-Sent Events)
    • handleClusterInfo

      public void handleClusterInfo(HttpExchange exchange) throws IOException
      Deprecated.
      Handle GET /api/v1/cluster/info
      Throws:
      IOException
    • handleClusterMembers

      public void handleClusterMembers(HttpExchange exchange) throws IOException
      Deprecated.
      Handle GET /api/v1/cluster/members
      Throws:
      IOException
    • handleClusterHealth

      public void handleClusterHealth(HttpExchange exchange) throws IOException
      Deprecated.
      Handle GET /api/v1/cluster/health
      Throws:
      IOException
    • close

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