本文整理匯總了Java中com.hazelcast.config.Config.addMapConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java Config.addMapConfig方法的具體用法?Java Config.addMapConfig怎麽用?Java Config.addMapConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hazelcast.config.Config
的用法示例。
在下文中一共展示了Config.addMapConfig方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@PostConstruct
public void init() {
Config config = this.hazelcastInstance.getConfig();
String mapName = this.sessionProperties.getMapName();
MapConfig mapConfig = config.getMapConfigOrNull(mapName);
if (mapConfig == null) {
// @formatter:off
MapAttributeConfig principalNameAttributeConfig = new MapAttributeConfig()
.setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
.setExtractor(PrincipalNameExtractor.class.getName());
// @formatter:on
MapIndexConfig principalNameIndexConfig = new MapIndexConfig(
HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false);
// @formatter:off
mapConfig = new MapConfig(mapName)
.addMapAttributeConfig(principalNameAttributeConfig)
.addMapIndexConfig(principalNameIndexConfig);
// @formatter:on
config.addMapConfig(mapConfig);
}
}
示例2: init
import com.hazelcast.config.Config; //導入方法依賴的package包/類
public void init() {
//Specific map time to live
MapConfig myMapConfig = new MapConfig();
myMapConfig.setName("cachetest");
myMapConfig.setTimeToLiveSeconds(10);
//Package config
Config myConfig = new Config();
myConfig.addMapConfig(myMapConfig);
//Symmetric Encryption
SymmetricEncryptionConfig symmetricEncryptionConfig = new SymmetricEncryptionConfig();
symmetricEncryptionConfig.setAlgorithm("DESede");
symmetricEncryptionConfig.setSalt("saltysalt");
symmetricEncryptionConfig.setPassword("lamepassword");
symmetricEncryptionConfig.setIterationCount(1337);
//Weak Network config..
NetworkConfig networkConfig = new NetworkConfig();
networkConfig.setSymmetricEncryptionConfig(symmetricEncryptionConfig);
myConfig.setNetworkConfig(networkConfig);
Hazelcast.init(myConfig);
cacheMap = Hazelcast.getMap("cachetest");
}
示例3: hazelcastInstance
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Bean
public HazelcastInstance hazelcastInstance() {
Config config = new Config();
if (zkEnabled) {
addZkConfig(config);
}
config.addMapConfig(createDeviceCredentialsCacheConfig());
return Hazelcast.newHazelcastInstance(config);
}
示例4: Transport
import com.hazelcast.config.Config; //導入方法依賴的package包/類
/**
* Initializes the {@link HazelcastInstance} for this global runtime instance.
*
* @param runtime
* the global runtime instance
* @param master
* member to connect to or null
* @param localhost
* the preferred ip address of this host or null
* @param compact
* reduce thread creation if set
* @param kryo
* use kryo serialization if set
*/
protected Transport(GlobalRuntimeImpl runtime, String master,
String localhost, boolean compact, boolean kryo) {
this.runtime = runtime;
// config
final Config config = new Config();
config.setProperty("hazelcast.logging.type", "none");
config.setProperty("hazelcast.wait.seconds.before.join", "0");
config.setProperty("hazelcast.socket.connect.timeout.seconds", "1");
config.setProperty("hazelcast.connection.monitor.max.faults", "0");
if (compact) {
config.setProperty("hazelcast.operation.thread.count", "2");
config.setProperty("hazelcast.operation.generic.thread.count", "2");
config.setProperty("hazelcast.io.thread.count", "2");
config.setProperty("hazelcast.event.thread.count", "2");
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.ASYNC_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SYSTEM_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SCHEDULED_EXECUTOR, 2));
}
// kryo
if (kryo) {
config.getSerializationConfig().addSerializerConfig(
new SerializerConfig().setTypeClass(SerializableRunnable.class)
.setImplementation(new KryoSerializer()));
}
config.addMapConfig(
new MapConfig(APGAS_FINISH).setInMemoryFormat(InMemoryFormat.OBJECT));
// join config
final JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true);
if (localhost != null) {
System.setProperty("hazelcast.local.localAddress", localhost);
}
if (master != null) {
join.getTcpIpConfig().addMember(master);
}
config.setInstanceName(APGAS);
hazelcast = Hazelcast.newHazelcastInstance(config);
me = hazelcast.getCluster().getLocalMember();
allMembers = hazelcast.getList(APGAS_PLACES);
allMembers.add(me);
int id = 0;
for (final Member member : allMembers) {
if (member.getUuid().equals(me.getUuid())) {
break;
}
++id;
}
here = id;
executor = hazelcast.getExecutorService(APGAS_EXECUTOR);
}
示例5: givenMemberHasClassLoaderConfigured_whenObjectIsStored_thenClassLoaderWillBeUsed
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Test
public void givenMemberHasClassLoaderConfigured_whenObjectIsStored_thenClassLoaderWillBeUsed() throws Exception {
String mapName = randomMapName();
Config config = new Config();
SubZero.useAsGlobalSerializer(config);
ClassLoader spyingClassLoader = createSpyingClassLoader();
config.setClassLoader(spyingClassLoader);
config.addMapConfig(new MapConfig(mapName).setInMemoryFormat(OBJECT));
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
IMap<Integer, Object> myMap = member.getMap(mapName);
myMap.put(0, new MyClass());
verify(spyingClassLoader).loadClass("info.jerrinot.subzero.ClassLoadingTest$MyClass");
}
示例6: configureCache
import com.hazelcast.config.Config; //導入方法依賴的package包/類
/**
* Add configuration for an {@link IMap} that will contain the event window.
* @param eventWindowName The name of the {@link IMap} to configure.
* @param timeToLiveSeconds The number of seconds to keep an event's identity in the window before discarding it.
* @param config The {@link Config} to add the {@link IMap} configuration to.
* @return The updated {@link Config}
*/
public static Config configureCache(String eventWindowName, int timeToLiveSeconds, Config config) {
config.addMapConfig(new MapConfig(eventWindowName).setTimeToLiveSeconds(timeToLiveSeconds));
return config;
}