use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class TableOperationsImpl method doFateOperation.
String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String, String> opts, String tableOrNamespaceName, boolean wait) throws AccumuloSecurityException, TableExistsException, TableNotFoundException, AccumuloException, NamespaceExistsException, NamespaceNotFoundException {
Long opid = null;
try {
opid = beginFateOperation();
executeFateOperation(opid, op, args, opts, !wait);
if (!wait) {
opid = null;
return null;
}
return waitForFateOperation(opid);
} catch (ThriftSecurityException e) {
switch(e.getCode()) {
case TABLE_DOESNT_EXIST:
throw new TableNotFoundException(null, tableOrNamespaceName, "Target table does not exist");
case NAMESPACE_DOESNT_EXIST:
throw new NamespaceNotFoundException(null, tableOrNamespaceName, "Target namespace does not exist");
default:
String tableInfo = context.getPrintableTableInfoFromName(tableOrNamespaceName);
throw new AccumuloSecurityException(e.user, e.code, tableInfo, e);
}
} catch (ThriftTableOperationException e) {
switch(e.getType()) {
case EXISTS:
throw new TableExistsException(e);
case NOTFOUND:
throw new TableNotFoundException(e);
case NAMESPACE_EXISTS:
throw new NamespaceExistsException(e);
case NAMESPACE_NOTFOUND:
throw new NamespaceNotFoundException(e);
case OFFLINE:
throw new TableOfflineException(e.getTableId() == null ? null : TableId.of(e.getTableId()), tableOrNamespaceName);
case BULK_CONCURRENT_MERGE:
throw new AccumuloBulkMergeException(e);
default:
throw new AccumuloException(e.description, e);
}
} catch (Exception e) {
throw new AccumuloException(e.getMessage(), e);
} finally {
context.clearTableListCache();
// always finish table op, even when exception
if (opid != null)
try {
finishFateOperation(opid);
} catch (Exception e) {
log.warn("Exception thrown while finishing fate table operation", e);
}
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ManagerClient method executeGeneric.
public static void executeGeneric(ClientContext context, ClientExec<ManagerClientService.Client> exec) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
ManagerClientService.Client client = null;
while (true) {
try {
client = getConnectionWithRetry(context);
exec.execute(client);
break;
} catch (TTransportException tte) {
log.debug("ManagerClient request failed, retrying ... ", tte);
sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (AccumuloException e) {
throw e;
} catch (ThriftTableOperationException e) {
switch(e.getType()) {
case NAMESPACE_NOTFOUND:
throw new TableNotFoundException(e.getTableName(), new NamespaceNotFoundException(e));
case NOTFOUND:
throw new TableNotFoundException(e);
default:
throw new AccumuloException(e);
}
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, re-creating" + " the connection to the active Manager");
} catch (Exception e) {
throw new AccumuloException(e);
} finally {
if (client != null)
close(client, context);
}
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class NamespaceOperationsImpl method testClassLoad.
@Override
public boolean testClassLoad(final String namespace, final String className, final String asTypeName) throws NamespaceNotFoundException, AccumuloException, AccumuloSecurityException {
EXISTING_NAMESPACE_NAME.validate(namespace);
checkArgument(className != null, "className is null");
checkArgument(asTypeName != null, "asTypeName is null");
try {
return ServerClient.executeRaw(context, client -> client.checkNamespaceClass(TraceUtil.traceInfo(), context.rpcCreds(), namespace, className, asTypeName));
} catch (ThriftTableOperationException e) {
switch(e.getType()) {
case NAMESPACE_NOTFOUND:
throw new NamespaceNotFoundException(e);
default:
throw new AccumuloException(e.description, e);
}
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (AccumuloException e) {
throw e;
} catch (Exception e) {
throw new AccumuloException(e);
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class Manager method mustBeOnline.
public void mustBeOnline(final TableId tableId) throws ThriftTableOperationException {
ServerContext context = getContext();
context.clearTableListCache();
if (context.getTableState(tableId) != TableState.ONLINE) {
throw new ThriftTableOperationException(tableId.canonical(), null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online");
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ClientServiceHandler method getNamespaceConfiguration.
@Override
public Map<String, String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException {
NamespaceId namespaceId;
try {
namespaceId = Namespaces.getNamespaceId(context, ns);
} catch (NamespaceNotFoundException e) {
String why = "Could not find namespace while getting configuration.";
throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why);
}
AccumuloConfiguration config = context.getNamespaceConfiguration(namespaceId);
return conf(credentials, config);
}
Aggregations