/** * 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(); }
/** * 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; }