-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEOMESA-3366 FSDS - fix Hadoop 3.4 AWS compatibility (#3124)
- Loading branch information
1 parent
f1aacf8
commit e4eceaf
Showing
20 changed files
with
526 additions
and
175 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
54 changes: 0 additions & 54 deletions
54
...on/src/main/scala/org/locationtech/geomesa/fs/storage/common/s3/S3ObjectTagObserver.scala
This file was deleted.
Oops, something went wrong.
This file contains 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
31 changes: 31 additions & 0 deletions
31
...rc/main/scala/org/locationtech/geomesa/fs/storage/common/s3/v1/S3VisibilityObserver.scala
This file contains 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,31 @@ | ||
/*********************************************************************** | ||
* Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Apache License, Version 2.0 | ||
* which accompanies this distribution and is available at | ||
* http://www.opensource.org/licenses/apache2.0.php. | ||
***********************************************************************/ | ||
|
||
package org.locationtech.geomesa.fs.storage.common.s3 | ||
package v1 | ||
|
||
import com.amazonaws.services.s3.AmazonS3 | ||
import com.amazonaws.services.s3.model.{ObjectTagging, SetObjectTaggingRequest, Tag} | ||
import org.apache.hadoop.fs.Path | ||
|
||
import java.util.Collections | ||
|
||
/** | ||
* Creates a tag containing the base64 encoded summary visibility for the observed file | ||
* | ||
* @param path file path | ||
* @param s3 s3 client | ||
* @param tag tag name to use | ||
*/ | ||
class S3VisibilityObserver(val path: Path, s3: AmazonS3, tag: String) extends AbstractS3VisibilityObserver(path) { | ||
override protected def makeTagRequest(bucket: String, key: String, visibility: String): Unit = { | ||
val tagging = new ObjectTagging(Collections.singletonList(new Tag(tag, visibility))) | ||
val request = new SetObjectTaggingRequest(bucket, key, tagging) | ||
s3.setObjectTagging(request) | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../scala/org/locationtech/geomesa/fs/storage/common/s3/v1/S3VisibilityObserverFactory.scala
This file contains 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,53 @@ | ||
/*********************************************************************** | ||
* Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Apache License, Version 2.0 | ||
* which accompanies this distribution and is available at | ||
* http://www.opensource.org/licenses/apache2.0.php. | ||
***********************************************************************/ | ||
|
||
package org.locationtech.geomesa.fs.storage.common.s3 | ||
package v1 | ||
|
||
import com.amazonaws.services.s3.AmazonS3 | ||
import org.apache.hadoop.conf.Configuration | ||
import org.apache.hadoop.fs.{FileSystem, Path} | ||
import org.geotools.api.feature.simple.SimpleFeatureType | ||
import org.locationtech.geomesa.fs.storage.common.observer.{FileSystemObserver, FileSystemObserverFactory} | ||
import org.locationtech.geomesa.utils.io.CloseQuietly | ||
|
||
import java.io.IOException | ||
|
||
/** | ||
* Visibility observer for aws sdk v1 | ||
*/ | ||
class S3VisibilityObserverFactory extends FileSystemObserverFactory { | ||
|
||
private var fs: FileSystem = _ | ||
private var s3: AmazonS3 = _ | ||
private var tag: String = _ | ||
|
||
override def init(conf: Configuration, root: Path, sft: SimpleFeatureType): Unit = { | ||
try { | ||
// use reflection to access to private client factory used by the s3a hadoop impl | ||
fs = root.getFileSystem(conf) | ||
val field = fs.getClass.getDeclaredField("s3") | ||
field.setAccessible(true) | ||
s3 = field.get(fs).asInstanceOf[AmazonS3] | ||
tag = conf.get(S3VisibilityObserverFactory.TagNameConfig, S3VisibilityObserverFactory.DefaultTag) | ||
} catch { | ||
case e: Exception => throw new RuntimeException("Unable to get s3 client", e) | ||
} | ||
} | ||
|
||
override def apply(path: Path): FileSystemObserver = new S3VisibilityObserver(path, s3, tag) | ||
|
||
override def close(): Unit = { | ||
if (fs != null) { | ||
val err = CloseQuietly(fs) | ||
s3 = null | ||
fs = null | ||
err.foreach(e => throw new IOException("Error closing S3 filesystem", e)) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...rc/main/scala/org/locationtech/geomesa/fs/storage/common/s3/v2/S3VisibilityObserver.scala
This file contains 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,29 @@ | ||
/*********************************************************************** | ||
* Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Apache License, Version 2.0 | ||
* which accompanies this distribution and is available at | ||
* http://www.opensource.org/licenses/apache2.0.php. | ||
***********************************************************************/ | ||
|
||
package org.locationtech.geomesa.fs.storage.common.s3 | ||
package v2 | ||
|
||
import org.apache.hadoop.fs.Path | ||
import software.amazon.awssdk.services.s3.S3Client | ||
import software.amazon.awssdk.services.s3.model.{PutObjectTaggingRequest, Tag, Tagging} | ||
|
||
/** | ||
* Creates a tag containing the base64 encoded summary visibility for the observed file | ||
* | ||
* @param path file path | ||
* @param s3 s3 client | ||
* @param tag tag name to use | ||
*/ | ||
class S3VisibilityObserver(path: Path, s3: S3Client, tag: String) extends AbstractS3VisibilityObserver(path) { | ||
override protected def makeTagRequest(bucket: String, key: String, visibility: String): Unit = { | ||
val tagging = Tagging.builder().tagSet(Tag.builder.key(tag).value(visibility).build()).build() | ||
val request = PutObjectTaggingRequest.builder.bucket(bucket).key(key).tagging(tagging).build() | ||
s3.putObjectTagging(request) | ||
} | ||
} |
Oops, something went wrong.