當前位置: 首頁>>代碼示例>>Java>>正文


Java Hazelcast.getHazelcastInstanceByName方法代碼示例

本文整理匯總了Java中com.hazelcast.core.Hazelcast.getHazelcastInstanceByName方法的典型用法代碼示例。如果您正苦於以下問題:Java Hazelcast.getHazelcastInstanceByName方法的具體用法?Java Hazelcast.getHazelcastInstanceByName怎麽用?Java Hazelcast.getHazelcastInstanceByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hazelcast.core.Hazelcast的用法示例。


在下文中一共展示了Hazelcast.getHazelcastInstanceByName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的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

示例2: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的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

示例3: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的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

示例4: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的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

示例5: getOrCreateHzInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
private HazelcastInstance getOrCreateHzInstance(Map<String, Object> parameters) {

        // Query param named 'hazelcastInstance' (if exists) overrides the instance that was set
        HazelcastInstance hzInstance = resolveAndRemoveReferenceParameter(parameters, HAZELCAST_INSTANCE_PARAM, HazelcastInstance.class);

        // check if an already created instance is given then just get instance by its name.
        if (hzInstance == null && parameters.get(HAZELCAST_INSTANCE_NAME_PARAM) != null) {
            hzInstance = Hazelcast.getHazelcastInstanceByName((String) parameters.get(HAZELCAST_INSTANCE_NAME_PARAM));
        }

        // Now create onw instance component
        if (hzInstance == null) {
            if (hazelcastInstance == null) {
                createOwnInstance = true;
                hazelcastInstance = createOwnInstance();
            }
            hzInstance = hazelcastInstance;
        }
        return hzInstance;
    }
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:HazelcastComponent.java

示例6: testFailover

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Test(timeout = 80000)
public void testFailover() throws Exception {
    CookieStore cookieStore = new BasicCookieStore();
    String value = executeRequest("read", SERVER_PORT_1, cookieStore);
    assertEquals("null", value);

    executeRequest("write", SERVER_PORT_1, cookieStore);

    instance1.stop();

    HazelcastInstance hzInstance1 = Hazelcast.getHazelcastInstanceByName("hzInstance1");
    if (hzInstance1 != null) {
        hzInstance1.shutdown();
    }

    value = executeRequest("read", SERVER_PORT_2, cookieStore);
    assertEquals("value", value);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-tomcat-sessionmanager,代碼行數:19,代碼來源:AbstractStickySessionsTest.java

示例7: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("uaa");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("uaa");
    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.uaa.domain.*", initializeDomainMapConfig(jHipsterProperties));
    // Uncomment if session needed
    //config.getMapConfigs().put("clustered-http-sessions", initializeClusteredSession(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:28,代碼來源:CacheConfiguration.java

示例8: getStatistics

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Override
protected CacheStatistics[] getStatistics() {
    final List<CacheStatistics> statsList = new ArrayList<>();
    final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
    LOGGER.debug("Locating hazelcast instance [{}]...", hz.getCluster().getInstanceName());
    final HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(hz.getCluster().getInstanceName());

    instance.getConfig().getMapConfigs().keySet().forEach(key -> {
        final IMap map = instance.getMap(key);
        LOGGER.debug("Starting to collect hazelcast statistics for map [{}] identified by key [{}]...", map, key);
        statsList.add(new HazelcastStatistics(map, hz.getCluster().getMembers().size()));
    });
    return statsList.toArray(new CacheStatistics[statsList.size()]);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:15,代碼來源:HazelcastMonitor.java

示例9: fillModel

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
    HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(INSTANCE_NAME);
    if (instance != null) {
        IMap<String, byte[]> taskCache = instance.getMap(TASK_CACHE_NAME);
        LocalMapStats statistics = taskCache.getLocalMapStats();
        model.put("statistics", statistics);
    }
}
 
開發者ID:rodm,項目名稱:teamcity-gradle-build-cache-plugin,代碼行數:9,代碼來源:BuildCachePage.java

示例10: hazelcastInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Bean
public HazelcastInstance hazelcastInstance(MessageServerConfig serverConfig) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance =
            Hazelcast.getHazelcastInstanceByName("message-server");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("message-server");
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    if (this.registration == null) {
        log.warn("No discovery service is set up, Hazelcast cannot create a cluster.");
    } else {
        // The serviceId is by default the application's name, see Spring Boot's
        // eureka.instance.appname property
        String serviceId = registration.getServiceId();
        log.debug("Configuring Hazelcast clustering for instanceId: {}", serviceId);
        config.getNetworkConfig().setPort(5701);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
        for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
            String clusterMember = instance.getHost() + ":5701";
            log.debug("Adding Hazelcast (prod) cluster member " + clusterMember);
            config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
        }
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.blt.talk.domain.*",
            initializeDomainMapConfig(serverConfig));
    return Hazelcast.newHazelcastInstance(config);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:33,代碼來源:HazelCastConfigration.java

