merge from asterix_lsm_stabilization rev 1451:1456
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization_managix@1457 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
index 62a92cc..0bf379d 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryInvertedIndexCreator.java
@@ -153,7 +153,7 @@
//prepare a LocalResourceMetadata which will be stored in NC's local resource repository
ILocalResourceMetadata localResourceMetadata = new LSMInvertedIndexLocalResourceMetadata(invListsTypeTraits,
primaryComparatorFactories, tokenTypeTraits, tokenComparatorFactories, tokenizerFactory,
- GlobalConfig.DEFAULT_INDEX_MEM_PAGE_SIZE, GlobalConfig.DEFAULT_INDEX_MEM_NUM_PAGES);
+ GlobalConfig.DEFAULT_INDEX_MEM_PAGE_SIZE, GlobalConfig.DEFAULT_INDEX_MEM_NUM_PAGES, isPartitioned);
ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
localResourceMetadata, LocalResource.LSMInvertedIndexResource);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
index e71d370..894fc16 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/LSMInvertedIndexLocalResourceMetadata.java
@@ -27,11 +27,12 @@
private final IBinaryTokenizerFactory tokenizerFactory;
private final int memPageSize;
private final int memNumPages;
+ private final boolean isPartitioned;
public LSMInvertedIndexLocalResourceMetadata(ITypeTraits[] invListTypeTraits,
IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits,
IBinaryComparatorFactory[] tokenCmpFactories, IBinaryTokenizerFactory tokenizerFactory, int memPageSize,
- int memNumPages) {
+ int memNumPages, boolean isPartitioned) {
this.invListTypeTraits = invListTypeTraits;
this.invListCmpFactories = invListCmpFactories;
this.tokenTypeTraits = tokenTypeTraits;
@@ -39,6 +40,7 @@
this.tokenizerFactory = tokenizerFactory;
this.memPageSize = memPageSize;
this.memNumPages = memNumPages;
+ this.isPartitioned = isPartitioned;
}
@Override
@@ -51,13 +53,23 @@
IInMemoryFreePageManager memFreePageManager = new DualIndexInMemoryFreePageManager(memNumPages,
metaDataFrameFactory);
try {
- return InvertedIndexUtils.createLSMInvertedIndex(memBufferCache, memFreePageManager,
- runtimeContextProvider.getFileMapManager(), invListTypeTraits, invListCmpFactories,
- tokenTypeTraits, tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
- runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider.getLSMMergePolicy(),
- runtimeContextProvider.getLSMInvertedIndexOperationTrackerFactory(),
- runtimeContextProvider.getLSMIOScheduler(),
- runtimeContextProvider.getLSMInvertedIndexIOOperationCallbackProvider(), partition);
+ if (isPartitioned) {
+ return InvertedIndexUtils.createPartitionedLSMInvertedIndex(memBufferCache, memFreePageManager,
+ runtimeContextProvider.getFileMapManager(), invListTypeTraits, invListCmpFactories,
+ tokenTypeTraits, tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
+ runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider.getLSMMergePolicy(),
+ runtimeContextProvider.getLSMInvertedIndexOperationTrackerFactory(),
+ runtimeContextProvider.getLSMIOScheduler(),
+ runtimeContextProvider.getLSMInvertedIndexIOOperationCallbackProvider(), partition);
+ } else {
+ return InvertedIndexUtils.createLSMInvertedIndex(memBufferCache, memFreePageManager,
+ runtimeContextProvider.getFileMapManager(), invListTypeTraits, invListCmpFactories,
+ tokenTypeTraits, tokenCmpFactories, tokenizerFactory, runtimeContextProvider.getBufferCache(),
+ runtimeContextProvider.getIOManager(), filePath, runtimeContextProvider.getLSMMergePolicy(),
+ runtimeContextProvider.getLSMInvertedIndexOperationTrackerFactory(),
+ runtimeContextProvider.getLSMIOScheduler(),
+ runtimeContextProvider.getLSMInvertedIndexIOOperationCallbackProvider(), partition);
+ }
} catch (IndexException e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
index 9ad66bc..8a2b188 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
@@ -95,13 +95,16 @@
//if the readOnlyBuffer should be reloaded, then load the log page from the log file.
//needReloadBuffer is set to true if the log record is read from the memory log page.
if (needReloadBuffer) {
- readOnlyBuffer = getReadOnlyBuffer(logicalLogLocator.getLsn(), logManager.getLogManagerProperties()
- .getLogBufferSize());
+ //log page size doesn't exceed integer boundary
+ int offset = (int)(logicalLogLocator.getLsn() % logManager.getLogManagerProperties().getLogPageSize());
+ long adjustedLSN = logicalLogLocator.getLsn() - offset;
+ readOnlyBuffer = getReadOnlyBuffer(adjustedLSN, logManager.getLogManagerProperties()
+ .getLogPageSize());
logicalLogLocator.setBuffer(readOnlyBuffer);
- logicalLogLocator.setMemoryOffset(0);
+ logicalLogLocator.setMemoryOffset(offset);
needReloadBuffer = false;
}
-
+
//check whether the currentOffset has enough space to have new log record by comparing
//the smallest log record type(which is commit)'s log header.
while (logicalLogLocator.getMemoryOffset() <= readOnlyBuffer.getSize()
@@ -133,7 +136,7 @@
long lsnpos = ((logicalLogLocator.getLsn() / logManager.getLogManagerProperties().getLogPageSize()) + 1)
* logManager.getLogManagerProperties().getLogPageSize();
- readOnlyBuffer = getReadOnlyBuffer(lsnpos, logManager.getLogManagerProperties().getLogBufferSize());
+ readOnlyBuffer = getReadOnlyBuffer(lsnpos, logManager.getLogManagerProperties().getLogPageSize());
if (readOnlyBuffer != null) {
logicalLogLocator.setBuffer(readOnlyBuffer);
logicalLogLocator.setLsn(lsnpos);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index c73f693..c27ae20 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -657,7 +657,9 @@
}
if (!valid) {
if (currentLogLocator.getLsn() != lastLSNLogLocator.getLsn()) {
- throw new ACIDException("Log File Corruption: lastLSN mismatch");
+ throw new ACIDException("LastLSN mismatch: " + lastLSNLogLocator.getLsn() + " vs "
+ + currentLogLocator.getLsn() + " during Rollback a transaction( " + txnContext.getJobId()
+ + ")");
} else {
break;//End of Log File
}