[ 
https://issues.apache.org/jira/browse/NIFI-3682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15975631#comment-15975631
 ] 

ASF GitHub Bot commented on NIFI-3682:
--------------------------------------

Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1682#discussion_r112255200
  
    --- Diff: 
nifi-nar-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java
 ---
    @@ -54,39 +57,51 @@
         private static final String LOGICAL_TYPE_TIMESTAMP_MILLIS = 
"timestamp-millis";
         private static final String LOGICAL_TYPE_TIMESTAMP_MICROS = 
"timestamp-micros";
     
    -
         public AvroSchemaRegistry() {
             this.schemaNameToSchemaMap = new HashMap<>();
         }
     
    -    @OnEnabled
    -    public void enable(ConfigurationContext configuratiponContext) throws 
InitializationException {
    -        
this.schemaNameToSchemaMap.putAll(configuratiponContext.getProperties().entrySet().stream()
    -            .filter(propEntry -> propEntry.getKey().isDynamic())
    -            .collect(Collectors.toMap(propEntry -> 
propEntry.getKey().getName(), propEntry -> propEntry.getValue())));
    +    @Override
    +    public String retrieveSchemaText(final String schemaName) throws 
SchemaNotFoundException {
    +        final String schemaText = schemaNameToSchemaMap.get(schemaName);
    +        if (schemaText == null) {
    +            throw new SchemaNotFoundException("Unable to find schema with 
name '" + schemaName + "'");
    +        }
    +
    +        return schemaText;
         }
     
         @Override
    -    public String retrieveSchemaText(String schemaName) {
    -        if (!this.schemaNameToSchemaMap.containsKey(schemaName)) {
    -            throw new IllegalArgumentException("Failed to find schema; 
Name: '" + schemaName + ".");
    -        } else {
    -            return this.schemaNameToSchemaMap.get(schemaName);
    -        }
    +    public RecordSchema retrieveSchema(final String schemaName) throws 
SchemaNotFoundException {
    +        final String schemaText = retrieveSchemaText(schemaName);
    +        final Schema schema = new Schema.Parser().parse(schemaText);
    +        return createRecordSchema(schema, schemaText, schemaName);
         }
     
         @Override
    -    public String retrieveSchemaText(String schemaName, Map<String, 
String> attributes) {
    -        throw new UnsupportedOperationException("This version of schema 
registry does not "
    -            + "support this operation, since schemas are only identofied 
by name.");
    +    public RecordSchema retrieveSchema(long schemaId, int version) throws 
IOException, SchemaNotFoundException {
    +        throw new SchemaNotFoundException("This Schema Registry does not 
support schema lookup by identifier and version - only by name.");
         }
     
         @Override
    +    public String retrieveSchemaText(long schemaId, int version) throws 
IOException, SchemaNotFoundException {
    +        throw new SchemaNotFoundException("This Schema Registry does not 
support schema lookup by identifier and version - only by name.");
    +    }
    +
         @OnDisabled
         public void close() throws Exception {
    -        this.schemaNameToSchemaMap.clear();
    +        schemaNameToSchemaMap.clear();
         }
     
    +
    +    @OnEnabled
    +    public void enable(final ConfigurationContext configuratiponContext) 
throws InitializationException {
    --- End diff --
    
    spelling mistake on the var name configuratiponContext


> Add "Schema Access Strategy" to Record Readers and Writers
> ----------------------------------------------------------
>
>                 Key: NIFI-3682
>                 URL: https://issues.apache.org/jira/browse/NIFI-3682
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Mark Payne
>            Assignee: Mark Payne
>             Fix For: 1.2.0
>
>
> Currently the record readers are mostly configured with a Schema Registry 
> service and the name of the schema. We should instead allow user to choose 
> one of several strategies for determining the schema: Schema Registry + 
> schema.name attribute, Schema Registry + identifier and version embedded at 
> start of record/stream, avro.schema attribute, embedded schema for cases like 
> Avro where the schema can be embedded in the content itself.
> On the writer side, we should also expose these options in order to convey 
> the schema information to others.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to