-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Mbyrd/cassandra 21258/trunk #4876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.cassandra.dht; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
|
|
@@ -103,6 +104,7 @@ public class RangeStreamer | |
| private final MovementMap movements; | ||
| private final MovementMap strictMovements; | ||
| private final boolean excludeAccordTables; | ||
| private final Set<String> tables; | ||
|
|
||
| public static class FetchReplica | ||
| { | ||
|
|
@@ -304,10 +306,11 @@ public RangeStreamer(ClusterMetadata metadata, | |
| int connectionsPerHost, | ||
| MovementMap movements, | ||
| MovementMap strictMovements, | ||
| boolean excludeAccordTables) | ||
| boolean excludeAccordTables, | ||
| Set<String> tables) | ||
| { | ||
| this(metadata, streamOperation, useStrictConsistency, proximity, stateStore, | ||
| FailureDetector.instance, connectSequentially, connectionsPerHost, movements, strictMovements, excludeAccordTables); | ||
| FailureDetector.instance, connectSequentially, connectionsPerHost, movements, strictMovements, excludeAccordTables, tables); | ||
| } | ||
|
|
||
| RangeStreamer(ClusterMetadata metadata, | ||
|
|
@@ -320,7 +323,8 @@ public RangeStreamer(ClusterMetadata metadata, | |
| int connectionsPerHost, | ||
| MovementMap movements, | ||
| MovementMap strictMovements, | ||
| boolean excludeAccordTables) | ||
| boolean excludeAccordTables, | ||
| Set<String> tables) | ||
| { | ||
| this.excludeAccordTables = excludeAccordTables; | ||
| Preconditions.checkArgument(streamOperation == StreamOperation.BOOTSTRAP || streamOperation == StreamOperation.REBUILD, streamOperation); | ||
|
|
@@ -333,6 +337,7 @@ public RangeStreamer(ClusterMetadata metadata, | |
| this.movements = movements; | ||
| this.strictMovements = strictMovements; | ||
| streamPlan.listeners(this.stateStore); | ||
| this.tables = tables; | ||
|
|
||
| // We're _always_ filtering out a local node and down sources | ||
| addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(failureDetector)); | ||
|
|
@@ -772,11 +777,15 @@ public StreamResultFuture fetchAsync() | |
| { | ||
| String[] cfNames = StreamPlan.nonAccordTablesForKeyspace(ksm); | ||
| if (cfNames != null) | ||
| { | ||
| cfNames = Arrays.stream(cfNames).filter(table -> tables == null || tables.contains(table)).toArray(String[]::new); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if In "rebuild" you do tables == null || tables.isEmpty() ? "(All tables)" : tables so null and empty is indeed as "everything" which is not the case here ... |
||
| streamPlan.requestRanges(source, keyspace, full, transientReplicas, cfNames); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| streamPlan.requestRanges(source, keyspace, full, transientReplicas); | ||
| String[] cfNames = tables == null ? new String[0] : tables.toArray(String[]::new); | ||
| streamPlan.requestRanges(source, keyspace, full, transientReplicas, cfNames); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ | |
| */ | ||
| package org.apache.cassandra.tools.nodetool; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.cassandra.tools.NodeProbe; | ||
|
|
||
| import picocli.CommandLine.Command; | ||
|
|
@@ -52,6 +55,11 @@ public class Rebuild extends AbstractCommand | |
| description = "Use --exclude-local-dc to exclude nodes in local data center as source for streaming.") | ||
| private boolean excludeLocalDatacenterNodes = false; | ||
|
|
||
| @Option(paramLabel = "specific_tables", | ||
| names = {"-tb", "--table"}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do this? |
||
| description = "Use -tb to scope the rebuild to particular table") | ||
| private Set<String> tables = new HashSet<>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so on empty --tables, all code path will be executed with empty set instead of null, right? |
||
|
|
||
| @Override | ||
| public void execute(NodeProbe probe) | ||
| { | ||
|
|
@@ -61,6 +69,6 @@ public void execute(NodeProbe probe) | |
| throw new IllegalArgumentException("Cannot specify tokens without keyspace."); | ||
| } | ||
|
|
||
| probe.rebuild(sourceDataCenterName, keyspace, tokens, specificSources, excludeLocalDatacenterNodes); | ||
| probe.rebuild(sourceDataCenterName, keyspace, tokens, specificSources, excludeLocalDatacenterNodes, tables); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe annotated this with
@Nullableor make it so that it works with empty set or similar