use of fish.payara.nucleus.requesttracing.store.strategy.LongestTraceStorageStrategy 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);
}
Aggregations