use of com.hazelcast.ringbuffer.RingbufferStore in project hazelcast by hazelcast.
the class RingbufferStoreWrapper method create.
/**
* Factory method that creates a {@link RingbufferStoreWrapper}. It attempts to create the ring buffer store from several
* sources :
* <ul>
* <li>checks if the config contains the store implementation</li>
* <li>tries to create the store from the ring buffer store class</li>
* <li>tries to create one from the ring buffer store factory</li>
* <li>tries to instantiate the factory from the factory class and create the store from the factory</li>
* </ul>
*
* @param namespace ring buffer namespace
* @param storeConfig store config of ring buffer
* @param inMemoryFormat the format of the stored items (BINARY, OBJECT or NATIVE). NATIVE format translates into
* binary values on the store method calls.
* @param serializationService serialization service.
* @return returns a new instance of {@link RingbufferStoreWrapper}
*/
public static RingbufferStoreWrapper create(ObjectNamespace namespace, RingbufferStoreConfig storeConfig, InMemoryFormat inMemoryFormat, SerializationService serializationService, ClassLoader classLoader) {
checkNotNull(namespace, "namespace should not be null");
checkNotNull(serializationService, "serializationService should not be null");
final RingbufferStoreWrapper storeWrapper = new RingbufferStoreWrapper(namespace);
storeWrapper.serializationService = serializationService;
if (storeConfig == null || !storeConfig.isEnabled()) {
return storeWrapper;
}
// create ring buffer store.
final RingbufferStore ringbufferStore = createRingbufferStore(namespace, storeConfig, classLoader);
if (ringbufferStore != null) {
storeWrapper.enabled = storeConfig.isEnabled();
storeWrapper.inMemoryFormat = inMemoryFormat;
storeWrapper.store = ringbufferStore;
}
return storeWrapper;
}
use of com.hazelcast.ringbuffer.RingbufferStore in project hazelcast by hazelcast.
the class LatencyTrackingRingbufferStoreTest method setup.
@Before
public void setup() {
HazelcastInstance hz = createHazelcastInstance();
plugin = new StoreLatencyPlugin(getNodeEngineImpl(hz));
delegate = mock(RingbufferStore.class);
ringbufferStore = new LatencyTrackingRingbufferStore<String>(delegate, plugin, NAMESPACE);
}
use of com.hazelcast.ringbuffer.RingbufferStore in project hazelcast by hazelcast.
the class RingbufferStoreConfigHolder method asRingbufferStoreConfig.
public RingbufferStoreConfig asRingbufferStoreConfig(SerializationService serializationService) {
RingbufferStoreConfig config = new RingbufferStoreConfig();
if (!StringUtil.isNullOrEmptyAfterTrim(className)) {
config.setClassName(className);
}
config.setEnabled(enabled);
if (!StringUtil.isNullOrEmptyAfterTrim(factoryClassName)) {
config.setFactoryClassName(factoryClassName);
}
config.setProperties(PropertiesUtil.fromMap(properties));
RingbufferStore storeImplementation = serializationService.toObject(implementation);
if (storeImplementation != null) {
config.setStoreImplementation(storeImplementation);
}
RingbufferStoreFactory storeFactoryImplementation = serializationService.toObject(factoryImplementation);
if (storeFactoryImplementation != null) {
config.setFactoryImplementation(storeFactoryImplementation);
}
return config;
}
Aggregations