/** * Update callback, this is called whenever a path is updated in zookeeper which we are monitoring. * * @param client The CuratorFramework * @param path The zookeeper path * @param data The change. * @throws IOException When update is impossible. */ public void update(CuratorFramework client, String path, byte[] data) throws IOException { if (data.length != 0) { String name = path.substring(path.lastIndexOf("/") + 1); if (path.startsWith(getType().getZookeeperRoot())) { LOG.debug("Updating the {} config: {} -> {}", getType().name(), name, new String(data == null?"".getBytes():data)); update(name, data); reloadCallback(name, getType()); } else if (ConfigurationType.GLOBAL.getZookeeperRoot().equals(path)) { LOG.debug("Updating the global config: {}", new String(data == null?"".getBytes():data)); getConfigurations().updateGlobalConfig(data); reloadCallback(name, ConfigurationType.GLOBAL); } } }
/** * Delete callback, this is called whenever a path is deleted in zookeeper which we are monitoring. * * @param client The CuratorFramework * @param path The zookeeper path * @param data The change. * @throws IOException When update is impossible. */ public void delete(CuratorFramework client, String path, byte[] data) throws IOException { String name = path.substring(path.lastIndexOf("/") + 1); if (path.startsWith(getType().getZookeeperRoot())) { LOG.debug("Deleting {} {} config from internal cache", getType().name(), name); delete(name); reloadCallback(name, getType()); } else if (ConfigurationType.GLOBAL.getZookeeperRoot().equals(path)) { LOG.debug("Deleting global config from internal cache"); getConfigurations().deleteGlobalConfig(); reloadCallback(name, ConfigurationType.GLOBAL); } }