Top Description Inners Fields Constructors Methods
org.apache.avro

public Class Protocol

extends JsonProperties
Class Inheritance
Imports
com.fasterxml.jackson.core.JsonGenerator, .JsonParser, com.fasterxml.jackson.databind.JsonNode, org.apache.avro.Schema.Field, .Schema.Field.Order, java.io.ByteArrayInputStream, .File, .IOException, .InputStream, .StringWriter, java.nio.charset.StandardCharsets, java.security.MessageDigest, java.util.ArrayList, .Arrays, .Collection, .Collections, .HashSet, .Iterator, .LinkedHashMap, .List, .Map, .Set

A set of messages forming an application protocol.

A protocol consists of:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
Protocol.Message

A protocol message.

private class

Field Summary

Modifier and TypeField and Description
private String
private static final Set<String>
private byte[]
private static final Set<String>
private final Map<String, Protocol.Message>
private String
private String
private static final Set<String>
public static final Schema
SYSTEM_ERROR

An error that can be thrown by any message.

public static final Schema
SYSTEM_ERRORS

Union type for generating system errors.

private Schema.Names
public static final long
VERSION

The version of the protocol specification implemented here.

Inherited from org.apache.avro.JsonProperties:
NULL_VALUE

Constructor Summary

AccessConstructor and Description
private
public
Protocol(Protocol p)

Constructs a similar Protocol instance with the same name, doc, and namespace as {code p} has.

public
Protocol(String name, String doc, String namespace)

public
Protocol(String name, String namespace)

Method Summary

Modifier and TypeMethod and Description
public Protocol.Message
createMessage(String name, String doc, Schema request)

Deprecated
Create a one-way message.
public Protocol.Message
createMessage(Protocol.Message m, Schema request)

Create a one-way message using the name, doc, and props of m.

public <T> Protocol.Message
createMessage(String name, String doc, JsonProperties propMap, Schema request)

Create a one-way message.

public <T> Protocol.Message
createMessage(String name, String doc, Map<String, ?> propMap, Schema request)

Create a one-way message.

public Protocol.Message
createMessage(String name, String doc, Schema request, Schema response, Schema errors)

Deprecated
Create a two-way message.
public Protocol.Message
createMessage(Protocol.Message m, Schema request, Schema response, Schema errors)

Create a two-way message using the name, doc, and props of m.

public <T> Protocol.Message
createMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors)

Create a two-way message.

public <T> Protocol.Message
createMessage(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors)

Create a two-way message.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
getDoc()

Doc string for this protocol.

public byte[]
getMD5()

Return the MD5 hash of the text of this protocol.

public Map<String, Protocol.Message>
getMessages()

The messages of this protocol.

public String
getName()

The name of this protocol.

public String
getNamespace()

The namespace of this protocol.

public Schema
getType(String name)

Returns the named type.

public Collection<Schema>
getTypes()

The types of this protocol.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public static void
main(String[] args)

public static Protocol
parse(File file)

Read a protocol from a Json file.

public static Protocol
parse(InputStream stream)

Read a protocol from a Json stream.

public static Protocol
parse(String string, String... more)

Read a protocol from one or more json strings

public static Protocol
parse(String string)

Read a protocol from a Json string.

private static Protocol
parse(JsonParser parser)

private void
private void
private String
private Protocol.Message
parseMessage(String messageName, JsonNode json)

private void
private void
private void
private void
private void
setName(String name, String namespace)

public void
setTypes(Collection<Schema> newTypes)

Set the types of this protocol.

pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Render this as JSON.
public String
toString(boolean
if true, pretty-print JSON.
pretty
)

Render this as JSON.

Inherited from org.apache.avro.JsonProperties:
addAllPropsaddPropaddPropgetObjectPropgetObjectPropsgetProphasPropspropsEqualpropsHashCodeputAllwriteProps

Field Detail

