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 2018/08/15 17:49:37 UTC

[GitHub] milleruntime commented on a change in pull request #604: Greatly simplify FileOperations

milleruntime commented on a change in pull request #604: Greatly simplify FileOperations
URL: https://github.com/apache/accumulo/pull/604#discussion_r210351076
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
 ##########
 @@ -234,116 +190,86 @@ public FileSystem getFileSystem() {
       return fs;
     }
 
-    protected void setConfiguration(Configuration fsConf) {
+    protected FileStuff configuration(Configuration fsConf) {
       this.fsConf = fsConf;
+      return this;
     }
 
     public Configuration getConfiguration() {
       return fsConf;
     }
 
-    public AccumuloConfiguration getTableConfiguration() {
-      return tableConfiguration;
+    public FileStuff tableConfiguration(AccumuloConfiguration tableConfiguration) {
+      this.tableConfiguration = tableConfiguration;
+      return this;
     }
 
-    /** Check for null parameters. */
-    protected void validate() {
-      Objects.requireNonNull(getFilename());
-      Objects.requireNonNull(getFileSystem());
-      Objects.requireNonNull(getConfiguration());
-      Objects.requireNonNull(getTableConfiguration());
+    public AccumuloConfiguration getTableConfiguration() {
+      return tableConfiguration;
     }
-  }
 
-  /** Builder interface parallel to {@link FileAccessOperation}. */
-  protected interface FileAccessOperationBuilder<SubbuilderType> extends NeedsFile<SubbuilderType>,
-      NeedsFileSystem<SubbuilderType>, NeedsTableConfiguration<SubbuilderType> {
-    // no optional/generic methods.
-  }
-
-  /**
-   * Operation object for performing {@code getFileSize()} operations.
-   */
-  protected class GetFileSizeOperation extends FileAccessOperation<GetFileSizeOperation>
-      implements GetFileSizeOperationBuilder {
-    /** Return the size of the file. */
-    @Override
-    public long execute() throws IOException {
-      validate();
-      return getFileSize(this);
+    public RateLimiter getRateLimiter() {
+      return rateLimiter;
     }
-  }
-
-  /**
-   * Builder interface for {@link GetFileSizeOperation}, allowing execution of {@code getFileSize()}
-   * operations.
-   */
-  public interface GetFileSizeOperationBuilder
-      extends FileAccessOperationBuilder<GetFileSizeOperationBuilder> {
-    /** Return the size of the file. */
-    long execute() throws IOException;
-  }
 
-  /**
-   * Options common to all {@code FileOperation}s which perform reading or writing.
-   */
-  protected static class FileIOOperation<SubclassType extends FileIOOperation<SubclassType>>
-      extends FileAccessOperation<SubclassType> {
-    private RateLimiter rateLimiter;
-
-    /** Specify a rate limiter for this operation. */
-    @SuppressWarnings("unchecked")
-    public SubclassType withRateLimiter(RateLimiter rateLimiter) {
+    public FileStuff rateLimiter(RateLimiter rateLimiter) {
       this.rateLimiter = rateLimiter;
-      return (SubclassType) this;
+      return this;
     }
 
-    public RateLimiter getRateLimiter() {
-      return rateLimiter;
+    /** Check for null parameters. */
+    public void validate() {
+      Objects.requireNonNull(getFilename());
 
 Review comment:
   Good idea, thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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