Connect to an Impalad instance: Usage: connect, defaults to the fqdn of the localhost and the protocol's default port connect connect , defaults to the protocol's default port
(self, args)
| 1040 | return host_port |
| 1041 | |
| 1042 | def do_connect(self, args): |
| 1043 | """Connect to an Impalad instance: |
| 1044 | Usage: connect, defaults to the fqdn of the localhost and the protocol's default port |
| 1045 | connect <hostname:port> |
| 1046 | connect <hostname>, defaults to the protocol's default port |
| 1047 | |
| 1048 | """ |
| 1049 | # Assume the user wants to connect to the local impalad if no connection string is |
| 1050 | # specified. Connecting to a kerberized impalad requires an fqdn as the host name. |
| 1051 | if self.use_ldap and self.ldap_password is None: |
| 1052 | self.ldap_password = getpass.getpass("LDAP password for %s: " % self.user) |
| 1053 | |
| 1054 | if self.use_jwt and self.jwt is None: |
| 1055 | self.jwt = getpass.getpass("Enter JWT: ") |
| 1056 | |
| 1057 | if self.use_oauth and self.oauth is None: |
| 1058 | self.oauth_get_access_token() |
| 1059 | if self.oauth is None and self.oauth_mock_response is None: |
| 1060 | self.oauth = getpass.getpass("Enter OAUTH: ") |
| 1061 | |
| 1062 | if not args: args = socket.getfqdn() |
| 1063 | tokens = args.split(" ") |
| 1064 | addr = tokens[0] |
| 1065 | host_port = self.__parse_host_port(addr) |
| 1066 | protocol = options.protocol.lower() |
| 1067 | if not host_port: |
| 1068 | print("Connection string must either be empty, or of the form " |
| 1069 | "<hostname[:port]>", file=sys.stderr) |
| 1070 | return CmdStatus.ERROR |
| 1071 | elif len(host_port) == 1: |
| 1072 | if options.strict_hs2_protocol: |
| 1073 | if protocol == 'hs2': |
| 1074 | port = str(DEFAULT_STRICT_HS2_PORT) |
| 1075 | elif protocol == 'hs2-http': |
| 1076 | port = str(DEFAULT_STRICT_HS2_HTTP_PORT) |
| 1077 | else: |
| 1078 | print("Invalid protocol specified for 'strict_hs2_protocol' option: %s" |
| 1079 | % protocol, file=sys.stderr) |
| 1080 | raise FatalShellException() |
| 1081 | elif protocol == 'hs2': |
| 1082 | port = str(DEFAULT_HS2_PORT) |
| 1083 | elif protocol == 'hs2-http': |
| 1084 | port = str(DEFAULT_HS2_HTTP_PORT) |
| 1085 | elif protocol == 'beeswax': |
| 1086 | port = str(DEFAULT_BEESWAX_PORT) |
| 1087 | else: |
| 1088 | print("Invalid protocol specified: %s" % protocol, file=sys.stderr) |
| 1089 | raise FatalShellException() |
| 1090 | host_port.append(port) |
| 1091 | self.impalad = tuple(host_port) |
| 1092 | self.close_connection() |
| 1093 | self.imp_client = self._new_impala_client() |
| 1094 | self._connect() |
| 1095 | # If the connection fails and the Kerberos has not been enabled, |
| 1096 | # check for a valid kerberos ticket and retry the connection |
| 1097 | # with kerberos enabled. |
| 1098 | if not self.imp_client.connected and not self.use_kerberos: |
| 1099 | try: |
no test coverage detected