Search in sources :

Example 21 with NamespaceNotFoundException

use of org.apache.accumulo.core.client.NamespaceNotFoundException 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 {
    checkArgument(namespace != null, "namespace is null");
    checkArgument(className != null, "className is null");
    checkArgument(asTypeName != null, "asTypeName is null");
    try {
        return ServerClient.executeRaw(context, new ClientExecReturn<Boolean, ClientService.Client>() {

            @Override
            public Boolean execute(ClientService.Client client) throws Exception {
                return client.checkNamespaceClass(Tracer.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);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) ClientService(org.apache.accumulo.core.client.impl.thrift.ClientService) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) NamespaceNotEmptyException(org.apache.accumulo.core.client.NamespaceNotEmptyException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException)

Example 22 with NamespaceNotFoundException

use of org.apache.accumulo.core.client.NamespaceNotFoundException in project accumulo by apache.

the class Namespaces method getNamespaceId.

/**
 * Look for namespace ID in ZK. Throw NamespaceNotFoundException if not found.
 */
public static Namespace.ID getNamespaceId(Instance instance, String namespaceName) throws NamespaceNotFoundException {
    final ArrayList<Namespace.ID> singleId = new ArrayList<>(1);
    getAllNamespaces(instance, (id, name) -> {
        if (name.equals(namespaceName))
            singleId.add(Namespace.ID.of(id));
    });
    if (singleId.isEmpty())
        throw new NamespaceNotFoundException(null, namespaceName, "getNamespaceId() failed to find namespace");
    return singleId.get(0);
}
Also used : ArrayList(java.util.ArrayList) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException)

Example 23 with NamespaceNotFoundException

use of org.apache.accumulo.core.client.NamespaceNotFoundException in project accumulo by apache.

the class Namespaces method getNamespaceName.

/**
 * Look for namespace name in ZK. Throw NamespaceNotFoundException if not found.
 */
public static String getNamespaceName(Instance instance, Namespace.ID namespaceId) throws NamespaceNotFoundException {
    String name;
    ZooCache zc = getZooCache(instance);
    byte[] path = zc.get(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + namespaceId.canonicalID() + Constants.ZNAMESPACE_NAME);
    if (path != null)
        name = new String(path, UTF_8);
    else
        throw new NamespaceNotFoundException(namespaceId.canonicalID(), null, "getNamespaceName() failed to find namespace");
    return name;
}
Also used : ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException)

Aggregations

NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)23 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)12 AccumuloException (org.apache.accumulo.core.client.AccumuloException)10 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)8 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)7 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)7 TableExistsException (org.apache.accumulo.core.client.TableExistsException)6 IOException (java.io.IOException)5 TreeMap (java.util.TreeMap)4 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)4 IteratorScope (org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)4 TTransportException (org.apache.thrift.transport.TTransportException)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Entry (java.util.Map.Entry)3 NamespaceNotEmptyException (org.apache.accumulo.core.client.NamespaceNotEmptyException)3 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)3 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)3 FileNotFoundException (java.io.FileNotFoundException)2