From 05a21c6c717b5efc35154459948fb46c9810213b Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Wed, 17 Aug 2011 16:46:10 -0700 Subject: [PATCH] HBASE-3917. Separate the Avro schema definition file from the code Since the code is autogenerated this should just work. --- .../java/org/apache/hadoop/hbase/avro/hbase.avpr | 609 -------------------- .../org/apache/hadoop/hbase/avro/hbase.genavro | 271 --------- .../org/apache/hadoop/hbase/avro/hbase.avpr | 609 ++++++++++++++++++++ .../org/apache/hadoop/hbase/avro/hbase.genavro | 271 +++++++++ 4 files changed, 880 insertions(+), 880 deletions(-) delete mode 100644 src/main/java/org/apache/hadoop/hbase/avro/hbase.avpr delete mode 100644 src/main/java/org/apache/hadoop/hbase/avro/hbase.genavro create mode 100644 src/main/resources/org/apache/hadoop/hbase/avro/hbase.avpr create mode 100644 src/main/resources/org/apache/hadoop/hbase/avro/hbase.genavro diff --git a/src/main/java/org/apache/hadoop/hbase/avro/hbase.avpr b/src/main/java/org/apache/hadoop/hbase/avro/hbase.avpr deleted file mode 100644 index 68f3664..0000000 --- a/src/main/java/org/apache/hadoop/hbase/avro/hbase.avpr +++ /dev/null @@ -1,609 +0,0 @@ -{ - "protocol" : "HBase", - "namespace" : "org.apache.hadoop.hbase.avro.generated", - "types" : [ { - "type" : "record", - "name" : "AServerAddress", - "fields" : [ { - "name" : "hostname", - "type" : "string" - }, { - "name" : "inetSocketAddress", - "type" : "string" - }, { - "name" : "port", - "type" : "int" - } ] - }, { - "type" : "record", - "name" : "ARegionLoad", - "fields" : [ { - "name" : "memStoreSizeMB", - "type" : "int" - }, { - "name" : "name", - "type" : "bytes" - }, { - "name" : "storefileIndexSizeMB", - "type" : "int" - }, { - "name" : "storefiles", - "type" : "int" - }, { - "name" : "storefileSizeMB", - "type" : "int" - }, { - "name" : "stores", - "type" : "int" - } ] - }, { - "type" : "record", - "name" : "AServerLoad", - "fields" : [ { - "name" : "load", - "type" : "int" - }, { - "name" : "maxHeapMB", - "type" : "int" - }, { - "name" : "memStoreSizeInMB", - "type" : "int" - }, { - "name" : "numberOfRegions", - "type" : "int" - }, { - "name" : "numberOfRequests", - "type" : "int" - }, { - "name" : "regionsLoad", - "type" : { - "type" : "array", - "items" : "ARegionLoad" - } - }, { - "name" : "storefileIndexSizeInMB", - "type" : "int" - }, { - "name" : "storefiles", - "type" : "int" - }, { - "name" : "storefileSizeInMB", - "type" : "int" - }, { - "name" : "usedHeapMB", - "type" : "int" - } ] - }, { - "type" : "record", - "name" : "AServerInfo", - "fields" : [ { - "name" : "infoPort", - "type" : "int" - }, { - "name" : "load", - "type" : "AServerLoad" - }, { - "name" : "serverAddress", - "type" : "AServerAddress" - }, { - "name" : "serverName", - "type" : "string" - }, { - "name" : "startCode", - "type" : "long" - } ] - }, { - "type" : "record", - "name" : "AClusterStatus", - "fields" : [ { - "name" : "averageLoad", - "type" : "double" - }, { - "name" : "deadServerNames", - "type" : { - "type" : "array", - "items" : "string" - } - }, { - "name" : "deadServers", - "type" : "int" - }, { - "name" : "hbaseVersion", - "type" : "string" - }, { - "name" : "regionsCount", - "type" : "int" - }, { - "name" : "requestsCount", - "type" : "int" - }, { - "name" : "serverInfos", - "type" : { - "type" : "array", - "items" : "AServerInfo" - } - }, { - "name" : "servers", - "type" : "int" - } ] - }, { - "type" : "enum", - "name" : "ACompressionAlgorithm", - "symbols" : [ "LZO", "GZ", "NONE" ] - }, { - "type" : "record", - "name" : "AFamilyDescriptor", - "fields" : [ { - "name" : "name", - "type" : "bytes" - }, { - "name" : "compression", - "type" : [ "ACompressionAlgorithm", "null" ] - }, { - "name" : "maxVersions", - "type" : [ "int", "null" ] - }, { - "name" : "blocksize", - "type" : [ "int", "null" ] - }, { - "name" : "inMemory", - "type" : [ "boolean", "null" ] - }, { - "name" : "timeToLive", - "type" : [ "int", "null" ] - }, { - "name" : "blockCacheEnabled", - "type" : [ "boolean", "null" ] - } ] - }, { - "type" : "record", - "name" : "ATableDescriptor", - "fields" : [ { - "name" : "name", - "type" : "bytes" - }, { - "name" : "families", - "type" : [ { - "type" : "array", - "items" : "AFamilyDescriptor" - }, "null" ] - }, { - "name" : "maxFileSize", - "type" : [ "long", "null" ] - }, { - "name" : "memStoreFlushSize", - "type" : [ "long", "null" ] - }, { - "name" : "rootRegion", - "type" : [ "boolean", "null" ] - }, { - "name" : "metaRegion", - "type" : [ "boolean", "null" ] - }, { - "name" : "metaTable", - "type" : [ "boolean", "null" ] - }, { - "name" : "readOnly", - "type" : [ "boolean", "null" ] - }, { - "name" : "deferredLogFlush", - "type" : [ "boolean", "null" ] - } ] - }, { - "type" : "record", - "name" : "AColumn", - "fields" : [ { - "name" : "family", - "type" : "bytes" - }, { - "name" : "qualifier", - "type" : [ "bytes", "null" ] - } ] - }, { - "type" : "record", - "name" : "ATimeRange", - "fields" : [ { - "name" : "minStamp", - "type" : "long" - }, { - "name" : "maxStamp", - "type" : "long" - } ] - }, { - "type" : "record", - "name" : "AGet", - "fields" : [ { - "name" : "row", - "type" : "bytes" - }, { - "name" : "columns", - "type" : [ { - "type" : "array", - "items" : "AColumn" - }, "null" ] - }, { - "name" : "timestamp", - "type" : [ "long", "null" ] - }, { - "name" : "timerange", - "type" : [ "ATimeRange", "null" ] - }, { - "name" : "maxVersions", - "type" : [ "int", "null" ] - } ] - }, { - "type" : "record", - "name" : "AResultEntry", - "fields" : [ { - "name" : "family", - "type" : "bytes" - }, { - "name" : "qualifier", - "type" : "bytes" - }, { - "name" : "value", - "type" : "bytes" - }, { - "name" : "timestamp", - "type" : "long" - } ] - }, { - "type" : "record", - "name" : "AResult", - "fields" : [ { - "name" : "row", - "type" : "bytes" - }, { - "name" : "entries", - "type" : { - "type" : "array", - "items" : "AResultEntry" - } - } ] - }, { - "type" : "record", - "name" : "AColumnValue", - "fields" : [ { - "name" : "family", - "type" : "bytes" - }, { - "name" : "qualifier", - "type" : "bytes" - }, { - "name" : "value", - "type" : "bytes" - }, { - "name" : "timestamp", - "type" : [ "long", "null" ] - } ] - }, { - "type" : "record", - "name" : "APut", - "fields" : [ { - "name" : "row", - "type" : "bytes" - }, { - "name" : "columnValues", - "type" : { - "type" : "array", - "items" : "AColumnValue" - } - } ] - }, { - "type" : "record", - "name" : "ADelete", - "fields" : [ { - "name" : "row", - "type" : "bytes" - }, { - "name" : "columns", - "type" : [ { - "type" : "array", - "items" : "AColumn" - }, "null" ] - } ] - }, { - "type" : "record", - "name" : "AScan", - "fields" : [ { - "name" : "startRow", - "type" : [ "bytes", "null" ] - }, { - "name" : "stopRow", - "type" : [ "bytes", "null" ] - }, { - "name" : "columns", - "type" : [ { - "type" : "array", - "items" : "AColumn" - }, "null" ] - }, { - "name" : "timestamp", - "type" : [ "long", "null" ] - }, { - "name" : "timerange", - "type" : [ "ATimeRange", "null" ] - }, { - "name" : "maxVersions", - "type" : [ "int", "null" ] - } ] - }, { - "type" : "error", - "name" : "AIOError", - "fields" : [ { - "name" : "message", - "type" : "string" - } ] - }, { - "type" : "error", - "name" : "AIllegalArgument", - "fields" : [ { - "name" : "message", - "type" : "string" - } ] - }, { - "type" : "error", - "name" : "ATableExists", - "fields" : [ { - "name" : "message", - "type" : "string" - } ] - }, { - "type" : "error", - "name" : "AMasterNotRunning", - "fields" : [ { - "name" : "message", - "type" : "string" - } ] - } ], - "messages" : { - "getHBaseVersion" : { - "request" : [ ], - "response" : "string", - "errors" : [ "AIOError" ] - }, - "getClusterStatus" : { - "request" : [ ], - "response" : "AClusterStatus", - "errors" : [ "AIOError" ] - }, - "listTables" : { - "request" : [ ], - "response" : { - "type" : "array", - "items" : "ATableDescriptor" - }, - "errors" : [ "AIOError" ] - }, - "describeTable" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "ATableDescriptor", - "errors" : [ "AIOError" ] - }, - "isTableEnabled" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "boolean", - "errors" : [ "AIOError" ] - }, - "tableExists" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "boolean", - "errors" : [ "AIOError" ] - }, - "describeFamily" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "family", - "type" : "bytes" - } ], - "response" : "AFamilyDescriptor", - "errors" : [ "AIOError" ] - }, - "createTable" : { - "request" : [ { - "name" : "table", - "type" : "ATableDescriptor" - } ], - "response" : "null", - "errors" : [ "AIOError", "AIllegalArgument", "ATableExists", "AMasterNotRunning" ] - }, - "deleteTable" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "modifyTable" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "tableDescriptor", - "type" : "ATableDescriptor" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "enableTable" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "disableTable" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "flush" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "split" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "addFamily" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "family", - "type" : "AFamilyDescriptor" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "deleteFamily" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "family", - "type" : "bytes" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "modifyFamily" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "familyName", - "type" : "bytes" - }, { - "name" : "familyDescriptor", - "type" : "AFamilyDescriptor" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "get" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "get", - "type" : "AGet" - } ], - "response" : "AResult", - "errors" : [ "AIOError" ] - }, - "exists" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "get", - "type" : "AGet" - } ], - "response" : "boolean", - "errors" : [ "AIOError" ] - }, - "put" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "put", - "type" : "APut" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "delete" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "delete", - "type" : "ADelete" - } ], - "response" : "null", - "errors" : [ "AIOError" ] - }, - "incrementColumnValue" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "row", - "type" : "bytes" - }, { - "name" : "family", - "type" : "bytes" - }, { - "name" : "qualifier", - "type" : "bytes" - }, { - "name" : "amount", - "type" : "long" - }, { - "name" : "writeToWAL", - "type" : "boolean" - } ], - "response" : "long", - "errors" : [ "AIOError" ] - }, - "scannerOpen" : { - "request" : [ { - "name" : "table", - "type" : "bytes" - }, { - "name" : "scan", - "type" : "AScan" - } ], - "response" : "int", - "errors" : [ "AIOError" ] - }, - "scannerClose" : { - "request" : [ { - "name" : "scannerId", - "type" : "int" - } ], - "response" : "null", - "errors" : [ "AIOError", "AIllegalArgument" ] - }, - "scannerGetRows" : { - "request" : [ { - "name" : "scannerId", - "type" : "int" - }, { - "name" : "numberOfRows", - "type" : "int" - } ], - "response" : { - "type" : "array", - "items" : "AResult" - }, - "errors" : [ "AIOError", "AIllegalArgument" ] - } - } -} \ No newline at end of file diff --git a/src/main/java/org/apache/hadoop/hbase/avro/hbase.genavro b/src/main/java/org/apache/hadoop/hbase/avro/hbase.genavro deleted file mode 100644 index c326072..0000000 --- a/src/main/java/org/apache/hadoop/hbase/avro/hbase.genavro +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Avro protocol for a "gateway" service - */ -@namespace("org.apache.hadoop.hbase.avro.generated") -protocol HBase { - - // - // TYPES - // - - // - // Cluster metadata - // - // TODO(hammer): Best way to represent java.net.InetSocketAddress? - record AServerAddress { - string hostname; - string inetSocketAddress; - int port; - } - - record ARegionLoad { - int memStoreSizeMB; - bytes name; - int storefileIndexSizeMB; - int storefiles; - int storefileSizeMB; - int stores; - } - - record AServerLoad { - int load; - int maxHeapMB; - int memStoreSizeInMB; - int numberOfRegions; - int numberOfRequests; - array regionsLoad; - int storefileIndexSizeInMB; - int storefiles; - int storefileSizeInMB; - int usedHeapMB; - } - - record AServerInfo { - int infoPort; - AServerLoad load; - AServerAddress serverAddress; - string serverName; - long startCode; - } - - // TODO(hammer): Implement reusable Writable to Avro record converter? - record AClusterStatus { - double averageLoad; - array deadServerNames; - int deadServers; - string hbaseVersion; - int regionsCount; - int requestsCount; - array serverInfos; - int servers; - } - - // - // Family metadata - // - // TODO(hammer): how to keep in sync with Java Enum? - enum ACompressionAlgorithm { - LZO, GZ, NONE - } - - // TODO(hammer): include COLUMN_DESCRIPTOR_VERSION? - // TODO(hammer): add new bloomfilter stuff - record AFamilyDescriptor { - bytes name; - union { ACompressionAlgorithm, null } compression; - union { int, null } maxVersions; - union { int, null } blocksize; - union { boolean, null } inMemory; - union { int, null } timeToLive; - union { boolean, null } blockCacheEnabled; - } - - // - // Table metadata - // - // TODO(hammer): include TABLE_DESCRIPTOR_VERSION? - record ATableDescriptor { - bytes name; - union { array, null } families; - union { long, null } maxFileSize; - union { long, null } memStoreFlushSize; - union { boolean, null } rootRegion; - union { boolean, null } metaRegion; - union { boolean, null } metaTable; - union { boolean, null } readOnly; - union { boolean, null } deferredLogFlush; - } - - // - // Single-Row DML (Get) - // - record AColumn { - bytes family; - union { bytes, null } qualifier; - } - - record ATimeRange { - long minStamp; - long maxStamp; - } - - // TODO(hammer): Add filter options - record AGet { - bytes row; - union { array, null } columns; - union { long, null } timestamp; - union { ATimeRange, null } timerange; - union { int, null } maxVersions; - } - - record AResultEntry { - bytes family; - bytes qualifier; - bytes value; - long timestamp; - } - - // Avro maps can't use non-string keys, so using an array for now - record AResult { - bytes row; - array entries; - } - - // - // Single-Row DML (Put) - // - // TODO(hammer): Reuse a single KeyValue-style record for Get and Put? - record AColumnValue { - bytes family; - bytes qualifier; - bytes value; - union { long, null } timestamp; - } - - record APut { - bytes row; - array columnValues; - } - - // - // Single-Row DML (Delete) - // - // TODO(hammer): Add fields when API is rationalized (HBASE-2609) - record ADelete { - bytes row; - union { array, null } columns; - } - - // - // Multi-Row DML (Scan) - // - record AScan { - union { bytes, null } startRow; - union { bytes, null } stopRow; - union { array, null } columns; - union { long, null } timestamp; - union { ATimeRange, null } timerange; - union { int, null } maxVersions; - } - - // - // ERRORS - // - - /** - * An AIOError error signals that an error occurred communicating - * to the HBase master or a HBase region server. Also used to return - * more general HBase error conditions. - */ - error AIOError { - string message; - } - - /** - * An AIllegalArgument error indicates an illegal or invalid - * argument was passed into a procedure. - */ - error AIllegalArgument { - string message; - } - - /** - * An ATableExists error that a table with the specified - * name already exists - */ - error ATableExists { - string message; - } - - /** - * An AMasterNotRunning error means we couldn't reach the Master. - */ - error AMasterNotRunning { - string message; - } - - // - // MESSAGES - // - - // TODO(hammer): surgery tools - // TODO(hammer): checkAndPut/flushCommits - // TODO(hammer): MultiPut/Get/Delete - - // Cluster metadata - string getHBaseVersion() throws AIOError; - AClusterStatus getClusterStatus() throws AIOError; - array listTables() throws AIOError; - - // Table metadata - ATableDescriptor describeTable(bytes table) throws AIOError; - boolean isTableEnabled(bytes table) throws AIOError; - boolean tableExists(bytes table) throws AIOError; - - // Family metadata - AFamilyDescriptor describeFamily(bytes table, bytes family) throws AIOError; - - // Table admin - void createTable(ATableDescriptor table) throws AIOError, AIllegalArgument, ATableExists, AMasterNotRunning; - void deleteTable(bytes table) throws AIOError; - void modifyTable(bytes table, ATableDescriptor tableDescriptor) throws AIOError; - void enableTable(bytes table) throws AIOError; - void disableTable(bytes table) throws AIOError; - void flush(bytes table) throws AIOError; - void split(bytes table) throws AIOError; - - // Family admin - void addFamily(bytes table, AFamilyDescriptor family) throws AIOError; - void deleteFamily(bytes table, bytes family) throws AIOError; - void modifyFamily(bytes table, bytes familyName, AFamilyDescriptor familyDescriptor) throws AIOError; - - // Single-row DML - AResult get(bytes table, AGet get) throws AIOError; - boolean exists(bytes table, AGet get) throws AIOError; - void put(bytes table, APut put) throws AIOError; - void delete(bytes table, ADelete delete) throws AIOError; - long incrementColumnValue(bytes table, bytes row, bytes family, bytes qualifier, long amount, boolean writeToWAL) throws AIOError; - - // Multi-row DML (read-only) - int scannerOpen(bytes table, AScan scan) throws AIOError; - void scannerClose(int scannerId) throws AIOError, AIllegalArgument; - array scannerGetRows(int scannerId, int numberOfRows) throws AIOError, AIllegalArgument; -} diff --git a/src/main/resources/org/apache/hadoop/hbase/avro/hbase.avpr b/src/main/resources/org/apache/hadoop/hbase/avro/hbase.avpr new file mode 100644 index 0000000..68f3664 --- /dev/null +++ b/src/main/resources/org/apache/hadoop/hbase/avro/hbase.avpr @@ -0,0 +1,609 @@ +{ + "protocol" : "HBase", + "namespace" : "org.apache.hadoop.hbase.avro.generated", + "types" : [ { + "type" : "record", + "name" : "AServerAddress", + "fields" : [ { + "name" : "hostname", + "type" : "string" + }, { + "name" : "inetSocketAddress", + "type" : "string" + }, { + "name" : "port", + "type" : "int" + } ] + }, { + "type" : "record", + "name" : "ARegionLoad", + "fields" : [ { + "name" : "memStoreSizeMB", + "type" : "int" + }, { + "name" : "name", + "type" : "bytes" + }, { + "name" : "storefileIndexSizeMB", + "type" : "int" + }, { + "name" : "storefiles", + "type" : "int" + }, { + "name" : "storefileSizeMB", + "type" : "int" + }, { + "name" : "stores", + "type" : "int" + } ] + }, { + "type" : "record", + "name" : "AServerLoad", + "fields" : [ { + "name" : "load", + "type" : "int" + }, { + "name" : "maxHeapMB", + "type" : "int" + }, { + "name" : "memStoreSizeInMB", + "type" : "int" + }, { + "name" : "numberOfRegions", + "type" : "int" + }, { + "name" : "numberOfRequests", + "type" : "int" + }, { + "name" : "regionsLoad", + "type" : { + "type" : "array", + "items" : "ARegionLoad" + } + }, { + "name" : "storefileIndexSizeInMB", + "type" : "int" + }, { + "name" : "storefiles", + "type" : "int" + }, { + "name" : "storefileSizeInMB", + "type" : "int" + }, { + "name" : "usedHeapMB", + "type" : "int" + } ] + }, { + "type" : "record", + "name" : "AServerInfo", + "fields" : [ { + "name" : "infoPort", + "type" : "int" + }, { + "name" : "load", + "type" : "AServerLoad" + }, { + "name" : "serverAddress", + "type" : "AServerAddress" + }, { + "name" : "serverName", + "type" : "string" + }, { + "name" : "startCode", + "type" : "long" + } ] + }, { + "type" : "record", + "name" : "AClusterStatus", + "fields" : [ { + "name" : "averageLoad", + "type" : "double" + }, { + "name" : "deadServerNames", + "type" : { + "type" : "array", + "items" : "string" + } + }, { + "name" : "deadServers", + "type" : "int" + }, { + "name" : "hbaseVersion", + "type" : "string" + }, { + "name" : "regionsCount", + "type" : "int" + }, { + "name" : "requestsCount", + "type" : "int" + }, { + "name" : "serverInfos", + "type" : { + "type" : "array", + "items" : "AServerInfo" + } + }, { + "name" : "servers", + "type" : "int" + } ] + }, { + "type" : "enum", + "name" : "ACompressionAlgorithm", + "symbols" : [ "LZO", "GZ", "NONE" ] + }, { + "type" : "record", + "name" : "AFamilyDescriptor", + "fields" : [ { + "name" : "name", + "type" : "bytes" + }, { + "name" : "compression", + "type" : [ "ACompressionAlgorithm", "null" ] + }, { + "name" : "maxVersions", + "type" : [ "int", "null" ] + }, { + "name" : "blocksize", + "type" : [ "int", "null" ] + }, { + "name" : "inMemory", + "type" : [ "boolean", "null" ] + }, { + "name" : "timeToLive", + "type" : [ "int", "null" ] + }, { + "name" : "blockCacheEnabled", + "type" : [ "boolean", "null" ] + } ] + }, { + "type" : "record", + "name" : "ATableDescriptor", + "fields" : [ { + "name" : "name", + "type" : "bytes" + }, { + "name" : "families", + "type" : [ { + "type" : "array", + "items" : "AFamilyDescriptor" + }, "null" ] + }, { + "name" : "maxFileSize", + "type" : [ "long", "null" ] + }, { + "name" : "memStoreFlushSize", + "type" : [ "long", "null" ] + }, { + "name" : "rootRegion", + "type" : [ "boolean", "null" ] + }, { + "name" : "metaRegion", + "type" : [ "boolean", "null" ] + }, { + "name" : "metaTable", + "type" : [ "boolean", "null" ] + }, { + "name" : "readOnly", + "type" : [ "boolean", "null" ] + }, { + "name" : "deferredLogFlush", + "type" : [ "boolean", "null" ] + } ] + }, { + "type" : "record", + "name" : "AColumn", + "fields" : [ { + "name" : "family", + "type" : "bytes" + }, { + "name" : "qualifier", + "type" : [ "bytes", "null" ] + } ] + }, { + "type" : "record", + "name" : "ATimeRange", + "fields" : [ { + "name" : "minStamp", + "type" : "long" + }, { + "name" : "maxStamp", + "type" : "long" + } ] + }, { + "type" : "record", + "name" : "AGet", + "fields" : [ { + "name" : "row", + "type" : "bytes" + }, { + "name" : "columns", + "type" : [ { + "type" : "array", + "items" : "AColumn" + }, "null" ] + }, { + "name" : "timestamp", + "type" : [ "long", "null" ] + }, { + "name" : "timerange", + "type" : [ "ATimeRange", "null" ] + }, { + "name" : "maxVersions", + "type" : [ "int", "null" ] + } ] + }, { + "type" : "record", + "name" : "AResultEntry", + "fields" : [ { + "name" : "family", + "type" : "bytes" + }, { + "name" : "qualifier", + "type" : "bytes" + }, { + "name" : "value", + "type" : "bytes" + }, { + "name" : "timestamp", + "type" : "long" + } ] + }, { + "type" : "record", + "name" : "AResult", + "fields" : [ { + "name" : "row", + "type" : "bytes" + }, { + "name" : "entries", + "type" : { + "type" : "array", + "items" : "AResultEntry" + } + } ] + }, { + "type" : "record", + "name" : "AColumnValue", + "fields" : [ { + "name" : "family", + "type" : "bytes" + }, { + "name" : "qualifier", + "type" : "bytes" + }, { + "name" : "value", + "type" : "bytes" + }, { + "name" : "timestamp", + "type" : [ "long", "null" ] + } ] + }, { + "type" : "record", + "name" : "APut", + "fields" : [ { + "name" : "row", + "type" : "bytes" + }, { + "name" : "columnValues", + "type" : { + "type" : "array", + "items" : "AColumnValue" + } + } ] + }, { + "type" : "record", + "name" : "ADelete", + "fields" : [ { + "name" : "row", + "type" : "bytes" + }, { + "name" : "columns", + "type" : [ { + "type" : "array", + "items" : "AColumn" + }, "null" ] + } ] + }, { + "type" : "record", + "name" : "AScan", + "fields" : [ { + "name" : "startRow", + "type" : [ "bytes", "null" ] + }, { + "name" : "stopRow", + "type" : [ "bytes", "null" ] + }, { + "name" : "columns", + "type" : [ { + "type" : "array", + "items" : "AColumn" + }, "null" ] + }, { + "name" : "timestamp", + "type" : [ "long", "null" ] + }, { + "name" : "timerange", + "type" : [ "ATimeRange", "null" ] + }, { + "name" : "maxVersions", + "type" : [ "int", "null" ] + } ] + }, { + "type" : "error", + "name" : "AIOError", + "fields" : [ { + "name" : "message", + "type" : "string" + } ] + }, { + "type" : "error", + "name" : "AIllegalArgument", + "fields" : [ { + "name" : "message", + "type" : "string" + } ] + }, { + "type" : "error", + "name" : "ATableExists", + "fields" : [ { + "name" : "message", + "type" : "string" + } ] + }, { + "type" : "error", + "name" : "AMasterNotRunning", + "fields" : [ { + "name" : "message", + "type" : "string" + } ] + } ], + "messages" : { + "getHBaseVersion" : { + "request" : [ ], + "response" : "string", + "errors" : [ "AIOError" ] + }, + "getClusterStatus" : { + "request" : [ ], + "response" : "AClusterStatus", + "errors" : [ "AIOError" ] + }, + "listTables" : { + "request" : [ ], + "response" : { + "type" : "array", + "items" : "ATableDescriptor" + }, + "errors" : [ "AIOError" ] + }, + "describeTable" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "ATableDescriptor", + "errors" : [ "AIOError" ] + }, + "isTableEnabled" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "boolean", + "errors" : [ "AIOError" ] + }, + "tableExists" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "boolean", + "errors" : [ "AIOError" ] + }, + "describeFamily" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "family", + "type" : "bytes" + } ], + "response" : "AFamilyDescriptor", + "errors" : [ "AIOError" ] + }, + "createTable" : { + "request" : [ { + "name" : "table", + "type" : "ATableDescriptor" + } ], + "response" : "null", + "errors" : [ "AIOError", "AIllegalArgument", "ATableExists", "AMasterNotRunning" ] + }, + "deleteTable" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "modifyTable" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "tableDescriptor", + "type" : "ATableDescriptor" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "enableTable" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "disableTable" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "flush" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "split" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "addFamily" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "family", + "type" : "AFamilyDescriptor" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "deleteFamily" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "family", + "type" : "bytes" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "modifyFamily" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "familyName", + "type" : "bytes" + }, { + "name" : "familyDescriptor", + "type" : "AFamilyDescriptor" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "get" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "get", + "type" : "AGet" + } ], + "response" : "AResult", + "errors" : [ "AIOError" ] + }, + "exists" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "get", + "type" : "AGet" + } ], + "response" : "boolean", + "errors" : [ "AIOError" ] + }, + "put" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "put", + "type" : "APut" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "delete" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "delete", + "type" : "ADelete" + } ], + "response" : "null", + "errors" : [ "AIOError" ] + }, + "incrementColumnValue" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "row", + "type" : "bytes" + }, { + "name" : "family", + "type" : "bytes" + }, { + "name" : "qualifier", + "type" : "bytes" + }, { + "name" : "amount", + "type" : "long" + }, { + "name" : "writeToWAL", + "type" : "boolean" + } ], + "response" : "long", + "errors" : [ "AIOError" ] + }, + "scannerOpen" : { + "request" : [ { + "name" : "table", + "type" : "bytes" + }, { + "name" : "scan", + "type" : "AScan" + } ], + "response" : "int", + "errors" : [ "AIOError" ] + }, + "scannerClose" : { + "request" : [ { + "name" : "scannerId", + "type" : "int" + } ], + "response" : "null", + "errors" : [ "AIOError", "AIllegalArgument" ] + }, + "scannerGetRows" : { + "request" : [ { + "name" : "scannerId", + "type" : "int" + }, { + "name" : "numberOfRows", + "type" : "int" + } ], + "response" : { + "type" : "array", + "items" : "AResult" + }, + "errors" : [ "AIOError", "AIllegalArgument" ] + } + } +} \ No newline at end of file diff --git a/src/main/resources/org/apache/hadoop/hbase/avro/hbase.genavro b/src/main/resources/org/apache/hadoop/hbase/avro/hbase.genavro new file mode 100644 index 0000000..c326072 --- /dev/null +++ b/src/main/resources/org/apache/hadoop/hbase/avro/hbase.genavro @@ -0,0 +1,271 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Avro protocol for a "gateway" service + */ +@namespace("org.apache.hadoop.hbase.avro.generated") +protocol HBase { + + // + // TYPES + // + + // + // Cluster metadata + // + // TODO(hammer): Best way to represent java.net.InetSocketAddress? + record AServerAddress { + string hostname; + string inetSocketAddress; + int port; + } + + record ARegionLoad { + int memStoreSizeMB; + bytes name; + int storefileIndexSizeMB; + int storefiles; + int storefileSizeMB; + int stores; + } + + record AServerLoad { + int load; + int maxHeapMB; + int memStoreSizeInMB; + int numberOfRegions; + int numberOfRequests; + array regionsLoad; + int storefileIndexSizeInMB; + int storefiles; + int storefileSizeInMB; + int usedHeapMB; + } + + record AServerInfo { + int infoPort; + AServerLoad load; + AServerAddress serverAddress; + string serverName; + long startCode; + } + + // TODO(hammer): Implement reusable Writable to Avro record converter? + record AClusterStatus { + double averageLoad; + array deadServerNames; + int deadServers; + string hbaseVersion; + int regionsCount; + int requestsCount; + array serverInfos; + int servers; + } + + // + // Family metadata + // + // TODO(hammer): how to keep in sync with Java Enum? + enum ACompressionAlgorithm { + LZO, GZ, NONE + } + + // TODO(hammer): include COLUMN_DESCRIPTOR_VERSION? + // TODO(hammer): add new bloomfilter stuff + record AFamilyDescriptor { + bytes name; + union { ACompressionAlgorithm, null } compression; + union { int, null } maxVersions; + union { int, null } blocksize; + union { boolean, null } inMemory; + union { int, null } timeToLive; + union { boolean, null } blockCacheEnabled; + } + + // + // Table metadata + // + // TODO(hammer): include TABLE_DESCRIPTOR_VERSION? + record ATableDescriptor { + bytes name; + union { array, null } families; + union { long, null } maxFileSize; + union { long, null } memStoreFlushSize; + union { boolean, null } rootRegion; + union { boolean, null } metaRegion; + union { boolean, null } metaTable; + union { boolean, null } readOnly; + union { boolean, null } deferredLogFlush; + } + + // + // Single-Row DML (Get) + // + record AColumn { + bytes family; + union { bytes, null } qualifier; + } + + record ATimeRange { + long minStamp; + long maxStamp; + } + + // TODO(hammer): Add filter options + record AGet { + bytes row; + union { array, null } columns; + union { long, null } timestamp; + union { ATimeRange, null } timerange; + union { int, null } maxVersions; + } + + record AResultEntry { + bytes family; + bytes qualifier; + bytes value; + long timestamp; + } + + // Avro maps can't use non-string keys, so using an array for now + record AResult { + bytes row; + array entries; + } + + // + // Single-Row DML (Put) + // + // TODO(hammer): Reuse a single KeyValue-style record for Get and Put? + record AColumnValue { + bytes family; + bytes qualifier; + bytes value; + union { long, null } timestamp; + } + + record APut { + bytes row; + array columnValues; + } + + // + // Single-Row DML (Delete) + // + // TODO(hammer): Add fields when API is rationalized (HBASE-2609) + record ADelete { + bytes row; + union { array, null } columns; + } + + // + // Multi-Row DML (Scan) + // + record AScan { + union { bytes, null } startRow; + union { bytes, null } stopRow; + union { array, null } columns; + union { long, null } timestamp; + union { ATimeRange, null } timerange; + union { int, null } maxVersions; + } + + // + // ERRORS + // + + /** + * An AIOError error signals that an error occurred communicating + * to the HBase master or a HBase region server. Also used to return + * more general HBase error conditions. + */ + error AIOError { + string message; + } + + /** + * An AIllegalArgument error indicates an illegal or invalid + * argument was passed into a procedure. + */ + error AIllegalArgument { + string message; + } + + /** + * An ATableExists error that a table with the specified + * name already exists + */ + error ATableExists { + string message; + } + + /** + * An AMasterNotRunning error means we couldn't reach the Master. + */ + error AMasterNotRunning { + string message; + } + + // + // MESSAGES + // + + // TODO(hammer): surgery tools + // TODO(hammer): checkAndPut/flushCommits + // TODO(hammer): MultiPut/Get/Delete + + // Cluster metadata + string getHBaseVersion() throws AIOError; + AClusterStatus getClusterStatus() throws AIOError; + array listTables() throws AIOError; + + // Table metadata + ATableDescriptor describeTable(bytes table) throws AIOError; + boolean isTableEnabled(bytes table) throws AIOError; + boolean tableExists(bytes table) throws AIOError; + + // Family metadata + AFamilyDescriptor describeFamily(bytes table, bytes family) throws AIOError; + + // Table admin + void createTable(ATableDescriptor table) throws AIOError, AIllegalArgument, ATableExists, AMasterNotRunning; + void deleteTable(bytes table) throws AIOError; + void modifyTable(bytes table, ATableDescriptor tableDescriptor) throws AIOError; + void enableTable(bytes table) throws AIOError; + void disableTable(bytes table) throws AIOError; + void flush(bytes table) throws AIOError; + void split(bytes table) throws AIOError; + + // Family admin + void addFamily(bytes table, AFamilyDescriptor family) throws AIOError; + void deleteFamily(bytes table, bytes family) throws AIOError; + void modifyFamily(bytes table, bytes familyName, AFamilyDescriptor familyDescriptor) throws AIOError; + + // Single-row DML + AResult get(bytes table, AGet get) throws AIOError; + boolean exists(bytes table, AGet get) throws AIOError; + void put(bytes table, APut put) throws AIOError; + void delete(bytes table, ADelete delete) throws AIOError; + long incrementColumnValue(bytes table, bytes row, bytes family, bytes qualifier, long amount, boolean writeToWAL) throws AIOError; + + // Multi-row DML (read-only) + int scannerOpen(bytes table, AScan scan) throws AIOError; + void scannerClose(int scannerId) throws AIOError, AIllegalArgument; + array scannerGetRows(int scannerId, int numberOfRows) throws AIOError, AIllegalArgument; +} -- 1.7.6