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

FISH-7337 Don't Block Hazelcast by Default #6271

Merged
merged 2 commits into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2016-2021] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2023 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -41,6 +41,7 @@

import com.hazelcast.spi.tenantcontrol.TenantControl;
import com.hazelcast.spi.tenantcontrol.TenantControlFactory;
import java.util.function.Supplier;
import org.glassfish.api.invocation.ComponentInvocation;
import org.glassfish.api.invocation.InvocationManager;
import org.glassfish.internal.api.Globals;
Expand All @@ -53,11 +54,13 @@
*/
public class PayaraHazelcastTenantFactory implements TenantControlFactory {
private static final String DISABLE_BLOCKING_PROPERTY = "fish.payara.tenantcontrol.blocking.disable";
private static final Supplier<Boolean> getDisableBlockingProperty =
() -> Boolean.parseBoolean(System.getProperty(DISABLE_BLOCKING_PROPERTY, Boolean.TRUE.toString()));

private final JavaEEContextUtil ctxUtil = Globals.getDefaultHabitat().getService(JavaEEContextUtil.class);
private final InvocationManager invocationMgr = Globals.getDefaultHabitat().getService(InvocationManager.class);

static boolean blockingDisabled = Boolean.getBoolean(DISABLE_BLOCKING_PROPERTY);
static boolean blockingDisabled = getDisableBlockingProperty.get();

@Override
public TenantControl saveCurrentTenant() {
Expand All @@ -66,7 +69,7 @@ public TenantControl saveCurrentTenant() {
if (invocation != null) {
tenantControl = invocation.getRegistryFor(TenantControl.class);
if (tenantControl == null && ctxUtil.isInvocationLoaded()) {
blockingDisabled = Boolean.getBoolean(DISABLE_BLOCKING_PROPERTY);
blockingDisabled = getDisableBlockingProperty.get();
tenantControl = new PayaraHazelcastTenant();
invocation.setRegistryFor(TenantControl.class, tenantControl);
} else if (tenantControl == null) {
Expand Down