/** * 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 LocationRegistryRemote getLocationRegistry() throws NotAvailableException, InterruptedException { return CachedLocationRegistryRemote.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 LocationRegistryRemote getLocationRegistry(final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { CachedLocationRegistryRemote.getRegistry().waitForData(); } return CachedLocationRegistryRemote.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 " + CachedLocationRegistryRemote.class.getSimpleName() + "!", ex); } }
/** * Do not use this method! Use Registries.getLocationRegistry() instead! * * @return * * @throws org.openbase.jul.exception.NotAvailableException * @deprecated Do not use this method! Use Registries.getLocationRegistry() instead! */ @Deprecated default LocationRegistry getLocationRegistry() throws NotAvailableException { // method is only needed because the registry is still throwing a InterruptedException which will removed in a future release. // todo release: can be removed later on try { try { return CachedLocationRegistryRemote.getRegistry(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new FatalImplementationErrorException("", this, ex); } } catch (CouldNotPerformException ex) { throw new NotAvailableException(LocationRegistry.class); } }
/** * {@inheritDoc } * * @throws InterruptedException {@inheritDoc } * @throws CouldNotPerformException {@inheritDoc } */ @Override public void activate() throws InterruptedException, CouldNotPerformException { if (!CachedLocationRegistryRemote.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(locationUnitConfigRemoteRegistry.getEntryMap()); super.activate(); }
public List<LocationRemote> getNeighborLocationList(final boolean waitForData) throws CouldNotPerformException { final List<LocationRemote> neighborList = new ArrayList<>(); try { for (UnitConfig locationUnitConfig : CachedLocationRegistryRemote.getRegistry().getNeighborLocations(getId())) { neighborList.add(Units.getUnit(locationUnitConfig, waitForData, LOCATION)); } } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all neighbors!", ex); } return neighborList; }
/** * * @return * @throws CouldNotPerformException * @deprecated please use Registries.getLocationRegistry().getNeighborLocations(String locationId) instead. */ @Override @Deprecated public List<String> getNeighborLocationIds() throws CouldNotPerformException { final List<String> neighborIdList = new ArrayList<>(); try { for (UnitConfig locationConfig : CachedLocationRegistryRemote.getRegistry().getNeighborLocations(getId())) { neighborIdList.add(locationConfig.getId()); } } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get CachedLocationRegistryRemote!", ex); } return neighborIdList; }
public List<LocationRemote> getChildLocationList(final boolean waitForData) throws CouldNotPerformException { final List<LocationRemote> childList = new ArrayList<>(); for (String childId : getConfig().getLocationConfig().getChildIdList()) { try { childList.add(Units.getUnit(CachedLocationRegistryRemote.getRegistry().getLocationConfigById(childId), waitForData, LOCATION)); } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all child locations!", ex); } } return childList; }
public List<LocationRemote> getChildLocationList(final boolean waitForData) throws CouldNotPerformException { final List<LocationRemote> childList = new ArrayList<>(); for (String childId : getConfig().getLocationConfig().getChildIdList()) { try { childList.add(Units.getUnit(CachedLocationRegistryRemote.getRegistry().getLocationConfigById(childId), waitForData, LOCATION)); } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all child locations!", ex); } } return childList; } }
public List<ConnectionRemote> getConnectionList(final boolean waitForData) throws CouldNotPerformException { if (!getConfig().getLocationConfig().getType().equals(LocationType.TILE)) { throw new CouldNotPerformException("Location is not a Tile!"); } List<ConnectionRemote> connectionList = new ArrayList<>(); try { for (UnitConfig connectionUnitConfig : CachedLocationRegistryRemote.getRegistry().getConnectionConfigs()) { ConnectionRemote connection = Units.getUnit(connectionUnitConfig, waitForData, CONNECTION); if (connection.getConfig().getConnectionConfig().getTileIdList().contains(getId())) { connectionList.add(connection); } } } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all connections!", ex); } return connectionList; }
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; }