ARTEMIS-1663 Fixing Encoding on PageCountPendingImpl

The PageCountPendingImpl was increasing the encode size without using its full allocation.
This was causing issues on replication as the encode is also used to determine the size of the packets.
however the packets were not receive the full allocated data causing missing packets on the replication
and test failures.

This is fixing the issue
This commit is contained in:
Clebert Suconic 2018-02-13 11:38:16 -05:00
parent f329b5b3f5
commit 9b104930c2
7 changed files with 11 additions and 11 deletions

View File

@ -135,7 +135,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter {
// We have to make sure this is sync here
// not syncing this to disk may cause the page files to be out of sync on pages.
// we can't afford the case where a page file is written without a record here
long id = storage.storePendingCounter(this.subscriptionID, page.getPageId(), increment);
long id = storage.storePendingCounter(this.subscriptionID, page.getPageId());
pendingInfo = new PendingCounter(id, increment, size);
pendingCounters.put((long) page.getPageId(), pendingInfo);
} else {
@ -422,7 +422,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter {
/**
* @param id
* @param count
* @param size
* @param persistentSize
*/
PendingCounter(long id, int count, long persistentSize) {
super();

View File

@ -338,7 +338,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
*/
long storePageCounter(long txID, long queueID, long value, long persistentSize) throws Exception;
long storePendingCounter(long queueID, long pageID, int inc) throws Exception;
long storePendingCounter(long queueID, long pageID) throws Exception;
void deleteIncrementRecord(long txID, long recordID) throws Exception;

View File

@ -1388,11 +1388,11 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp
}
@Override
public long storePendingCounter(final long queueID, final long pageID, final int inc) throws Exception {
public long storePendingCounter(final long queueID, final long pageID) throws Exception {
readLock();
try {
final long recordID = idGenerator.generateID();
PageCountPendingImpl pendingInc = new PageCountPendingImpl(queueID, pageID, inc);
PageCountPendingImpl pendingInc = new PageCountPendingImpl(queueID, pageID);
// We must guarantee the record sync before we actually write on the page otherwise we may get out of sync
// on the counter
messageJournal.appendAddRecord(recordID, JournalRecordIds.PAGE_CURSOR_PENDING_COUNTER, pendingInc, true);

View File

@ -33,7 +33,7 @@ public class PageCountPendingImpl implements EncodingSupport, PageCountPending {
}
public PageCountPendingImpl(long queueID, long pageID, int inc) {
public PageCountPendingImpl(long queueID, long pageID) {
this.queueID = queueID;
this.pageID = pageID;
}
@ -65,7 +65,7 @@ public class PageCountPendingImpl implements EncodingSupport, PageCountPending {
@Override
public int getEncodeSize() {
return DataConstants.SIZE_LONG * 3;
return DataConstants.SIZE_LONG * 2;
}
@Override

View File

@ -472,7 +472,7 @@ public class NullStorageManager implements StorageManager {
}
@Override
public long storePendingCounter(long queueID, long pageID, int inc) throws Exception {
public long storePendingCounter(long queueID, long pageID) throws Exception {
return -1;
}

View File

@ -592,7 +592,7 @@ public class TransactionImplTest extends ActiveMQTestBase {
}
@Override
public long storePendingCounter(long queueID, long pageID, int inc) throws Exception {
public long storePendingCounter(long queueID, long pageID) throws Exception {
return 0;
}

View File

@ -673,8 +673,8 @@ public class SendAckFailTest extends ActiveMQTestBase {
}
@Override
public long storePendingCounter(long queueID, long pageID, int inc) throws Exception {
return manager.storePendingCounter(queueID, pageID, inc);
public long storePendingCounter(long queueID, long pageID) throws Exception {
return manager.storePendingCounter(queueID, pageID);
}
@Override