Search in sources :

Example 1 with GetServerMetaResp

use of org.apache.drill.exec.proto.UserProtos.GetServerMetaResp in project drill by apache.

the class DrillDatabaseMetaDataImpl method getServerMeta.

private ServerMeta getServerMeta() throws SQLException {
    assert getServerMetaSupported();
    if (serverMeta == null) {
        synchronized (this) {
            if (serverMeta == null) {
                DrillConnectionImpl connection = (DrillConnectionImpl) getConnection();
                try {
                    GetServerMetaResp resp = connection.getClient().getServerMeta().get();
                    if (resp.getStatus() != RequestStatus.OK) {
                        DrillPBError drillError = resp.getError();
                        throw new SQLException("Error when getting server meta: " + drillError.getMessage());
                    }
                    serverMeta = resp.getServerMeta();
                    convertSupport = SQLConvertSupport.toSQLConvertSupport(serverMeta.getConvertSupportList());
                } catch (InterruptedException e) {
                    throw new SQLException("Interrupted when getting server meta", e);
                } catch (ExecutionException e) {
                    Throwable cause = e.getCause();
                    if (cause == null) {
                        throw new AssertionError("Something unknown happened", e);
                    }
                    Throwables.propagateIfPossible(cause);
                    throw new SQLException("Error when getting server meta", cause);
                }
            }
        }
    }
    return serverMeta;
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) SQLException(java.sql.SQLException) GetServerMetaResp(org.apache.drill.exec.proto.UserProtos.GetServerMetaResp) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with GetServerMetaResp

use of org.apache.drill.exec.proto.UserProtos.GetServerMetaResp in project drill by apache.

the class TestServerMetaProvider method testServerMeta.

@Test
public void testServerMeta() throws Exception {
    GetServerMetaResp resp = client.getServerMeta().get();
    assertNotNull(resp);
    assertEquals(RequestStatus.OK, resp.getStatus());
    assertNotNull(resp.getServerMeta());
    ServerMeta serverMeta = resp.getServerMeta();
    logger.trace("Server metadata: {}", serverMeta);
    assertEquals(Quoting.BACK_TICK.string, serverMeta.getIdentifierQuoteString());
}
Also used : ServerMeta(org.apache.drill.exec.proto.UserProtos.ServerMeta) GetServerMetaResp(org.apache.drill.exec.proto.UserProtos.GetServerMetaResp) Test(org.junit.Test)

Aggregations

GetServerMetaResp (org.apache.drill.exec.proto.UserProtos.GetServerMetaResp)2 SQLException (java.sql.SQLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 DrillPBError (org.apache.drill.exec.proto.UserBitShared.DrillPBError)1 ServerMeta (org.apache.drill.exec.proto.UserProtos.ServerMeta)1 Test (org.junit.Test)1