/** * This method registers this registry remote as a registry proxy for the registry controller where the given remote registry is based on. * This object than can be used for registry state checks and synchronization issues. * * @param registry a remote registry which must not be compatible with the Message type {@code M} declared for this registry remote. */ protected void registerRemoteRegistry(final RemoteRegistry<?, ?, ?> registry) { remoteRegistries.add(registry); registry.setRegistryRemote(this); }
/** * {@inheritDoc} */ @Override public void shutdown() { super.shutdown(); remoteRegistries.stream().forEach((remoteRegistry) -> { remoteRegistry.shutdown(); }); }
@Override public void activate() throws InterruptedException, CouldNotPerformException { super.activate(); getRemoteRegistries().forEach((remoteRegistry) -> { remoteRegistry.addObserver(synchronisationObserver); }); // initial check synchronized (virtualRegistrySyncLock) { virtualRegistrySyncLock.notifyAll(); } }
@Override public void deactivate() throws InterruptedException, CouldNotPerformException { getRemoteRegistries().forEach((remoteRegistry) -> { remoteRegistry.removeObserver(synchronisationObserver); }); super.deactivate(); }
@Override public void update(final Observable<M> source, final M data) throws Exception { try { if (data == null) { throw new NotAvailableException("RegistryData"); } final List<M> entryList = new ArrayList<>(); for (final FieldDescriptor fieldDescriptor : fieldDescriptors) { for (int i = 0; i < data.getRepeatedFieldCount(fieldDescriptor); i++) { entryList.add((M) data.getRepeatedField(fieldDescriptor, i)); } } // final int initialSize = entryList.size(); // final int sizeBefore = remoteRegistry.getMessages().size(); final List<M> filteredList = this.filter.filter(entryList); remoteRegistry.notifyRegistryUpdate(filteredList); // LOGGER.info("triggered for: " + remoteRegistry + " from [" + initialSize + ", " + filteredList.size() + " | " + sizeBefore + ", "+remoteRegistry.getMessages().size()+"]"); // remoteRegistry.notifyRegistryUpdate(this.filter.filter(entryList)); } catch (CouldNotPerformException | IndexOutOfBoundsException | ClassCastException | NullPointerException ex) { ExceptionPrinter.printHistory("Registry synchronization failed!", ex, LOGGER); } } }
@Override public void shutdown() { super.shutdown(); remoteRegistryList.stream().forEach((remoteRegistry) -> { remoteRegistry.shutdown(); }); registryList.stream().forEach((registry) -> { registry.shutdown(); }); }