You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by chaithu14 <gi...@git.apache.org> on 2016/05/02 08:27:59 UTC

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-2019 S3-Input Imple...

GitHub user chaithu14 opened a pull request:

    https://github.com/apache/incubator-apex-malhar/pull/263

    APEXMALHAR-2019 S3-Input Implemented S3 Input Module

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/chaithu14/incubator-apex-malhar APEXMALHAR-2019-S3-Input

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-apex-malhar/pull/263.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #263
    
----
commit 7e3b98237d28b6081c0f62bde3e64dec28996bb5
Author: Chaitanya <ch...@datatorrent.com>
Date:   2016-04-27T10:22:54Z

    APEXMALHAR-2019-S3-Input Implemented S3 Input Module

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-2019 S3-Input Imple...

Posted by yogidevendra <gi...@git.apache.org>.
Github user yogidevendra commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/263#discussion_r61708375
  
    --- Diff: library/src/main/java/com/datatorrent/lib/io/fs/S3FileSplitter.java ---
    @@ -0,0 +1,56 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * 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
    + *
    + *   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 com.datatorrent.lib.io.fs;
    +
    +
    +import java.io.IOException;
    +import org.apache.hadoop.fs.FileSystem;
    +import com.datatorrent.api.Context;
    +
    +/**
    + * S3FileSplitter extends from FSFileSplitter and dissables the parallel read functionality
    + * explicitly in case of s3 or s3n schemes.
    + * Parallel read will work only if the scheme is "s3a" and the Hadoop version is 2.7+.
    --- End diff --
    
    add link to amazon s3 wiki page to explain details about hadoop version and scheme.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-2019 S3-Input Imple...

Posted by yogidevendra <gi...@git.apache.org>.
Github user yogidevendra commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/263#discussion_r61708028
  
    --- Diff: library/src/main/java/com/datatorrent/lib/io/fs/S3FileSplitter.java ---
    @@ -0,0 +1,56 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * 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
    + *
    + *   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 com.datatorrent.lib.io.fs;
    +
    +
    +import java.io.IOException;
    +import org.apache.hadoop.fs.FileSystem;
    +import com.datatorrent.api.Context;
    +
    +/**
    + * S3FileSplitter extends from FSFileSplitter and dissables the parallel read functionality
    + * explicitly in case of s3 or s3n schemes.
    + * Parallel read will work only if the scheme is "s3a" and the Hadoop version is 2.7+.
    + * Parallel read doesn't work in the case of the scheme is "s3n/s3". In this case, this operator explicitly
    + * disables the parallel read functionality.
    + */
    +public class S3FileSplitter extends FSFileSplitter
    +{
    +  public S3FileSplitter()
    +  {
    --- End diff --
    
    Not required.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-2019 S3-Input Imple...

Posted by yogidevendra <gi...@git.apache.org>.
Github user yogidevendra commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/263#discussion_r61707966
  
    --- Diff: library/src/main/java/com/datatorrent/lib/io/fs/S3BlockReader.java ---
    @@ -0,0 +1,89 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * 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
    + *
    + *   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 com.datatorrent.lib.io.fs;
    +
    +import java.io.IOException;
    +import org.apache.hadoop.fs.FSDataInputStream;
    +import org.apache.hadoop.fs.Path;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.datatorrent.api.Context;
    +import com.datatorrent.lib.io.block.BlockMetadata;
    +import com.datatorrent.lib.io.block.BlockReader;
    +import com.datatorrent.lib.io.block.ReaderContext;
    +
    +/**
    + * S3BlockReader extends from BlockReader and serves the functionality of read objects and
    + * parse Block metadata
    + */
    +public class S3BlockReader extends BlockReader
    +{
    +  protected transient String s3bucketUri;
    +
    +  public S3BlockReader()
    +  {
    +    this.readerContext = new S3BlockReaderContext();
    +  }
    +
    +  @Override
    +  public void setup(Context.OperatorContext context)
    +  {
    +    super.setup(context);
    +    s3bucketUri = fs.getScheme() + "://" + extractBucket(uri);
    +  }
    +
    +  @VisibleForTesting
    +  protected String extractBucket(String s3uri)
    +  {
    +    return s3uri.substring(s3uri.indexOf('@') + 1, s3uri.indexOf("/", s3uri.indexOf('@')));
    +  }
    +
    +  @Override
    +  protected FSDataInputStream setupStream(BlockMetadata.FileBlockMetadata block) throws IOException
    +  {
    +    FSDataInputStream ins = fs.open(new Path(s3bucketUri + block.getFilePath()));
    +    ins.seek(block.getOffset());
    +    return ins;
    +  }
    +
    +  /**
    +   * BlockReadeContext for reading S3 Blocks.<br/>
    +   * This should use read API without offset.
    +   */
    +  private static class S3BlockReaderContext extends ReaderContext.FixedBytesReaderContext<FSDataInputStream>
    +  {
    +    @Override
    +    protected Entity readEntity() throws IOException
    --- End diff --
    
    mention the difference from super in javadocs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-2019 S3-Input Imple...

Posted by yogidevendra <gi...@git.apache.org>.
Github user yogidevendra commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/263#discussion_r61707948
  
    --- Diff: library/src/main/java/com/datatorrent/lib/io/fs/S3BlockReader.java ---
    @@ -0,0 +1,89 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * 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
    + *
    + *   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 com.datatorrent.lib.io.fs;
    +
    +import java.io.IOException;
    +import org.apache.hadoop.fs.FSDataInputStream;
    +import org.apache.hadoop.fs.Path;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.datatorrent.api.Context;
    +import com.datatorrent.lib.io.block.BlockMetadata;
    +import com.datatorrent.lib.io.block.BlockReader;
    +import com.datatorrent.lib.io.block.ReaderContext;
    +
    +/**
    + * S3BlockReader extends from BlockReader and serves the functionality of read objects and
    + * parse Block metadata
    + */
    +public class S3BlockReader extends BlockReader
    +{
    +  protected transient String s3bucketUri;
    +
    +  public S3BlockReader()
    +  {
    +    this.readerContext = new S3BlockReaderContext();
    +  }
    +
    +  @Override
    +  public void setup(Context.OperatorContext context)
    +  {
    +    super.setup(context);
    +    s3bucketUri = fs.getScheme() + "://" + extractBucket(uri);
    +  }
    +
    +  @VisibleForTesting
    +  protected String extractBucket(String s3uri)
    --- End diff --
    
    javadoc. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---