use of org.apache.thrift.TApplicationException in project hive by apache.
the class TestForeignKey method addNoSuchCatalog.
@Test
public void addNoSuchCatalog() throws TException {
Table parentTable = testTables[0];
List<SQLPrimaryKey> pk = new SQLPrimaryKeyBuilder().onTable(parentTable).addColumn("col1").build(metaStore.getConf());
client.addPrimaryKey(pk);
try {
List<SQLForeignKey> fk = new SQLForeignKeyBuilder().setTableName(testTables[0].getTableName()).setDbName(testTables[0].getDbName()).setCatName("nosuch").fromPrimaryKey(pk).addColumn("col2").build(metaStore.getConf());
client.addForeignKey(fk);
Assert.fail();
} catch (InvalidObjectException | TApplicationException e) {
// NOP
}
}
use of org.apache.thrift.TApplicationException in project hive by apache.
the class TestNotNullConstraint method addNoSuchTable.
@Test
public void addNoSuchTable() throws TException {
try {
List<SQLNotNullConstraint> nn = new SQLNotNullConstraintBuilder().setTableName("nosuch").addColumn("col2").build(metaStore.getConf());
client.addNotNullConstraint(nn);
Assert.fail();
} catch (InvalidObjectException | TApplicationException e) {
// NOP
}
}
use of org.apache.thrift.TApplicationException in project hive by apache.
the class TestPrimaryKey method addNoSuchTable.
@Test
public void addNoSuchTable() throws TException {
try {
List<SQLPrimaryKey> pk = new SQLPrimaryKeyBuilder().setTableName("nosuch").addColumn("col2").build(metaStore.getConf());
client.addPrimaryKey(pk);
Assert.fail();
} catch (InvalidObjectException | TApplicationException e) {
// NOP
}
}
use of org.apache.thrift.TApplicationException in project hive by apache.
the class RetryingMetaStoreClient method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object ret;
int retriesMade = 0;
TException caughtException;
boolean allowReconnect = !method.isAnnotationPresent(NoReconnect.class);
boolean allowRetry = true;
Annotation[] directives = method.getDeclaredAnnotations();
if (directives != null) {
for (Annotation a : directives) {
if (a instanceof RetrySemantics.CannotRetry) {
allowRetry = false;
}
}
}
while (true) {
try {
SecurityUtils.reloginExpiringKeytabUser();
if (allowReconnect) {
if (retriesMade > 0 || hasConnectionLifeTimeReached(method)) {
if (this.ugi != null) {
// Perform reconnect with the proper user context
try {
LOG.info("RetryingMetaStoreClient trying reconnect as " + this.ugi);
this.ugi.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws MetaException {
base.reconnect();
return null;
}
});
} catch (UndeclaredThrowableException e) {
Throwable te = e.getCause();
if (te instanceof PrivilegedActionException) {
throw te.getCause();
} else {
throw te;
}
}
lastConnectionTime = System.currentTimeMillis();
} else {
LOG.warn("RetryingMetaStoreClient unable to reconnect. No UGI information.");
throw new MetaException("UGI information unavailable. Will not attempt a reconnect.");
}
}
}
if (metaCallTimeMap == null) {
ret = method.invoke(base, args);
} else {
// need to capture the timing
long startTime = System.currentTimeMillis();
ret = method.invoke(base, args);
long timeTaken = System.currentTimeMillis() - startTime;
addMethodTime(method, timeTaken);
}
break;
} catch (UndeclaredThrowableException e) {
throw e.getCause();
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof TApplicationException) {
TApplicationException tae = (TApplicationException) t;
switch(tae.getType()) {
case TApplicationException.UNSUPPORTED_CLIENT_TYPE:
case TApplicationException.UNKNOWN_METHOD:
case TApplicationException.WRONG_METHOD_NAME:
case TApplicationException.INVALID_PROTOCOL:
throw t;
default:
// TODO: most other options are probably unrecoverable... throw?
caughtException = tae;
}
} else if ((t instanceof TProtocolException) || (t instanceof TTransportException)) {
// TODO: most protocol exceptions are probably unrecoverable... throw?
caughtException = (TException) t;
} else if ((t instanceof MetaException) && isRecoverableMetaException((MetaException) t)) {
caughtException = (MetaException) t;
} else {
throw t;
}
} catch (MetaException e) {
if (isRecoverableMetaException(e)) {
caughtException = e;
} else {
throw e;
}
}
if (retriesMade >= retryLimit || base.isLocalMetaStore() || !allowRetry) {
throw caughtException;
}
retriesMade++;
LOG.warn("MetaStoreClient lost connection. Attempting to reconnect (" + retriesMade + " of " + retryLimit + ") after " + retryDelaySeconds + "s. " + method.getName(), caughtException);
Thread.sleep(retryDelaySeconds * 1000);
}
return ret;
}
use of org.apache.thrift.TApplicationException in project hive by apache.
the class TestCheckConstraint method doubleAddUniqueConstraint.
@Test
public void doubleAddUniqueConstraint() throws TException {
Table table = testTables[0];
// Make sure get on a table with no key returns empty list
CheckConstraintsRequest rqst = new CheckConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
List<SQLCheckConstraint> fetched = client.getCheckConstraints(rqst);
Assert.assertTrue(fetched.isEmpty());
// Single column unnamed primary key in default catalog and database
List<SQLCheckConstraint> cc = new SQLCheckConstraintBuilder().onTable(table).addColumn("col1").setCheckExpression("> 0").build(metaStore.getConf());
client.addCheckConstraint(cc);
try {
cc = new SQLCheckConstraintBuilder().onTable(table).addColumn("col2").setCheckExpression("= 'this string intentionally left empty'").build(metaStore.getConf());
client.addCheckConstraint(cc);
Assert.fail();
} catch (InvalidObjectException | TApplicationException e) {
// NOP
}
}
Aggregations