public final class SchemaRegistryClient extends Object
SchemaRegistryClient is a client API for the SchemaRegistry service.
Client allows only read-only access to service. It doesn't support the ability to mutate
the service.
Example usage of the client.
...
SchemaRegistryClient client = new SchemaRegistryClient();
...
client.setAcceptEncoding("application/json");
client.setConnectionTimeout(2000); // 2 seconds of connect timeout.
client.setReadTimeout(1000); // 1 second of read timeout.
try {
Response info = client.getSchema("test", 2);
} catch (IOException e) {
...
} catch (URIException e) {
...
} catch (RestClientException e) {
...
}
...
| Constructor and Description |
|---|
SchemaRegistryClient(String baseUrl) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAcceptEncoding() |
String |
getBaseUrl() |
int |
getConnectionTimeout() |
static SchemaRegistryClient |
getInstance(ExecutorContext context)
Returns a instance of
SchemaRegistryClient initialized with service url. |
int |
getReadTimeout() |
byte[] |
getSchema(String namespace,
String id)
Retrieves schema provided a schema id.
|
byte[] |
getSchema(String namespace,
String id,
long version)
Retrieves schema provided a schema id and version of the schema.
|
List<Long> |
getVersions(String namespace,
String id)
Gets all the versions of schemas given a schema id.
|
void |
setAcceptEncoding(String acceptEncoding) |
void |
setConnectionTimeout(int connectionTimeout)
Sets the connection timeout in milliseconds.
|
void |
setReadTimeout(int readTimeout)
Sets the read timeout in milliseconds.
|
public SchemaRegistryClient(String baseUrl)
public static SchemaRegistryClient getInstance(ExecutorContext context)
SchemaRegistryClient initialized with service url.context - of the pipeline in which this client is invoked.public byte[] getSchema(String namespace, String id, long version) throws URISyntaxException, IOException, RestClientException
namespace - the schema namespaceid - the schema idversion - the schema versionResponse of the schema.URISyntaxException - thrown if there are issue with construction of url.IOException - throw when there are issues connecting to the service.RestClientException - thrown when there are issues with request or response returned.public byte[] getSchema(String namespace, String id) throws URISyntaxException, IOException, RestClientException
namespace - the schema namespaceid - the schema idSchemaInfo of the schema if ok, else null.URISyntaxException - thrown if there are issue with construction of url.IOException - throw when there are issues connecting to the service.RestClientException - thrown when there are issues with request or response returned.public List<Long> getVersions(String namespace, String id) throws URISyntaxException, IOException, RestClientException
namespace - the schema namespaceid - the schema idURISyntaxException - thrown if there are issue with construction of url.IOException - throw when there are issues connecting to the service.RestClientException - thrown when there are issues with request or response returned.public String getBaseUrl()
public String getAcceptEncoding()
public void setAcceptEncoding(String acceptEncoding)
acceptEncoding - sets the accept encoding for the client.public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
connectionTimeout - specified in milliseconds.public int getReadTimeout()
public void setReadTimeout(int readTimeout)
readTimeout - Copyright © 2020 CDAP Licensed under the Apache License, Version 2.0.