Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds thread interrupt flag check to StoreWorker #8345

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,9 +28,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import static com.hazelcast.util.CollectionUtil.isNotEmpty;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;

/**
* Processes store operations.
Expand Down Expand Up @@ -371,6 +372,9 @@ private List<DelayedEntry> retryCall(RetryTask task) {
for (; k < RETRY_TIMES_OF_A_FAILED_STORE_OPERATION; k++) {
try {
result = task.run();
} catch (InterruptedException ex) {
currentThread().interrupt();
break;
} catch (Exception ex) {
exception = ex;
}
Expand Down Expand Up @@ -428,9 +432,9 @@ private interface RetryTask<T> {

private void sleepSeconds(long secs) {
try {
TimeUnit.SECONDS.sleep(secs);
SECONDS.sleep(secs);
} catch (InterruptedException e) {
logger.warning(e);
currentThread().interrupt();
}
}

Expand Down
Expand Up @@ -38,6 +38,7 @@
import java.util.concurrent.atomic.AtomicInteger;

import static com.hazelcast.util.CollectionUtil.isEmpty;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;

/**
Expand Down Expand Up @@ -97,6 +98,10 @@ public void run() {
List<DelayedEntry> backupsList = null;

for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if (currentThread().isInterrupted()) {
break;
}

RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
if (!hasEntryInWriteBehindQueue(recordStore)) {
continue;
Expand Down