Search in sources :

Example 11 with ThriftSecurityException

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

the class FateServiceHandler method waitForFateOperation.

@Override
public String waitForFateOperation(TInfo tinfo, TCredentials credentials, long opid) throws ThriftSecurityException, ThriftTableOperationException {
    authenticate(credentials);
    TStatus status = manager.fate.waitForCompletion(opid);
    if (status == TStatus.FAILED) {
        Exception e = manager.fate.getException(opid);
        if (e instanceof ThriftTableOperationException)
            throw (ThriftTableOperationException) e;
        else if (e instanceof ThriftSecurityException)
            throw (ThriftSecurityException) e;
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException(e);
    }
    String ret = manager.fate.getReturn(opid);
    if (ret == null)
        // thrift does not like returning null
        ret = "";
    return ret;
}
Also used : TStatus(org.apache.accumulo.fate.ReadOnlyTStore.TStatus) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)

Example 12 with ThriftSecurityException

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

the class ManagerClientServiceHandler method setSystemProperty.

@Override
public void setSystemProperty(TInfo info, TCredentials c, String property, String value) throws TException {
    if (!manager.security.canPerformSystemActions(c))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
        SystemPropUtil.setSystemProperty(manager.getContext(), property, value);
        updatePlugins(property);
    } catch (IllegalArgumentException iae) {
        // throw the exception here so it is not caught and converted to a generic TException
        throw iae;
    } catch (Exception e) {
        Manager.log.error("Problem setting config property in zookeeper", e);
        throw new TException(e.getMessage());
    }
}
Also used : TException(org.apache.thrift.TException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TabletDeletedException(org.apache.accumulo.core.metadata.schema.TabletDeletedException) KeeperException(org.apache.zookeeper.KeeperException) TException(org.apache.thrift.TException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 13 with ThriftSecurityException

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

the class ManagerClientServiceHandler method alterTableProperty.

private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException {
    final TableId tableId = ClientServiceHandler.checkTableId(manager.getContext(), tableName, op);
    NamespaceId namespaceId = getNamespaceIdFromTableId(op, tableId);
    if (!manager.security.canAlterTable(c, tableId, namespaceId))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
        if (value == null || value.isEmpty()) {
            TablePropUtil.removeTableProperty(manager.getContext(), tableId, property);
        } else if (!TablePropUtil.setTableProperty(manager.getContext(), 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(manager.getContext(), tableName, op);
        log.info("Error altering table property", e);
        throw new ThriftTableOperationException(tableId.canonical(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property");
    } catch (Exception e) {
        log.error("Problem altering table property", e);
        throw new ThriftTableOperationException(tableId.canonical(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property");
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) NamespaceId(org.apache.accumulo.core.data.NamespaceId) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TabletDeletedException(org.apache.accumulo.core.metadata.schema.TabletDeletedException) KeeperException(org.apache.zookeeper.KeeperException) TException(org.apache.thrift.TException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) KeeperException(org.apache.zookeeper.KeeperException)

Example 14 with ThriftSecurityException

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

the class ManagerClientServiceHandler method shutdown.

@Override
public void shutdown(TInfo info, TCredentials c, boolean stopTabletServers) throws ThriftSecurityException {
    if (!manager.security.canPerformSystemActions(c))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    if (stopTabletServers) {
        manager.setManagerGoalState(ManagerGoalState.CLEAN_STOP);
        EventCoordinator.Listener eventListener = manager.nextEvent.getListener();
        do {
            eventListener.waitForEvents(Manager.ONE_SECOND);
        } while (manager.tserverSet.size() > 0);
    }
    manager.setManagerState(ManagerState.STOP);
}
Also used : ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)

Example 15 with ThriftSecurityException

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

the class ManagerClientServiceHandler method shutdownTabletServer.

@Override
public void shutdownTabletServer(TInfo info, TCredentials c, String tabletServer, boolean force) throws ThriftSecurityException {
    if (!manager.security.canPerformSystemActions(c))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    final TServerInstance doomed = manager.tserverSet.find(tabletServer);
    if (!force) {
        final TServerConnection server = manager.tserverSet.getConnection(doomed);
        if (server == null) {
            Manager.log.warn("No server found for name {}", tabletServer);
            return;
        }
    }
    long tid = manager.fate.startTransaction();
    String msg = "Shutdown tserver " + tabletServer;
    manager.fate.seedTransaction(tid, new TraceRepo<>(new ShutdownTServer(doomed, force)), false, msg);
    manager.fate.waitForCompletion(tid);
    manager.fate.delete(tid);
    log.debug("FATE op shutting down " + tabletServer + " finished");
}
Also used : TServerConnection(org.apache.accumulo.server.manager.LiveTServerSet.TServerConnection) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) ShutdownTServer(org.apache.accumulo.manager.tserverOps.ShutdownTServer)

Aggregations

ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)61 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)33 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)28 TException (org.apache.thrift.TException)25 ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)20 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)14 AccumuloException (org.apache.accumulo.core.client.AccumuloException)14 TableId (org.apache.accumulo.core.data.TableId)14 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)14 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)13 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)13 NamespaceId (org.apache.accumulo.core.data.NamespaceId)11 Tablet (org.apache.accumulo.tserver.tablet.Tablet)10 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)10 HashSet (java.util.HashSet)9 NotServingTabletException (org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException)9 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8