/** * Removes an element from a ListSet and updates the configuration file accordingly. If the * element doesn't exist, then nothing will be changed. * * @param setName name of the ListSet. * @param listName name of the element to remove from the ListSet. */ public static void removeFromListSet(final String setName, final String listName) { final Set<String> listSet = getListSet(setName); if (!listSet.isEmpty()) { listSet.remove(listName); switchboard.setConfig(setName, collection2string(listSet)); } }
/** checks the resources and pauses crawls if necessary */ public void resourceObserverJob() { MemoryControl.setDHTMbyte(getMinFreeMemory()); normalizedDiskFree = getNormalizedDiskFree(); normalizedMemoryFree = getNormalizedMemoryFree(); if (normalizedDiskFree.compareTo(Space.HIGH) < 0 || normalizedMemoryFree.compareTo(Space.HIGH) < 0) { if (normalizedDiskFree.compareTo(Space.HIGH) < 0) { // pause crawls if (!sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) { log.logInfo("pausing local crawls"); sb.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL); } if (!sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL)) { log.logInfo("pausing remote triggered crawls"); sb.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL); } } if ((normalizedDiskFree == Space.LOW || normalizedMemoryFree.compareTo(Space.HIGH) < 0) && sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false)) { log.logInfo("disabling index receive"); sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false); sb.peers.mySeed().setFlagAcceptRemoteIndex(false); sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true); } } else { if (sb.getConfigBool( SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false)) { // we were wrong! log.logInfo("enabling index receive"); sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true); sb.peers.mySeed().setFlagAcceptRemoteIndex(true); sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false); } log.logInfo("resources ok"); } }
/** * Adds an element to an existing ListSet. If the ListSet doesn't exist yet, a new one will be * added. If the ListSet already contains an identical element, then nothing happens. * * <p>The new list will be written to the configuartion file. * * @param setName * @param newListName */ public static void updateListSet(final String setName, final String newListName) { final Set<String> listSet = getListSet(setName); listSet.add(newListName); switchboard.setConfig(setName, collection2string(listSet)); }