Package org.apache.avro
Class Protocol
java.lang.Object
org.apache.avro.JsonProperties
org.apache.avro.Protocol
A set of messages forming an application protocol.
A protocol consists of:
- a name for the protocol;
- an optional namespace, further qualifying the name;
- a list of types, or named
schemas
; - a list of errors, or named
schemas
for exceptions; - a list of named messages, each of which specifies,
- request, the parameter schemas;
- one of either;
- one-way
- response, the response schema;
- errors, an optional list of potential error schema names.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.avro.JsonProperties
JsonProperties.Null
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Schema
An error that can be thrown by any message.static final Schema
Union type for generating system errors.static final long
The version of the protocol specification implemented here.Fields inherited from class org.apache.avro.JsonProperties
NULL_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a one-way message.createMessage
(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors) Create a two-way message.createMessage
(String name, String doc, JsonProperties propMap, Schema request) Create a one-way message.createMessage
(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors) Create a two-way message.createMessage
(String name, String doc, Schema request) Deprecated.Deprecated.createMessage
(Protocol.Message m, Schema request) Create a one-way message using thename
,doc
, andprops
ofm
.createMessage
(Protocol.Message m, Schema request, Schema response, Schema errors) Create a two-way message using thename
,doc
, andprops
ofm
.boolean
getDoc()
Doc string for this protocol.byte[]
getMD5()
Return the MD5 hash of the text of this protocol.The messages of this protocol.getName()
The name of this protocol.The namespace of this protocol.Returns the named type.getTypes()
The types of this protocol.Deprecated.can return invalid schemata: do NOT use!int
hashCode()
static void
static Protocol
Read a protocol from a Json file.static Protocol
parse
(InputStream stream) Read a protocol from a Json stream.static Protocol
Read a protocol from a Json string.static Protocol
Read a protocol from one or more json stringsvoid
setTypes
(Collection<Schema> newTypes) Set the types of this protocol.toString()
Render this as JSON.toString
(boolean pretty) Render this as JSON.Methods inherited from class org.apache.avro.JsonProperties
addAllProps, addProp, addProp, forEachProperty, getObjectProp, getObjectProp, getObjectProps, getProp, hasProps, propsContainsKey, putAll
-
Field Details
-
VERSION
public static final long VERSIONThe version of the protocol specification implemented here.- See Also:
-
SYSTEM_ERROR
An error that can be thrown by any message. -
SYSTEM_ERRORS
Union type for generating system errors.
-
-
Constructor Details
-
Protocol
Constructs a similar Protocol instance with the samename
,doc
, andnamespace
as {code p} has. It also copies all theprops
. -
Protocol
-
Protocol
-
-
Method Details
-
getName
The name of this protocol. -
getNamespace
The namespace of this protocol. Qualifies its name. -
getDoc
Doc string for this protocol. -
getTypes
The types of this protocol. -
getUnresolvedTypes
Deprecated.can return invalid schemata: do NOT use! -
getType
Returns the named type. -
setTypes
Set the types of this protocol. -
getMessages
The messages of this protocol. -
createMessage
Deprecated.Create a one-way message. -
createMessage
Create a one-way message using thename
,doc
, andprops
ofm
. -
createMessage
public Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request) Create a one-way message. -
createMessage
public Protocol.Message createMessage(String name, String doc, Map<String, ?> propMap, Schema request) Create a one-way message. -
createMessage
@Deprecated public Protocol.Message createMessage(String name, String doc, Schema request, Schema response, Schema errors) Deprecated.Create a two-way message. -
createMessage
public Protocol.Message createMessage(Protocol.Message m, Schema request, Schema response, Schema errors) Create a two-way message using thename
,doc
, andprops
ofm
. -
createMessage
public Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors) Create a two-way message. -
createMessage
public Protocol.Message createMessage(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors) Create a two-way message. -
equals
-
hashCode
public int hashCode() -
toString
Render this as JSON. -
toString
Render this as JSON.- Parameters:
pretty
- if true, pretty-print JSON.
-
getMD5
public byte[] getMD5()Return the MD5 hash of the text of this protocol. -
parse
Read a protocol from a Json file.- Throws:
IOException
-
parse
Read a protocol from a Json stream.- Throws:
IOException
-
parse
Read a protocol from one or more json strings -
parse
Read a protocol from a Json string. -
main
- Throws:
Exception
-