docback to summary
private String doc
FIELD_RESERVEDback to summary
private static final Set<String> FIELD_RESERVED
md5back to summary
private byte[] md5
MESSAGE_RESERVEDback to summary
private static final Set<String> MESSAGE_RESERVED
messagesback to summary
private final Map<String, Protocol.Message> messages
nameback to summary
private String name
namespaceback to summary
private String namespace
PROTOCOL_RESERVEDback to summary
private static final Set<String> PROTOCOL_RESERVED
SYSTEM_ERRORback to summary
public static final Schema SYSTEM_ERROR

An error that can be thrown by any message.

SYSTEM_ERRORSback to summary
public static final Schema SYSTEM_ERRORS

Union type for generating system errors.

typesback to summary
private Schema.Names types
VERSIONback to summary
public static final long VERSION

The version of the protocol specification implemented here.

Constructor Detail

Protocolback to summary
private Protocol()
Protocolback to summary
public Protocol(Protocol p)

Constructs a similar Protocol instance with the same name, doc, and namespace as {code p} has. It also copies all the props.

Protocolback to summary
public Protocol(String name, String doc, String namespace)
Protocolback to summary
public Protocol(String name, String namespace)

Method Detail

createMessageback to summary
public Protocol.Message createMessage(String name, String doc, Schema request)

Deprecated

Create a one-way message.

Annotations
@Deprecated
createMessageback to summary
public Protocol.Message createMessage(Protocol.Message m, Schema request)

Create a one-way message using the name, doc, and props of m.

createMessageback to summary
public <T> Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request)

Create a one-way message.

createMessageback to summary
public <T> Protocol.Message createMessage(String name, String doc, Map<String, ?> propMap, Schema request)

Create a one-way message.

createMessageback to summary
public Protocol.Message createMessage(String name, String doc, Schema request, Schema response, Schema errors)

Deprecated

Create a two-way message.

Annotations
@Deprecated
createMessageback to summary
public Protocol.Message createMessage(Protocol.Message m, Schema request, Schema response, Schema errors)

Create a two-way message using the name, doc, and props of m.

createMessageback to summary
public <T> Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors)

Create a two-way message.

createMessageback to summary
public <T> Protocol.Message createMessage(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors)

Create a two-way message.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDocback to summary
public String getDoc()

Doc string for this protocol.

getMD5back to summary
public byte[] getMD5()

Return the MD5 hash of the text of this protocol.

getMessagesback to summary
public Map<String, Protocol.Message> getMessages()

The messages of this protocol.

getNameback to summary
public String getName()

The name of this protocol.

getNamespaceback to summary
public String getNamespace()

The namespace of this protocol. Qualifies its name.

getTypeback to summary
public Schema getType(String name)

Returns the named type.

getTypesback to summary
public Collection<Schema> getTypes()

The types of this protocol.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
mainback to summary
public static void main(String[] args) throws Exception
parseback to summary
public static Protocol parse(File file) throws IOException

Read a protocol from a Json file.

parseback to summary
public static Protocol parse(InputStream stream) throws IOException

Read a protocol from a Json stream.

parseback to summary
public static Protocol parse(String string, String... more)

Read a protocol from one or more json strings

parseback to summary
public static Protocol parse(String string)

Read a protocol from a Json string.

parseback to summary
private static Protocol parse(JsonParser parser)
parseback to summary
private void parse(JsonNode json)
parseDocback to summary
private void parseDoc(JsonNode json)
parseDocNodeback to summary
private String parseDocNode(JsonNode json)
parseMessageback to summary
private Protocol.Message parseMessage(String messageName, JsonNode json)
parseMessagesback to summary
private void parseMessages(JsonNode json)
parseNameAndNamespaceback to summary
private void parseNameAndNamespace(JsonNode json)
parsePropsback to summary
private void parseProps(JsonNode json)
parseTypesback to summary
private void parseTypes(JsonNode json)
setNameback to summary
private void setName(String name, String namespace)
setTypesback to summary
public void setTypes(Collection<Schema> newTypes)

Set the types of this protocol.

toJsonback to summary
pack-priv void toJson(JsonGenerator gen) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Render this as JSON.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
toStringback to summary
public String toString(boolean pretty)

Render this as JSON.

Parameters
pretty:boolean

if true, pretty-print JSON.

