Search in sources :

Example 1 with GetInfoValue

use of org.apache.hive.service.cli.GetInfoValue in project cdap by caskdata.

the class BaseHiveExploreService method getInfo.

@Override
public MetaDataInfo getInfo(MetaDataInfo.InfoType infoType) throws ExploreException, SQLException {
    startAndWait();
    try {
        MetaDataInfo ret = infoType.getDefaultValue();
        if (ret != null) {
            return ret;
        }
        SessionHandle sessionHandle = null;
        Map<String, String> sessionConf = startSession();
        try {
            sessionHandle = openHiveSession(sessionConf);
            // Convert to GetInfoType
            GetInfoType hiveInfoType = null;
            for (GetInfoType t : GetInfoType.values()) {
                if (t.name().equals("CLI_" + infoType.name())) {
                    hiveInfoType = t;
                    break;
                }
            }
            if (hiveInfoType == null) {
                // Should not come here, unless there is a mismatch between Explore and Hive info types.
                LOG.warn("Could not find Hive info type %s", infoType);
                return null;
            }
            GetInfoValue val = cliService.getInfo(sessionHandle, hiveInfoType);
            LOG.trace("Retrieving info: {}, got value {}", infoType, val);
            return new MetaDataInfo(val.getStringValue(), val.getShortValue(), val.getIntValue(), val.getLongValue());
        } finally {
            closeInternal(getQueryHandle(sessionConf), new ReadOnlyOperationInfo(sessionHandle, null, sessionConf, "", ""));
        }
    } catch (HiveSQLException e) {
        throw getSqlException(e);
    } catch (Throwable e) {
        throw new ExploreException(e);
    }
}
Also used : GetInfoType(org.apache.hive.service.cli.GetInfoType) GetInfoValue(org.apache.hive.service.cli.GetInfoValue) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) SessionHandle(org.apache.hive.service.cli.SessionHandle) MetaDataInfo(co.cask.cdap.explore.service.MetaDataInfo) ExploreException(co.cask.cdap.explore.service.ExploreException)

Example 2 with GetInfoValue

use of org.apache.hive.service.cli.GetInfoValue in project hive by apache.

the class ThriftCLIServiceClient method getInfo.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getInfo(org.apache.hive.service.cli.SessionHandle, java.util.List)
   */
@Override
public GetInfoValue getInfo(SessionHandle sessionHandle, GetInfoType infoType) throws HiveSQLException {
    try {
        // FIXME extract the right info type
        TGetInfoReq req = new TGetInfoReq(sessionHandle.toTSessionHandle(), infoType.toTGetInfoType());
        TGetInfoResp resp = cliService.GetInfo(req);
        checkStatus(resp.getStatus());
        return new GetInfoValue(resp.getInfoValue());
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TGetInfoReq(org.apache.hive.service.rpc.thrift.TGetInfoReq) GetInfoValue(org.apache.hive.service.cli.GetInfoValue) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetInfoResp(org.apache.hive.service.rpc.thrift.TGetInfoResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 3 with GetInfoValue

use of org.apache.hive.service.cli.GetInfoValue in project hive by apache.

the class ThriftCLIService method GetInfo.

@Override
public TGetInfoResp GetInfo(TGetInfoReq req) throws TException {
    TGetInfoResp resp = new TGetInfoResp();
    try {
        GetInfoValue getInfoValue = cliService.getInfo(new SessionHandle(req.getSessionHandle()), GetInfoType.getGetInfoType(req.getInfoType()));
        resp.setInfoValue(getInfoValue.toTGetInfoValue());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error getting info: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : GetInfoValue(org.apache.hive.service.cli.GetInfoValue) TGetInfoResp(org.apache.hive.service.rpc.thrift.TGetInfoResp) SessionHandle(org.apache.hive.service.cli.SessionHandle) 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

GetInfoValue (org.apache.hive.service.cli.GetInfoValue)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)3 SessionHandle (org.apache.hive.service.cli.SessionHandle)2 TGetInfoResp (org.apache.hive.service.rpc.thrift.TGetInfoResp)2 TException (org.apache.thrift.TException)2 ExploreException (co.cask.cdap.explore.service.ExploreException)1 MetaDataInfo (co.cask.cdap.explore.service.MetaDataInfo)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 LoginException (javax.security.auth.login.LoginException)1 ServiceException (org.apache.hive.service.ServiceException)1 GetInfoType (org.apache.hive.service.cli.GetInfoType)1 TGetInfoReq (org.apache.hive.service.rpc.thrift.TGetInfoReq)1