You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2010/01/29 17:23:54 UTC

svn commit: r904542 - in /incubator/cassandra/trunk: build.xml interface/cassandra.avpr

Author: eevans
Date: Fri Jan 29 16:23:54 2010
New Revision: 904542

URL: http://svn.apache.org/viewvc?rev=904542&view=rev
Log:
avro rpc schema and code generation

Patch by eevans

Added:
    incubator/cassandra/trunk/interface/cassandra.avpr
Modified:
    incubator/cassandra/trunk/build.xml

Modified: incubator/cassandra/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/build.xml?rev=904542&r1=904541&r2=904542&view=diff
==============================================================================
--- incubator/cassandra/trunk/build.xml (original)
+++ incubator/cassandra/trunk/build.xml Fri Jan 29 16:23:54 2010
@@ -34,6 +34,7 @@
     <property name="javadoc.dir" value="${build.dir}/javadoc"/>
     <property name="interface.dir" value="${basedir}/interface"/>
     <property name="interface.src.dir" value="${interface.dir}/gen-java"/>
+    <property name="interface.avro.dir" value="${interface.dir}/avro/java"/>
     <property name="test.dir" value="${basedir}/test"/>
     <property name="test.resources" value="${test.dir}/resources"/>
     <property name="test.classes" value="${build.dir}/test/classes"/>
@@ -86,6 +87,7 @@
     <target name="clean">
         <delete dir="${build.dir}" />
         <delete dir="${build.src.gen-java}" />
+        <delete dir="${interface.avro.dir}" />
     </target>
     <target depends="clean" name="cleanall"/>
 
@@ -109,7 +111,7 @@
       </java> 
     </target>
 
-    <target name="ivy-download" unless="ivy.jar.exists">
+    <target name="ivy-download" unless="ivy.jar.exists" depends="init">
       <echo>Downloading Ivy...</echo>
       <get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
            dest="${build.dir}/lib/ivy-${ivy.version}.jar" usetimestamp="true" />
@@ -127,6 +129,33 @@
                     pattern="${build.dir.lib}/[artifact]-[revision].[ext]" />
     </target>
 
+    <!-- Generate -->
+    <target name="generate" depends="init">
+      <taskdef name="protocol"
+               classname="org.apache.avro.specific.ProtocolTask">
+        <classpath refid="cassandra.classpath" />
+      </taskdef>
+      <taskdef name="schema" classname="org.apache.avro.specific.SchemaTask">
+        <classpath refid="cassandra.classpath" />
+      </taskdef>
+      <taskdef name="paranamer" 
+          classname="com.thoughtworks.paranamer.ant.ParanamerGeneratorTask">
+        <classpath refid="cassandra.classpath" />
+      </taskdef>
+  
+      <protocol destdir="${interface.avro.dir}">
+        <fileset dir="${interface.dir}">
+          <include name="**/*.avpr" />
+        </fileset>
+      </protocol>
+  
+      <schema destdir="${interface.avro.dir}">
+        <fileset dir="${interface.dir}">
+          <include name="**/*.avsc" />
+        </fileset>
+      </schema>
+    </target>
+
     <target name="gen-thrift-java">
       <echo>Generating Thrift Java code from ${basedir}/interface/cassandra.thrift ....</echo>
       <exec executable="thrift" dir="${basedir}/interface">
@@ -150,7 +179,7 @@
 	The build target builds all the .class files
     -->
     <target name="build"
-            depends="build-subprojects,build-project,ivy-retrieve"/>
+            depends="ivy-retrieve,generate,build-subprojects,build-project"/>
     <target name="build-subprojects"/>
     <target name="codecoverage" depends="cobertura-instrument,test,cobertura-report"/>
     	
@@ -162,6 +191,9 @@
             <src path="${interface.src.dir}"/>
             <classpath refid="cassandra.classpath"/>
         </javac>
+
+        <paranamer sourceDirectory="${interface.avro.dir}"
+               outputDirectory="${build.classes}"/>
     </target>
 
     <!--

