/** * Method blocks until the registry is not handling any tasks and is currently consistent. * <p> * Note: If you have just modified the registry this method can maybe return immediately if the task is not yet received by the registry controller. So you should prefer the futures of the modification methods for synchronization tasks. * * @throws InterruptedException is thrown in case the thread was externally interrupted. * @throws org.openbase.jul.exception.CouldNotPerformException is thrown if the wait could not be performed. */ public static void waitUntilReady() throws InterruptedException, CouldNotPerformException { getRegistry().waitUntilReady(); }
public static void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException { getRegistry().waitForData(timeout, timeUnit); }
/** * Returns an initialized and activated remote registry. * * @return the remote registry instance. * @throws NotAvailableException * @throws InterruptedException is thrown if thread is externally interrupted. */ public static UserActivityRegistryRemote getUserActivityRegistry() throws NotAvailableException, InterruptedException { return CachedUserActivityRegistryRemote.getRegistry(); }
public synchronized static void reinitialize() throws InterruptedException, CouldNotPerformException { try { if (shutdown) { throw new InvalidStateException("Remote service is shutting down!"); } getRegistry().reinit(REMOTE_LOCK); getRegistry().requestData().get(10, TimeUnit.SECONDS); } catch (ExecutionException | TimeoutException | CouldNotPerformException | CancellationException ex) { throw new CouldNotPerformException("Could not reinitialize " + CachedUserActivityRegistryRemote.class.getSimpleName() + "!", ex); } }
@Override public Boolean containsUserActivityClassById(String userActivityClassId) throws CouldNotPerformException { validateData(); return userActivityClassRemoteRegistry.contains(userActivityClassId); }
@Override public Boolean isUserActivityClassRegistryConsistent() throws CouldNotPerformException { try { validateData(); return getData().getUserActivityClassRegistryConsistent(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not check consistency!", ex); } }
@Override public Boolean isConsistent() throws CouldNotPerformException { return isUserActivityClassRegistryConsistent() && isUserActivityConfigRegistryConsistent(); } }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.InitializationException {@inheritDoc} */ @Override protected void registerRemoteRegistries() throws CouldNotPerformException { /* ATTENTION: the order here is important, if somebody registers an observer * on one of these remote registries and tries to get values from other remote registries * which are registered later than these are not synced yet */ registerRemoteRegistry(userActivityClassRemoteRegistry); registerRemoteRegistry(userActivityConfigRemoteRegistry); }
public UserActivityRegistryRemote() throws InstantiationException, InterruptedException { super(JPUserActivityRegistryScope.class, UserActivityRegistryData.class); try { this.userActivityClassRemoteRegistry = new SynchronizedRemoteRegistry<>(this.getIntenalPriorizedDataObservable(), this, UserActivityRegistryData.USER_ACTIVITY_CLASS_FIELD_NUMBER); this.userActivityConfigRemoteRegistry = new SynchronizedRemoteRegistry<>(this.getIntenalPriorizedDataObservable(), this, UserActivityRegistryData.USER_ACTIVITY_CONFIG_FIELD_NUMBER); } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
/** * Returns an initialized and activated remote registry. * * @param waitForData defines if this call should block until the registry data is available. * @return the remote registry instance. * @throws NotAvailableException * @throws InterruptedException is thrown if thread is externally interrupted. */ public static UserActivityRegistryRemote getUserActivityRegistry(final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { CachedUserActivityRegistryRemote.getRegistry().waitForData(); } return CachedUserActivityRegistryRemote.getRegistry(); }
@Override public List<UserActivityClass> getUserActivityClasses() throws CouldNotPerformException { validateData(); return userActivityClassRemoteRegistry.getMessages(); }
@Override public Boolean isUserActivityConfigRegistryConsistent() throws CouldNotPerformException { try { validateData(); return getData().getUserActivityConfigRegistryConsistent(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not check consistency!", ex); } }
public static void waitForData() throws InterruptedException, CouldNotPerformException { getRegistry().waitForData(); }
@Override public UserActivityConfig getUserActivityConfigById(String userActivityConfigId) throws CouldNotPerformException { validateData(); return userActivityConfigRemoteRegistry.getMessage(userActivityConfigId); }
@Override public Boolean containsUserActivityConfig(UserActivityConfig userActivityConfig) throws CouldNotPerformException { validateData(); return userActivityConfigRemoteRegistry.contains(userActivityConfig); }
@Override public Boolean containsUserActivityConfigById(String userActivityConfigId) throws CouldNotPerformException { validateData(); return userActivityConfigRemoteRegistry.contains(userActivityConfigId); }
@Override public Boolean containsUserActivityClass(UserActivityClass userActivityClass) throws CouldNotPerformException { validateData(); return userActivityClassRemoteRegistry.contains(userActivityClass); }
@Override public UserActivityClass getUserActivityClassById(String userActivityClassId) throws CouldNotPerformException { validateData(); return userActivityClassRemoteRegistry.getMessage(userActivityClassId); }
@Override public List<UserActivityConfig> getUserActivityConfigs() throws CouldNotPerformException { validateData(); return userActivityConfigRemoteRegistry.getMessages(); }
@Override public UserActivityClass getUserActivityClassByType(UserActivityType userActivityType) throws CouldNotPerformException { validateData(); for (UserActivityClass userActivityClass : userActivityClassRemoteRegistry.getMessages()) { if (userActivityClass.getType() == userActivityType) { return userActivityClass; } } throw new NotAvailableException("user activty class " + userActivityType.name()); }