Java 类com.hazelcast.config.ServiceConfig 实例源码

项目:hazelcast-jet    文件:Jet.java   
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()));
}
项目:hazel-local-cache    文件:MainTest.java   
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");

    }
项目:scheduled-executor    文件:MainTest.java   
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);
    }