예제 #1
0
 /**
  * Return {@code true} if the specified dn is contained in the parent set, or in the specified DN
  * cache. This would indicate that the parent has already been processed. It returns {@code false}
  * otherwise.
  *
  * <p>It will optionally check the dn2id database for the dn if the specified cleared backend
  * boolean is {@code true}.
  *
  * @param dn The DN to check for.
  * @param dnCache The importer DN cache.
  * @param clearedBackend Set to {@code true} if the import process cleared the backend before
  *     processing.
  * @return {@code true} if the dn is contained in the parent ID, or {@code false} otherwise.
  * @throws DatabaseException If an error occurred searching the DN cache, or dn2id database.
  * @throws InterruptedException If an error occurred processing the pending map.
  */
 public boolean isParentProcessed(DN dn, DNCache dnCache, boolean clearedBackend)
     throws DatabaseException, InterruptedException {
   synchronized (synchObject) {
     if (parentSet.contains(dn)) {
       return true;
     }
   }
   // The DN was not in the parent set. Make sure it isn't pending.
   try {
     assureNotPending(dn);
   } catch (InterruptedException e) {
     logger.error(ERR_IMPORT_LDIF_PENDING_ERR, e.getMessage());
     throw e;
   }
   // Either parent is in the DN cache,
   // or else check the dn2id database for the DN (only if backend wasn't cleared)
   final boolean parentThere =
       dnCache.contains(dn)
           || (!clearedBackend && getDN2ID().get(null, dn, LockMode.DEFAULT) != null);
   // Add the DN to the parent set if needed.
   if (parentThere) {
     synchronized (synchObject) {
       if (parentSet.size() >= PARENT_ID_SET_SIZE) {
         Iterator<DN> iterator = parentSet.iterator();
         iterator.next();
         iterator.remove();
       }
       parentSet.add(dn);
     }
   }
   return parentThere;
 }
예제 #2
0
  /** {@inheritDoc} */
  @Override()
  public boolean isIndexed(AttributeType attributeType, IndexType indexType) {
    try {
      EntryContainer ec = rootContainer.getEntryContainer(baseDNs[0]);
      AttributeIndex ai = ec.getAttributeIndex(attributeType);
      if (ai == null) {
        return false;
      }

      Set<LocalDBIndexCfgDefn.IndexType> indexTypes = ai.getConfiguration().getIndexType();
      switch (indexType) {
        case PRESENCE:
          return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.PRESENCE);

        case EQUALITY:
          return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.EQUALITY);

        case SUBSTRING:
        case SUBINITIAL:
        case SUBANY:
        case SUBFINAL:
          return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.SUBSTRING);

        case GREATER_OR_EQUAL:
        case LESS_OR_EQUAL:
          return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.ORDERING);

        case APPROXIMATE:
          return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.APPROXIMATE);

        default:
          return false;
      }
    } catch (Exception e) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      return false;
    }
  }