Hi james, after studying your works, I find that our basic idea is alike but
our implementation is a little different. It appears my design is simpler
than yours. The following is the comparison:
1, my design only has 4 files: NettyFrameDecoder.java,
NettyFrameEncoder.java, NettyServer.java and NettyTransceiver.java, in which
Encoder/Decoder classes transform data structure between List<ByteBuffer>
(need by Responder) and ChannelBuffer (need by Netty), Server class as a
server and Transceiver as a client. The design is more similar with
SocketServer and SocketTransceiver, so does the usage. i.e.
// server
Responder responder = new SpecificResponder(Mail.class, new
MailImpl());
Server server = new NettyServer(responder, new
InetSocketAddress(0));
Thread.sleep(1000); // waiting for server startup
// client
int serverPort = server.getPort();
Transceiver transceiver = new NettyTransceiver(new
InetSocketAddress(serverPort));
Mail proxy = (Mail)SpecificRequestor.getClient(Mail.class,
transceiver);
Message msg = new Message();
msg.to = new Utf8("wife");
msg.from = new Utf8("husband");
msg.body = new Utf8("I love you!");
try {
Utf8 result = proxy.send(msg);
System.out.println("Result: " + result);
} finally {
transceiver.close();
server.close();
}
2, your design has about 10 files because you use more handlers in the
pipeline and more top level classes such as client/server PipelineFactory.
The biggest difference is that your client and server class design is not
similar with SocketTransceiver/SocketServer or HttpTransceiver/HttpServer
pair. And the usage method is :
// server
netSocketAddress address = new InetSocketAddress(port);
AvroServer server = new AvroServer(address); // where is the
Responder instance ?
// client
InetSocketAddress address = new InetSocketAddress(port);
AvroClient client = new AvroClient(address);
Message message = createMessage(to, from, body);
String response = client.dispatch(message); // not use the Proxy
pattern
System.out.println("response: " + response);
client.dispose();
In your design there is a problem that you create a specific Responder
instance using specific protocol in AvroServerHandler which could not be
reused in other circumstances.
So, I think my design is more close to the Avro's way. How do you think
about it? and anyone else?
- harry
On Fri, Jun 25, 2010 at 11:47 AM, James Todd <[email protected]> wrote:
> the latest/greatest patch against AVRO-405 is:
> https://issues.apache.org/jira/secure/attachment/12441447/AVRO-405.patch
>
> it's a merge of bo shin's and my work.
>
> there is more to do here, should be summarized in the comments iirc, but it
> would be great to get this initial spike done and build
> on from that point.
>
> best,
>
> - james
>
> On Thu, Jun 24, 2010 at 8:04 PM, harry wang <[email protected]> wrote:
>
> > OK. But it seems that someone else has already made a netty-rpc patch. I
> > would like to see if my work could be merged into it.
> >
> > - harry
> >
> > On Fri, Jun 25, 2010 at 2:50 AM, Doug Cutting <[email protected]>
> wrote:
> >
> > > This would make a great contribution!
> > >
> > > Can you please attach it as a patch to an issue in Jira?
> > >
> > > Thanks,
> > >
> > > Doug
> > >
> > >
> > > On 06/24/2010 11:29 AM, harry wang wrote:
> > >
> > >> hi, I have implemented the Avro RPC Server and Transceiver using
> Netty.
> > If
> > >> anyone is interested in it, you can look at
> > >> http://github.com/coolwhy/avro-rpc-on-netty. Any suggestion is
> welcome.
> > >> Thanks!
> > >>
> > >> - harry
> > >>
> > >>
> >
>