com.instaclustr.cassandra.sidecar.resource.CassandraConfigResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cassandra-sidecar Show documentation
Show all versions of cassandra-sidecar Show documentation
Sidecar for Apache Cassandra
package com.instaclustr.cassandra.sidecar.resource;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
@Path("/config")
@Produces("application/yaml")
public class CassandraConfigResource {
@GET
public Response getCassandraConfiguration() {
try {
final Optional cassandraYaml = Files.walk(Paths.get("/var/lib/cassandra")).filter(p -> {
String name = p.toFile().getName();
return name.startsWith("cassandra") && name.endsWith(".yaml");
}).findFirst();
if (cassandraYaml.isPresent()) {
return Response.ok(new String(Files.readAllBytes(cassandraYaml.get())), "application/yaml").build();
} else {
return Response.status(NOT_FOUND).build();
}
} catch (final Exception ex) {
return Response.serverError().build();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy