Skip to content

Commit

Permalink
Add RepairRun GET resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Bj0rnen committed Dec 9, 2014
1 parent d5a6d09 commit d5b61b4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/spotify/reaper/ReaperApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.spotify.reaper.resources.ClusterResource;
import com.spotify.reaper.resources.PingResource;
import com.spotify.reaper.resources.RepairRunResource;
import com.spotify.reaper.resources.TableResource;
import com.spotify.reaper.service.RepairRunner;
import com.spotify.reaper.storage.IStorage;
Expand Down Expand Up @@ -60,10 +61,12 @@ public void run(ReaperApplicationConfiguration config,
final PingResource pingResource = new PingResource();
final ClusterResource addClusterResource = new ClusterResource(storage);
final TableResource addTableResource = new TableResource(config, storage);
final RepairRunResource addRepairRunResource = new RepairRunResource(storage);

environment.jersey().register(pingResource);
environment.jersey().register(addClusterResource);
environment.jersey().register(addTableResource);
environment.jersey().register(addRepairRunResource);

LOG.info("Reaper is ready to accept connections");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.Optional;

import com.spotify.reaper.core.RepairRun;
import com.spotify.reaper.storage.IStorage;

import org.slf4j.Logger;
Expand Down Expand Up @@ -43,12 +44,13 @@ public RepairRunResource(IStorage storage) {

@GET
@Path("/{id}")
public Response getCluster(@PathParam("id") Long repairRunId) {
public Response getRepairRun(@PathParam("id") Long repairRunId) {
LOG.info("get repair_run called with: id = {}", repairRunId);
return Response.ok().entity("not implemented yet").build();
RepairRun repairRun = storage.getRepairRun(repairRunId, null);
return Response.ok().entity(repairRun).build();
}

// We probably don't want to create repair runs with this resource,
// but actually only by posting the cluster resource.
// but actually only by posting the table resource.
// Get here is used only for providing visibility to what is going on with the run.
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TableResource(ReaperApplicationConfiguration config, IStorage storage) {

@GET
@Path("/{clusterName}/{keyspace}/{table}")
public Response getCluster(@PathParam("clusterName") String clusterName,
public Response getTable(@PathParam("clusterName") String clusterName,
@PathParam("keyspace") String keyspace,
@PathParam("table") String table) {
LOG.info("get table called with: clusterName = {}, keyspace = {}, table = {}",
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/spotify/reaper/storage/MemoryStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.math.BigInteger;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -40,7 +41,7 @@ public class MemoryStorage implements IStorage {
private ConcurrentMap<Long, ColumnFamily> columnFamilies = Maps.newConcurrentMap();
private ConcurrentMap<TableName, ColumnFamily> columnFamiliesByName = Maps.newConcurrentMap();
private ConcurrentMap<Long, RepairSegment> repairSegments = Maps.newConcurrentMap();
private ConcurrentMap<Long, ConcurrentMap<Long, RepairSegment>> repairSegmentsByRunId =
private ConcurrentMap<Long, LinkedHashMap<Long, RepairSegment>> repairSegmentsByRunId =
Maps.newConcurrentMap();

public static class TableName {
Expand Down Expand Up @@ -146,8 +147,7 @@ public ColumnFamily getColumnFamily(String cluster, String keyspace, String tabl

@Override
public int addRepairSegments(Collection<RepairSegment.Builder> segments) {
//Collection<RepairSegment> newSegments = Lists.newArrayList();
ConcurrentMap<Long, RepairSegment> newSegments = Maps.newConcurrentMap();
LinkedHashMap<Long, RepairSegment> newSegments = Maps.newLinkedHashMap();
for (RepairSegment.Builder segment : segments) {
RepairSegment newRepairSegment = segment.build(SEGMENT_ID.incrementAndGet());
repairSegments.put(newRepairSegment.getId(), newRepairSegment);
Expand Down

0 comments on commit d5b61b4

Please sign in to comment.