示例11: SiddhiManager

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
public SiddhiManager(SiddhiConfiguration siddhiConfiguration) {

        if (siddhiConfiguration.isDistributedProcessing()) {
            HazelcastInstance hazelcastInstance = Hazelcast.getHazelcastInstanceByName(siddhiConfiguration.getInstanceIdentifier());
            if (hazelcastInstance == null) {
                this.siddhiContext = new SiddhiContext(siddhiConfiguration.getQueryPlanIdentifier(), SiddhiContext.ProcessingState.ENABLE_INTERNAL);
                Config hazelcastConf = new Config();
                //hazelcastConf.setProperty("hazelcast.logging.type", "log4j");

                hazelcastConf.setConfigurationFile(new File("/opt/rb/etc/rb-bi/siddhi-hazelcast.xml"));
                //hazelcastConf.getGroupConfig().setName(siddhiConfiguration.getQueryPlanIdentifier());
                //hazelcastConf.setInstanceName(siddhiConfiguration.getInstanceIdentifier());
                hazelcastInstance = Hazelcast.newHazelcastInstance(hazelcastConf);
            } else {
                this.siddhiContext = new SiddhiContext(siddhiConfiguration.getQueryPlanIdentifier(), SiddhiContext.ProcessingState.ENABLE_EXTERNAL);
            }
            siddhiContext.setHazelcastInstance(hazelcastInstance);
            siddhiContext.setGlobalIndexGenerator(new GlobalIndexGenerator(siddhiContext));
        } else {
            this.siddhiContext = new SiddhiContext(siddhiConfiguration.getQueryPlanIdentifier(), SiddhiContext.ProcessingState.DISABLED);
        }

        this.siddhiContext.setEventBatchSize(siddhiConfiguration.getEventBatchSize());
        this.siddhiContext.setAsyncProcessing(siddhiConfiguration.isAsyncProcessing());
        this.siddhiContext.setSiddhiExtensions(siddhiConfiguration.getSiddhiExtensions());
        this.siddhiContext.setThreadBarrier(new ThreadBarrier());
        this.siddhiContext.setThreadPoolExecutor(new ThreadPoolExecutor(siddhiConfiguration.getThreadExecutorCorePoolSize(),
                siddhiConfiguration.getThreadExecutorMaxPoolSize(),
                50,
                TimeUnit.MICROSECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new SiddhiThreadFactory("Executor")));
        this.siddhiContext.setScheduledExecutorService(Executors.newScheduledThreadPool(siddhiConfiguration.getThreadSchedulerCorePoolSize(), new SiddhiThreadFactory("Scheduler")));
        this.siddhiContext.setSnapshotService(new SnapshotService(siddhiContext));
        this.siddhiContext.setPersistenceService(new PersistenceService(siddhiContext));
        this.siddhiContext.setEventMonitorService(new EventMonitorService(siddhiContext));


    }
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:40,代碼來源:SiddhiManager.java

示例12: destroy

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
/**
 * Destroys currently allocated instance.
 */
public void destroy() {
    log.info("Shutting down Hazelcast instance [{}]..", hcInstanceName);
    final HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(
            hcInstanceName);
    if (instance != null) {
        instance.shutdown();
    }
}
 
開發者ID:summerDp,項目名稱:dpCms,代碼行數:12,代碼來源:HazelcastSessionDao.java

示例13: loadInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Override
public HazelcastInstance loadInstance() throws CacheException {
    if (existingInstanceName != null) {
        instance = Hazelcast.getHazelcastInstanceByName(existingInstanceName);
        if (instance == null) {
            throw new CacheException("No instance with name [" + existingInstanceName + "] could be found.");
        }
    } else  {
        instance = Hazelcast.newHazelcastInstance(config);
    }
    return instance;
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate5,代碼行數:13,代碼來源:HazelcastInstanceLoader.java

示例14: loadExistingInstance

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
private static HazelcastInstance loadExistingInstance(ClusteredSessionService sessionService, String instanceName)
        throws ServletException {

    LOGGER.info("Using existing Hazelcast instance with name [" + instanceName + "] for session replication");
    HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(instanceName);
    if (instance == null) {
        throw new ServletException("Hazelcast instance with name [" + instanceName + "] could not be found.");
    }
    instance.getLifecycleService().addLifecycleListener(new ClientLifecycleListener(sessionService));
    return instance;
}
 
開發者ID:hazelcast,項目名稱:hazelcast-wm,代碼行數:12,代碼來源:HazelcastInstanceLoader.java

示例15: lifecycleEvent

import com.hazelcast.core.Hazelcast; //導入方法依賴的package包/類
@Override
public void lifecycleEvent(LifecycleEvent event) {
    String shutdown = System.getProperty("hazelcast.tomcat.shutdown_hazelcast_instance");
    if (getConfigLocation() == null) {
        setConfigLocation("hazelcast-default.xml");
    }

    if ("start".equals(event.getType())) {
        try {
            config = ConfigLoader.load(getConfigLocation());
        } catch (IOException e) {
            throw new RuntimeException("failed to load Config:", e);
        }

        if (config == null) {
            throw new RuntimeException("failed to find configLocation:" + getConfigLocation());
        }
        if (config.getInstanceName() == null) {
            config.setInstanceName(SessionManager.DEFAULT_INSTANCE_NAME);
        }
        Hazelcast.getOrCreateHazelcastInstance(config);
    } else if ("stop".equals(event.getType()) && !"false".equals(shutdown)) {
        HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(SessionManager.DEFAULT_INSTANCE_NAME);
        if (instance != null) {
            instance.shutdown();
        }
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-tomcat-sessionmanager,代碼行數:29,代碼來源:P2PLifecycleListener.java


注:本文中的com.hazelcast.core.Hazelcast.getHazelcastInstanceByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。