avro rpc schema and code generation

Patch by eevans

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@904542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eric Evans 2010-01-29 16:23:54 +00:00
parent 26c95ff453
commit 1cd17032ea
2 changed files with 134 additions and 2 deletions

View File

@ -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>
<!--

100
interface/cassandra.avpr Normal file
View File

@ -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"
}
}
}