Skip to content

Commit

Permalink
Allow for automatically blacklisting any TWCS or DTCS tables within a…
Browse files Browse the repository at this point in the history
… keyspace

 Fixes #577.

 ref:
   - #585
   - #602
  • Loading branch information
denniskline authored and michaelsembwever committed Jan 26, 2019
1 parent 4124b79 commit dfa792f
Show file tree
Hide file tree
Showing 31 changed files with 765 additions and 205 deletions.
12 changes: 12 additions & 0 deletions src/docs/content/docs/configuration/reaper_specific.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ Sets the default repair type unless specifically defined for each run. Note that

<br/>

### `blacklistTwcsTables`

Type: *Boolean*

Default: *false*

Disables repairs of any tables that use either the `TimeWindowCompactionStrategy` or `DateTieredCompactionStrategy`. This automatic blacklisting is not stored in schedules or repairs. It is applied when repairs are triggered and visible in the UI for running repairs. Not storing which tables are TWCS/DTCS ensures changes to a table's compaction strategy are honored on every new repair.

*Note*: It is recommended to enable this option as repairing these tables, when they contain TTL'd data, causes overlaps between partitions across the configured time windows the sstables reside in. This leads to an increased disk usage as the older sstables are unable to be expired despite only containing TTL's data. Repairing DTCS tables has additional issues and is generally not recommended.

<br/>

### `jmxAuth`

