You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/03/08 18:52:40 UTC
[GitHub] [accumulo] arvindshmicrosoft opened a new pull request #1555: Fix
idempotency bug in importtable
arvindshmicrosoft opened a new pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555
The previous implementation would fail when an interrupted importtable
operation was retried by FATE, as it would not find (already moved)
files in the exported directory. Additionally, this commit also removes
a chatty fs.exists() check.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390072003
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Guava Sets is definitely better over commons-collections CollectionUtils. We still use Guava in 2.x, so that should be fine. If you want a pure-Java way to do it, you could use Streams:
```java
Stream.concat(importing.stream(),imported.stream()).collect(Collectors.toSet()).equals(Set.of(fileNameMappings.values()));
```
Guava's `Sets.union` is cleaner.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on issue #1555: Fix idempotency
bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on issue #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#issuecomment-598354436
Merged into master in commit 84d5b995302c8774c6e9024612aff7495dd73727. There was a simple merge conflict that I resolved.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390583240
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
I did check. Sets is okay.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390649146
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
guava-beta-checker requires errorprone. I'm not sold on the idea of dictating the compiler in the build, especially not for the default build. The spotbugs plugin would be less invasive (not sure that's the right word I mean). In any case, that can be a separate issue, if it matters.
I'm going to make one more pass with some comments.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390599213
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
@arvindshmicrosoft I found #298.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390054896
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
This seems quite elegant, and I am working toward this. The only question I have at this stage is the usage of the Guava Sets class. I presume there are no concerns (both for this PR and from later porting this to 2.x) on using Sets here? I did try using CollectionUtils but it seems far easier to perform set operations with the Sets class.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390652459
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
This doesn't match our formatter style. Before we merge this, make sure the code is formatted and the basic QA checks pass (`mvn clean verify -DskipTests`).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390589351
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
Review comment:
Would be nice to avoid creating the concatenated string unless needed.
```suggestion
if(log.isDebugEnabled()){
log.debug("Files already present in imported (target) directory: {}",
StringUtils.join(imported.toArray(), ","));
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390603013
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Great, so looks like we are fine for the purposes of this PR?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390747591
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
Review comment:
Addressed in latest commit
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r389808195
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Could possibly avoid the linear search in each loop iteration with something like the following before the loop.
```java
Set<String> exporting = Arrays.stream(exportedFiles).map(fstat ->
fstat.getPath().getName()).map(fileNameMapping::get).collect(Collectors.toSet());
Set<String> exported = Arrays.stream(importedFiles).map(fstat ->
fstat.getPath().getName()).collect(Collectors.toSet());
//ensure Sets.union(exporting, exported) equals new HashSet<>(fileNameMappings.values)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390054590
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
+ if (Arrays.stream(exportedFiles).filter(fstat ->
+ fstat.getPath().getName().equals(oldFileName)).count() != 1) {
+ if (Arrays.stream(importedFiles).filter(fstat ->
+ fstat.getPath().getName().equals(fileNameMappings.get(oldFileName))).count() != 1) {
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
+ TableOperation.IMPORT, TableOperationExceptionType.OTHER,
+ "File referenced by exported table does not exist " + oldFileName);
+ }
Review comment:
Thank you Christopher! I did implement this and have it as a viable option - but I would like to evaluate Keith's suggestion as well before finalizing.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r389421651
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
+ if (Arrays.stream(exportedFiles).filter(fstat ->
+ fstat.getPath().getName().equals(oldFileName)).count() != 1) {
+ if (Arrays.stream(importedFiles).filter(fstat ->
+ fstat.getPath().getName().equals(fileNameMappings.get(oldFileName))).count() != 1) {
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
+ TableOperation.IMPORT, TableOperationExceptionType.OTHER,
+ "File referenced by exported table does not exist " + oldFileName);
+ }
Review comment:
Not sure if it's worth it, but I think you could maybe reuse the lambda used for the Predicate, as in the following.
Also, I think `.noneMatch(p)` is probably better than `.filter(p).count() != 1`, since it's not really possible to have multiple files in the same directory match on the same file name anyway... so the result is always binary (present or absent).
```suggestion
// given a name, return a predicate that can check a FileStatus for a match against that name
Function<String,Predicate<FileStatus>> nameEq = name -> fstat -> fstat.getPath().getName().equals(name);
for (String oldFileName : fileNameMappings.keySet()) {
if (Arrays.stream(exportedFiles).noneMatch(nameEq.apply(oldFileName))) {
String newFileName = fileNameMappings.get(oldFileName);
if (Arrays.stream(importedFiles).noneMatch(nameEq.apply(newFileName))) {
throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
TableOperation.IMPORT, TableOperationExceptionType.OTHER,
"File referenced by exported table does not exist " + oldFileName);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390649967
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
Review comment:
`fstat -> fstat.getPath().getName()` is used twice. The lines can be shortened (possibly to one line each) if that lambda was saved in a reusable `Function<FileStatus,String> fileStatusName = fstat -> fstat.getPath().getName();` variable or similar.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390672867
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
For small changes I only run `mvn compile` to format the code and let Travis CI do the basic quality checks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390601162
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Actually #340 would be the one to look at.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390747302
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
Addressed in latest commit
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390747528
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
Review comment:
Addressed in latest commit - however FYI the formatter still causes the lines to wrap.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390736443
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
Sorry for the overlook. I will ensure the QA checks pass before the next commit.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r389827975
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
Review comment:
This is a really nice change, avoiding all of the individual namenode RPCs
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390672867
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
For small changes I only `mvn compile` to format the code and let Travis CI do the basic quality checks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner merged pull request #1555: Fix idempotency
bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner merged pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r389808195
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Could possibly avoid the linear search in each loop iteration with something like the following before the loop.
```java
Set<String> exporting = Arrays.stream(exportedFiles).map(fstat ->
fstat.getPath().getName()).map(fileNameMapping::get).collect(Collectors.toSet());
Set<String> exported = Arrays.stream(importedFiles).map(fstat ->
fstat.getPath().getName()).collect(Collectors.toSet());
//ensure Sets.union(exporting, exported) equals new HashSet<>(fileNameMappings.values())
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r389808195
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Could possibly avoid the linear search in each loop iteration with something like the following before the loop.
```java
Set<String> importing = Arrays.stream(exportedFiles).map(fstat ->
fstat.getPath().getName()).map(fileNameMapping::get).collect(Collectors.toSet());
Set<String> imported = Arrays.stream(importedFiles).map(fstat ->
fstat.getPath().getName()).collect(Collectors.toSet());
//ensure Sets.union(importing, imported) equals new HashSet<>(fileNameMappings.values())
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390569652
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
I can create a separate PR with the guava-beta-checker added and emitting WARN for such beta APIs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390651487
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
Review comment:
In addition to Keith's suggestion, we'll need to be careful about the use of commons-lang here when we merge to the master branch, which now uses commons-lang3. If you wanted to avoid that, you could instead use the built-in Java Joiner, as in:
```suggestion
imported.stream().collect(Collectors.joining(",")));
```
It's only slightly longer, but removes an unneeded library dependency.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on issue #1555: Fix
idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on issue #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#issuecomment-596238932
For reference, the issue is easily simulated if the Accumulo master process is killed when imporrtable is running. Subsequently when master is restarted, FATE calls into the MoveExportedFiles code and then errors out:
```
[shell.Shell] ERROR: org.apache.accumulo.core.client.AccumuloException: File referenced by exported table does not exists A0000k8u.rf
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390072003
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Guava Sets is definitely better over commons-collections CollectionUtils. We still use Guava in 2.x, so that should be fine. If you want a pure-Java way to do it, you could use Streams:
```java
Stream.concat(importing.stream(),imported.stream()).collect(Collectors.toSet()).equals(Set.copyOf(fileNameMappings.values()));
```
Guava's `Sets.union` is cleaner.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] ctubbsii commented on a change in pull request #1555:
Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390715190
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
- for (FileStatus fileStatus : files) {
+ Set<String> missingFiles = Sets.difference(new HashSet<String>(fileNameMappings.values()),
+ new HashSet<String>(Sets.union(importing, imported)));
+
+ if (!missingFiles.isEmpty())
+ {
Review comment:
That's fine, too. I typically do it locally, since it doesn't take that long, and it results in fewer round trips to resolve all the issues. Also, we have limited executors on Travis that we share with the rest of the ASF, so it can take awhile before it runs in Travis.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390540627
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
Thanks for the tip! I used the [guava-beta-checker](https://github.com/google/guava-beta-checker) plugin to quickly establish if there is any new impact introduced by the usage of Sets. Thankfully, there is none, but in the process, I noticed there are many other @Beta APIs used by previously existing code which are flagged by the plugin. For example, the use of Stopwatch and RateLimiter classes (and others) is flagged. I think that is a separate cleanup project on its own!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] keith-turner commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
keith-turner commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390451052
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,17 +49,22 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
Review comment:
One potential problem with using Guava is the `@Beta` APIs. Those should be avoided, but its so easy to use them. I forget to check. I am not sure if Sets or any of its methods are `@Beta`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [accumulo] arvindshmicrosoft commented on a change in pull request
#1555: Fix idempotency bug in importtable
Posted by GitBox <gi...@apache.org>.
arvindshmicrosoft commented on a change in pull request #1555: Fix idempotency bug in importtable
URL: https://github.com/apache/accumulo/pull/1555#discussion_r390747326
##########
File path: server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
##########
@@ -48,21 +55,35 @@
Map<String,String> fileNameMappings = PopulateMetadataTable.readMappingFile(fs, tableInfo);
- for (String oldFileName : fileNameMappings.keySet()) {
- if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName,
- TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
- }
- }
+ FileStatus[] exportedFiles = fs.listStatus(new Path(tableInfo.exportDir));
+ FileStatus[] importedFiles = fs.listStatus(new Path(tableInfo.importDir));
+
+ Set<String> importing = Arrays.stream(exportedFiles).map(fstat -> fstat.getPath().getName())
+ .map(fileNameMappings::get).collect(Collectors.toSet());
- FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
+ Set<String> imported = Arrays.stream(importedFiles).map(fstat -> fstat.getPath().getName())
+ .collect(Collectors.toSet());
+ log.debug("Files already present in imported (target) directory: {}",
+ StringUtils.join(imported.toArray(), ","));
Review comment:
Addressed in latest commit
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services