Search in sources :

Example 1 with TSetClientInfoResp

use of org.apache.hive.service.rpc.thrift.TSetClientInfoResp in project hive by apache.

the class ThriftCLIServiceClient method setApplicationName.

@Override
public void setApplicationName(SessionHandle sh, String value) throws HiveSQLException {
    try {
        TSetClientInfoReq req = new TSetClientInfoReq(sh.toTSessionHandle());
        req.putToConfiguration("ApplicationName", value);
        TSetClientInfoResp resp = cliService.SetClientInfo(req);
        checkStatus(resp.getStatus());
    } catch (TException e) {
        throw new HiveSQLException(e);
    }
}
Also used : TException(org.apache.thrift.TException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TSetClientInfoResp(org.apache.hive.service.rpc.thrift.TSetClientInfoResp) TSetClientInfoReq(org.apache.hive.service.rpc.thrift.TSetClientInfoReq)

Example 2 with TSetClientInfoResp

use of org.apache.hive.service.rpc.thrift.TSetClientInfoResp in project hive by apache.

the class HiveConnection method sendClientInfo.

private void sendClientInfo() throws SQLClientInfoException {
    TSetClientInfoReq req = new TSetClientInfoReq(sessHandle);
    Map<String, String> map = new HashMap<>();
    if (clientInfo != null) {
        for (Entry<Object, Object> e : clientInfo.entrySet()) {
            if (e.getKey() == null || e.getValue() == null)
                continue;
            map.put(e.getKey().toString(), e.getValue().toString());
        }
    }
    req.setConfiguration(map);
    try {
        TSetClientInfoResp openResp = client.SetClientInfo(req);
        Utils.verifySuccess(openResp.getStatus());
    } catch (TException | SQLException e) {
        LOG.error("Error sending client info", e);
        throw new SQLClientInfoException("Error sending client info", null, e);
    }
}
Also used : TException(org.apache.thrift.TException) SQLClientInfoException(java.sql.SQLClientInfoException) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) TSetClientInfoResp(org.apache.hive.service.rpc.thrift.TSetClientInfoResp) TSetClientInfoReq(org.apache.hive.service.rpc.thrift.TSetClientInfoReq)

Example 3 with TSetClientInfoResp

use of org.apache.hive.service.rpc.thrift.TSetClientInfoResp in project hive by apache.

the class ThriftCLIService method SetClientInfo.

@Override
public TSetClientInfoResp SetClientInfo(TSetClientInfoReq req) throws TException {
    // TODO: We don't do anything for now, just log this for debugging.
    // We may be able to make use of this later, e.g. for workload management.
    TSetClientInfoResp resp = null;
    if (req.isSetConfiguration()) {
        StringBuilder sb = null;
        SessionHandle sh = null;
        for (Map.Entry<String, String> e : req.getConfiguration().entrySet()) {
            if (sb == null) {
                sh = new SessionHandle(req.getSessionHandle());
                sb = new StringBuilder("Client information for ").append(sh).append(": ");
            } else {
                sb.append(", ");
            }
            sb.append(e.getKey()).append(" = ").append(e.getValue());
            if ("ApplicationName".equals(e.getKey())) {
                try {
                    cliService.setApplicationName(sh, e.getValue());
                } catch (Exception ex) {
                    LOG.warn("Error setting application name", ex);
                    resp = new TSetClientInfoResp(HiveSQLException.toTStatus(ex));
                }
            }
        }
        if (sb != null) {
            LOG.info("{}", sb);
        }
    }
    return resp == null ? new TSetClientInfoResp(OK_STATUS) : resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) Map(java.util.Map) HashMap(java.util.HashMap) TSetClientInfoResp(org.apache.hive.service.rpc.thrift.TSetClientInfoResp) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

TSetClientInfoResp (org.apache.hive.service.rpc.thrift.TSetClientInfoResp)3 TException (org.apache.thrift.TException)3 HashMap (java.util.HashMap)2 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 TSetClientInfoReq (org.apache.hive.service.rpc.thrift.TSetClientInfoReq)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 SQLClientInfoException (java.sql.SQLClientInfoException)1 SQLException (java.sql.SQLException)1 Map (java.util.Map)1 LoginException (javax.security.auth.login.LoginException)1 ServiceException (org.apache.hive.service.ServiceException)1 SessionHandle (org.apache.hive.service.cli.SessionHandle)1