Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.observation.annotation.Observed;
import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
Expand Down Expand Up @@ -428,7 +428,7 @@ public SolrMetrics getCollectionStats(
QueryResponse statsResponse = solrClient.query(actualCollection, new SolrQuery(ALL_DOCUMENTS_QUERY).setRows(0));

return new SolrMetrics(buildIndexStats(lukeResponse), buildQueryStats(statsResponse),
fetchCacheMetrics(actualCollection), fetchHandlerMetrics(actualCollection), new Date());
fetchCacheMetrics(actualCollection), fetchHandlerMetrics(actualCollection), Instant.now());
}

/**
Expand Down Expand Up @@ -967,10 +967,10 @@ public SolrHealthStatus checkHealth(@McpToolParam(description = "Solr collection
new SolrQuery(ALL_DOCUMENTS_QUERY).setRows(0));

return new SolrHealthStatus(true, null, pingResponse.getElapsedTime(),
statsResponse.getResults().getNumFound(), new Date(), actualCollection, null, null);
statsResponse.getResults().getNumFound(), Instant.now(), actualCollection, null, null);

} catch (Exception e) {
return new SolrHealthStatus(false, e.getMessage(), null, null, new Date(), actualCollection, null, null);
return new SolrHealthStatus(false, e.getMessage(), null, null, Instant.now(), actualCollection, null, null);
}
}

Expand Down Expand Up @@ -1027,6 +1027,6 @@ public CollectionCreationResult createCollection(
CollectionAdminRequest.createCollection(name, effectiveConfigSet, effectiveShards, effectiveRf)
.process(solrClient);

return new CollectionCreationResult(name, true, "Collection created successfully", new Date());
return new CollectionCreationResult(name, true, "Collection created successfully", Instant.now());
}
}
8 changes: 4 additions & 4 deletions src/main/java/org/apache/solr/mcp/server/collection/Dtos.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Date;
import java.time.Instant;

/**
* Data Transfer Objects (DTOs) for the Apache Solr MCP Server.
Expand Down Expand Up @@ -104,7 +104,7 @@ record SolrMetrics(
HandlerStats handlerStats,

/** Timestamp when these metrics were collected, formatted as ISO 8601 */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") Date timestamp) {
@JsonFormat(shape = JsonFormat.Shape.STRING) Instant timestamp) {
}

/**
Expand Down Expand Up @@ -464,7 +464,7 @@ record SolrHealthStatus(
Long totalDocuments,

/** Timestamp when this health check was performed, formatted as ISO 8601 */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") Date lastChecked,
@JsonFormat(shape = JsonFormat.Shape.STRING) Instant lastChecked,

/** Name of the collection that was checked */
String collection,
Expand Down Expand Up @@ -497,5 +497,5 @@ record CollectionCreationResult(
String message,

/** Timestamp when the collection was created, formatted as ISO 8601 */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") Date createdAt) {
@JsonFormat(shape = JsonFormat.Shape.STRING) Instant createdAt) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void testCheckHealth_healthy() {
assertEquals((long) DOC_COUNT, status.totalDocuments(), "Health check should report indexed document count");

assertNotNull(status.lastChecked());
assertTrue(System.currentTimeMillis() - status.lastChecked().getTime() < 5000);
assertTrue(java.time.Duration.between(status.lastChecked(), java.time.Instant.now()).toMillis() < 5000);
}

@Test
Expand Down