-
Notifications
You must be signed in to change notification settings - Fork 478
Fix for #2872. Makes exporttable command volume aware. #3228
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
Open
AlbertWhitlock
wants to merge
10
commits into
apache:main
Choose a base branch
from
AlbertWhitlock:acc2872
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
439816f
Initial commit for #2872. Make exporttable command volume aware.
AlbertWhitlock 477fd4e
Fixed syntax error. Added {} to if.
AlbertWhitlock 92e5ffc
Improved way to collect volume name and changed naming of new distcp.…
AlbertWhitlock 5df4df5
Cleaned up class and started test case
AlbertWhitlock aa66552
Added IT class and improved WriteExportFiles.java
AlbertWhitlock 71f9e52
Restored original ShellServerIT. Renamed IT class. Modified checks in…
AlbertWhitlock 6e19c8a
removed ExportTableCommandWitlMultipleVolumes.java
AlbertWhitlock 3e2ebf6
Merge branch 'main' of https://github.com/apache/accumulo into acc2872
AlbertWhitlock fced61f
Made suggested change to exportTable method
AlbertWhitlock fe5fd30
Changes to old test and added a new test file
AlbertWhitlock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
test/src/main/java/org/apache/accumulo/test/ExportTableCommandWitlMultipleVolumes.java
AlbertWhitlock marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
AlbertWhitlock marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * 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 | ||
| * | ||
| * https://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.accumulo.test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.io.File; | ||
| import java.time.Duration; | ||
| import java.util.Map; | ||
| import java.util.SortedSet; | ||
| import java.util.TreeSet; | ||
|
|
||
| import org.apache.accumulo.core.client.Accumulo; | ||
| import org.apache.accumulo.core.client.AccumuloClient; | ||
| import org.apache.accumulo.core.client.BatchWriter; | ||
| import org.apache.accumulo.core.client.Scanner; | ||
| import org.apache.accumulo.core.conf.Property; | ||
| import org.apache.accumulo.core.data.Key; | ||
| import org.apache.accumulo.core.data.Mutation; | ||
| import org.apache.accumulo.core.data.Range; | ||
| import org.apache.accumulo.core.data.Value; | ||
| import org.apache.accumulo.core.metadata.MetadataTable; | ||
| import org.apache.accumulo.core.metadata.schema.MetadataSchema; | ||
| import org.apache.accumulo.core.security.Authorizations; | ||
| import org.apache.accumulo.harness.AccumuloClusterHarness; | ||
| import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.fs.RawLocalFileSystem; | ||
| import org.apache.hadoop.io.Text; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class ExportTableCommandWitlMultipleVolumes extends AccumuloClusterHarness { | ||
|
|
||
| private static final Logger log = LoggerFactory.getLogger(ImportExportIT.class); | ||
|
|
||
| Path v1, v2; | ||
|
|
||
| public static String[] row_numbers = "1,2,3,4,5,6,7,8,9,10".split(","); | ||
|
|
||
| String baseDirStr = ""; | ||
| String baseDir2Str = ""; | ||
|
|
||
| @Override | ||
| protected Duration defaultTimeout() { | ||
| return Duration.ofMinutes(1); | ||
| } | ||
|
|
||
| @Override | ||
| public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) { | ||
| File baseDir = cfg.getDir(); | ||
| baseDirStr = baseDir.toString(); | ||
|
|
||
| // get first volume name | ||
| String[] baseDirArray = baseDirStr.split("/"); | ||
| String originalVolume = baseDirArray[2]; | ||
|
|
||
| // get second volume name | ||
| String[] baseDir2Array = baseDirArray; | ||
| baseDir2Array[2] = baseDir2Array[2] + "2"; | ||
| String secondVolume = baseDir2Array[2]; | ||
|
|
||
| // make second volume base directory | ||
| for (String element : baseDir2Array) { | ||
| baseDir2Str = baseDir2Str + "/" + element; | ||
| } | ||
| File baseDir2 = new File(baseDir2Str); | ||
|
|
||
| File v1f = new File(baseDir, "volumes/v1"); | ||
| File v2f = new File(baseDir2, "volumes/v2"); | ||
|
|
||
| v1 = new Path("file://" + v1f.getAbsolutePath()); | ||
| v2 = new Path("file://" + v2f.getAbsolutePath()); | ||
|
|
||
| // Run MAC on two locations in the local file system | ||
| cfg.setProperty(Property.INSTANCE_VOLUMES, v1 + "," + v2); | ||
|
|
||
| // use raw local file system so walogs sync and flush will work | ||
| hadoopCoreSite.set("fs.file.impl", RawLocalFileSystem.class.getName()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExportCommand() throws Exception { | ||
| try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { | ||
|
|
||
| final String tableName = getUniqueNames(1)[0]; | ||
| client.tableOperations().create(tableName); | ||
|
|
||
| // add splits to table | ||
| SortedSet<Text> partitions = new TreeSet<>(); | ||
| for (String s : row_numbers) { | ||
| partitions.add(new Text(s)); | ||
| } | ||
| client.tableOperations().addSplits(tableName, partitions); | ||
|
|
||
| try (BatchWriter bw = client.createBatchWriter(tableName)) { | ||
| for (int i = 1; i <= 5000000; i++) { | ||
| Mutation m = new Mutation(Integer.toString(i)); | ||
| if (i % 2 != 0) { | ||
| m.put(Integer.toString(i), "", String | ||
| .format("file://localhost:8020/accumulo/tables/1/default_tablet/I00000%dp.rf", i)); | ||
| } else { | ||
| m.put(Integer.toString(i), "", String | ||
| .format("file://localhost:8020/accumulo/tables/2/default_tablet/I00000%dp.rf", i)); | ||
| } | ||
| bw.addMutation(m); | ||
| } | ||
| } | ||
|
|
||
| client.tableOperations().compact(tableName, null, null, true, true); | ||
| client.tableOperations().flush(tableName, null, null, true); | ||
|
|
||
| Path outputDir = new Path(cluster.getTemporaryPath(), getClass().getName()); | ||
| Path exportDir = new Path(outputDir, "export"); | ||
| client.tableOperations().offline(tableName, true); | ||
| client.tableOperations().exportTable(tableName, exportDir.toString()); | ||
|
|
||
| try (Scanner scanner = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) { | ||
| scanner.setRange(new Range("1", "1<")); | ||
| scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); | ||
|
|
||
| for (Map.Entry<Key,Value> entry : scanner) { | ||
| log.info("Key is: " + entry.getKey()); | ||
| log.info("Value is: " + entry.getValue()); | ||
| boolean inV1 = entry.getKey().getColumnQualifier().toString().contains(v1.toString()); | ||
| boolean inV2 = entry.getKey().getColumnQualifier().toString().contains(v2.toString()); | ||
| assertTrue(inV1 || inV2); | ||
| } | ||
| } | ||
|
|
||
| FileSystem fs = cluster.getFileSystem(); | ||
AlbertWhitlock marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fs.deleteOnExit(v1); | ||
| fs.deleteOnExit(v2); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.