This document describes the REST APIs provided by DistributedStorage.
All API endpoints are relative to the base URL:
http://<host>:<port>/api/v1
Authentication is performed using the X-User-ID header, which should contain the unique identifier for the user making the request.
Example:
X-User-ID: 123
Uploads a file to the distributed storage system.
Endpoint: POST /files/upload
Headers:
X-User-ID: User identifier (required)Content-Type:multipart/form-data
Request Parameters:
file: The file to upload (required)
Response:
{
"fileId": 123,
"fileName": "example.pdf",
"fileSize": 1024,
"contentType": "application/pdf",
"timestamp": "2025-02-27T14:30:45.123Z",
"nodeId": "container-456"
}Status Codes:
200 OK: File uploaded successfully400 Bad Request: Invalid request500 Internal Server Error: Server error
Downloads a file from the storage system.
Endpoint: GET /files/{fileId}
Path Parameters:
fileId: Unique identifier of the file (required)
Headers:
X-User-ID: User identifier (required)
Response:
- File content with appropriate Content-Type header
Status Codes:
200 OK: File downloaded successfully404 Not Found: File not found500 Internal Server Error: Server error
Deletes a file from the storage system.
Endpoint: DELETE /files/{fileId}
Path Parameters:
fileId: Unique identifier of the file (required)
Headers:
X-User-ID: User identifier (required)
Status Codes:
204 No Content: File deleted successfully404 Not Found: File not found500 Internal Server Error: Server error
Registers a new storage node with the system.
Endpoint: POST /nodes/register
Request Body:
{
"containerId": 12345,
"containerName": "storage-node-1",
"hostAddress": "192.168.1.100",
"port": 8081,
"capacity": 1073741824
}Response:
{
"status": "success",
"message": "Node registered successfully",
"nodeId": 12345
}Status Codes:
200 OK: Node registered successfully400 Bad Request: Invalid request500 Internal Server Error: Server error
Updates the status and metrics of a registered node.
Endpoint: POST /nodes/heartbeat
Request Body:
{
"containerId": 12345,
"status": "ACTIVE",
"usedSpace": 536870912
}Response:
{
"status": "success",
"message": "Heartbeat processed successfully"
}Status Codes:
200 OK: Heartbeat processed successfully400 Bad Request: Invalid request500 Internal Server Error: Server error
Retrieves the health status of a specific node.
Endpoint: GET /health/status/{nodeId}
Path Parameters:
nodeId: Node identifier (required)
Response:
{
"nodeId": "12345",
"healthy": true,
"lastChecked": "2025-02-27T14:35:22.456Z",
"responseTime": 45,
"statusMessage": "OK"
}Status Codes:
200 OK: Health status retrieved successfully404 Not Found: Node not found500 Internal Server Error: Server error
Retrieves the health status of all active nodes.
Endpoint: GET /health/status
Response:
{
"12345": {
"nodeId": "12345",
"healthy": true,
"lastChecked": "2025-02-27T14:35:22.456Z",
"responseTime": 45,
"statusMessage": "OK"
},
"67890": {
"nodeId": "67890",
"healthy": false,
"lastChecked": "2025-02-27T14:35:10.123Z",
"responseTime": 1200,
"statusMessage": "Connection timeout"
}
}Status Codes:
200 OK: Health statuses retrieved successfully500 Internal Server Error: Server error
Retrieves system-wide performance metrics.
Endpoint: GET /metrics/stats
Response:
{
"totalRequests": 15240,
"successfulRequests": 15180,
"failedRequests": 60,
"averageResponseTime": 156.7,
"p95ResponseTime": 325.4,
"p99ResponseTime": 496.2
}Status Codes:
200 OK: Metrics retrieved successfully500 Internal Server Error: Server error
Retrieves performance metrics for a specific node.
Endpoint: GET /metrics/node/{nodeId}
Path Parameters:
nodeId: Node identifier (required)
Response:
{
"totalRequests": 5240,
"successfulRequests": 5228,
"failedRequests": 12,
"averageResponseTime": 145.3,
"p95ResponseTime": 312.8,
"p99ResponseTime": 476.5
}Status Codes:
200 OK: Metrics retrieved successfully404 Not Found: Node not found500 Internal Server Error: Server error
Retrieves performance metrics for all active nodes.
Endpoint: GET /metrics/nodes
Response:
{
"12345": {
"totalRequests": 5240,
"successfulRequests": 5228,
"failedRequests": 12,
"averageResponseTime": 145.3,
"p95ResponseTime": 312.8,
"p99ResponseTime": 476.5
},
"67890": {
"totalRequests": 6120,
"successfulRequests": 6105,
"failedRequests": 15,
"averageResponseTime": 162.1,
"p95ResponseTime": 338.5,
"p99ResponseTime": 510.7
}
}Status Codes:
200 OK: Metrics retrieved successfully500 Internal Server Error: Server error
Retrieves a summary of the entire system's state and performance.
Endpoint: GET /metrics/summary
Response:
{
"globalStats": {
"totalRequests": 15240,
"successfulRequests": 15180,
"failedRequests": 60,
"averageResponseTime": 156.7,
"p95ResponseTime": 325.4,
"p99ResponseTime": 496.2
},
"activeNodes": 8,
"totalRequests": 15240,
"avgResponseTime": 156.7
}Status Codes:
200 OK: Summary retrieved successfully500 Internal Server Error: Server error
Selects an appropriate node for a file operation based on the specified strategy.
Endpoint: GET /loadbalancer/node
Query Parameters:
strategy: Load balancing strategy to use (optional)fileSize: Size of the file in bytes (required)
Response:
{
"containerId": 12345,
"containerName": "storage-node-1",
"hostAddress": "192.168.1.100",
"port": 8081,
"capacity": 1073741824,
"usedSpace": 536870912,
"status": "ACTIVE",
"createdAt": "2025-01-15T10:30:00.000Z"
}Status Codes:
200 OK: Node selected successfully404 Not Found: No suitable node found500 Internal Server Error: Server error
Notifies the load balancer that a request has been completed.
Endpoint: POST /loadbalancer/node/{nodeId}/complete
Path Parameters:
nodeId: Node identifier (required)
Status Codes:
200 OK: Notification successful500 Internal Server Error: Server error