private bool IntegrateIntoLiveDatabase(IServerLeafSubGrid sourceSubGrid, IServerLeafSubGrid targetSubGrid, ISubGridSegmentIterator segmentIterator, Action <int, int> subGridChangeNotifier) { // Note the fact that this sub grid will be changed and become dirty as a result // of the cell pass integration targetSubGrid.SetDirty(); targetSubGrid.Integrate(sourceSubGrid, segmentIterator, false); subGridChangeNotifier?.Invoke(targetSubGrid.OriginX, targetSubGrid.OriginY); // Save the integrated state of the sub grid segments to allow Ignite to store & socialize the update // within the cluster. // Failure to save a piece of data aborts the entire integration var result = false; if (_target.SaveLeafSubGrid(targetSubGrid, _storageProxySubGrids, _storageProxySubGridSegments, InvalidatedSpatialStreams)) { // Successfully saving the sub grid directory information is the point at which this sub grid may be recognized to exist // in the site model. Note this by including it within the SiteModel existence map _siteModel.ExistenceMap.SetCell(targetSubGrid.OriginX >> SubGridTreeConsts.SubGridIndexBitsPerLevel, targetSubGrid.OriginY >> SubGridTreeConsts.SubGridIndexBitsPerLevel, true); result = true; } else { _log.LogError($"Sub grid leaf save failed for {targetSubGrid}, existence map not modified."); } // Finally, mark the source sub grid as not being dirty. We need to do this to allow // the sub grid to permit its destruction as all changes have been merged into the target. if (result) { sourceSubGrid.AllChangesMigrated(); } return(result); }