@Override
    public SqlGatewayEndpoint createSqlGatewayEndpoint(Context context) {
        SqlGatewayEndpointFactoryUtils.EndpointFactoryHelper helper =
                SqlGatewayEndpointFactoryUtils.createEndpointFactoryHelper(this, context);
        ReadableConfig configuration = helper.getOptions();
        validate(configuration);
        return new HiveServer2Endpoint(
                context.getSqlGatewayService(),
                getInetSocketAddress(configuration),
                checkNotNull(configuration.get(THRIFT_MAX_MESSAGE_SIZE)),
                (int) configuration.get(THRIFT_LOGIN_TIMEOUT).toMillis(),
                (int) configuration.get(THRIFT_LOGIN_BEBACKOFF_SLOT_LENGTH).toMillis(),
                configuration.get(THRIFT_WORKER_THREADS_MIN),
                configuration.get(THRIFT_WORKER_THREADS_MAX),
                configuration.get(THRIFT_WORKER_KEEPALIVE_TIME),
                configuration.get(CATALOG_NAME),
                HiveCatalog.createHiveConf(configuration.get(CATALOG_HIVE_CONF_DIR), null),
                configuration.get(CATALOG_DEFAULT_DATABASE),
                configuration.get(MODULE_NAME));
    }
@Test
    public void testCreateHiveServer2Endpoint() throws Exception {
        assertThat(
                        SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(
                                service, Configuration.fromMap(getDefaultConfig())))
                .isEqualTo(
                        Collections.singletonList(
                                new HiveServer2Endpoint(
                                        service,
                                        new InetSocketAddress("localhost", port),
                                        maxMessageSize,
                                        (int) loginTimeout.toMillis(),
                                        (int) backOffSlotLength.toMillis(),
                                        minWorkerThreads,
                                        maxWorkerThreads,
                                        workerAliveDuration,
                                        catalogName,
                                        HiveTestUtils.createHiveConf(),
                                        defaultDatabase,
                                        moduleName)));
    }