当前位置: 首页>>代码示例>>Java>>正文


Java HazelcastInstance类代码示例

本文整理汇总了Java中com.hazelcast.core.HazelcastInstance的典型用法代码示例。如果您正苦于以下问题:Java HazelcastInstance类的具体用法?Java HazelcastInstance怎么用?Java HazelcastInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HazelcastInstance类属于com.hazelcast.core包,在下文中一共展示了HazelcastInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
public static void main(String[] args) {
    Config cfg = new Config();
    HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
    Map<Integer, String> mapCustomers = instance.getMap("customers");
    mapCustomers.put(1, "Joe");
    mapCustomers.put(2, "Ali");
    mapCustomers.put(3, "Avi");

    System.out.println("Customer with key 1: "+ mapCustomers.get(1));
    System.out.println("Map Size:" + mapCustomers.size());

    Queue<String> queueCustomers = instance.getQueue("customers");
    queueCustomers.offer("Tom");
    queueCustomers.offer("Mary");
    queueCustomers.offer("Jane");
    System.out.println("First customer: " + queueCustomers.poll());
    System.out.println("Second customer: "+ queueCustomers.peek());
    System.out.println("Queue size: " + queueCustomers.size());
}
 
开发者ID:datathings,项目名称:greycat,代码行数:20,代码来源:HazelcastScheduler.java

示例2: HazelcastTicketRegistry

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
/**
 * Instantiates a new Hazelcast ticket registry.
 *
 * @param hz                                   An instance of {@code HazelcastInstance}
 * @param mapName                              Name of map to use
 * @param ticketGrantingTicketTimeoutInSeconds TTL for TGT entries
 * @param serviceTicketTimeoutInSeconds        TTL for ST entries
 * @param pageSize                             the page size
 */
