use of com.hazelcast.config.EventJournalConfig in project hazelcast by hazelcast.
the class AdvancedCacheJournalTest method getConfig.
@Override
protected Config getConfig() {
CacheSimpleConfig cacheConfig = new CacheSimpleConfig().setName("*");
cacheConfig.getEvictionConfig().setSize(Integer.MAX_VALUE);
cacheConfig.setEventJournalConfig(new EventJournalConfig().setEnabled(true));
return super.getConfig().setProperty(ClusterProperty.PARTITION_COUNT.getName(), String.valueOf(PARTITION_COUNT)).addCacheConfig(cacheConfig);
}
use of com.hazelcast.config.EventJournalConfig in project hazelcast by hazelcast.
the class CacheEventJournalBounceTest method getConfig.
@Override
protected Config getConfig() {
final CacheSimpleConfig cacheConfig = new CacheSimpleConfig().setName(TEST_CACHE_NAME);
cacheConfig.getEvictionConfig().setSize(Integer.MAX_VALUE);
Config config = super.getConfig().addCacheConfig(cacheConfig);
config.getCacheConfig(TEST_CACHE_NAME).setEventJournalConfig(new EventJournalConfig().setEnabled(true).setCapacity(10000));
return config;
}
use of com.hazelcast.config.EventJournalConfig in project hazelcast by hazelcast.
the class RingbufferCacheEventJournalImpl method getRingbufferOrFail.
/**
* Gets or creates a ringbuffer for an event journal or throws an exception if no
* event journal is configured. The caller should call
* {@link #hasEventJournal(ObjectNamespace)} before invoking this method to avoid getting
* the exception. This method can be used to get the ringbuffer on which future events
* will be added once the cache has been created.
* <p>
* NOTE: The cache config should have already been created in the cache service before
* invoking this method.
*
* @param namespace the cache namespace, containing the full prefixed cache name
* @param partitionId the cache partition ID
* @return the cache partition event journal
* @throws CacheNotExistsException if the cache configuration was not found
* @throws IllegalStateException if there is no event journal configured for this cache
*/
private RingbufferContainer<InternalEventJournalCacheEvent, Object> getRingbufferOrFail(ObjectNamespace namespace, int partitionId) {
RingbufferService ringbufferService = getRingbufferService();
RingbufferContainer<InternalEventJournalCacheEvent, Object> container = ringbufferService.getContainerOrNull(partitionId, namespace);
if (container != null) {
return container;
}
EventJournalConfig config = getEventJournalConfig(namespace);
if (config == null) {
throw new IllegalStateException(format("There is no event journal configured for cache %s or the journal is disabled", namespace.getObjectName()));
}
return getOrCreateRingbufferContainer(namespace, partitionId, config);
}
use of com.hazelcast.config.EventJournalConfig in project hazelcast by hazelcast.
the class CustomTypeFactory method createEventJournalConfig.
public static EventJournalConfig createEventJournalConfig(boolean enabled, int capacity, int timeToLiveSeconds) {
EventJournalConfig config = new EventJournalConfig();
config.setEnabled(enabled);
config.setCapacity(capacity);
config.setTimeToLiveSeconds(timeToLiveSeconds);
return config;
}
use of com.hazelcast.config.EventJournalConfig in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleCacheNode.
void handleCacheNode(Node node, CacheSimpleConfig cacheConfig) throws Exception {
for (Node n : childElements(node)) {
String nodeName = cleanNodeName(n);
if (matches("key-type", nodeName)) {
cacheConfig.setKeyType(getAttribute(n, "class-name"));
} else if (matches("value-type", nodeName)) {
cacheConfig.setValueType(getAttribute(n, "class-name"));
} else if (matches("statistics-enabled", nodeName)) {
cacheConfig.setStatisticsEnabled(getBooleanValue(getTextContent(n)));
} else if (matches("management-enabled", nodeName)) {
cacheConfig.setManagementEnabled(getBooleanValue(getTextContent(n)));
} else if (matches("read-through", nodeName)) {
cacheConfig.setReadThrough(getBooleanValue(getTextContent(n)));
} else if (matches("write-through", nodeName)) {
cacheConfig.setWriteThrough(getBooleanValue(getTextContent(n)));
} else if (matches("cache-loader-factory", nodeName)) {
cacheConfig.setCacheLoaderFactory(getAttribute(n, "class-name"));
} else if (matches("cache-loader", nodeName)) {
cacheConfig.setCacheLoader(getAttribute(n, "class-name"));
} else if (matches("cache-writer-factory", nodeName)) {
cacheConfig.setCacheWriterFactory(getAttribute(n, "class-name"));
} else if (matches("cache-writer", nodeName)) {
cacheConfig.setCacheWriter(getAttribute(n, "class-name"));
} else if (matches("expiry-policy-factory", nodeName)) {
cacheConfig.setExpiryPolicyFactoryConfig(getExpiryPolicyFactoryConfig(n));
} else if (matches("cache-entry-listeners", nodeName)) {
cacheListenerHandle(n, cacheConfig);
} else if (matches("in-memory-format", nodeName)) {
cacheConfig.setInMemoryFormat(InMemoryFormat.valueOf(upperCaseInternal(getTextContent(n))));
} else if (matches("backup-count", nodeName)) {
cacheConfig.setBackupCount(getIntegerValue("backup-count", getTextContent(n)));
} else if (matches("async-backup-count", nodeName)) {
cacheConfig.setAsyncBackupCount(getIntegerValue("async-backup-count", getTextContent(n)));
} else if (matches("wan-replication-ref", nodeName)) {
cacheWanReplicationRefHandle(n, cacheConfig);
} else if (matches("eviction", nodeName)) {
cacheConfig.setEvictionConfig(getEvictionConfig(n, false, false));
} else if (matches("split-brain-protection-ref", nodeName)) {
cacheConfig.setSplitBrainProtectionName(getTextContent(n));
} else if (matches("partition-lost-listeners", nodeName)) {
cachePartitionLostListenerHandle(n, cacheConfig);
} else if (matches("merge-policy", nodeName)) {
MergePolicyConfig mpConfig = createMergePolicyConfig(n, cacheConfig.getMergePolicyConfig());
cacheConfig.setMergePolicyConfig(mpConfig);
} else if (matches("event-journal", nodeName)) {
EventJournalConfig eventJournalConfig = new EventJournalConfig();
handleViaReflection(n, cacheConfig, eventJournalConfig);
} else if (matches("hot-restart", nodeName)) {
cacheConfig.setHotRestartConfig(createHotRestartConfig(n));
} else if (matches("data-persistence", nodeName)) {
cacheConfig.setDataPersistenceConfig(createDataPersistenceConfig(n));
} else if (matches("disable-per-entry-invalidation-events", nodeName)) {
cacheConfig.setDisablePerEntryInvalidationEvents(getBooleanValue(getTextContent(n)));
} else if (matches("merkle-tree", nodeName)) {
handleViaReflection(n, cacheConfig, cacheConfig.getMerkleTreeConfig());
}
}
try {
checkCacheConfig(cacheConfig, null);
} catch (IllegalArgumentException e) {
throw new InvalidConfigurationException(e.getMessage());
}
config.addCacheConfig(cacheConfig);
}
Aggregations