Class ProgressTracker

java.lang.Object
neqsim.mcp.runners.ProgressTracker

public final class ProgressTracker extends Object
Progress tracking for long-running MCP simulations.

Provides a simple mechanism for runners to report progress that can be polled by agents via the get_progress tool. Each long-running operation creates a progress tracker identified by an operation ID. The tracker stores milestone events and percentage completion.

Usage in a runner:

String opId = ProgressTracker.start("dynamic_simulation", 100);
for (int step = 0; step < 100; step++) {
  // ... do work ...
  ProgressTracker.update(opId, step + 1, "Completed step " + (step + 1));
}
ProgressTracker.complete(opId, "Simulation finished successfully");
Version:
1.0
Author:
Even Solbraa
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
    • OPERATIONS

      private static final ConcurrentHashMap<String, ProgressTracker.OperationProgress> OPERATIONS
      Active progress trackers keyed by operation ID.
    • nextId

      private static long nextId
      Counter for generating unique operation IDs.
  • Constructor Details

    • ProgressTracker

      private ProgressTracker()
      Private constructor.
  • Method Details

    • start

      public static String start(String operationType, int totalSteps)
      Starts tracking a new long-running operation.
      Parameters:
      operationType - the type of operation (e.g., "dynamic_simulation", "parametric_sweep")
      totalSteps - the total number of steps expected
      Returns:
      the operation ID for polling
    • update

      public static void update(String operationId, int currentStep, String message)
      Updates progress for an operation.
      Parameters:
      operationId - the operation ID
      currentStep - the current step number (1-based)
      message - a status message
    • complete

      public static void complete(String operationId, String finalMessage)
      Marks an operation as complete.
      Parameters:
      operationId - the operation ID
      finalMessage - the completion message
    • fail

      public static void fail(String operationId, String errorMessage)
      Marks an operation as failed.
      Parameters:
      operationId - the operation ID
      errorMessage - the error message
    • getProgress

      public static String getProgress(String operationId)
      Gets the current progress for an operation.
      Parameters:
      operationId - the operation ID
      Returns:
      JSON with progress details
    • listActive

      public static String listActive()
      Lists all active (non-completed) operations.
      Returns:
      JSON with active operations
    • evictOldOperations

      private static void evictOldOperations()
      Removes completed operations older than 5 minutes.