コード例 #1
0
  public static void markInActiveUnManagedExportMask(
      URI storageSystemUri,
      Set<URI> discoveredUnManagedExportMasks,
      DbClient dbClient,
      PartitionManager partitionManager) {

    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(
        ContainmentConstraint.Factory.getStorageSystemUnManagedExportMaskConstraint(
            storageSystemUri),
        result);
    Set<URI> allMasksInDatabase = new HashSet<URI>();
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
      allMasksInDatabase.add(it.next());
    }

    SetView<URI> onlyAvailableinDB =
        Sets.difference(allMasksInDatabase, discoveredUnManagedExportMasks);

    if (!onlyAvailableinDB.isEmpty()) {
      _log.info(
          "these UnManagedExportMasks are orphaned and will be cleaned up:"
              + Joiner.on("\t").join(onlyAvailableinDB));

      List<UnManagedExportMask> unManagedExportMasksToBeDeleted =
          new ArrayList<UnManagedExportMask>();
      Iterator<UnManagedExportMask> unManagedExportMasks =
          dbClient.queryIterativeObjects(
              UnManagedExportMask.class, new ArrayList<URI>(onlyAvailableinDB));

      while (unManagedExportMasks.hasNext()) {

        UnManagedExportMask uem = unManagedExportMasks.next();
        if (null == uem || uem.getInactive()) {
          continue;
        }

        _log.info("Setting UnManagedExportMask {} inactive", uem.getMaskingViewPath());
        uem.setStorageSystemUri(NullColumnValueGetter.getNullURI());
        uem.setInactive(true);
        unManagedExportMasksToBeDeleted.add(uem);
      }
      if (!unManagedExportMasksToBeDeleted.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(
            unManagedExportMasksToBeDeleted,
            Constants.DEFAULT_PARTITION_SIZE,
            dbClient,
            UNMANAGED_EXPORT_MASK);
      }
    }
  }