You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2016/04/04 20:30:36 UTC
[6/9] accumulo git commit: ACCUMULO-4147 Add Accumulo Namespace
Operations to Proxy
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8839fe51/proxy/src/main/cpp/AccumuloProxy_server.skeleton.cpp
----------------------------------------------------------------------
diff --git a/proxy/src/main/cpp/AccumuloProxy_server.skeleton.cpp b/proxy/src/main/cpp/AccumuloProxy_server.skeleton.cpp
index 302aec2..6c2f52f 100644
--- a/proxy/src/main/cpp/AccumuloProxy_server.skeleton.cpp
+++ b/proxy/src/main/cpp/AccumuloProxy_server.skeleton.cpp
@@ -338,6 +338,21 @@ class AccumuloProxyHandler : virtual public AccumuloProxyIf {
printf("revokeTablePermission\n");
}
+ void grantNamespacePermission(const std::string& login, const std::string& user, const std::string& namespaceName, const NamespacePermission::type perm) {
+ // Your implementation goes here
+ printf("grantNamespacePermission\n");
+ }
+
+ bool hasNamespacePermission(const std::string& login, const std::string& user, const std::string& namespaceName, const NamespacePermission::type perm) {
+ // Your implementation goes here
+ printf("hasNamespacePermission\n");
+ }
+
+ void revokeNamespacePermission(const std::string& login, const std::string& user, const std::string& namespaceName, const NamespacePermission::type perm) {
+ // Your implementation goes here
+ printf("revokeNamespacePermission\n");
+ }
+
void createBatchScanner(std::string& _return, const std::string& login, const std::string& tableName, const BatchScanOptions& options) {
// Your implementation goes here
printf("createBatchScanner\n");
@@ -423,6 +438,106 @@ class AccumuloProxyHandler : virtual public AccumuloProxyIf {
printf("getFollowing\n");
}
+ void systemNamespace(std::string& _return) {
+ // Your implementation goes here
+ printf("systemNamespace\n");
+ }
+
+ void defaultNamespace(std::string& _return) {
+ // Your implementation goes here
+ printf("defaultNamespace\n");
+ }
+
+ void listNamespaces(std::vector<std::string> & _return, const std::string& login) {
+ // Your implementation goes here
+ printf("listNamespaces\n");
+ }
+
+ bool namespaceExists(const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("namespaceExists\n");
+ }
+
+ void createNamespace(const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("createNamespace\n");
+ }
+
+ void deleteNamespace(const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("deleteNamespace\n");
+ }
+
+ void renameNamespace(const std::string& login, const std::string& oldNamespaceName, const std::string& newNamespaceName) {
+ // Your implementation goes here
+ printf("renameNamespace\n");
+ }
+
+ void setNamespaceProperty(const std::string& login, const std::string& namespaceName, const std::string& property, const std::string& value) {
+ // Your implementation goes here
+ printf("setNamespaceProperty\n");
+ }
+
+ void removeNamespaceProperty(const std::string& login, const std::string& namespaceName, const std::string& property) {
+ // Your implementation goes here
+ printf("removeNamespaceProperty\n");
+ }
+
+ void getNamespaceProperties(std::map<std::string, std::string> & _return, const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("getNamespaceProperties\n");
+ }
+
+ void namespaceIdMap(std::map<std::string, std::string> & _return, const std::string& login) {
+ // Your implementation goes here
+ printf("namespaceIdMap\n");
+ }
+
+ void attachNamespaceIterator(const std::string& login, const std::string& namespaceName, const IteratorSetting& setting, const std::set<IteratorScope::type> & scopes) {
+ // Your implementation goes here
+ printf("attachNamespaceIterator\n");
+ }
+
+ void removeNamespaceIterator(const std::string& login, const std::string& namespaceName, const std::string& name, const std::set<IteratorScope::type> & scopes) {
+ // Your implementation goes here
+ printf("removeNamespaceIterator\n");
+ }
+
+ void getNamespaceIteratorSetting(IteratorSetting& _return, const std::string& login, const std::string& namespaceName, const std::string& name, const IteratorScope::type scope) {
+ // Your implementation goes here
+ printf("getNamespaceIteratorSetting\n");
+ }
+
+ void listNamespaceIterators(std::map<std::string, std::set<IteratorScope::type> > & _return, const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("listNamespaceIterators\n");
+ }
+
+ void checkNamespaceIteratorConflicts(const std::string& login, const std::string& namespaceName, const IteratorSetting& setting, const std::set<IteratorScope::type> & scopes) {
+ // Your implementation goes here
+ printf("checkNamespaceIteratorConflicts\n");
+ }
+
+ int32_t addNamespaceConstraint(const std::string& login, const std::string& namespaceName, const std::string& constraintClassName) {
+ // Your implementation goes here
+ printf("addNamespaceConstraint\n");
+ }
+
+ void removeNamespaceConstraint(const std::string& login, const std::string& namespaceName, const int32_t id) {
+ // Your implementation goes here
+ printf("removeNamespaceConstraint\n");
+ }
+
+ void listNamespaceConstraints(std::map<std::string, int32_t> & _return, const std::string& login, const std::string& namespaceName) {
+ // Your implementation goes here
+ printf("listNamespaceConstraints\n");
+ }
+
+ bool testNamespaceClassLoad(const std::string& login, const std::string& namespaceName, const std::string& className, const std::string& asTypeName) {
+ // Your implementation goes here
+ printf("testNamespaceClassLoad\n");
+ }
+
};
int main(int argc, char **argv) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8839fe51/proxy/src/main/cpp/proxy_types.cpp
----------------------------------------------------------------------
diff --git a/proxy/src/main/cpp/proxy_types.cpp b/proxy/src/main/cpp/proxy_types.cpp
index 8c443e0..09c2d9c 100644
--- a/proxy/src/main/cpp/proxy_types.cpp
+++ b/proxy/src/main/cpp/proxy_types.cpp
@@ -87,6 +87,30 @@ const char* _kSystemPermissionNames[] = {
};
const std::map<int, const char*> _SystemPermission_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(8, _kSystemPermissionValues, _kSystemPermissionNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+int _kNamespacePermissionValues[] = {
+ NamespacePermission::READ,
+ NamespacePermission::WRITE,
+ NamespacePermission::ALTER_NAMESPACE,
+ NamespacePermission::GRANT,
+ NamespacePermission::ALTER_TABLE,
+ NamespacePermission::CREATE_TABLE,
+ NamespacePermission::DROP_TABLE,
+ NamespacePermission::BULK_IMPORT,
+ NamespacePermission::DROP_NAMESPACE
+};
+const char* _kNamespacePermissionNames[] = {
+ "READ",
+ "WRITE",
+ "ALTER_NAMESPACE",
+ "GRANT",
+ "ALTER_TABLE",
+ "CREATE_TABLE",
+ "DROP_TABLE",
+ "BULK_IMPORT",
+ "DROP_NAMESPACE"
+};
+const std::map<int, const char*> _NamespacePermission_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(9, _kNamespacePermissionValues, _kNamespacePermissionNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+
int _kScanTypeValues[] = {
ScanType::SINGLE,
ScanType::BATCH
@@ -4442,4 +4466,295 @@ const char* MutationsRejectedException::what() const throw() {
}
}
+
+NamespaceExistsException::~NamespaceExistsException() throw() {
+}
+
+
+void NamespaceExistsException::__set_msg(const std::string& val) {
+ this->msg = val;
+}
+
+uint32_t NamespaceExistsException::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->msg);
+ this->__isset.msg = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t NamespaceExistsException::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+ xfer += oprot->writeStructBegin("NamespaceExistsException");
+
+ xfer += oprot->writeFieldBegin("msg", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->msg);
+ xfer += oprot->writeFieldEnd();
+
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+void swap(NamespaceExistsException &a, NamespaceExistsException &b) {
+ using ::std::swap;
+ swap(a.msg, b.msg);
+ swap(a.__isset, b.__isset);
+}
+
+NamespaceExistsException::NamespaceExistsException(const NamespaceExistsException& other189) : TException() {
+ msg = other189.msg;
+ __isset = other189.__isset;
+}
+NamespaceExistsException& NamespaceExistsException::operator=(const NamespaceExistsException& other190) {
+ msg = other190.msg;
+ __isset = other190.__isset;
+ return *this;
+}
+void NamespaceExistsException::printTo(std::ostream& out) const {
+ using ::apache::thrift::to_string;
+ out << "NamespaceExistsException(";
+ out << "msg=" << to_string(msg);
+ out << ")";
+}
+
+const char* NamespaceExistsException::what() const throw() {
+ try {
+ std::stringstream ss;
+ ss << "TException - service has thrown: " << *this;
+ this->thriftTExceptionMessageHolder_ = ss.str();
+ return this->thriftTExceptionMessageHolder_.c_str();
+ } catch (const std::exception&) {
+ return "TException - service has thrown: NamespaceExistsException";
+ }
+}
+
+
+NamespaceNotFoundException::~NamespaceNotFoundException() throw() {
+}
+
+
+void NamespaceNotFoundException::__set_msg(const std::string& val) {
+ this->msg = val;
+}
+
+uint32_t NamespaceNotFoundException::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->msg);
+ this->__isset.msg = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t NamespaceNotFoundException::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+ xfer += oprot->writeStructBegin("NamespaceNotFoundException");
+
+ xfer += oprot->writeFieldBegin("msg", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->msg);
+ xfer += oprot->writeFieldEnd();
+
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+void swap(NamespaceNotFoundException &a, NamespaceNotFoundException &b) {
+ using ::std::swap;
+ swap(a.msg, b.msg);
+ swap(a.__isset, b.__isset);
+}
+
+NamespaceNotFoundException::NamespaceNotFoundException(const NamespaceNotFoundException& other191) : TException() {
+ msg = other191.msg;
+ __isset = other191.__isset;
+}
+NamespaceNotFoundException& NamespaceNotFoundException::operator=(const NamespaceNotFoundException& other192) {
+ msg = other192.msg;
+ __isset = other192.__isset;
+ return *this;
+}
+void NamespaceNotFoundException::printTo(std::ostream& out) const {
+ using ::apache::thrift::to_string;
+ out << "NamespaceNotFoundException(";
+ out << "msg=" << to_string(msg);
+ out << ")";
+}
+
+const char* NamespaceNotFoundException::what() const throw() {
+ try {
+ std::stringstream ss;
+ ss << "TException - service has thrown: " << *this;
+ this->thriftTExceptionMessageHolder_ = ss.str();
+ return this->thriftTExceptionMessageHolder_.c_str();
+ } catch (const std::exception&) {
+ return "TException - service has thrown: NamespaceNotFoundException";
+ }
+}
+
+
+NamespaceNotEmptyException::~NamespaceNotEmptyException() throw() {
+}
+
+
+void NamespaceNotEmptyException::__set_msg(const std::string& val) {
+ this->msg = val;
+}
+
+uint32_t NamespaceNotEmptyException::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+ apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+ uint32_t xfer = 0;
+ std::string fname;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+
+ xfer += iprot->readStructBegin(fname);
+
+ using ::apache::thrift::protocol::TProtocolException;
+
+
+ while (true)
+ {
+ xfer += iprot->readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ switch (fid)
+ {
+ case 1:
+ if (ftype == ::apache::thrift::protocol::T_STRING) {
+ xfer += iprot->readString(this->msg);
+ this->__isset.msg = true;
+ } else {
+ xfer += iprot->skip(ftype);
+ }
+ break;
+ default:
+ xfer += iprot->skip(ftype);
+ break;
+ }
+ xfer += iprot->readFieldEnd();
+ }
+
+ xfer += iprot->readStructEnd();
+
+ return xfer;
+}
+
+uint32_t NamespaceNotEmptyException::write(::apache::thrift::protocol::TProtocol* oprot) const {
+ uint32_t xfer = 0;
+ apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+ xfer += oprot->writeStructBegin("NamespaceNotEmptyException");
+
+ xfer += oprot->writeFieldBegin("msg", ::apache::thrift::protocol::T_STRING, 1);
+ xfer += oprot->writeString(this->msg);
+ xfer += oprot->writeFieldEnd();
+
+ xfer += oprot->writeFieldStop();
+ xfer += oprot->writeStructEnd();
+ return xfer;
+}
+
+void swap(NamespaceNotEmptyException &a, NamespaceNotEmptyException &b) {
+ using ::std::swap;
+ swap(a.msg, b.msg);
+ swap(a.__isset, b.__isset);
+}
+
+NamespaceNotEmptyException::NamespaceNotEmptyException(const NamespaceNotEmptyException& other193) : TException() {
+ msg = other193.msg;
+ __isset = other193.__isset;
+}
+NamespaceNotEmptyException& NamespaceNotEmptyException::operator=(const NamespaceNotEmptyException& other194) {
+ msg = other194.msg;
+ __isset = other194.__isset;
+ return *this;
+}
+void NamespaceNotEmptyException::printTo(std::ostream& out) const {
+ using ::apache::thrift::to_string;
+ out << "NamespaceNotEmptyException(";
+ out << "msg=" << to_string(msg);
+ out << ")";
+}
+
+const char* NamespaceNotEmptyException::what() const throw() {
+ try {
+ std::stringstream ss;
+ ss << "TException - service has thrown: " << *this;
+ this->thriftTExceptionMessageHolder_ = ss.str();
+ return this->thriftTExceptionMessageHolder_.c_str();
+ } catch (const std::exception&) {
+ return "TException - service has thrown: NamespaceNotEmptyException";
+ }
+}
+
} // namespace
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8839fe51/proxy/src/main/cpp/proxy_types.h
----------------------------------------------------------------------
diff --git a/proxy/src/main/cpp/proxy_types.h b/proxy/src/main/cpp/proxy_types.h
index f7cce4c..e5daf2e 100644
--- a/proxy/src/main/cpp/proxy_types.h
+++ b/proxy/src/main/cpp/proxy_types.h
@@ -76,6 +76,22 @@ struct SystemPermission {
extern const std::map<int, const char*> _SystemPermission_VALUES_TO_NAMES;
+struct NamespacePermission {
+ enum type {
+ READ = 0,
+ WRITE = 1,
+ ALTER_NAMESPACE = 2,
+ GRANT = 3,
+ ALTER_TABLE = 4,
+ CREATE_TABLE = 5,
+ DROP_TABLE = 6,
+ BULK_IMPORT = 7,
+ DROP_NAMESPACE = 8
+ };
+};
+
+extern const std::map<int, const char*> _NamespacePermission_VALUES_TO_NAMES;
+
struct ScanType {
enum type {
SINGLE = 0,
@@ -217,6 +233,12 @@ class TableExistsException;
class MutationsRejectedException;
+class NamespaceExistsException;
+
+class NamespaceNotFoundException;
+
+class NamespaceNotEmptyException;
+
typedef struct _Key__isset {
_Key__isset() : row(false), colFamily(false), colQualifier(false), colVisibility(false), timestamp(true) {}
bool row :1;
@@ -1955,6 +1977,150 @@ inline std::ostream& operator<<(std::ostream& out, const MutationsRejectedExcept
return out;
}
+typedef struct _NamespaceExistsException__isset {
+ _NamespaceExistsException__isset() : msg(false) {}
+ bool msg :1;
+} _NamespaceExistsException__isset;
+
+class NamespaceExistsException : public ::apache::thrift::TException {
+ public:
+
+ NamespaceExistsException(const NamespaceExistsException&);
+ NamespaceExistsException& operator=(const NamespaceExistsException&);
+ NamespaceExistsException() : msg() {
+ }
+
+ virtual ~NamespaceExistsException() throw();
+ std::string msg;
+
+ _NamespaceExistsException__isset __isset;
+
+ void __set_msg(const std::string& val);
+
+ bool operator == (const NamespaceExistsException & rhs) const
+ {
+ if (!(msg == rhs.msg))
+ return false;
+ return true;
+ }
+ bool operator != (const NamespaceExistsException &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const NamespaceExistsException & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+ virtual void printTo(std::ostream& out) const;
+ mutable std::string thriftTExceptionMessageHolder_;
+ const char* what() const throw();
+};
+
+void swap(NamespaceExistsException &a, NamespaceExistsException &b);
+
+inline std::ostream& operator<<(std::ostream& out, const NamespaceExistsException& obj)
+{
+ obj.printTo(out);
+ return out;
+}
+
+typedef struct _NamespaceNotFoundException__isset {
+ _NamespaceNotFoundException__isset() : msg(false) {}
+ bool msg :1;
+} _NamespaceNotFoundException__isset;
+
+class NamespaceNotFoundException : public ::apache::thrift::TException {
+ public:
+
+ NamespaceNotFoundException(const NamespaceNotFoundException&);
+ NamespaceNotFoundException& operator=(const NamespaceNotFoundException&);
+ NamespaceNotFoundException() : msg() {
+ }
+
+ virtual ~NamespaceNotFoundException() throw();
+ std::string msg;
+
+ _NamespaceNotFoundException__isset __isset;
+
+ void __set_msg(const std::string& val);
+
+ bool operator == (const NamespaceNotFoundException & rhs) const
+ {
+ if (!(msg == rhs.msg))
+ return false;
+ return true;
+ }
+ bool operator != (const NamespaceNotFoundException &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const NamespaceNotFoundException & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+ virtual void printTo(std::ostream& out) const;
+ mutable std::string thriftTExceptionMessageHolder_;
+ const char* what() const throw();
+};
+
+void swap(NamespaceNotFoundException &a, NamespaceNotFoundException &b);
+
+inline std::ostream& operator<<(std::ostream& out, const NamespaceNotFoundException& obj)
+{
+ obj.printTo(out);
+ return out;
+}
+
+typedef struct _NamespaceNotEmptyException__isset {
+ _NamespaceNotEmptyException__isset() : msg(false) {}
+ bool msg :1;
+} _NamespaceNotEmptyException__isset;
+
+class NamespaceNotEmptyException : public ::apache::thrift::TException {
+ public:
+
+ NamespaceNotEmptyException(const NamespaceNotEmptyException&);
+ NamespaceNotEmptyException& operator=(const NamespaceNotEmptyException&);
+ NamespaceNotEmptyException() : msg() {
+ }
+
+ virtual ~NamespaceNotEmptyException() throw();
+ std::string msg;
+
+ _NamespaceNotEmptyException__isset __isset;
+
+ void __set_msg(const std::string& val);
+
+ bool operator == (const NamespaceNotEmptyException & rhs) const
+ {
+ if (!(msg == rhs.msg))
+ return false;
+ return true;
+ }
+ bool operator != (const NamespaceNotEmptyException &rhs) const {
+ return !(*this == rhs);
+ }
+
+ bool operator < (const NamespaceNotEmptyException & ) const;
+
+ uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
+ uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
+
+ virtual void printTo(std::ostream& out) const;
+ mutable std::string thriftTExceptionMessageHolder_;
+ const char* what() const throw();
+};
+
+void swap(NamespaceNotEmptyException &a, NamespaceNotEmptyException &b);
+
+inline std::ostream& operator<<(std::ostream& out, const NamespaceNotEmptyException& obj)
+{
+ obj.printTo(out);
+ return out;
+}
+
} // namespace
#endif
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8839fe51/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index 9750db5..7e2c312 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -26,6 +26,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -49,6 +50,9 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.NamespaceExistsException;
+import org.apache.accumulo.core.client.NamespaceNotEmptyException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.ScannerBase;
import org.apache.accumulo.core.client.TableExistsException;
@@ -60,6 +64,7 @@ import org.apache.accumulo.core.client.admin.CompactionConfig;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.admin.TimeType;
import org.apache.accumulo.core.client.impl.Credentials;
+import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
@@ -76,6 +81,7 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.security.NamespacePermission;
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.util.ByteBufferUtil;
@@ -309,6 +315,25 @@ public class ProxyServer implements AccumuloProxy.Iface {
}
}
+ private void handleExceptionNNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ throw ex;
+ } catch (AccumuloException e) {
+ Throwable cause = e.getCause();
+ if (null != cause && NamespaceNotFoundException.class.equals(cause.getClass())) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(cause.toString());
+ }
+ handleAccumuloException(e);
+ } catch (AccumuloSecurityException e) {
+ handleAccumuloSecurityException(e);
+ } catch (NamespaceNotFoundException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(ex.toString());
+ } catch (Exception e) {
+ throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
+ }
+ }
+
private void handleException(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
try {
@@ -977,6 +1002,38 @@ public class ProxyServer implements AccumuloProxy.Iface {
}
}
+ @Override
+ public void grantNamespacePermission(ByteBuffer login, String user, String namespaceName, org.apache.accumulo.proxy.thrift.NamespacePermission perm)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ getConnector(login).securityOperations().grantNamespacePermission(user, namespaceName, NamespacePermission.getPermissionById((byte) perm.getValue()));
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ @Override
+ public boolean hasNamespacePermission(ByteBuffer login, String user, String namespaceName, org.apache.accumulo.proxy.thrift.NamespacePermission perm)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ return getConnector(login).securityOperations()
+ .hasNamespacePermission(user, namespaceName, NamespacePermission.getPermissionById((byte) perm.getValue()));
+ } catch (Exception e) {
+ handleException(e);
+ return false;
+ }
+ }
+
+ @Override
+ public void revokeNamespacePermission(ByteBuffer login, String user, String namespaceName, org.apache.accumulo.proxy.thrift.NamespacePermission perm)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ getConnector(login).securityOperations().revokeNamespacePermission(user, namespaceName, NamespacePermission.getPermissionById((byte) perm.getValue()));
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
private Authorizations getAuthorizations(Set<ByteBuffer> authorizations) {
List<String> auths = new ArrayList<String>();
for (ByteBuffer bbauth : authorizations) {
@@ -1549,6 +1606,238 @@ public class ProxyServer implements AccumuloProxy.Iface {
}
@Override
+ public String systemNamespace() throws TException {
+ return Namespaces.ACCUMULO_NAMESPACE;
+ }
+
+ @Override
+ public String defaultNamespace() throws TException {
+ return Namespaces.DEFAULT_NAMESPACE;
+ }
+
+ @Override
+ public List<String> listNamespaces(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ return new LinkedList<>(getConnector(login).namespaceOperations().list());
+ } catch (Exception e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ @Override
+ public boolean namespaceExists(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ return getConnector(login).namespaceOperations().exists(namespaceName);
+ } catch (Exception e) {
+ handleException(e);
+ return false;
+ }
+ }
+
+ @Override
+ public void createNamespace(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceExistsException, TException {
+ try {
+ getConnector(login).namespaceOperations().create(namespaceName);
+ } catch (NamespaceExistsException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceExistsException(e.toString());
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ @Override
+ public void deleteNamespace(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException, TException {
+ try {
+ getConnector(login).namespaceOperations().delete(namespaceName);
+ } catch (NamespaceNotFoundException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(e.toString());
+ } catch (NamespaceNotEmptyException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException(e.toString());
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ @Override
+ public void renameNamespace(ByteBuffer login, String oldNamespaceName, String newNamespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException,
+ org.apache.accumulo.proxy.thrift.NamespaceExistsException, TException {
+ try {
+ getConnector(login).namespaceOperations().rename(oldNamespaceName, newNamespaceName);
+ } catch (NamespaceNotFoundException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(e.toString());
+ } catch (NamespaceExistsException e) {
+ throw new org.apache.accumulo.proxy.thrift.NamespaceExistsException(e.toString());
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ @Override
+ public void setNamespaceProperty(ByteBuffer login, String namespaceName, String property, String value)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ getConnector(login).namespaceOperations().setProperty(namespaceName, property, value);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public void removeNamespaceProperty(ByteBuffer login, String namespaceName, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ getConnector(login).namespaceOperations().removeProperty(namespaceName, property);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public Map<String,String> getNamespaceProperties(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ Map<String,String> props = new HashMap<>();
+ for (Map.Entry<String,String> entry : getConnector(login).namespaceOperations().getProperties(namespaceName)) {
+ props.put(entry.getKey(), entry.getValue());
+ }
+ return props;
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return null;
+ }
+ }
+
+ @Override
+ public Map<String,String> namespaceIdMap(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
+ try {
+ return getConnector(login).namespaceOperations().namespaceIdMap();
+ } catch (Exception e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ @Override
+ public void attachNamespaceIterator(ByteBuffer login, String namespaceName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
+ Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ if (null != scopes && scopes.size() > 0) {
+ getConnector(login).namespaceOperations().attachIterator(namespaceName, getIteratorSetting(setting), getIteratorScopes(scopes));
+ } else {
+ getConnector(login).namespaceOperations().attachIterator(namespaceName, getIteratorSetting(setting));
+ }
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public void removeNamespaceIterator(ByteBuffer login, String namespaceName, String name, Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ getConnector(login).namespaceOperations().removeIterator(namespaceName, name, getIteratorScopes(scopes));
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public org.apache.accumulo.proxy.thrift.IteratorSetting getNamespaceIteratorSetting(ByteBuffer login, String namespaceName, String name,
+ org.apache.accumulo.proxy.thrift.IteratorScope scope) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ IteratorSetting setting = getConnector(login).namespaceOperations().getIteratorSetting(namespaceName, name, getIteratorScope(scope));
+ return new org.apache.accumulo.proxy.thrift.IteratorSetting(setting.getPriority(), setting.getName(), setting.getIteratorClass(), setting.getOptions());
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return null;
+ }
+ }
+
+ @Override
+ public Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> listNamespaceIterators(ByteBuffer login, String namespaceName)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> namespaceIters = new HashMap<>();
+ for (Map.Entry<String,EnumSet<IteratorScope>> entry : getConnector(login).namespaceOperations().listIterators(namespaceName).entrySet()) {
+ namespaceIters.put(entry.getKey(), getProxyIteratorScopes(entry.getValue()));
+ }
+ return namespaceIters;
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return null;
+ }
+ }
+
+ @Override
+ public void checkNamespaceIteratorConflicts(ByteBuffer login, String namespaceName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
+ Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ getConnector(login).namespaceOperations().checkIteratorConflicts(namespaceName, getIteratorSetting(setting), getIteratorScopes(scopes));
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public int addNamespaceConstraint(ByteBuffer login, String namespaceName, String constraintClassName)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ return getConnector(login).namespaceOperations().addConstraint(namespaceName, constraintClassName);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return -1;
+ }
+ }
+
+ @Override
+ public void removeNamespaceConstraint(ByteBuffer login, String namespaceName, int id) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ getConnector(login).namespaceOperations().removeConstraint(namespaceName, id);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ }
+ }
+
+ @Override
+ public Map<String,Integer> listNamespaceConstraints(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
+ org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ return getConnector(login).namespaceOperations().listConstraints(namespaceName);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return null;
+ }
+ }
+
+ @Override
+ public boolean testNamespaceClassLoad(ByteBuffer login, String namespaceName, String className, String asTypeName)
+ throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
+ org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException {
+ try {
+ return getConnector(login).namespaceOperations().testClassLoad(namespaceName, className, asTypeName);
+ } catch (Exception e) {
+ handleExceptionNNF(e);
+ return false;
+ }
+ }
+
+ @Override
public void pingTabletServer(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException,
org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
try {