Thanks Doug,

My complete working definition is as below for anyone stumbling on this thread.
Tim


{"namespace": "org.gbif.portalanalytics",
 "protocol": "LogEvent",

 "types": [
     {"name": "Event", "type": "record",
      "fields": [
          {"name": "message", "type": "string"},
          {
                "name": "sourceComponentType",
                "type":
                {
                        "name": "SOURCE_COMPONENT_TYPES",
                        "type": "enum",
                        "symbols" : ["OCCURRENCE_HARVESTER", 
"CHECKLIST_HARVESTER", "USER"]
                 }
          },
          {"name": "instanceId", "type": "string"},
          {"name": "sessionId", "type": "string", "default": null},
          {"name": "count", "type": "int", "default": 0},
          {"name": "sourceId", "type": "string"},
          {"name": "userId", "type": "string"},
          {
                "name": "level",
                "type":
                {
                        "name": "LEVEL_TYPES",
                        "type": "enum",
                        "symbols" : ["DEBUG", "INFO", "WARN", "ERROR"]
                }
          },
          {"name": "agentId", "type": "string"},
          {
                "name": "objectType",
                "type":
                {
                        "name": "OBJECT_TYPES",
                        "type": "enum",
                        "symbols" : ["OCCURRENCE", "NAME_USAGE"]
                }
          },
          {"name": "objectId", "type": "string"},
          {"name": "message", "type": "string"},
          {"name": "sensitive", "type": "boolean", "default": "false"}
      ]
     }
 ],

 "messages": {
         "openSession": {
         "request": [],
         "response": "string"
         },

         "closeSession": {
         "request": [{"name": "sessionId", "type": "string"}],
         "response": []
         },

     "log": {
         "request": [{"name": "event", "type": "Event"}],
         "response": "string"
     }
 }
}


On Mon, Aug 2, 2010 at 5:59 PM, Doug Cutting <[email protected]> wrote:
> The sourceComponentTypeField should look something like:
>
> {"name": "sourceComponentType",
>  "type": {"type": "enum", "symbols": [ ... ] }
> }
>
> This is the same error message that confused Sam in:
>
> https://issues.apache.org/jira/browse/AVRO-583
>
> Doug
>
> On 08/02/2010 08:46 AM, Tim Robertson wrote:
>>
>> Hi all,
>>
>> I am new to avro, and using it to implement an http RPC transport
>> layer to allow distributed components to push to a centralised event
>> log.
>>
>> I have the following types in my .avpr:
>>
>>  "types": [
>>      {"name": "Event", "type": "record",
>>       "fields": [
>>           {"name": "message", "type": "string"},
>>           {
>>                "type": "enum",
>>                "name": "sourceComponentType",
>>                "symbols" : ["OCCURRENCE_HARVESTER", "CHECKLIST_HARVESTER",
>> "USER"]
>>           },
>>           {"name": "instanceId", "type": "string"},
>>           {"name": "sessionId", "type": "string", "default": null},
>>           {"name": "count", "type": "int", "default": 0},
>>           {"name": "sourceId", "type": "string"},
>>           {"name": "userId", "type": "string"},
>>           {
>>                "type": "enum",
>>                "name": "level",
>>                "symbols" : ["DEBUG", "INFO", "WARN", "ERROR"]
>>           },
>>           {"name": "agentId", "type": "string"},
>>           {
>>                "type": "enum",
>>                "name": "objectType",
>>                "symbols" : ["OCCURRENCE", "NAME_USAGE"]
>>           },
>>           {"name": "objectId", "type": "string"},
>>           {"name": "message", "type": "string"},
>>           {"name": "sensitive", "type": "boolean", "default": "false"}
>>       ]
>>      }
>>
>> but on protocol compilation get:
>>
>> org.apache.avro.SchemaParseException: Undefined name: "enum"
>>        at org.apache.avro.Schema.parse(Schema.java:876)
>>        at org.apache.avro.Schema.parse(Schema.java:912)
>>        at org.apache.avro.Protocol.parseTypes(Protocol.java:325)
>>        at org.apache.avro.Protocol.parse(Protocol.java:288)
>>        at org.apache.avro.Protocol.parse(Protocol.java:278)
>>        at org.apache.avro.Protocol.parse(Protocol.java:262)
>>        at
>> org.apache.avro.specific.SpecificCompiler.compileProtocol(SpecificCompiler.java:104)
>>        at org.apache.avro.mojo.AvroMojo.execute(AvroMojo.java:163)
>>        at
>> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>>        at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>>        at
>> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at
>> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>>        at
>> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>>
>>
>> Can someone spot an error please?  I'm on 1.3.3 and just copied the
>> example in the docs on
>> http://avro.apache.org/docs/1.3.3/spec.html#Enums
>>
>> Thanks,
>> Tim
>

Reply via email to