Search in sources :

Example 31 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException in project accumulo by apache.

the class MasterClientServiceHandler method alterTableProperty.

private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException {
    final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, op);
    Namespace.ID namespaceId = getNamespaceIdFromTableId(op, tableId);
    if (!master.security.canAlterTable(c, tableId, namespaceId))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
        if (value == null || value.isEmpty()) {
            TablePropUtil.removeTableProperty(tableId, property);
        } else if (!TablePropUtil.setTableProperty(tableId, property, value)) {
            throw new Exception("Invalid table property.");
        }
    } catch (KeeperException.NoNodeException e) {
        // race condition... table no longer exists? This call will throw an exception if the table was deleted:
        ClientServiceHandler.checkTableId(master.getInstance(), tableName, op);
        log.info("Error altering table property", e);
        throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property");
    } catch (Exception e) {
        log.error("Problem altering table property", e);
        throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property");
    }
}
Also used : MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) ReplicationTable(org.apache.accumulo.core.replication.ReplicationTable) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) Namespace(org.apache.accumulo.core.client.impl.Namespace) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TabletDeletedException(org.apache.accumulo.server.util.TabletIterator.TabletDeletedException) KeeperException(org.apache.zookeeper.KeeperException) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) KeeperException(org.apache.zookeeper.KeeperException)

Example 32 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException in project accumulo by apache.

the class MasterReplicationCoordinator method getServicerAddress.

@Override
public String getServicerAddress(String remoteTableId, TCredentials creds) throws ReplicationCoordinatorException, TException {
    try {
        security.authenticateUser(master.rpcCreds(), creds);
    } catch (ThriftSecurityException e) {
        log.error("{} failed to authenticate for replication to {}", creds.getPrincipal(), remoteTableId);
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.CANNOT_AUTHENTICATE, "Could not authenticate " + creds.getPrincipal());
    }
    Set<TServerInstance> tservers = master.onlineTabletServers();
    if (tservers.isEmpty()) {
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.NO_AVAILABLE_SERVERS, "No tservers are available for replication");
    }
    TServerInstance tserver = getRandomTServer(tservers, rand.nextInt(tservers.size()));
    String replServiceAddr;
    try {
        replServiceAddr = new String(reader.getData(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver.hostPort(), null), UTF_8);
    } catch (KeeperException | InterruptedException e) {
        log.error("Could not fetch repliation service port for tserver", e);
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.SERVICE_CONFIGURATION_UNAVAILABLE, "Could not determine port for replication service running at " + tserver.hostPort());
    }
    return replServiceAddr;
}
Also used : ReplicationCoordinatorException(org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) KeeperException(org.apache.zookeeper.KeeperException)

Example 33 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException in project accumulo by apache.

the class Writer method updateServer.

private static void updateServer(ClientContext context, Mutation m, KeyExtent extent, HostAndPort server) throws TException, NotServingTabletException, ConstraintViolationException, AccumuloSecurityException {
    checkArgument(m != null, "m is null");
    checkArgument(extent != null, "extent is null");
    checkArgument(server != null, "server is null");
    checkArgument(context != null, "context is null");
    TabletClientService.Iface client = null;
    try {
        client = ThriftUtil.getTServerClient(server, context);
        client.update(Tracer.traceInfo(), context.rpcCreds(), extent.toThrift(), m.toThrift(), TDurability.DEFAULT);
        return;
    } catch (ThriftSecurityException e) {
        throw new AccumuloSecurityException(e.user, e.code);
    } finally {
        ThriftUtil.returnClient((TServiceClient) client);
    }
}
Also used : AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)

Example 34 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException in project accumulo by apache.

the class MiniAccumuloClusterImpl method getMasterMonitorInfo.

/**
 * Get programmatic interface to information available in a normal monitor. XXX the returned structure won't contain information about the metadata table
 * until there is data in it. e.g. if you want to see the metadata table you should create a table.
 *
 * @since 1.6.1
 */
public MasterMonitorInfo getMasterMonitorInfo() throws AccumuloException, AccumuloSecurityException {
    MasterClientService.Iface client = null;
    while (true) {
        try {
            Instance instance = new ZooKeeperInstance(getClientConfig());
            ClientContext context = new ClientContext(instance, new Credentials("root", new PasswordToken("unchecked")), getClientConfig());
            client = MasterClient.getConnectionWithRetry(context);
            return client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
        } catch (ThriftSecurityException exception) {
            throw new AccumuloSecurityException(exception);
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            log.debug("Contacted a Master which is no longer active, retrying");
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } catch (TException exception) {
            throw new AccumuloException(exception);
        } finally {
            if (client != null) {
                MasterClient.close(client);
            }
        }
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) Credentials(org.apache.accumulo.core.client.impl.Credentials) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 35 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException in project accumulo by apache.

the class ClientServiceHandler method bulkImportFiles.

@Override
public List<String> bulkImportFiles(TInfo tinfo, final TCredentials credentials, final long tid, final String tableId, final List<String> files, final String errorDir, final boolean setTime) throws ThriftSecurityException, ThriftTableOperationException, TException {
    try {
        if (!security.canPerformSystemActions(credentials))
            throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
        bulkImportStatus.updateBulkImportStatus(files, BulkImportState.INITIAL);
        log.debug("Got request to bulk import files to table({}): {}", tableId, files);
        return transactionWatcher.run(Constants.BULK_ARBITRATOR_TYPE, tid, new Callable<List<String>>() {

            @Override
            public List<String> call() throws Exception {
                bulkImportStatus.updateBulkImportStatus(files, BulkImportState.PROCESSING);
                try {
                    return BulkImporter.bulkLoad(context, tid, tableId, files, errorDir, setTime);
                } finally {
                    bulkImportStatus.removeBulkImportStatus(files);
                }
            }
        });
    } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
    } catch (Exception ex) {
        throw new TException(ex);
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) List(java.util.List) ArrayList(java.util.ArrayList) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)

Aggregations

ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)45 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)38 AccumuloException (org.apache.accumulo.core.client.AccumuloException)23 TException (org.apache.thrift.TException)23 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)22 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)16 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)12 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 TTransportException (org.apache.thrift.transport.TTransportException)10 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)8 Namespace (org.apache.accumulo.core.client.impl.Namespace)6 Table (org.apache.accumulo.core.client.impl.Table)6 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)6 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)6 HostAndPort (org.apache.accumulo.core.util.HostAndPort)6 Key (org.apache.accumulo.core.data.Key)5 Range (org.apache.accumulo.core.data.Range)5 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 TApplicationException (org.apache.thrift.TApplicationException)5