From 461f45713566e5634a34de1eea5edb9cdb4130c9 Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Wed, 12 Aug 2020 12:49:56 +0100 Subject: [PATCH] FISH-82 Add check for if ClusteredStore is actually active --- .../store/RequestTraceStoreFactory.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nucleus/payara-modules/requesttracing-core/src/main/java/fish/payara/nucleus/requesttracing/store/RequestTraceStoreFactory.java b/nucleus/payara-modules/requesttracing-core/src/main/java/fish/payara/nucleus/requesttracing/store/RequestTraceStoreFactory.java index aa1d57968e4..3a7569d70c8 100644 --- a/nucleus/payara-modules/requesttracing-core/src/main/java/fish/payara/nucleus/requesttracing/store/RequestTraceStoreFactory.java +++ b/nucleus/payara-modules/requesttracing-core/src/main/java/fish/payara/nucleus/requesttracing/store/RequestTraceStoreFactory.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2017-2019 Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2017-2020 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 @@ -44,13 +44,13 @@ import fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy; import fish.payara.nucleus.requesttracing.store.strategy.TraceStorageStrategy; import fish.payara.nucleus.store.ClusteredStore; +import org.glassfish.api.event.Events; +import org.glassfish.hk2.api.ServiceHandle; +import org.glassfish.internal.api.Globals; import java.util.Map; import java.util.UUID; -import org.glassfish.api.event.Events; -import org.glassfish.internal.api.Globals; - /** * A factory for generating a * {@link fish.payara.nucleus.requesttracing.store.RequestTraceStoreInterface}. @@ -87,7 +87,12 @@ public static RequestTraceStoreInterface getStore(Events events, boolean reservo } // Get a clustered store if possible - ClusteredStore clusteredStore = Globals.getDefaultHabitat().getService(ClusteredStore.class); + ClusteredStore clusteredStore = null; + ServiceHandle serviceHandle = Globals.getDefaultHabitat().getServiceHandle(ClusteredStore.class); + if (serviceHandle != null && serviceHandle.isActive()) { + clusteredStore = serviceHandle.getService(); + } + if (clusteredStore != null && clusteredStore.isEnabled()) { Map store = (Map) clusteredStore.getMap(storeName); return new ClusteredRequestTraceStore(store, strategy);