You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tcp_port.rb
    path of file: ./repos/puppet-elasticsearch/lib/puppet/provider/es_instance_conn_validator
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
require 'puppet/util/es_instance_validator'

# This file cont
    
  def exists?
    start_time = Time.now
    timeout = resource[:timeout]
    sleep_interval = resource[:sleep_interval]

    success = validator.attempt_connection

    while success == false && ((Time.now - start_time) < timeout)
      # It can take several seconds for the Elasticsearch to start up;
      # especially on the first install.  Therefore, our first connection attempt
      # may fail.  Here we have somewhat arbitrarily chosen to retry every 10
      # seconds until the configurable timeout has expired.
      Puppet.debug("Failed to connect to Elasticsearch; sleeping #{sleep_interval} seconds before retry")
      sleep sleep_interval
      success = validator.attempt_connection
    end