@Override public Schema getLatestSchemaByTopic(String topic) throws SchemaRegistryException { String schemaName = topic + this.schemaNameSuffix; try { return new Schema.Parser().parse(this.schemaRegistryClient.getLatestSchemaMetadata(schemaName).getSchema()); } catch (IOException | RestClientException e) { log.error("Failed to get schema for topic " + topic + "; subject " + schemaName); throw new SchemaRegistryException(e); } }
@Override public Schema getLatestSchemaByTopic(String topic) throws SchemaRegistryException { String schemaName = topic + this.schemaNameSuffix; try { return new Schema.Parser().parse(this.schemaRegistryClient.getLatestSchemaMetadata(schemaName).getSchema()); } catch (IOException | RestClientException e) { log.error("Failed to get schema for topic " + topic + "; subject " + schemaName); throw new SchemaRegistryException(e); } }
@Override public Schema retrieveSchema(TableId table, String topic) { String subject = getSubject(topic); try { logger.debug("Retrieving schema information for topic {} with subject {}", topic, subject); SchemaMetadata latestSchemaMetadata = schemaRegistryClient.getLatestSchemaMetadata(subject); org.apache.avro.Schema avroSchema = new Parser().parse(latestSchemaMetadata.getSchema()); return avroData.toConnectSchema(avroSchema); } catch (IOException | RestClientException exception) { throw new ConnectException(String.format( "Exception while fetching latest schema metadata for topic=%s, subject=%s", topic, subject), exception ); } }
private void downloadSchema(final String url, final String subject) { try { final SchemaMetadata metadata = RegistryClientSingleton .getInstance().client(url).getLatestSchemaMetadata(subject); writeSchemas(subject, metadata.getSchema()); } catch (IOException | RestClientException e) { e.printStackTrace(); } }
latestSchema = new Schema.Parser().parse(metadata.getSchema()); latestVersion = metadata.getVersion();