throws AvroRemoteException {
GenericRecord params = (GenericRecord)request;
if ("hello".equals(message.getName())) {
LOG.info("hello: "+params.get("greeting"));
return new Utf8("goodbye");
}
if ("echo".equals(message.getName())) {
Object record = params.get("record");
LOG.info("echo: "+record);
return record;
}
if ("echoBytes".equals(message.getName())) {
Object data = params.get("data");
LOG.info("echoBytes: "+data);
return data;
}
if ("error".equals(message.getName())) {
if (throwUndeclaredError) throw new RuntimeException("foo");
GenericRecord error =
new GenericData.Record(PROTOCOL.getType("TestError"));
error.put("message", new Utf8("an error"));
throw new AvroRemoteException(error);
}
throw new AvroRuntimeException("unexpected message: "+message.getName());
}