Class AmazonEc2Reference

java.lang.Object
org.opensearch.common.util.concurrent.AbstractRefCounted
org.opensearch.discovery.ec2.AmazonEc2Reference
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, Releasable, RefCounted

public class AmazonEc2Reference
extends AbstractRefCounted
implements Releasable
Handles the shutdown of the wrapped AmazonEC2 using reference counting.
  • Method Summary

    Modifier and Type Method Description
    com.amazonaws.services.ec2.AmazonEC2 client()
    Returns the underlying `AmazonEC2` client.
    void close()
    Call when the client is not needed anymore.
    protected void closeInternal()  

    Methods inherited from class org.opensearch.common.util.concurrent.AbstractRefCounted

    alreadyClosed, decRef, getName, incRef, refCount, tryIncRef

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • close

      public void close()
      Call when the client is not needed anymore.
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Specified by:
      close in interface Releasable
    • client

      public com.amazonaws.services.ec2.AmazonEC2 client()
      Returns the underlying `AmazonEC2` client. All method calls are permitted BUT NOT shutdown. Shutdown is called when reference count reaches 0.
    • closeInternal

      protected void closeInternal()
      Specified by:
      closeInternal in class AbstractRefCounted