MCPcopy Create free account
hub / github.com/apache/impala / _connect

Method _connect

shell/impala_shell/impala_shell.py:1150–1205  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1148 self.set_query_options = new_query_options
1149
1150 def _connect(self):
1151 try:
1152 self.server_version, self.webserver_address = self.imp_client.connect()
1153 except MissingThriftMethodException as e:
1154 if options.protocol.lower() == 'beeswax':
1155 port_flag = "-beeswax_port"
1156 addtl_suggestion = ""
1157 else:
1158 assert options.protocol.lower() == 'hs2'
1159 port_flag = "-hs2_port"
1160 addtl_suggestion = (" Also check that the Impala daemon connected to has version "
1161 "3.3 or greater. impala-shell only supports connecting to "
1162 "the HS2 interface of Impala version 3.3 or greater. For "
1163 "older Impala versions you must use the (deprecated) beeswax "
1164 "protocol with the --protocol=beeswax.")
1165 # We get a TApplicationException if the transport is valid,
1166 # but the RPC does not exist.
1167 print("\n".join(textwrap.wrap(
1168 "Error: Unable to communicate with impalad service because of the error "
1169 "reported below. The service does not implement a required Thrift method. "
1170 "The service may not be an Impala Daemon or you may have specified the wrong "
1171 "port to connect to. Check host:port to ensure that the port matches the "
1172 "{port_flag} flag on the Impala Daemon and try again.{addtl_suggestion}".format(
1173 port_flag=port_flag, addtl_suggestion=addtl_suggestion))), file=sys.stderr)
1174 print(str(e), file=sys.stderr)
1175 self.close_connection()
1176 raise
1177 except ImportError:
1178 print("Unable to import the python 'ssl' module. It is"
1179 " required for an SSL-secured connection.", file=sys.stderr)
1180 raise FatalShellException()
1181 except socket.error as e:
1182 # if the socket was interrupted, reconnect the connection with the client
1183 if e.errno == errno.EINTR:
1184 self._reconnect_cancellation()
1185 else:
1186 print("%s %s: %s" % (self.SOCKET_ERROR_MESSAGE, e.errno, e), file=sys.stderr)
1187 self.close_connection()
1188 self.prompt = self.DISCONNECTED_PROMPT
1189 except Exception as e:
1190 if self.ldap_password_cmd and \
1191 self.ldap_password and \
1192 self.ldap_password.endswith('\n'):
1193 print("Warning: LDAP password contains a trailing newline. "
1194 "Did you use 'echo' instead of 'echo -n'?", file=sys.stderr)
1195 if self.use_ssl and sys.version_info < (2, 7, 9) \
1196 and "EOF occurred in violation of protocol" in str(e):
1197 print("Warning: TLSv1.2 is not supported for Python < 2.7.9", file=sys.stderr)
1198 log_exception_with_timestamp(e, "Exception",
1199 self.ERROR_CONNECTING_MESSAGE + type(e).__name__)
1200 # A secure connection may still be open. So we explicitly close it.
1201 self.close_connection()
1202 # If a connection to another impalad failed while already connected
1203 # reset the prompt to disconnected.
1204 self.server_version = self.UNKNOWN_SERVER_VERSION
1205 self.prompt = self.DISCONNECTED_PROMPT
1206
1207 def _reconnect_cancellation(self):

Callers 3

precmdMethod · 0.95
do_connectMethod · 0.95

Calls 9

close_connectionMethod · 0.95
FatalShellExceptionClass · 0.85
wrapMethod · 0.80
typeEnum · 0.50
connectMethod · 0.45
joinMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected