OpenSearch/plugins
Kartik fb9e150076
Refactoring gated and ref-counted interfaces and their implementations (#2396)
* Reducing duplication in plugins around ref-counted releasable classes

Both AmazonEc2Reference and AmazonS3Reference duplicate the same logic - a subclass of AbstractRefCounted that also implements Releasable. This change centralizes this paradigm into a AbstractRefCountedReleasable class and supports both clients via generics. It also updates all fetching implementations to use the get() method instead of client()

Signed-off-by: Kartik Ganesh <gkart@amazon.com>

* Introduce Reference classes for the Closeable and AutoCloseable interfaces

These classes allow you to wrap a reference instance with an onClose runnable that is executed when close() is invoked. Two separate classes are needed because the close() signatures for the two interfaces are different. This change takes the first step to have implementing classes extend from these generic superclasses, before attempting to remove the subclasses entirely. The get() method is also replaced throughout the code base.

Note that there is also a separate Releasable interface that has a similar access pattern, but is implemented separately. This is used in AbstractRefCountedReleasable introduced in a prior commit

Signed-off-by: Kartik Ganesh <gkart@amazon.com>

* More improvements and refactoring

* Functionality around one-way gating is now moved to a dedicated class - OneWayGate. This replaces duplicate functionality throughout the code.
* The two *Reference classes have been renamed to Gated* since that better represents their functionality
* The AbstractRefCountedReleasable has been improved to no longer be abstract by accepting the shutdown hook. This removes the need for the inner class in ReleasableBytesReference, and further simplifies the plugin subclasses (these could probably be removed entirely).
* Finally, unit tests have been added for some classes

Signed-off-by: Kartik Ganesh <gkart@amazon.com>

* Added tests for GatedCloseable

Also updated the license information in GatedAutoCloseableTests

Signed-off-by: Kartik Ganesh <gkart@amazon.com>

* Fixing license information in new files

Signed-off-by: Kartik Ganesh <gkart@amazon.com>

* Added unit tests for RefCountedReleasable

Signed-off-by: Kartik Ganesh <gkart@amazon.com>
2022-03-09 12:21:09 -08:00
..
analysis-icu [Remove] remaining type usage in Client and AbstractClient (#2258) 2022-02-25 13:35:48 -06:00
analysis-kuromoji Enabling spotless, disabling checkstyle check on plugins (#1488) 2021-11-01 17:40:06 -07:00
analysis-nori Enabling spotless, disabling checkstyle check on plugins (#1488) 2021-11-01 17:40:06 -07:00
analysis-phonetic [Remove] Analyzer Deprecations (#1741) 2021-12-16 12:51:49 -06:00
analysis-smartcn Enabling spotless, disabling checkstyle check on plugins (#1488) 2021-11-01 17:40:06 -07:00
analysis-stempel [Deprecate] Setting explicit version on analysis component (#1978) 2022-01-26 20:46:28 -06:00
analysis-ukrainian Bump morfologik-fsa from 2.1.1 to 2.1.8 in /plugins/analysis-ukrainian (#2278) 2022-02-28 12:16:56 -08:00
discovery-azure-classic Replace exclusionary words whitelist and blacklist in the places that won't impact backwards compatibility (#2178) 2022-03-04 16:34:09 -08:00
discovery-ec2 Refactoring gated and ref-counted interfaces and their implementations (#2396) 2022-03-09 12:21:09 -08:00
discovery-gce Update to log4j 2.17.1 (#1820) 2021-12-28 17:06:42 -05:00
examples Replace exclusionary words whitelist and blacklist in the places that won't impact backwards compatibility (#2178) 2022-03-04 16:34:09 -08:00
ingest-attachment Upgrading bouncycastle to 1.70 (#1832) 2022-01-03 07:35:38 -05:00
mapper-annotated-text [Remove] 6x skip from yml (#2153) 2022-02-22 23:20:18 -06:00
mapper-murmur3 [Refactor] MapperService to QueryShardContext in valueFetcher (#2027) 2022-02-08 08:38:20 -05:00
mapper-size [Remove] types from PutMappingRequest (#2335) 2022-03-04 13:30:43 -06:00
repository-azure Bump guava from 30.1.1-jre to 31.1-jre in /plugins/repository-azure (#2382) 2022-03-07 13:08:07 -05:00
repository-gcs Bump forbiddenapis from 2.7 to 3.2 in /buildSrc/src/testKit/thirdPartyAudit (#2185) 2022-02-24 11:27:44 -08:00
repository-hdfs Bump gson from 2.8.9 to 2.9.0 in /plugins/repository-hdfs (#2279) 2022-02-28 12:17:16 -08:00
repository-s3 Refactoring gated and ref-counted interfaces and their implementations (#2396) 2022-03-09 12:21:09 -08:00
store-smb [Remove] Types from GET/MGET (#2168) 2022-02-21 11:37:27 -06:00
transport-nio Bump forbiddenapis from 2.7 to 3.2 in /buildSrc/src/testKit/thirdPartyAudit (#2185) 2022-02-24 11:27:44 -08:00
build.gradle [License] Add SPDX and OpenSearch Modification license header (#509) 2021-04-09 14:28:18 -05:00