asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "abdullah alamoudi (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Ensure LogManager Doesn't Exceed the Size of the Log Page Qu...
Date Fri, 04 Nov 2016 16:22:40 GMT
abdullah alamoudi has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1342

Change subject: Ensure LogManager Doesn't Exceed the Size of the Log Page Queues
......................................................................

Ensure LogManager Doesn't Exceed the Size of the Log Page Queues

Change-Id: If6427576a31090a057ee6a3d25e35eef5cdd86f8
---
M asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
1 file changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/42/1342/1

diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
index 814bcfc..34a11aa 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/logging/LogManager.java
@@ -97,8 +97,8 @@
     }
 
     private void initializeLogManager(long nextLogFileId) {
-        emptyQ = new LinkedBlockingQueue<LogBuffer>(numLogPages);
-        flushQ = new LinkedBlockingQueue<LogBuffer>(numLogPages);
+        emptyQ = new LinkedBlockingQueue<>(numLogPages);
+        flushQ = new LinkedBlockingQueue<>(numLogPages);
         for (int i = 0; i < numLogPages; i++) {
             emptyQ.offer(new LogBuffer(txnSubsystem, logPageSize, flushLSN));
         }
@@ -182,6 +182,15 @@
 
     protected void getAndInitNewPage(int logSize) {
         if (logSize > logPageSize) {
+            // before creating a new page, we need to discard of another page since our queues
have fixed capacity
+            appendPage = null;
+            while (appendPage == null) {
+                try {
+                    appendPage = emptyQ.take();
+                } catch (InterruptedException e) {
+                    //ignore
+                }
+            }
             // for now, alloc a new buffer for each large page
             // TODO: pool large pages
             appendPage = new LogBuffer(txnSubsystem, logSize, flushLSN);
@@ -192,6 +201,7 @@
             while (appendPage == null) {
                 try {
                     appendPage = emptyQ.take();
+                    // TODO: (Discuss!!) if this turns out to be a large page, should we
replace it?? 
                 } catch (InterruptedException e) {
                     //ignore
                 }
@@ -299,10 +309,6 @@
                 e.printStackTrace();
             }
         }
-    }
-
-    public MutableLong getFlushLSN() {
-        return flushLSN;
     }
 
     private long initializeLogAnchor(long nextLogFileId) {
@@ -440,7 +446,7 @@
                 }
             });
             if (logFileNames != null && logFileNames.length != 0) {
-                logFileIds = new ArrayList<Long>();
+                logFileIds = new ArrayList<>();
                 for (String fileName : logFileNames) {
                     logFileIds.add(Long.parseLong(fileName.substring(logFilePrefix.length()
+ 1)));
                 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1342
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6427576a31090a057ee6a3d25e35eef5cdd86f8
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamousaa@gmail.com>

Mime
View raw message