/** * 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 UserRegistryRemote getUserRegistry() throws NotAvailableException, InterruptedException { return CachedUserRegistryRemote.getRegistry(); }
/** * Method shutdown all registry instances. * * Please use method with care! * Make sure no other instances are using the cached remote instances before shutdown. * * Note: This method takes only effect in unit tests, otherwise this call is ignored. During normal operation there is not need for a manual registry shutdown because each registry takes care of its shutdown. */ public static void shutdown() { CachedUnitRegistryRemote.shutdown(); CachedAgentRegistryRemote.shutdown(); CachedAppRegistryRemote.shutdown(); CachedDeviceRegistryRemote.shutdown(); CachedLocationRegistryRemote.shutdown(); CachedSceneRegistryRemote.shutdown(); CachedUserRegistryRemote.shutdown(); CachedUserActivityRegistryRemote.shutdown(); }
/** * Method only returns if all available registries are synchronized. * * @throws CouldNotPerformException * @throws InterruptedException is thrown if thread is externally interrupted. */ public static void waitForData() throws CouldNotPerformException, InterruptedException { CachedUnitRegistryRemote.waitForData(); CachedAgentRegistryRemote.waitForData(); CachedAppRegistryRemote.waitForData(); CachedDeviceRegistryRemote.waitForData(); CachedLocationRegistryRemote.waitForData(); CachedSceneRegistryRemote.waitForData(); CachedUserRegistryRemote.waitForData(); CachedUserActivityRegistryRemote.waitForData(); }
/** * Method forces a resynchronization on all remote registries. * * @throws CouldNotPerformException * @throws InterruptedException */ public static void reinitialize() throws CouldNotPerformException, InterruptedException { CachedUnitRegistryRemote.reinitialize(); CachedAgentRegistryRemote.reinitialize(); CachedAppRegistryRemote.reinitialize(); CachedDeviceRegistryRemote.reinitialize(); CachedLocationRegistryRemote.reinitialize(); CachedSceneRegistryRemote.reinitialize(); CachedUserRegistryRemote.reinitialize(); CachedUserActivityRegistryRemote.reinitialize(); }
/** * Method blocks until all registries are not handling any tasks and are all consistent. * * 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 { CachedUnitRegistryRemote.waitUntilReady(); CachedAgentRegistryRemote.waitUntilReady(); CachedAppRegistryRemote.waitUntilReady(); CachedDeviceRegistryRemote.waitUntilReady(); CachedLocationRegistryRemote.waitUntilReady(); CachedSceneRegistryRemote.waitUntilReady(); CachedUserRegistryRemote.waitUntilReady(); CachedUserActivityRegistryRemote.waitUntilReady(); } }
CachedUserRegistryRemote.shutdown();
/** * 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 UserRegistryRemote getUserRegistry(final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { CachedUserRegistryRemote.getRegistry().waitForData(); } return CachedUserRegistryRemote.getRegistry(); }
/** * Method blocks until the registry is not handling any tasks and is currently consistent. * * 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); }
public static void waitForData() throws InterruptedException, CouldNotPerformException { getRegistry().waitForData(); }
public synchronized static void reinitialize() throws InterruptedException, CouldNotPerformException { try { getRegistry().reinit(REMOTE_LOCK); getRegistry().requestData().get(10, TimeUnit.SECONDS); } catch (ExecutionException | TimeoutException | CouldNotPerformException | CancellationException ex) { throw new CouldNotPerformException("Could not reinitialize " + CachedUserRegistryRemote.class.getSimpleName() + "!", ex); } }
/** * {@inheritDoc } * * @throws InterruptedException {@inheritDoc } * @throws CouldNotPerformException {@inheritDoc } */ @Override public void activate() throws InterruptedException, CouldNotPerformException { if (!CachedUserRegistryRemote.getRegistry().equals(this)) { logger.warn("You are using a " + getClass().getSimpleName() + " which is not maintained by the global registry singelton! This is extremely inefficient! Please use \"Registries.get" + getClass().getSimpleName().replace("Remote", "") + "()\" instead creating your own instances!"); } authorizationFilter.setAuthorizationGroups(unitRegistry.getAuthorizationGroupUnitConfigRemoteRegistry().getEntryMap()); authorizationFilter.setLocations(unitRegistry.getLocationUnitConfigRemoteRegistry().getEntryMap()); super.activate(); }
public static boolean isDataAvailable() { try { return CachedUnitRegistryRemote.getRegistry().isDataAvailable() && CachedAgentRegistryRemote.getRegistry().isDataAvailable() && CachedAppRegistryRemote.getRegistry().isDataAvailable() && CachedDeviceRegistryRemote.getRegistry().isDataAvailable() && CachedLocationRegistryRemote.getRegistry().isDataAvailable() && CachedSceneRegistryRemote.getRegistry().isDataAvailable() && CachedUserRegistryRemote.getRegistry().isDataAvailable() && CachedUserActivityRegistryRemote.getRegistry().isDataAvailable(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } catch (NotAvailableException ex) { // at least one remote is not available. } return false; }