diff --git a/imixs-archive-service/src/main/java/org/imixs/archive/service/cassandra/DataService.java b/imixs-archive-service/src/main/java/org/imixs/archive/service/cassandra/DataService.java index e1daf02..88eae91 100644 --- a/imixs-archive-service/src/main/java/org/imixs/archive/service/cassandra/DataService.java +++ b/imixs-archive-service/src/main/java/org/imixs/archive/service/cassandra/DataService.java @@ -14,14 +14,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import jakarta.ejb.Stateless; -import jakarta.enterprise.event.Event; -import jakarta.inject.Inject; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.Marshaller; -import jakarta.xml.bind.Unmarshaller; - import org.imixs.archive.service.ArchiveException; import org.imixs.archive.service.resync.ResyncService; import org.imixs.workflow.FileData; @@ -37,6 +29,14 @@ import com.datastax.driver.core.Row; import com.datastax.driver.core.SimpleStatement; +import jakarta.ejb.Stateless; +import jakarta.enterprise.event.Event; +import jakarta.inject.Inject; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; + /** * The SnapshotService is used to store a imixs snapshot into the cluster * keyspace. @@ -129,9 +129,10 @@ public void saveSnapshot(ItemCollection snapshot) throws ArchiveException { // verify if this snapshot is already stored - if so, we do not overwrite // the origin data. See issue #40 + // For example this situation also occurs when restoring a remote snapshot. if (existSnapshot(snapshotID)) { // skip! - logger.info("...snapshot '" + snapshot.getUniqueID() + "' already exits...."); + logger.fine("...snapshot '" + snapshot.getUniqueID() + "' already exits...."); return; } @@ -220,13 +221,13 @@ public ItemCollection loadSnapshot(String snapshotID, boolean mergeDocuments) th if (row != null) { // load ItemCollection object ByteBuffer data = row.getBytes(COLUMN_DATA); - if (data!=null && data.hasArray()) { + if (data != null && data.hasArray()) { snapshot = getItemCollection(data.array()); // next we need to load the document data if exists... mergeDocumentData(snapshot); } else { - logger.warning("no data found for snapshotId '"+snapshotID+"'"); + logger.warning("no data found for snapshotId '" + snapshotID + "'"); } } else { // does not exist - create empty object diff --git a/imixs-archive-service/src/main/java/org/imixs/archive/service/restore/RestoreService.java b/imixs-archive-service/src/main/java/org/imixs/archive/service/restore/RestoreService.java index c8f9500..bb79e9a 100644 --- a/imixs-archive-service/src/main/java/org/imixs/archive/service/restore/RestoreService.java +++ b/imixs-archive-service/src/main/java/org/imixs/archive/service/restore/RestoreService.java @@ -267,19 +267,16 @@ void onTimeout(jakarta.ejb.Timer timer) throws Exception { // we search for snapshotIDs until we found one or the syncdate is after the // restore.to point. while (localDateRestoreTo.isAfter(localDateSyncPoint)) { - List snapshotIDs = dataService.loadSnapshotsByDate(localDateSyncPoint.toLocalDate()); // verify all snapshots of this day.... if (!snapshotIDs.isEmpty()) { - logger.info("......restore snapshot date " + localDateSyncPoint); + logger.info("......validate snapshot date " + localDateSyncPoint + "..."); // print out the snapshotIDs we found for (String snapshotID : snapshotIDs) { - String latestSnapshot = findLatestSnapshotID(snapshotID, restoreFrom, restoreTo); - // did we found a snapshot to restore? ItemCollection snapshot; String remoteSnapshotID = null; - if (latestSnapshot != null) { + if (latestSnapshot != null && matchFilterOptions(latestSnapshot, options)) { // yes, lets see if this snapshot is already restored or synced? try { remoteSnapshotID = remoteAPIService @@ -291,30 +288,26 @@ void onTimeout(jakarta.ejb.Timer timer) throws Exception { logger.finest( "......no need to restore - snapshot:" + latestSnapshot + " is up to date!"); } else { - // test the filter options - if (matchFilterOptions(latestSnapshot, options)) { - long _tmpSize = -1; - try { - logger.info("......restoring: " + latestSnapshot); - snapshot = dataService.loadSnapshot(latestSnapshot); - _tmpSize = dataService.calculateSize(XMLDocumentAdapter.getDocument(snapshot)); - logger.finest("......size=: " + _tmpSize); - - remoteAPIService.restoreSnapshot(snapshot); - - restoreSize = restoreSize + _tmpSize; - restoreCount++; - snapshot = null; - } catch (Exception e) { - logger.severe("...Failed to restore '" + latestSnapshot + "' (" - + messageService.userFriendlyBytes(_tmpSize) + ") - " + e.getMessage()); - restoreErrors++; - } + // start restore... + long _tmpSize = -1; + try { + logger.info("......restore snapshot " + latestSnapshot + " ..."); + snapshot = dataService.loadSnapshot(latestSnapshot); + _tmpSize = dataService.calculateSize(XMLDocumentAdapter.getDocument(snapshot)); + logger.finest("......size=: " + _tmpSize); + remoteAPIService.restoreSnapshot(snapshot); + restoreSize = restoreSize + _tmpSize; + restoreCount++; + snapshot = null; + } catch (Exception e) { + logger.severe("...Failed to restore '" + latestSnapshot + "' (" + + messageService.userFriendlyBytes(_tmpSize) + ") - " + e.getMessage()); + restoreErrors++; } } } else { - logger.warning( - ".... unexpected data situation: no latest snapshot found, matching requested restore time range!"); + logger.fine( + ".... no snapshot found matching requested restore time range and options"); } } }