in hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractMemoryLSMComponent.java [117:160]
public void threadExit(LSMOperationType opType, boolean failedOperation, boolean isMutableComponent)
throws HyracksDataException {
switch (opType) {
case FORCE_MODIFICATION:
case MODIFICATION:
if (isMutableComponent) {
writerCount--;
//A failed operation should not change the component state since it's better for the failed operation's effect to be no-op.
if (state == ComponentState.READABLE_WRITABLE && !failedOperation && isFull()) {
state = ComponentState.READABLE_UNWRITABLE;
}
} else {
readerCount--;
if (state == ComponentState.UNREADABLE_UNWRITABLE && readerCount == 0) {
state = ComponentState.INACTIVE;
}
}
break;
case REPLICATE:
case SEARCH:
readerCount--;
if (state == ComponentState.UNREADABLE_UNWRITABLE && readerCount == 0) {
state = ComponentState.INACTIVE;
}
break;
case FLUSH:
if (state != ComponentState.READABLE_UNWRITABLE_FLUSHING) {
throw new IllegalStateException("Flush sees an illegal LSM memory compoenent state: " + state);
}
readerCount--;
if (readerCount == 0) {
state = ComponentState.INACTIVE;
} else {
state = ComponentState.UNREADABLE_UNWRITABLE;
}
break;
default:
throw new UnsupportedOperationException("Unsupported operation " + opType);
}
if (readerCount <= -1 || writerCount <= -1) {
throw new IllegalStateException("Invalid reader or writer count " + readerCount + " - " + writerCount);
}
}