public void performBookKeeping(Map<String,StorageSystemViewObject> scannedSystemsNativeGuidsMap,List<URI> providerList){
  StorageSystem storageSystem=null;
  List<StorageSystem> systemsToPersist=new ArrayList<StorageSystem>();
  List<StorageSystem> systemsToCreate=new ArrayList<StorageSystem>();
  Set<String> scannedSystemNativeGuidKeySet;
synchronized (scannedSystemsNativeGuidsMap) {
    scannedSystemNativeGuidKeySet=new HashSet(scannedSystemsNativeGuidsMap.keySet());
  }
  Set<URI> scannedProviderList=new HashSet<URI>(providerList);
  Map<URI,List<String>> providersToUpdate=new HashMap<URI,List<String>>();
  for (  String scannedSystemNativeGuid : scannedSystemNativeGuidKeySet) {
    try {
      _logger.info("Found during scan : scannedSystemNativeGuid {}",scannedSystemNativeGuid);
      List<StorageSystem> systems=CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient,scannedSystemNativeGuid);
      if (DecommissionedResource.checkDecommissioned(_dbClient,scannedSystemNativeGuid,StorageSystem.class)) {
        scannedSystemsNativeGuidsMap.remove(scannedSystemNativeGuid);
        _logger.info("Storage system {} was decommissioned and cannot be added to Vipr",scannedSystemNativeGuid);
        continue;
      }
      if (null == systems || systems.isEmpty()) {
        storageSystem=createStorageSystem(scannedSystemsNativeGuidsMap.get(scannedSystemNativeGuid),scannedSystemNativeGuid,providersToUpdate);
        if (storageSystem != null) {
          systemsToCreate.add(storageSystem);
          _logger.info("Added new storage system to be created to the create list with Native Guid: {}",storageSystem.getNativeGuid());
        }
      }
    }
 catch (    Exception e) {
      _logger.error(e.getMessage(),e);
      _logger.error("Exception while creating new system: {} due to {}",storageSystem != null ? storageSystem.getId() : "N/A",e.getCause());
    }
  }
  try {
    _dbClient.createObject(systemsToCreate);
  }
 catch (  DatabaseException ex) {
    _logger.error("Exception occurred while persisting new StorageSystems due to ",ex);
  }
  updateActiveProviderDetailsInDbSystem(scannedSystemsNativeGuidsMap,systemsToPersist,scannedProviderList,providersToUpdate);
  persistAllSystemsAndProviders(systemsToPersist,getSMISProvidersWithUpdatedSystems(providersToUpdate));
}

public void performBookKeeping ( Map < String , StorageSystemViewObject > scannedSystemsNativeGuidsMap , List < URI > providerList ) { StorageSystem storageSystem = null ; List < StorageSystem > systemsToPersist = new ArrayList < StorageSystem > ( ) ; List < StorageSystem > systemsToCreate = new ArrayList < StorageSystem > ( ) ; Set < String > scannedSystemNativeGuidKeySet ; synchronized ( scannedSystemsNativeGuidsMap ) { scannedSystemNativeGuidKeySet = new HashSet ( scannedSystemsNativeGuidsMap . keySet ( ) ) ; } Set < URI > scannedProviderList = new HashSet < URI > ( providerList ) ; Map < URI , List < String > > providersToUpdate = new HashMap < URI , List < String > > ( ) ; for ( String scannedSystemNativeGuid : scannedSystemNativeGuidKeySet ) { try { _logger . info ( "Found during scan : scannedSystemNativeGuid {}" , scannedSystemNativeGuid ) ; List < StorageSystem > systems = CustomQueryUtility . getActiveStorageSystemByNativeGuid ( _dbClient , scannedSystemNativeGuid ) ; if ( DecommissionedResource . checkDecommissioned ( _dbClient , scannedSystemNativeGuid , StorageSystem . class ) ) { scannedSystemsNativeGuidsMap . remove ( scannedSystemNativeGuid ) ; _logger . info ( "Storage system {} was decommissioned and cannot be added to Vipr" , scannedSystemNativeGuid ) ; continue ; } if ( null == systems || systems . isEmpty ( ) ) { storageSystem = createStorageSystem ( scannedSystemsNativeGuidsMap . get ( scannedSystemNativeGuid ) , scannedSystemNativeGuid , providersToUpdate ) ; if ( storageSystem != null ) { systemsToCreate . add ( storageSystem ) ; _logger . info ( "Added new storage system to be created to the create list with Native Guid: {}" , storageSystem . getNativeGuid ( ) ) ; } } } catch ( Exception e ) { _logger . error ( e . getMessage ( ) , e ) ; _logger . error ( "Exception while creating new system: {} due to {}" , storageSystem != null ? storageSystem . getId ( ) : "N/A" , e . getCause ( ) ) ; } } try { _dbClient . createObject ( systemsToCreate ) ; } catch ( DatabaseException ex ) { _logger . error ( "Exception occurred while persisting new StorageSystems due to " , ex ) ; } updateActiveProviderDetailsInDbSystem ( scannedSystemsNativeGuidsMap , systemsToPersist , scannedProviderList , providersToUpdate ) ; persistAllSystemsAndProviders ( systemsToPersist , getSMISProvidersWithUpdatedSystems ( providersToUpdate ) ) ; }
1 . iterate through the scanner result cache . 2 . for each serialid , find a storagesystem . 3 . if it is null , then create a new storagesystem and update the details . 4 . if it is not null , then update active providers & registered status .
