本文整理匯總了Java中com.hazelcast.config.Config.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Config.setProperty方法的具體用法?Java Config.setProperty怎麽用?Java Config.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hazelcast.config.Config
的用法示例。
在下文中一共展示了Config.setProperty方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testIntegration
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Test
public void testIntegration() {
String zookeeperURL = zkTestServer.getConnectString();
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty("hazelcast.discovery.enabled", "true");
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zookeeperURL);
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
int instance1Size = instance1.getCluster().getMembers().size();
assertEquals(2, instance1Size);
int instance2Size = instance2.getCluster().getMembers().size();
assertEquals(2, instance2Size);
}
示例2: testIntegration_urlNotConfigured
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Test
public void testIntegration_urlNotConfigured() {
exception.expect(IllegalStateException.class);
exception.expectMessage("Zookeeper URL cannot be null.");
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty("hazelcast.discovery.enabled", "true");
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
int instance1Size = instance1.getCluster().getMembers().size();
assertEquals(2, instance1Size);
int instance2Size = instance2.getCluster().getMembers().size();
assertEquals(2, instance2Size);
}
示例3: doStart
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
if (maximumRedeliveries < 0) {
throw new IllegalArgumentException("Maximum redelivery retries must be zero or a positive integer.");
}
if (recoveryInterval < 0) {
throw new IllegalArgumentException("Recovery interval must be zero or a positive integer.");
}
ObjectHelper.notEmpty(mapName, "repositoryName");
if (useLocalHzInstance) {
Config cfg = new XmlConfigBuilder().build();
cfg.setProperty("hazelcast.version.check.enabled", "false");
hzInstance = Hazelcast.newHazelcastInstance(cfg);
} else {
ObjectHelper.notNull(hzInstance, "hzInstanse");
}
cache = hzInstance.getMap(mapName);
if (useRecovery) {
persistedCache = hzInstance.getMap(persistenceMapName);
}
}
示例4: hazelCastConfig
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Bean
public Config hazelCastConfig() {
Config config = new Config();
config.setInstanceName("hazelcast-packt-cache");
config.setProperty("hazelcast.jmx", "true");
MapConfig deptCache = new MapConfig();
deptCache.setTimeToLiveSeconds(20);
deptCache.setEvictionPolicy(EvictionPolicy.LFU);
config.getMapConfigs().put("hazeldept",deptCache);
return config;
}
示例5: setUp
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
final Config config = new Config();
config.getGroupConfig().setName(GROUP_NAME);
config.setProperty("hazelcast.logging.type", "slf4j");
this.hzInstance = Hazelcast.newHazelcastInstance(config);
this.hcConnectionStore = new HcConnectionStore("127.0.0.1:5701", GROUP_NAME, MAP_NAME, "192.168.90.1");
}
示例6: addZkConfig
import com.hazelcast.config.Config; //導入方法依賴的package包/類
private void addZkConfig(Config config) {
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED.getName(), Boolean.TRUE.toString());
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zkUrl);
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), zkDir);
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), HAZELCAST_CLUSTER_NAME);
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
}
示例7: newStandaloneHazelcastInstance
import com.hazelcast.config.Config; //導入方法依賴的package包/類
static HazelcastInstance newStandaloneHazelcastInstance() {
Config config = new Config();
config.setProperty("hazelcast.logging.type", "slf4j");
config.setProperty("hazelcast.shutdownhook.enabled", "false");
NetworkConfig network = config.getNetworkConfig();
network.getJoin().getTcpIpConfig().setEnabled(false);
network.getJoin().getMulticastConfig().setEnabled(false);
return Hazelcast.newHazelcastInstance(config);
}
示例8: 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);
}
示例9: createMemberConfig
import com.hazelcast.config.Config; //導入方法依賴的package包/類
private Config createMemberConfig(String zookeeperURL) {
Config config = new Config();
config.getNetworkConfig().setPort(HAZELCAST_BASE_PORT);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty("hazelcast.discovery.enabled", "true");
DiscoveryStrategyConfig discoveryStrategyConfig = createDiscoveryConfig(zookeeperURL);
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
return config;
}
示例10: decorate
import com.hazelcast.config.Config; //導入方法依賴的package包/類
private Config decorate(Config config, String licenceKey) {
config.setLicenseKey(licenceKey);
config.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "0");
final SecurityInterceptorConfig securityInterceptorConfig = new SecurityInterceptorConfig();
securityInterceptorConfig.setClassName(HazelcastSecurityInterceptor.class.getName());
final SecurityConfig securityConfig = config.getSecurityConfig();
securityConfig.setEnabled(true).addSecurityInterceptorConfig(securityInterceptorConfig);
//When you enable security all client requests are denied, so we need to give permission first
//security-interceptor will be run after checking this permission
final PermissionConfig permissionConfig = new PermissionConfig(PermissionConfig.PermissionType.ALL, "", null);
securityConfig.addClientPermissionConfig(permissionConfig);
return config;
}
示例11: createConfig
import com.hazelcast.config.Config; //導入方法依賴的package包/類
private Config createConfig() {
Config config = new Config("eetlite");
config.setProperty("hazelcast.logging.type", "slf4j");
config.setProperty("hazelcast.socket.client.bind.any", "false");
setCacheConfig(config, "cz.eetlite.adapter.*", TTL_ADAPTER_SECONDS);
setCacheConfig(config, "cz.eetlite.service.sso.jwt", TTL_LOGIN_SECONDS);
setCacheConfig(config, "cz.eetlite.service.sso.rsa", TTL_RSA_SECONDS);
setCacheConfig(config, "cz.eetlite.*", TTL_ALL_SECONDS);
setSlowOperationDetector(config);
return config;
}
示例12: test
import com.hazelcast.config.Config; //導入方法依賴的package包/類
@Test
public void test() {
Config config = new XmlConfigBuilder().build();
config.setProperty("hazelcast.discovery.enabled", "true");
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getTcpIpConfig().setEnabled(false);
DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
DiscoveryStrategyFactory discoveryStrategyFactory = new SomeRestServiceDiscoveryStrategyFactory();
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(discoveryStrategyFactory);
discoveryConfig.addDiscoveryStrategyConfig(discoveryStrategyConfig);
config.getNetworkConfig().setPort(55667);
HazelcastInstance hazelcastInstance1 = Hazelcast.newHazelcastInstance(config);
config.getNetworkConfig().setPort(1122);
HazelcastInstance hazelcastInstance2 = Hazelcast.newHazelcastInstance(config);
assertEquals(2, hazelcastInstance1.getCluster().getMembers().size());
assertEquals(2, hazelcastInstance2.getCluster().getMembers().size());
Hazelcast.shutdownAll();
}