/** * 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(); }
@Override public void activate() throws InterruptedException, CouldNotPerformException { // TODO is this wait for data realy needed? blocking activation method is some kind of bad behaviour. CachedLocationRegistryRemote.waitForData(); serviceRemoteManager.activate(); super.activate(); }
/** * 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 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(); } }
AuthenticatedServerManager.shutdown(); CachedLocationRegistryRemote.shutdown(); CachedSceneRegistryRemote.shutdown(); 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 LocationRegistryRemote getLocationRegistry(final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { CachedLocationRegistryRemote.getRegistry().waitForData(); } return CachedLocationRegistryRemote.getRegistry(); }
/** * 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 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 void updateUnitConfig(UnitConfig unitConfig, ServiceType serviceType) throws CouldNotPerformException, InterruptedException { try { CachedLocationRegistryRemote.waitForData(); try { getRemoteService().removeConnectionStateObserver(connectionStateObserver);
public static void waitForData() throws InterruptedException, CouldNotPerformException { getRegistry().waitForData(); }
public static void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException { getRegistry().waitForData(timeout, timeUnit); }
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); } }
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; }
/** * {@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(); }
/** * * @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; }