Пример #1
0
 @Test
 public void shouldCheckRepoExistenceBeforeTryingPurge()
     throws IOException, IllegalAccessException {
   factory.createSuiteTimeRepo("foo", LATEST_VERSION);
   Cache<EntryRepo> repos = (Cache<EntryRepo>) deref("cache", factory);
   List<String> keys = repos.keys();
   assertThat(keys.size(), is(1));
   String fooKey = keys.get(0);
   repos.clear();
   try {
     factory.purge(fooKey);
   } catch (IOException e) {
     e.printStackTrace();
     fail("Should not fail when trying to purge already purged entry");
   }
 }
Пример #2
0
  /*
   * (non-Javadoc)
   * @see org.mmbase.module.core.MMObjectBuilder#notify(org.mmbase.core.event.NodeEvent)
   */
  @Override
  public void notify(NodeEvent event) {
    if (log.isDebugEnabled()) {
      log.debug(
          "Changed "
              + event.getMachine()
              + " "
              + event.getNodeNumber()
              + " "
              + event.getBuilderName()
              + " "
              + NodeEvent.newTypeToOldType(event.getType()));
    }
    if (tableName.equals(event.getBuilderName())) {
      if (event.getType() == Event.TYPE_NEW) {
        MMObjectNode typeRelNode = getNode(event.getNodeNumber());
        if (typeRelNode != null) {
          Set<MMObjectNode> newTypeRels = addCacheEntry(typeRelNode, true);
          log.service("Added to typerelcache: " + newTypeRels);
        } else {
          log.warn("Could not found typerel node with number " + event.getNodeNumber());
        }

      } else {
        // something else changed in a typerel node? reread the complete typeRelNodes Set
        log.service(
            "Received '" + event + "' which is about typrels. Now re-reading the entire cache");
        readCache();
      }
      // also, clear all query-caches, because result may change by this. See MMB-348
      for (Cache qc : CacheManager.getMap().values()) {
        if (qc instanceof QueryResultCache) {
          qc.clear();
        }
      }
    }
    super.notify(event);
  }