Search in sources :

Example 1 with ReservoirTraceStorageStrategy

use of fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy in project Payara by payara.

the class RequestTraceStoreFactory method getStore.

/**
 * Generates a request trace store.
 *
 * @param reservoirSamplingEnabled whether the store should remove items
 * based on a reservoir sampling algorithm.
 * @param historic whether the store is a historic store or not.
 * @return a request trace store.
 */
public static RequestTraceStoreInterface getStore(Events events, boolean reservoirSamplingEnabled, boolean historic) {
    // Get the hazelcast store name for if it's a clustered store.
    String storeName;
    if (historic) {
        storeName = HISTORIC_REQUEST_TRACE_STORE;
    } else {
        storeName = REQUEST_TRACE_STORE;
    }
    // Determines a strategy for adding items to the store
    TraceStorageStrategy strategy;
    if (reservoirSamplingEnabled) {
        strategy = new ReservoirTraceStorageStrategy();
    } else {
        strategy = new LongestTraceStorageStrategy();
    }
    // Get a clustered store if possible
    ClusteredStore clusteredStore = Globals.getDefaultHabitat().getService(ClusteredStore.class);
    if (clusteredStore != null && clusteredStore.isEnabled()) {
        MultiMap<String, RequestTrace> store = (MultiMap) clusteredStore.getMultiMap(storeName);
        return new ClusteredRequestTraceStore(store, clusteredStore.getInstanceId(), strategy);
    }
    // Otherwise get a local store
    return new LocalRequestTraceStore(strategy);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) TraceStorageStrategy(fish.payara.nucleus.requesttracing.store.strategy.TraceStorageStrategy) ReservoirTraceStorageStrategy(fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy) LongestTraceStorageStrategy(fish.payara.nucleus.requesttracing.store.strategy.LongestTraceStorageStrategy) ClusteredStore(fish.payara.nucleus.store.ClusteredStore) LongestTraceStorageStrategy(fish.payara.nucleus.requesttracing.store.strategy.LongestTraceStorageStrategy) RequestTrace(fish.payara.notification.requesttracing.RequestTrace) ReservoirTraceStorageStrategy(fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy)

Aggregations

MultiMap (com.hazelcast.core.MultiMap)1 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)1 LongestTraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.LongestTraceStorageStrategy)1 ReservoirTraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy)1 TraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.TraceStorageStrategy)1 ClusteredStore (fish.payara.nucleus.store.ClusteredStore)1