public class LocalSchemaRegistryServer extends Object
String configPath = new File("schema-registry.yaml").getAbsolutePath(); LocalSchemaRegistryServer localSchemaRegistryServer = new LocalSchemaRegistryServer(configPath); try { localSchemaRegistryServer.start(); SchemaRegistryClient schemaRegistryClient = createSchemaRegistryClient(localSchemaRegistryServer.getLocalPort()); // registering schema metadata SchemaMetadata schemaMetadata = new SchemaMetadata.Builder("foo").type("avro").build(); boolean success = schemaRegistryClient.registerSchemaMetadata(schemaMetadata); // registering a new schema String schemaName = schemaMetadata.getName(); String schema1 = IOUtils.toString(LocalRegistryServerTest.class.getResourceAsStream("/schema-1.avsc"), "UTF-8"); Integer v1 = schemaRegistryClient.addSchemaVersion(schemaName, new SchemaVersion(schema1, "Initial version of the schema")); } finally { localSchemaRegistryServer.stop(); }
| Constructor and Description |
|---|
LocalSchemaRegistryServer(String configFilePath)
Creates an instance of
LocalSchemaRegistryServer with the given configFilePath |
| Modifier and Type | Method and Description |
|---|---|
int |
getAdminPort() |
int |
getLocalPort() |
String |
getLocalURL() |
boolean |
hasLeadership()
Returns true if this server is the leader in registry cluster.
|
void |
start()
Starts the server if it is not started yet.
|
void |
stop() |
public LocalSchemaRegistryServer(String configFilePath)
LocalSchemaRegistryServer with the given configFilePathconfigFilePath - Path of the config file for this server which contains all the required configuration.public void start()
throws Exception
Exceptionpublic int getLocalPort()
public int getAdminPort()
public String getLocalURL()
public boolean hasLeadership()
Copyright © 2020. All rights reserved.