sijie commented on a change in pull request #1549: offloadPrefix implementation 
for managed ledger
URL: https://github.com/apache/incubator-pulsar/pull/1549#discussion_r181167564
 
 

 ##########
 File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
 ##########
 @@ -1850,9 +1854,172 @@ public void offloadFailed(ManagedLedgerException e, 
Object ctx) {
 
     @Override
     public void asyncOffloadPrefix(Position pos, OffloadCallback callback, 
Object ctx) {
-        callback.offloadFailed(new ManagedLedgerException("Not implemented"), 
ctx);
+        PositionImpl requestOffloadTo = (PositionImpl)pos;
+        if (!isValidPosition(requestOffloadTo)) {
+            callback.offloadFailed(new InvalidCursorPositionException("Invalid 
position for offload"), ctx);
+            return;
+        }
+
+        Position firstUnoffloaded;
+
+        List<LedgerInfo> ledgersToOffload = Lists.newArrayList();
+        synchronized (this) {
+            log.info("[{}] Start ledgersOffload. ledgers={} totalSize={}", 
name, ledgers.keySet(),
+                     TOTAL_SIZE_UPDATER.get(this));
+
+            if (STATE_UPDATER.get(this) == State.Closed) {
+                log.info("[{}] Ignoring offload request since the managed 
ledger was already closed", name);
+                callback.offloadFailed(new ManagedLedgerAlreadyClosedException(
+                                               "Can't offload closed managed 
ledger"), ctx);
 
 Review comment:
   nit: better add the managed ledger name in the exception message?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Reply via email to