Added: incubator/cassandra/trunk/interface/cassandra.avpr
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/cassandra.avpr?rev=904542&view=auto
==============================================================================
--- incubator/cassandra/trunk/interface/cassandra.avpr (added)
+++ incubator/cassandra/trunk/interface/cassandra.avpr Fri Jan 29 16:23:54 2010
@@ -0,0 +1,100 @@
+{
+  "namespace":  "org.apache.cassandra.avro",
+  "protocol":   "Cassandra",
+
+  "types": [
+      {"name": "ColumnPath", "type": "record",
+          "fields": [
+            {"name": "column_family", "type": "string"},
+            {"name": "super_column", "type": ["bytes", "null"]},
+            {"name": "column", "type": ["bytes", "null"]}
+        ]
+      },
+      {"name": "Column", "type": "record",
+          "fields": [
+            {"name": "name", "type": "bytes"},
+            {"name": "value", "type": "bytes"},
+            {"name": "timestamp", "type": "long"}
+        ]
+      },
+      {"name": "SuperColumn", "type": "record",
+          "fields": [
+            {"name": "name", "type": "bytes"},
+            {"name": "columns", "type": {"type": "array", "items": "Column"}}
+        ]
+      },
+      {"name": "ColumnOrSuperColumn", "type": "record",
+          "fields": [
+            {"name": "column", "type": ["Column", "null"]},
+            {"name": "super_column", "type": ["SuperColumn", "null"]}
+        ]
+      },
+      {"name": "ConsistencyLevel", "type": "enum",
+          "symbols": [
+            "ZERO", "ONE", "QUORUM", "DCQUORUM", "DCQUORUMSYNC", "ALL"
+          ]
+      },
+      {"name": "InvalidRequestException", "type": "error",
+          "fields": [
+            {"name": "why", "type": ["string", "null"]}
+          ]
+      },
+      {"name": "NotFoundException", "type": "error",
+          "fields": [
+            {"name": "why", "type": ["string", "null"]}
+          ]
+      },
+      {"name": "UnavailableException", "type": "error",
+          "fields": [
+            {"name": "why", "type": ["string", "null"]}
+          ]
+      },
+      {"name": "TimedOutException", "type": "error",
+          "fields": [
+            {"name": "why", "type": ["string", "null"]}
+          ]
+      }
+  ],
+
+  "messages": {
+    "get": {
+        "request": [
+            {"name": "keyspace", "type": "string"},
+            {"name": "key", "type": "string"},
+            {"name": "column_path", "type": "ColumnPath"},
+            {"name": "consistency_level", "type": "ConsistencyLevel"}
+        ],
+        "response": "ColumnOrSuperColumn",
+        "errors": ["InvalidRequestException", "NotFoundException",
+            "UnavailableException", "TimedOutException"]
+    },
+    "insert": {
+        "request": [
+            {"name": "keyspace", "type": "string"},
+            {"name": "key", "type": "string"},
+            {"name": "column_path", "type": "ColumnPath"},
+            {"name": "value", "type": "bytes"},
+            {"name": "timestamp", "type": "long"},
+            {"name": "consistency_level", "type": "ConsistencyLevel"}
+        ],
+        "response": "null",
+        "errors": ["InvalidRequestException", "UnavailableException",
+            "TimedOutException"]
+    },
+    "batch_insert": {
+        "request": [
+            {"name": "keyspace", "type": "string"},
+            {"name": "key", "type": "string"},
+            {"name": "cfmap", "type": {"type": "map", "values": {"type": "array", "items": "ColumnOrSuperColumn"}}},
+            {"name": "consistency_level", "type": "ConsistencyLevel"}
+        ],
+        "response": "null",
+        "errors": ["InvalidRequestException", "UnavailableException",
+            "TimedOutException"]
+    },
+    "get_api_version": {
+        "request": [],
+        "response": "string"
+    }
+  }
+}