本文整理了Java中org.apache.avro.Protocol.createMessage()
方法的一些代码示例,展示了Protocol.createMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.createMessage()
方法的具体详情如下:
包路径:org.apache.avro.Protocol
类名称:Protocol
方法名:createMessage
[英]Create a one-way message.
[中]创建单向消息。
代码示例来源:origin: org.apache.avro/avro
/** Create a one-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),request);
}
/** Create a one-way message. */
代码示例来源:origin: org.apache.avro/avro
/** Create a two-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request,
Schema response, Schema errors) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),
request, response, errors);
}
/** Create a two-way message. */
代码示例来源:origin: apache/avro
errs.add(getSchema(err, names));
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
代码示例来源:origin: apache/avro
private Protocol addStringType(Protocol p) {
if (stringType != StringType.String)
return p;
Protocol newP = new Protocol(p.getName(), p.getDoc(), p.getNamespace());
Map<Schema,Schema> types = new LinkedHashMap<>();
for (Map.Entry<String, Object> a : p.getObjectProps().entrySet()) {
newP.addProp(a.getKey(), a.getValue());
}
// annotate types
Collection<Schema> namedTypes = new LinkedHashSet<>();
for (Schema s : p.getTypes())
namedTypes.add(addStringType(s, types));
newP.setTypes(namedTypes);
// annotate messages
Map<String,Message> newM = newP.getMessages();
for (Message m : p.getMessages().values())
newM.put(m.getName(), m.isOneWay()
? newP.createMessage(m,
addStringType(m.getRequest(), types))
: newP.createMessage(m,
addStringType(m.getRequest(), types),
addStringType(m.getResponse(), types),
addStringType(m.getErrors(), types)));
return newP;
}
代码示例来源:origin: org.apache.avro/avro
errs.add(getSchema(err, names));
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
代码示例来源:origin: apache/avro
if (value.isOneWay()) {
Schema replacement = resolve(replacements, value.getRequest(), protocol);
nvalue = result.createMessage(value.getName(), value.getDoc(),
value, replacement);
} else {
Schema response = resolve(replacements, value.getResponse(), protocol);
Schema errors = resolve(replacements, value.getErrors(), protocol);
nvalue = result.createMessage(value.getName(), value.getDoc(),
value, request, response, errors);
代码示例来源:origin: apache/avro
{if (true) throw error("One-way message'"+name+"' must return void", token);}
{if (true) return oneWay
? p.createMessage(name, msgDoc, props, request)
: p.createMessage(name, msgDoc, props, request, response, errors);}
throw new Error("Missing return statement in function");
代码示例来源:origin: apache/avro
/** Test that Responder ignores one-way with stateless transport. */
@Test public void testStatelessOneway() throws Exception {
// a version of the Simple protocol that doesn't declare "ack" one-way
Protocol protocol = new Protocol("Simple", "org.apache.avro.test");
Protocol.Message message =
protocol.createMessage("ack", null,
Schema.createRecord(new ArrayList<>()),
Schema.create(Schema.Type.NULL),
Schema.createUnion(new ArrayList<>()));
protocol.getMessages().put("ack", message);
// call a server over a stateless protocol that has a one-way "ack"
GenericRequestor requestor =
new GenericRequestor(protocol, createTransceiver());
requestor.request("ack", new GenericData.Record(message.getRequest()));
// make the request again, to better test handshakes w/ differing protocols
requestor.request("ack", new GenericData.Record(message.getRequest()));
}
代码示例来源:origin: apache/avro
protocol.createMessage("echo", null, Schema.createRecord(params),
record,
Schema.createUnion(new ArrayList<>()));
代码示例来源:origin: apache/avro
@Test
/** Construct and use a different protocol whose "hello" method has an extra
argument to check that schema is sent to parse request. */
public void testHandshake() throws IOException {
Protocol protocol = new Protocol("Simple", "org.apache.avro.test");
List<Field> fields = new ArrayList<>();
fields.add(new Schema.Field("extra", Schema.create(Schema.Type.BOOLEAN),
null, null));
fields.add(new Schema.Field("greeting", Schema.create(Schema.Type.STRING),
null, null));
Protocol.Message message =
protocol.createMessage("hello",
null /* doc */,
Schema.createRecord(fields),
Schema.create(Schema.Type.STRING),
Schema.createUnion(new ArrayList<>()));
protocol.getMessages().put("hello", message);
Transceiver t
= new SocketTransceiver(new InetSocketAddress(server.getPort()));
try {
GenericRequestor r = new GenericRequestor(protocol, t);
GenericRecord params = new GenericData.Record(message.getRequest());
params.put("extra", Boolean.TRUE);
params.put("greeting", new Utf8("bob"));
Utf8 response = (Utf8)r.request("hello", params);
assertEquals(new Utf8("goodbye"), response);
} finally {
t.close();
}
}
代码示例来源:origin: apache/avro
@Test
/** Construct and use a protocol whose "hello" method has an extra
argument to check that schema is sent to parse request. */
public void testParamVariation() throws Exception {
Protocol protocol = new Protocol("Simple", "org.apache.avro.test");
List<Schema.Field> fields = new ArrayList<>();
fields.add(new Schema.Field("extra", Schema.create(Schema.Type.BOOLEAN),
null, null));
fields.add(new Schema.Field("greeting", Schema.create(Schema.Type.STRING),
null, null));
Protocol.Message message =
protocol.createMessage("hello",
null /* doc */,
Schema.createRecord(fields),
Schema.create(Schema.Type.STRING),
Schema.createUnion(new ArrayList<>()));
protocol.getMessages().put("hello", message);
Transceiver t = createTransceiver();
try {
GenericRequestor r = new GenericRequestor(protocol, t);
addRpcPlugins(r);
GenericRecord params = new GenericData.Record(message.getRequest());
params.put("extra", Boolean.TRUE);
params.put("greeting", "bob");
String response = r.request("hello", params).toString();
assertEquals("goodbye", response);
} finally {
t.close();
}
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/** Create a two-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request,
Schema response, Schema errors) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),
request, response, errors);
}
/** Create a two-way message. */
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro
/** Create a one-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),request);
}
/** Create a one-way message. */
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro
/** Create a two-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request,
Schema response, Schema errors) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),
request, response, errors);
}
/** Create a two-way message. */
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/** Create a one-way message. */
@Deprecated
public Message createMessage(String name, String doc, Schema request) {
return createMessage(name, doc, new LinkedHashMap<String,String>(),request);
}
/** Create a one-way message. */
代码示例来源:origin: org.apache.hadoop/avro
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
代码示例来源:origin: com.facebook.presto.hive/hive-apache
errs.add(getSchema(err, names));
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
代码示例来源:origin: org.apache.cassandra.deps/avro
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro
errs.add(getSchema(err, names));
Schema errors = Schema.createUnion(errs);
return protocol.createMessage(method.getName(), null /* doc */, request, response, errors);
内容来源于网络,如有侵权,请联系作者删除!