Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Avro Client-Server - generic vs specific


Copy link to this message
-
Re: Avro Client-Server - generic vs specific

Can I use the following code rather the maven plugin:

Idl parserIDL = new
Idl(Main.class.getResourceAsStream("/net/avro/protocol_man.avdl"));
   Protocol protocol = parserIDL.CompilationUnit();
   mediatorResponder = new MediatorResponder(protocol);
   startNettyServer(mediatorResponder);
   parserIDL.close();

Where mediator Responder is:

public class MediatorResponder extends GenericResponder{
     public MediatorResponder(Protocol protocol) {
         super(protocol);
     }

     @Override
     public Object respond(Protocol.Message msg, Object request) throws
Exception {
         String msgName = msg.getName();
         switch(msgName){
             case "hello":     System.out.println("HELLO"); break;
             case "bye":     System.out.println("BYE"); break;
             default:
                 throw new AvroRuntimeException("unexcepcted message: "
+ msgName);
         }

         return null;
     }

}

?

W dniu 01.10.2013 20:41, Doug Cutting pisze:
> On Tue, Oct 1, 2013 at 10:57 AM, michał <[EMAIL PROTECTED]> wrote:
>> 1. Would it be possible to program client-server and generate the protocol
>> classes programmatically at compile time?
> Yes.  This is supported through Avro's Maven plugins by adding
> something like the following to your pom.xml:
>
> <plugin>
>    <groupId>org.apache.avro</groupId>
>    <artifactId>avro-maven-plugin</artifactId>
>    <version>${avro.version}</version>
>    <executions>
>      <execution>
>        <phase>generate-sources</phase>
>        <goals>
>          <goal>schema</goal>
>          <goal>protocol</goal>
>          <goal>idl-protocol</goal>
>        </goals>
>      </execution>
>    </executions>
> </plugin>
>
> This will compile .avpr files from src/main/avro, generating .avsc and
> .avpr files in target/generated-sources/avro, then compile these to
> create .java files in target/generated-sources/java which will be
> compiled by the normal Maven java compilation plugins.
>
> Doug

NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB