idGenerator.refresh(); long flushLsn = logRecord.getLSN(); if (flushLsn == 0) {
@Test public void testAllocateComponentId() throws HyracksDataException { int numMemoryComponents = 2; DatasetInfo dsInfo = new DatasetInfo(101, null); ILSMComponentIdGenerator idGenerator = new LSMComponentIdGenerator(numMemoryComponents, MIN_VALID_COMPONENT_ID); ILSMIndex mockIndex = Mockito.mock(ILSMIndex.class); Mockito.when(mockIndex.getNumberOfAllMemoryComponents()).thenReturn(numMemoryComponents); ILSMMemoryComponent mockComponent = Mockito.mock(AbstractLSMMemoryComponent.class); Mockito.when(mockIndex.getCurrentMemoryComponent()).thenReturn(mockComponent); LSMIOOperationCallback callback = new LSMIOOperationCallback(dsInfo, mockIndex, idGenerator.getId(), mockIndexCheckpointManagerProvider()); ILSMComponentId initialId = idGenerator.getId(); // simulate a partition is flushed before allocated idGenerator.refresh(); long flushLsn = 1L; ILSMComponentId nextComponentId = idGenerator.getId(); callback.allocated(mockComponent); callback.recycled(mockComponent); checkMemoryComponent(initialId, mockComponent); }
@Override public void run() { ILSMIndexAccessor lsmAccessor = lsmBtree.createAccessor(NoOpIndexAccessParameters.INSTANCE); try { dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath) .refresh(); ILSMComponentId next = dsLifecycleMgr .getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); long flushLsn = nc.getTransactionSubsystem().getLogManager().getAppendLSN(); Map<String, Object> flushMap = new HashMap<>(); flushMap.put(LSMIOOperationCallback.KEY_FLUSH_LOG_LSN, flushLsn); flushMap.put(LSMIOOperationCallback.KEY_NEXT_COMPONENT_ID, next); lsmAccessor.getOpContext().setParameters(flushMap); lsmAccessor.deleteComponents(predicate); } catch (HyracksDataException e) { failure = e; } } };
for (int i = 0; i < 100; i++) { idGenerator.refresh(); ILSMComponentId expectedId = idGenerator.getId(); long flushLsn = 0L;
StorageTestUtils.searchAndAssertCount(nc, PARTITION, StorageTestUtils.TOTAL_NUM_OF_RECORDS); ILSMIndexAccessor lsmAccessor = lsmBtree.createAccessor(NoOpIndexAccessParameters.INSTANCE); dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); ILSMComponentId next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); flushLsn = nc.getTransactionSubsystem().getLogManager().getAppendLSN();
dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); ILSMComponentId next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); lsmAccessor = lsmBtree.createAccessor(NoOpIndexAccessParameters.INSTANCE); long lsn = LSMIOOperationCallback.getTreeIndexLSN(diskComponents.get(0).getMetadata()); dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); flushLsn = nc.getTransactionSubsystem().getLogManager().getAppendLSN();
StorageTestUtils.searchAndAssertCount(nc, PARTITION, StorageTestUtils.TOTAL_NUM_OF_RECORDS); ILSMIndexAccessor lsmAccessor = lsmBtree.createAccessor(NoOpIndexAccessParameters.INSTANCE); dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); ILSMComponentId next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).refresh(); next = dsLifecycleMgr.getComponentIdGenerator(StorageTestUtils.DATASET_ID, PARTITION, indexPath).getId(); flushLsn = nc.getTransactionSubsystem().getLogManager().getAppendLSN();