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;
}
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());
}
}
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");
}
}
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);
}
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");
}
Aggregations