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 @@ -257,6 +257,25 @@ public void drain() throws IOException, InterruptedException, ExecutionException
.drain();
}

/**
* {@inheritDoc}
*/
@Override
public List<String> getParentRepairStatus(int cmd)
{
return jmxClient.proxy(StorageJmxOperations.class, STORAGE_SERVICE_OBJ_NAME)
.getParentRepairStatus(cmd);
}

/**
* {@inheritDoc}
*/
public int repair(String keyspace, Map<String, String> repairOptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override

CI should fail w/o the annotation.

{
StorageJmxOperations ssProxy = jmxClient.proxy(StorageJmxOperations.class, STORAGE_SERVICE_OBJ_NAME);
return ssProxy.repairAsync(keyspace, repairOptions);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.cassandra.sidecar.adapters.base;

/**
* Enum representing the repair options supported.
* This class mimics the options supported by the repair operation in Apache Cassandra
* as defined in org.apache.cassandra.repair.messages.RepairOption
* (<a href="https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/repair/messages/RepairOption.java">...</a>)
*/
public enum RepairOptions
{
/**
* Whether to repair only the primary range of the node (true/false)
*/
PRIMARY_RANGE("primaryRange"),
/**
* Whether to perform an incremental repair (true/false)
* If false, a full repair is performed
*/
INCREMENTAL("incremental"),
/**
* Specific token ranges to repair
*/
RANGES("ranges"),
/**
* List of column families (tables) to repair (comma-separated)
*/
COLUMNFAMILIES("columnFamilies"),
/**
* Restrict repair to specific data centers (comma-separated)
*/
DATACENTERS("dataCenters"),
/**
* Restrict repair to specific hosts (comma-separated IPs or hostnames)
*/
HOSTS("hosts"),
/**
* Force the repair operation
*/
FORCE_REPAIR("forceRepair"),
/**
* Type of preview repair to run before actual repair
* Options: "none", "auto", "running", "full"
* Mainly used to assess data consistency without actually repairing
*/
PREVIEW("previewKind");

private final String value;

RepairOptions(String value)
{
this.value = value;
}

/**
* @return Name corresponding to the repair option
*/
public String optionName()
{
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,16 @@ public int getCompactionThroughputMbPerSec()
{
return delegate.getCompactionThroughputMbPerSec();
}

@Override
public int repairAsync(String keyspace, Map<String, String> options)
{
return delegate.repairAsync(keyspace, options);
}

@Override
public List<String> getParentRepairStatus(int cmd)
{
return delegate.getParentRepairStatus(cmd);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,20 @@ public interface StorageJmxOperations
* @return the current compaction throughput in megabytes per second, or 0 if throughput cannot be determined
*/
int getCompactionThroughputMbPerSec();

/**
* Trigger an async repair operation for the given keyspace and options
* @param keyspace keyspace to be repaired
* @param options repair options
* @return repair command number, or 0 if nothing to repair
*/
int repairAsync(String keyspace, Map<String, String> options);

/**
* Get the status of a given parent repair session.
* @param cmd the int reference returned when issuing the repair
* @return status of parent repair from ParentRepairStatus
* followed by final message or messages of the session
*/
List<String> getParentRepairStatus(int cmd);
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public final class ApiEndpointsV1
public static final String NODE_DRAIN_ROUTE = API_V1 + CASSANDRA + "/operations/drain";
public static final String STREAM_STATS_ROUTE = API_V1 + CASSANDRA + "/stats/streams";
public static final String TABLE_STATS_ROUTE = API_V1 + CASSANDRA + PER_KEYSPACE + PER_TABLE + "/stats";
public static final String REPAIR_ROUTE = API_V1 + CASSANDRA + PER_KEYSPACE + "/repair";


// Live Migration APIs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.cassandra.sidecar.common.request;

import io.netty.handler.codec.http.HttpMethod;
import org.apache.cassandra.sidecar.common.ApiEndpointsV1;
import org.apache.cassandra.sidecar.common.request.data.RepairPayload;
import org.apache.cassandra.sidecar.common.response.OperationalJobResponse;

/**
* Class representing the repair API request
*/
public class RepairRequest extends JsonRequest<OperationalJobResponse>
{
private final RepairPayload repairRequestPayload;


/**
* Constructs a Sidecar repair request with the given parameters.
*
* @param keyspace name of the keyspace in the cluster
* @param repairRequestPayload request payload
*/
public RepairRequest(String keyspace, RepairPayload repairRequestPayload)
{
super(requestURI(keyspace));
this.repairRequestPayload = repairRequestPayload;
}

@Override
public HttpMethod method()
{
return HttpMethod.PUT;
}

@Override
public Object requestBody()
{
return repairRequestPayload;
}

static String requestURI(String keyspace)
{
return ApiEndpointsV1.REPAIR_ROUTE
.replaceAll(ApiEndpointsV1.KEYSPACE_PATH_PARAM, keyspace);
}
}
Loading
Loading