Optional setting to allow Reaper to establish JMX connections to Cassandra clusters using password based JMX authentication.
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper-cassandra-ssl.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: cassandra
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
repairManagerSchedulingIntervalSeconds: 10
activateQueryLogger: false
jmxConnectionTimeoutInSeconds: 5
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper-cassandra.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: cassandra
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
enableDynamicSeedList: true
repairManagerSchedulingIntervalSeconds: 10
activateQueryLogger: false
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper-h2.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: h2
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
enableDynamicSeedList: true
repairManagerSchedulingIntervalSeconds: 10
jmxConnectionTimeoutInSeconds: 5
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper-memory.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: memory
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
enableDynamicSeedList: true
repairManagerSchedulingIntervalSeconds: 10
jmxConnectionTimeoutInSeconds: 5
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper-postgres.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: postgres
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
enableDynamicSeedList: true
repairManagerSchedulingIntervalSeconds: 10
jmxConnectionTimeoutInSeconds: 5
Expand Down
3 changes: 2 additions & 1 deletion src/packaging/resource/cassandra-reaper.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015-2017 Spotify AB
# Copyright 2016-2018 The Last Pickle Ltd
# Copyright 2016-2019 The Last Pickle Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ hangingRepairTimeoutMins: 30
storageType: memory
enableCrossOrigin: true
incrementalRepair: false
blacklistTwcsTables: false
enableDynamicSeedList: true
repairManagerSchedulingIntervalSeconds: 10
activateQueryLogger: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2017 Spotify AB
* Copyright 2016-2018 The Last Pickle Ltd
* Copyright 2016-2019 The Last Pickle Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,6 +65,11 @@ public final class ReaperApplicationConfiguration extends Configuration {
@DefaultValue("false")
private Boolean incrementalRepair;

@JsonProperty
@NotNull
@DefaultValue("false")
private Boolean blacklistTwcsTables;

@DefaultValue("7")
private Integer scheduleDaysBetween;

Expand Down Expand Up @@ -185,6 +190,14 @@ public void setIncrementalRepair(boolean incrementalRepair) {
this.incrementalRepair = incrementalRepair;
}

public boolean getBlacklistTwcsTables() {
return blacklistTwcsTables != null ? blacklistTwcsTables : false;
}

public void setBlacklistTwcsTables(boolean blacklistTwcsTables) {
this.blacklistTwcsTables = blacklistTwcsTables;
}

public Integer getScheduleDaysBetween() {
return scheduleDaysBetween != null ? scheduleDaysBetween : 7;
}
Expand Down
77 changes: 77 additions & 0 deletions src/server/src/main/java/io/cassandrareaper/core/Table.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2018-2019 The Last Pickle Ltd
*
*
* Licensed 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 io.cassandrareaper.core;

import com.google.common.base.Preconditions;

public final class Table {

private final String name;
private final String compactionStrategy;

private Table(Builder builder) {
this.name = builder.name;
this.compactionStrategy = builder.compactionStrategy;
}

public String getName() {
return name;
}

public String getCompactionStrategy() {
return compactionStrategy;
}

public static Builder builder() {
return new Builder();
}

public String toString() {
return String.format("{name=%s, compactionStrategy=%s}", name, compactionStrategy);
}

public static final class Builder {

private String name;
private String compactionStrategy;

private Builder() {
}

public Table.Builder withName(String name) {
Preconditions.checkState(null == this.name, "`.withName(..)` can only be called once");
this.name = name;
return this;
}

public Table.Builder withCompactionStrategy(String compactionStrategy) {
Preconditions
.checkState(null == this.compactionStrategy, "`.withCompactionStrategy(..)` can only be called once");

this.compactionStrategy = compactionStrategy;
return this;
}

public Table build() {
Preconditions.checkNotNull(name, "`.withName(..)` must be called before `.build()`");
Preconditions.checkNotNull(compactionStrategy, "`.withCompactionStrategy(..)` must be called before `.build()`");
return new Table(this);
}
}

}
5 changes: 3 additions & 2 deletions src/server/src/main/java/io/cassandrareaper/jmx/JmxProxy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2017 Spotify AB
* Copyright 2016-2018 The Last Pickle Ltd
* Copyright 2016-2019 The Last Pickle Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@

import io.cassandrareaper.ReaperException;
import io.cassandrareaper.core.Segment;
import io.cassandrareaper.core.Table;
import io.cassandrareaper.service.RingRange;

import java.math.BigInteger;
Expand Down Expand Up @@ -80,7 +81,7 @@ public interface JmxProxy extends NotificationListener {

List<RingRange> getRangesForLocalEndpoint(String keyspace) throws ReaperException;

Set<String> getTableNamesForKeyspace(String keyspace) throws ReaperException;
Set<Table> getTablesForKeyspace(String keyspace) throws ReaperException;

/**
* @return list of tokens in the cluster
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2017 Spotify AB
* Copyright 2016-2018 The Last Pickle Ltd
* Copyright 2016-2019 The Last Pickle Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
import io.cassandrareaper.ReaperException;
import io.cassandrareaper.core.Cluster;
import io.cassandrareaper.core.Segment;
import io.cassandrareaper.core.Table;
import io.cassandrareaper.service.RingRange;

import java.io.IOException;
Expand Down Expand Up @@ -387,8 +388,8 @@ public List<String> getKeyspaces() {
}

@Override
public Set<String> getTableNamesForKeyspace(String keyspace) throws ReaperException {
Set<String> tableNames = new HashSet<>();
public Set<Table> getTablesForKeyspace(String keyspace) throws ReaperException {
Set<Table> tables = new HashSet<>();
Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> proxies;
try {
proxies = ColumnFamilyStoreMBeanIterator.getColumnFamilyStoreMBeanProxies(mbeanServer);
Expand All @@ -400,10 +401,13 @@ public Set<String> getTableNamesForKeyspace(String keyspace) throws ReaperExcept
String keyspaceName = proxyEntry.getKey();
if (keyspace.equalsIgnoreCase(keyspaceName)) {
ColumnFamilyStoreMBean columnFamilyMBean = proxyEntry.getValue();
tableNames.add(columnFamilyMBean.getColumnFamilyName());
tables.add(Table.builder()
.withName(columnFamilyMBean.getColumnFamilyName())
.withCompactionStrategy(columnFamilyMBean.getCompactionParameters().get("class"))
.build());
}
}
return tableNames;
return tables;
}

@Override
Expand Down
Loading

0 comments on commit dfa792f

Please sign in to comment.