@Autowired
public HazelcastTicketRegistry(
    @Qualifier("hazelcast")
    final HazelcastInstance hz,
    @Value("${hz.mapname:tickets}")
    final String mapName,
    @Value("${tgt.maxTimeToLiveInSeconds:28800}")
    final long ticketGrantingTicketTimeoutInSeconds,
    @Value("${st.timeToKillInSeconds:10}")
    final long serviceTicketTimeoutInSeconds,
    @Value("${hz.page.size:500}")
    final int pageSize) {

    this.registry = hz.getMap(mapName);
    this.ticketGrantingTicketTimeoutInSeconds = ticketGrantingTicketTimeoutInSeconds;
    this.serviceTicketTimeoutInSeconds = serviceTicketTimeoutInSeconds;
    this.hz = hz;
    this.pageSize = pageSize;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:HazelcastTicketRegistry.java

示例3: tenantConfigurationHazelcast

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean(TENANT_CONFIGURATION_HAZELCAST)
public HazelcastInstance tenantConfigurationHazelcast() throws IOException {
    log.info("{}", appProps.getHazelcast());

    Properties props = new Properties();
    props.putAll(appProps.getHazelcast());
    props.put(HAZELCAST_LOCAL_LOCAL_ADDRESS, InetUtils.getFirstNonLoopbackHostInfo().getIpAddress());

    String hazelcastConfigUrl = appProps.getHazelcast().get(HAZELCAST_CONFIG_URL_PROPERTY);
    InputStream in = context.getResource(hazelcastConfigUrl).getInputStream();

    Config config = new XmlConfigBuilder(in).setProperties(props).build();
    config.getNetworkConfig().setInterfaces(buildInterfaces(appProps.getHazelcast().get(INTERFACES)));
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    return hazelcastInstance;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:17,代码来源:XmConfigHazelcastConfiguration.java

示例4: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("balance");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("balance");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.icthh.xm.ms.balance.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:xm-online,项目名称:xm-ms-balance,代码行数:26,代码来源:CacheConfiguration.java

示例5: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
/**
 * Hazelcast instance that is used by the spring session
 * repository to broadcast session events. The name
 * of this bean must be left untouched.
 *
 * @return the hazelcast instance
 */
@Bean
public HazelcastInstance hazelcastInstance() {
    final Resource hzConfigResource = casProperties.getWebflow().getSession().getHzLocation();
    try {
        final URL configUrl = hzConfigResource.getURL();
        final Config config = new XmlConfigBuilder(hzConfigResource.getInputStream()).build();
        config.setConfigurationUrl(configUrl);
        config.setInstanceName(this.getClass().getSimpleName())
                .setProperty("hazelcast.logging.type", "slf4j")
                .setProperty("hazelcast.max.no.heartbeat.seconds", "300");
        return Hazelcast.newHazelcastInstance(config);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:HazelcastSessionConfiguration.java

示例6: main

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
public static void main(String[] args) {
    //System.setProperty("hazelcast.http.healthcheck.enabled", "true");
    final HazelcastInstance hazelcastInstance = newHazelcastInstance();

    HazelcastInstanceImpl hazelcastInstance1 = ((HazelcastInstanceProxy) hazelcastInstance).getOriginal();
    final InternalPartitionService partitionService = hazelcastInstance1.node.getPartitionService();

    boolean memberStateSafe = partitionService.isMemberStateSafe();
    System.out.println("memberStateSafe = " + memberStateSafe);
    boolean clusterSafe = memberStateSafe && !partitionService.hasOnGoingMigration();
    System.out.println("clusterSafe = " + clusterSafe);
    long migrationQueueSize = partitionService.getMigrationQueueSize();
    System.out.println("migrationQueueSize = " + migrationQueueSize);


}
 
开发者ID:gAmUssA,项目名称:testcontainers-hazelcast,代码行数:17,代码来源:TestScratchpad.java

示例7: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("dashboard");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("dashboard");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.icthh.xm.ms.dashboard.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:xm-online,项目名称:xm-ms-dashboard,代码行数:27,代码来源:CacheConfiguration.java

示例8: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("gate");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("gate");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.icthh.xm.gate.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:27,代码来源:CacheConfiguration.java

示例9: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("entity");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("entity");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.icthh.xm.ms.entity.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:27,代码来源:CacheConfiguration.java

示例10: hazelcastInstance

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    Config config = new Config();
    config.setInstanceName("operoncloudplatform");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("cloud.operon.platform.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:21,代码来源:CacheConfiguration.java

示例11: HazelcastTicketRegistry

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
/**
 * @param hz                                  An instance of {@code HazelcastInstance}
 * @param mapName                             Name of map to use
 * @param ticketGrantingTicketTimeoutInSeconds TTL for TGT entries
 * @param serviceTicketTimeoutInSeconds       TTL for ST entries
 */
@Autowired
public HazelcastTicketRegistry(
    @Qualifier("hazelcast")
    final HazelcastInstance hz,
    @Value("${hz.mapname:tickets}")
    final String mapName,
    @Value("${tgt.maxTimeToLiveInSeconds:28800}")
    final long ticketGrantingTicketTimeoutInSeconds,
    @Value("${st.timeToKillInSeconds:10}")
    final long serviceTicketTimeoutInSeconds) {

    this.registry = hz.getMap(mapName);
    this.ticketGrantingTicketTimeoutInSeconds = ticketGrantingTicketTimeoutInSeconds;
    this.serviceTicketTimeoutInSeconds = serviceTicketTimeoutInSeconds;
    this.hz = hz;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:23,代码来源:HazelcastTicketRegistry.java

示例12: executeSchemaChange

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
/**
 * Main method for executing the schema conversion to Hazelcast.
 * The method just needs to be called statically as it operates on files created during the initial
 * schema conversion process.
 */
public static void executeSchemaChange() {
    Config cfg = new Config();
    HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);

    mapNodes = instance.getMap("nodes");
    mapEdges = instance.getMap("edges");
    mapLabels = instance.getMap("labels");
    mapOut = instance.getMap("out");
    mapIn = instance.getMap("in");

    nodesMap();
    edgesMap();

    exampleQueries();
}
 
开发者ID:DTG-FRESCO,项目名称:cyp2sql,代码行数:21,代码来源:KeyValueTest.java

示例13: jGitRepository

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
@Primary
@SneakyThrows
public JGitRepository jGitRepository(ApplicationProperties applicationProperties, HazelcastInstance hazelcastInstance) {

    return new JGitRepository(applicationProperties.getGit(), new ReentrantLock()) {
        @Override
        protected void initRepository(){};
        @Override
        protected void pull(){};
        @Override
        protected void commitAndPush(String commitMsg){};
        @Override
        public List<com.icthh.xm.ms.configuration.domain.Configuration> findAll(){
            return emptyList();
        }
    };
}
 
开发者ID:xm-online,项目名称:xm-ms-config,代码行数:19,代码来源:TestConfiguration.java

示例14: jGitRepository

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
@Bean
@Primary
@SneakyThrows
public JGitRepository jGitRepository(ApplicationProperties applicationProperties, HazelcastInstance hazelcastInstance) {
    File tmpDir = createTmpDir("work");
    tmpDir.mkdirs();

    ApplicationProperties.GitProperties gitProps = new ApplicationProperties.GitProperties();
    gitProps.setMaxWaitTimeSecond(30);

    final Git git = Git.init().setBare(false).setDirectory(tmpDir).call();

    return new JGitRepository(gitProps, new ReentrantLock()) {
        @Override
        protected void initRepository(){};
        @Override
        protected void pull(){};
        @Override
        protected void commitAndPush(String commitMsg){};
    };
}
 
开发者ID:xm-online,项目名称:xm-ms-config,代码行数:22,代码来源:LocalJGitRespotioryConfiguration.java

示例15: HazelMap

import com.hazelcast.core.HazelcastInstance; //导入依赖的package包/类
/**
 * Initializes a new hazel async map.
 *
 * @param context the context requesting the map to be created.
 * @param future  called when the map is created.
 */
public HazelMap(Future<AsyncStorage> future, StorageContext<Value> context) {
    this.context = context;

    context.vertx().sharedData().<String, Value>getClusterWideMap(context.database(), cluster -> {
        if (cluster.succeeded()) {
            this.map = cluster.result();

            Optional<HazelcastInstance> hazel = Hazelcast.getAllHazelcastInstances().stream().findFirst();

            if (hazel.isPresent()) {
                HazelcastInstance instance = hazel.get();
                imap = instance.getMap(context.database());
                addIndex(Storable.idField);
                future.complete(this);
            } else {
                future.fail(CoreStrings.ERROR_NOT_CLUSTERED);
            }
        } else {
            future.fail(cluster.cause());
        }
    });
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:29,代码来源:HazelMap.java


注:本文中的com.hazelcast.core.HazelcastInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。