com.aliyun.datahub.client.impl.schemaregistry.DefaultSchemaRegistryFactory Maven / Gradle / Ivy
The newest version!
package com.aliyun.datahub.client.impl.schemaregistry;
import com.aliyun.datahub.client.DatahubClient;
import java.util.HashMap;
import java.util.Map;
public class DefaultSchemaRegistryFactory extends SchemaRegistryFactory {
private static final Map SCHEMA_REGISTRY_MAP = new HashMap<>();
@Override
public SchemaRegistryClient getSchemaRegistry(String endpoint, String accountKey, long intervalMs, DatahubClient defaultClient) {
String itemKey = endpoint + ":" + accountKey + ":" + intervalMs;
SchemaRegistryClient schemaRegistry = SCHEMA_REGISTRY_MAP.get(itemKey);
if (schemaRegistry == null) {
synchronized (DefaultSchemaRegistryFactory.class) {
schemaRegistry = SCHEMA_REGISTRY_MAP.get(itemKey);
if (schemaRegistry == null) {
schemaRegistry = new SchemaRegistryClientImpl(endpoint, accountKey, intervalMs, defaultClient);
SCHEMA_REGISTRY_MAP.put(itemKey, schemaRegistry);
}
}
}
return schemaRegistry;
}
}