@Override public void registerNodeDebut(String nodeUrl) { haServerNotificationManager.addNodeUrl(nodeUrl); }
public void notifyDebut() { notify("api/v1/schemaregistry/notifications/node/debut", serverUrl); }
@Override public void serverStarted(Server server) { String serverURL = server.getURI().toString(); haServerNotificationManager.setHomeNodeURL(serverURL); try { transactionManager.beginTransaction(TransactionIsolation.SERIALIZABLE); HostConfigStorable hostConfigStorable = storageManager.get(new HostConfigStorable(serverURL).getStorableKey()); if (hostConfigStorable == null) { storageManager.add(new HostConfigStorable(storageManager.nextId(HostConfigStorable.NAME_SPACE), serverURL, System.currentTimeMillis())); } haServerNotificationManager.refreshServerInfo(storageManager.<HostConfigStorable>list(HostConfigStorable.NAME_SPACE)); transactionManager.commitTransaction(); } catch (Exception e) { transactionManager.rollbackTransaction(); throw e; } haServerNotificationManager.notifyDebut(); refreshHAServerManagedTask = new RefreshHAServerManagedTask(storageManager,transactionManager, haServerNotificationManager); environment.lifecycle().manage(refreshHAServerManagedTask); refreshHAServerManagedTask.start(); } });
haServerNotificationManager.refreshServerInfo(hostConfigWithoutStaleEntries); HostConfigStorable hostConfWithUpdatedTimeStamp = storageManager.get(new HostConfigStorable(haServerNotificationManager.getHomeNodeURL()).getStorableKey()); if (hostConfWithUpdatedTimeStamp == null) { hostConfWithUpdatedTimeStamp = new HostConfigStorable(storageManager.nextId(HostConfigStorable.NAME_SPACE), haServerNotificationManager.getHomeNodeURL(), System.currentTimeMillis()); } else {
public MockSchemaRegistryClient() { StorageManager storageManager = new InMemoryStorageManager(); Collection<Map<String, Object>> schemaProvidersConfig = Collections.singleton(Collections.singletonMap("providerClass", AvroSchemaProvider.class.getName())); this.schemaRegistry = new DefaultSchemaRegistry(storageManager, null, schemaProvidersConfig, new HAServerNotificationManager(), new SchemaLockManager(new NOOPTransactionManager())); this.schemaRegistry.init(Collections.<String, Object>emptyMap()); }
private void invalidateSchemaBranchInAllHAServers(SchemaBranchCache.Key key) { schemaBranchCache.invalidateSchemaBranch(key); String keyAsString; try { keyAsString = ObjectMapperUtils.serializeToString(key); } catch (Exception e) { throw new RuntimeException(String.format("Failed to serialized key : %s", key),e); } haServerNotificationManager.notifyCacheInvalidation(schemaBranchCache.getCacheType(),keyAsString); } }
@Override public void serverStarted(Server server) { String serverURL = server.getURI().toString(); haServerNotificationManager.setHomeNodeURL(serverURL); try { transactionManager.beginTransaction(TransactionIsolation.SERIALIZABLE); HostConfigStorable hostConfigStorable = storageManager.get(new HostConfigStorable(serverURL).getStorableKey()); if (hostConfigStorable == null) { storageManager.add(new HostConfigStorable(storageManager.nextId(HostConfigStorable.NAME_SPACE), serverURL, System.currentTimeMillis())); } haServerNotificationManager.refreshServerInfo(storageManager.<HostConfigStorable>list(HostConfigStorable.NAME_SPACE)); transactionManager.commitTransaction(); } catch (Exception e) { transactionManager.rollbackTransaction(); throw e; } haServerNotificationManager.notifyDebut(); refreshHAServerManagedTask = new RefreshHAServerManagedTask(storageManager,transactionManager, haServerNotificationManager); environment.lifecycle().manage(refreshHAServerManagedTask); refreshHAServerManagedTask.start(); } });
haServerNotificationManager.refreshServerInfo(hostConfigWithoutStaleEntries); HostConfigStorable hostConfWithUpdatedTimeStamp = storageManager.get(new HostConfigStorable(haServerNotificationManager.getHomeNodeURL()).getStorableKey()); if (hostConfWithUpdatedTimeStamp == null) { hostConfWithUpdatedTimeStamp = new HostConfigStorable(storageManager.nextId(HostConfigStorable.NAME_SPACE), haServerNotificationManager.getHomeNodeURL(), System.currentTimeMillis()); } else {
@Before public void setup() throws IOException { schema1 = getSchema("/device.avsc"); schema2 = getSchema("/device-compat.avsc"); schemaName = "org.hwx.schemas.test-schema." + UUID.randomUUID(); StorageManager storageManager = new InMemoryStorageManager(); Collection<Map<String, Object>> schemaProvidersConfig = Collections.singleton(Collections.singletonMap("providerClass", AvroSchemaProvider.class.getName())); schemaRegistry = new DefaultSchemaRegistry(storageManager, null, schemaProvidersConfig, new HAServerNotificationManager(), new SchemaLockManager(new NOOPTransactionManager())); schemaRegistry.init(Collections.<String, Object>emptyMap()); }
private void invalidateSchemaInAllHAServer(SchemaVersionInfoCache.Key key) { schemaVersionInfoCache.invalidateSchema(key); String keyAsString; try { keyAsString = ObjectMapperUtils.serializeToString(key); } catch (Exception e) { throw new RuntimeException(String.format("Failed to serialized key : %s", key),e); } haServerNotificationManager.notifyCacheInvalidation(schemaVersionInfoCache.getCacheType(),keyAsString); }
public void notifyCacheInvalidation(SchemaRegistryCacheType schemaRegistryCacheType, String keyAsString) { notify(String.format("api/v1/schemaregistry/cache/%s/invalidate",schemaRegistryCacheType.name()), keyAsString); }