org.apache.avro back to summary

public Class Protocol.Message

extends JsonProperties
Class Inheritance
Known Direct Subclasses
org.apache.avro.Protocol.TwoWayMessage

A protocol message.

Field Summary

Modifier and TypeField and Description
private String
private String
private Schema
Inherited from org.apache.avro.JsonProperties:
NULL_VALUE

Constructor Summary

AccessConstructor and Description
private
Message(String name, String doc, JsonProperties propMap, Schema request)

Construct a message.

private
Message(String name, String doc, Map<String, ?> propMap, Schema request)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
public Schema
getErrors()

Errors that might be thrown.

public String
getName()

The name of this message.

public Schema
getRequest()

The parameters of this message.

public Schema
getResponse()

The returned data.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isOneWay()

Returns true if this is a one-way message, with no response or errors.

pack-priv void
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.apache.avro.JsonProperties:
addAllPropsaddPropaddPropgetObjectPropgetObjectPropsgetProphasPropspropsEqualpropsHashCodeputAllwriteProps

Field Detail

docback to summary
private String doc
nameback to summary
private String name
requestback to summary
private Schema request

Constructor Detail

Messageback to summary
private Message(String name, String doc, JsonProperties propMap, Schema request)

Construct a message.

Messageback to summary
private Message(String name, String doc, Map<String, ?> propMap, Schema request)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDocback to summary
public String getDoc()
getErrorsback to summary
public Schema getErrors()

Errors that might be thrown.

getNameback to summary
public String getName()

The name of this message.

getRequestback to summary
public Schema getRequest()

The parameters of this message.

getResponseback to summary
public Schema getResponse()

The returned data.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isOneWayback to summary
public boolean isOneWay()

Returns true if this is a one-way message, with no response or errors.

toJsonback to summary
pack-priv void toJson(JsonGenerator gen) throws IOException
toJson1back to summary
pack-priv void toJson1(JsonGenerator gen) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.apache.avro back to summary

private Class Protocol.TwoWayMessage

extends Message
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Schema
private Schema

Constructor Summary

AccessConstructor and Description
private
TwoWayMessage(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors)

Construct a message.

private
TwoWayMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides org.apache.avro.Protocol.Message.equals.

Indicates whether some other object is "equal to" this one.
public Schema
getErrors()

Overrides org.apache.avro.Protocol.Message.getErrors.

Errors that might be thrown.
public Schema
public int
hashCode()

Overrides org.apache.avro.Protocol.Message.hashCode.

Returns a hash code value for the object.
public boolean
isOneWay()

Overrides org.apache.avro.Protocol.Message.isOneWay.

Returns true if this is a one-way message, with no response or errors.
pack-priv void
Inherited from org.apache.avro.Protocol.Message:
getDocgetNamegetRequesttoJsontoString

Field Detail

errorsback to summary
private Schema errors
responseback to summary
private Schema response

Constructor Detail

TwoWayMessageback to summary
private TwoWayMessage(String name, String doc, Map<String, ?> propMap, Schema request, Schema response, Schema errors)

Construct a message.

TwoWayMessageback to summary
private TwoWayMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides org.apache.avro.Protocol.Message.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getErrorsback to summary
public Schema getErrors()

Overrides org.apache.avro.Protocol.Message.getErrors.

Doc from org.apache.avro.Protocol.Message.getErrors.

Errors that might be thrown.

Annotations
@Override
getResponseback to summary
public Schema getResponse()

Overrides org.apache.avro.Protocol.Message.getResponse.

Doc from org.apache.avro.Protocol.Message.getResponse.

The returned data.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.apache.avro.Protocol.Message.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isOneWayback to summary
public boolean isOneWay()

Overrides org.apache.avro.Protocol.Message.isOneWay.

Doc from org.apache.avro.Protocol.Message.isOneWay.

Returns true if this is a one-way message, with no response or errors.

Annotations
@Override
toJson1back to summary
pack-priv void toJson1(JsonGenerator gen) throws IOException

Overrides org.apache.avro.Protocol.Message.toJson1.

Annotations
@Override