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


Java ServiceConfig類代碼示例

本文整理匯總了Java中com.hazelcast.config.ServiceConfig的典型用法代碼示例。如果您正苦於以下問題:Java ServiceConfig類的具體用法?Java ServiceConfig怎麽用?Java ServiceConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: configureJetService

import com.hazelcast.config.ServiceConfig; //導入依賴的package包/類
static void configureJetService(JetConfig jetConfig) {
    if (!(jetConfig.getHazelcastConfig().getConfigPatternMatcher() instanceof MatchingPointConfigPatternMatcher)) {
        throw new UnsupportedOperationException("Custom config pattern matcher is not supported in Jet");
    }

    jetConfig.getHazelcastConfig().getServicesConfig()
             .addServiceConfig(new ServiceConfig().setEnabled(true)
                                                  .setName(JetService.SERVICE_NAME)
                                                  .setClassName(JetService.class.getName())
                                                  .setConfigObject(jetConfig));

    jetConfig.getHazelcastConfig().addMapConfig(new MapConfig(INTERNAL_JET_OBJECTS_PREFIX + "*")
             .setBackupCount(jetConfig.getInstanceConfig().getBackupCount())
             .setStatisticsEnabled(false)
             .setMergePolicy(IgnoreMergingEntryMapMergePolicy.class.getName()));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:17,代碼來源:Jet.java

示例2: main

import com.hazelcast.config.ServiceConfig; //導入依賴的package包/類
public static void main(String[] args) {

        final ServiceConfig serviceConfig = new ServiceConfig();
        serviceConfig.setEnabled(true);
        serviceConfig.setClassName(LocalCacheService.class.getName());
        serviceConfig.setName(LocalCacheService.SERVICE_NAME);

        final Config config = new Config();
        final ServicesConfig servicesConfig = config.getServicesConfig();
        servicesConfig.addServiceConfig(serviceConfig);

        final HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
        IMap localCache = instance.getDistributedObject(LocalCacheService.SERVICE_NAME, "foo");


        System.err.println("lc: " + localCache);

//        ClientConfig clientConfig = new ClientConfig();
//        ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
//        proxyFactoryConfig.setClassName(ProxyFactory.class.getName());
//        proxyFactoryConfig.setService(LocalCacheService.SERVICE_NAME);
//        clientConfig.addProxyFactoryConfig(proxyFactoryConfig);
//
//        HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
//
//        IQueue clientQ = client.getDistributedObject(LocalCacheService.SERVICE_NAME, "foo");

    }
 
開發者ID:gurbuzali,項目名稱:hazel-local-cache,代碼行數:29,代碼來源:MainTest.java

示例3: main

import com.hazelcast.config.ServiceConfig; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
        final ServiceConfig serviceConfig = new ServiceConfig();
        serviceConfig.setEnabled(true);
        serviceConfig.setClassName(ScheduledExecutorService.class.getName());
        serviceConfig.setName(ScheduledExecutorService.SERVICE_NAME);
        final Config config = new Config();
        final ServicesConfig servicesConfig = config.getServicesConfig();
        servicesConfig.addServiceConfig(serviceConfig);
        SerializationConfig memberSerializationConfig = config.getSerializationConfig();
//        PriorityPortableHook hook = new PriorityPortableHook();
//        memberSerializationConfig.addPortableFactory(PriorityPortableHook.F_ID, hook.createFactory());
        final HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
        IScheduledExecutorService scheduled = instance.getDistributedObject(ScheduledExecutorService.SERVICE_NAME, "foo");
        ScheduledFuture future = scheduled.scheduleAtFixedRate(new MyCallable(), 5, 5, TimeUnit.SECONDS);

        Thread.sleep(23000);

//        ClientConfig clientConfig = new ClientConfig();
//        ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
////        proxyFactoryConfig.setClassName(ProxyFactory.class.getName());
////        proxyFactoryConfig.setService(ScheduledExecutorService.SERVICE_NAME);
//        clientConfig.addProxyFactoryConfig(proxyFactoryConfig);
//        SerializationConfig clientSerializationConfig = clientConfig.getSerializationConfig();
////        clientSerializationConfig.addPortableFactory(PriorityPortableHook.F_ID, hook.createFactory());
//        HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
//        IQueue clientQ = client.getDistributedObject(ScheduledExecutorService.SERVICE_NAME, "foo");
//        clientQ.offer("veli");
//        clientQ.offer("ali");
//        Object ali = memberQ.poll();
//        Object veli = memberQ.poll();
//        System.err.println("ali: " + ali);
//        System.err.println("veli: " + veli);
    }
 
開發者ID:gurbuzali,項目名稱:scheduled-executor,代碼行數:34,代碼來源:MainTest.java


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