[ 
https://issues.apache.org/jira/browse/ARTEMIS-3297?focusedWorklogId=597070&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-597070
 ]

ASF GitHub Bot logged work on ARTEMIS-3297:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/May/21 03:48
            Start Date: 15/May/21 03:48
    Worklog Time Spent: 10m 
      Work Description: michaelandrepearce commented on a change in pull 
request #3580:
URL: https://github.com/apache/activemq-artemis/pull/3580#discussion_r632890048



##########
File path: 
artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
##########
@@ -2245,6 +2379,155 @@ private synchronized JournalLoadInformation load(final 
LoaderCallback loadManage
       }
    }
 
+
+   @Override
+   public void processBackupCleanup() {
+      if (journalRetentionFolder != null && (journalRetentionMaxFiles > 0 || 
journalRetentionPeriod > 0)) {
+
+         FilenameFilter fnf = new FilenameFilter() {
+            @Override
+            public boolean accept(final File file, final String name) {
+               return name != null && name.endsWith("." + 
filesRepository.getFileExtension());
+            }
+         };
+
+
+         if (journalRetentionPeriod > 0) {
+            String[] fileNames = journalRetentionFolder.list(fnf);
+            Arrays.sort(fileNames);
+
+            GregorianCalendar calendar = this.calendarThreadLocal.get();
+            calendar.setTimeInMillis(System.currentTimeMillis() - 
journalRetentionUnit.toMillis(journalRetentionPeriod));
+            long timeCutOf = calendar.getTimeInMillis();
+
+            for (String fileName : fileNames) {
+               long timeOnFile = getDatePortionMillis(fileName);
+               if (timeOnFile < timeCutOf) {
+                  logger.debug("File " + fileName + " is too old and should 
go");
+                  File fileToRemove = new File(journalRetentionFolder, 
fileName);
+                  if (!fileToRemove.delete()) {
+                     logger.debug("Could not remove " + fileToRemove);
+                  }
+               }
+            }
+         }
+
+         if (journalRetentionMaxFiles > 0) {
+            String[] fileNames = journalRetentionFolder.list(fnf);
+            Arrays.sort(fileNames);
+
+            if (fileNames.length > journalRetentionMaxFiles) {
+               int toRemove = fileNames.length - journalRetentionMaxFiles;
+
+               for (String file : fileNames) {
+                  logger.debug("Removing " + file);
+                  File fileToRemove = new File(journalRetentionFolder, file);
+                  fileToRemove.delete();
+                  toRemove--;
+                  if (toRemove <= 0) {
+                     break;
+                  }
+               }
+            }
+         }
+
+
+      }
+   }
+
+   @Override
+   public void processBackup() {
+      if (journalRetentionFolder != null) {
+         ArrayList<JournalFile> filesToMove;
+         synchronized (historyPendingFiles) {
+            filesToMove = new ArrayList<>(historyPendingFiles.size());
+            filesToMove.addAll(historyPendingFiles);
+            historyPendingFiles.clear();
+         }
+
+
+         Calendar calendar = calendarThreadLocal.get();

Review comment:
       Why in some places using gregorian and her just plain calendar




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 597070)
    Time Spent: 5h 20m  (was: 5h 10m)

> Journal Retention Feature
> -------------------------
>
>                 Key: ARTEMIS-3297
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3297
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>    Affects Versions: 2.17.0
>            Reporter: Clebert Suconic
>            Priority: Major
>             Fix For: 2.18.0
>
>          Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> We should keep historical backup of the journal data, and having tools to 
> recover data in case of data loss.
>  
> Data loss could mean by unbehaved client's (say you mistakenly acknowledged 
> data and your code caused the message to disappear earlier), or even after 
> eventual bugs on the broker.
>  
> To activate the functionality, you have to specify journal-history-data on 
> broker.xml.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to