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


Java SerializerConfig类代码示例

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


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

示例1: createConfig

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
private Config createConfig() {
	Config config;
	try {
		config = new XmlConfigBuilder(Application.class.getClassLoader().getResource(CONFIG_NAME)).build();
	}
	catch (IOException e) {
		logger.error(e.getMessage(), e);
		throw new Error(e);
	}

	config.getSerializationConfig().addDataSerializableFactory(SerializableFactory.ID, new SerializableFactory());

	config.getSerializationConfig().getSerializerConfigs().add(new SerializerConfig().setTypeClass(JsonNode.class)
			.setImplementation(JsonSerializer.makePlain(JsonNode.class)));

	return config;
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:18,代码来源:Hazelcast.java

示例2: testTypedCustomSerializer_configuredBySubclassing

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
@Test
public void testTypedCustomSerializer_configuredBySubclassing() throws Exception {
    String mapName = randomMapName();

    Config config = new Config();
    SerializerConfig serializerConfig = new SerializerConfig();
    serializerConfig.setClass(MySerializer.class);
    serializerConfig.setTypeClass(AnotherNonSerializableObject.class);
    config.getSerializationConfig().getSerializerConfigs().add(serializerConfig);

    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<Integer, AnotherNonSerializableObject> myMap = member.getMap(mapName);

    myMap.put(0, new AnotherNonSerializableObject());
    AnotherNonSerializableObject fromCache = myMap.get(0);

    assertEquals("deserialized", fromCache.name);
}
 
开发者ID:jerrinot,项目名称:subzero,代码行数:19,代码来源:TestCustomerSerializers.java

示例3: addCommandExecutorConfiguration

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
/**
 * Add configuration to the supplied {@link Config} to support the use of a {@link HazelcastCommandExecutor}.
 * @param config The {@link Config} to configure.
 * @return The updated {@link Config}.
 */
public Config addCommandExecutorConfiguration(Config config) {
    SerializerConfig serializerConfig = new SerializerConfig()
            .setImplementation(RemoteCommandSerialiser.using(
                    objectMapper,
                    CommandTypeMatcher.matchingAgainst(typeInfoMap)))
            .setTypeClass(RemoteCommand.class);

    ManagedContext managedContext = CommandProcessingManagedContext
            .processingCommandsWith(dispatchingCommandProcessor);

    config.getSerializationConfig().addSerializerConfig(serializerConfig);

    config.setManagedContext(config.getManagedContext() == null
            ? managedContext
            : CompositeManagedContext.of(managedContext, config.getManagedContext()));

    config.addExecutorConfig(new ExecutorConfig(executorName, threadsPerNode));
    return config;
}
 
开发者ID:opencredo,项目名称:concursus,代码行数:25,代码来源:HazelcastCommandExecutorConfiguration.java

示例4: setupSerializers

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
private void setupSerializers() {
    SerializerConfig scBNode = new SerializerConfig().setImplementation(new BNodeSerializer()).setTypeClass(KiWiAnonResource.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scBNode);

    SerializerConfig scBoolean = new SerializerConfig().setImplementation(new BooleanLiteralSerializer()).setTypeClass(KiWiBooleanLiteral.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scBoolean);

    SerializerConfig scDate = new SerializerConfig().setImplementation(new DateLiteralSerializer()).setTypeClass(KiWiDateLiteral.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scDate);

    SerializerConfig scDouble = new SerializerConfig().setImplementation(new DoubleLiteralSerializer()).setTypeClass(KiWiDoubleLiteral.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scDouble);

    SerializerConfig scInt = new SerializerConfig().setImplementation(new IntLiteralSerializer()).setTypeClass(KiWiIntLiteral.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scInt);

    SerializerConfig scString = new SerializerConfig().setImplementation(new StringLiteralSerializer()).setTypeClass(KiWiStringLiteral.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scString);

    SerializerConfig scTriple = new SerializerConfig().setImplementation(new TripleSerializer()).setTypeClass(KiWiTriple.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scTriple);

    SerializerConfig scUri = new SerializerConfig().setImplementation(new UriSerializer()).setTypeClass(KiWiUriResource.class);
    hcConfiguration.getSerializationConfig().addSerializerConfig(scUri);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:26,代码来源:HazelcastCacheManager.java

示例5: Transport

import com.hazelcast.config.SerializerConfig; //导入依赖的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);
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:75,代码来源:Transport.java

示例6: init

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
private void init() {
checkConfig();

if (usingHazelcast) {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getGroupConfig().setName(hazelcastUser).setPassword(hazelcastPassword);

    for (int i = 0; i < hazelcastServers.length; i++) {
	clientConfig.getNetworkConfig().addAddress(hazelcastServers[i]);
    }
    clientConfig.getSerializationConfig().getSerializerConfigs().add(new SerializerConfig().setTypeClass(MutableRepositoryItemExt.class).setImplementation(new MutableRepositoryItemExtHazelcastSerializer()));
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
    
    itemCache = client.getMap("itemCacheMap");
    //itemCache = new HashMap<String, MutableRepositoryItemExt>(); 
} else if (usingMapDB) {
    MutableRepositoryItemExtMapDBSerializer MutableRepositoryItemExtMapDBSerializer = new MutableRepositoryItemExtMapDBSerializer();
    MutableRepositoryItemExtArrayMapDBSerializer MutableRepositoryItemExtArrayMapDBSerializer = new MutableRepositoryItemExtArrayMapDBSerializer();

    mapDB = DBMaker.newTempFileDB().transactionDisable().asyncWriteEnable().make();
    itemCache = mapDB.createHashMap("itemCacheMap").keySerializer(org.mapdb.Serializer.STRING).valueSerializer(MutableRepositoryItemExtMapDBSerializer).make();
    MutableRepositoryItemExtArrayMapDBSerializer.setItemCache(itemCache);
    queryCache = mapDB.createHashMap("queryCacheMap").keySerializer(org.mapdb.Serializer.STRING).valueSerializer(MutableRepositoryItemExtArrayMapDBSerializer).make();

} else {
    itemCache = new ConcurrentHashMap<String, MutableRepositoryItemExt>();
    queryCache = new ConcurrentHashMap<String, MutableRepositoryItemExt>();
       
   }
   }
 
开发者ID:varelma,项目名称:atg-generics,代码行数:31,代码来源:GenericsRepository.java

示例7: useForClasses

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
/**
 * Use SubZero as a serializer for selected classes only.
 *
 * @param config Hazelcast configuration to inject SubZero into
 * @param classes classes Hazelcast should serialize via SubZero
 * @return Hazelcast configuration
 */
public static Config useForClasses(Config config, Class<?>...classes) {
    SerializationConfig serializationConfig = config.getSerializationConfig();
    for (Class<?> clazz : classes) {
        SerializerConfig serializerConfig = new SerializerConfig();
        Serializer<?> serializer = new Serializer(clazz);
        serializerConfig.setImplementation(serializer);
        serializerConfig.setTypeClass(clazz);
        serializationConfig.addSerializerConfig(serializerConfig);
    }
    return config;
}
 
开发者ID:jerrinot,项目名称:subzero,代码行数:19,代码来源:SubZero.java

示例8: useForClasses

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
@Test
public void useForClasses() {
    Config config = new Config();
    SubZero.useForClasses(config, String.class);

    Collection<SerializerConfig> serializerConfigs = config.getSerializationConfig().getSerializerConfigs();
    assertThat(serializerConfigs)
            .extracting("typeClass")
            .contains(String.class);
}
 
开发者ID:jerrinot,项目名称:subzero,代码行数:11,代码来源:SubZeroTest.java

示例9: createTypedConfig

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
private Config createTypedConfig() {
    Config config = new Config();

    SerializerConfig serializerConfig = new SerializerConfig()
            .setTypeClassName("info.jerrinot.subzero.it.Person")
            .setClassName("info.jerrinot.subzero.Serializer");

    SerializationConfig serializationConfig = config.getSerializationConfig();
    serializationConfig.addSerializerConfig(serializerConfig);

    return config;
}
 
开发者ID:jerrinot,项目名称:subzero,代码行数:13,代码来源:BaseSmokeTests.java

示例10: TypesafeHazelcastConfig

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
/**
 * @param name Hazelcast instance name
 * @param config TypeSafe typeSafeConfig
 * @param serializerConfigs can be empty
 */
public TypesafeHazelcastConfig(@NonNull final String name, @NonNull final com.typesafe.config.Config config, @NonNull final Set<SerializerConfig> serializerConfigs) {
    this.hazelcastConfig = createHazelcastConfig(
            name,
            config,
            serializerConfigs.isEmpty() ? Optional.empty() : Optional.of(ImmutableSet.copyOf(serializerConfigs))
    );
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:13,代码来源:TypesafeHazelcastConfig.java

示例11: testHazelcastConfigFactory_withSerializers

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
/**
 * Test of hazelcastConfigFactory method, of class HazelcastConfigFactory.
 */
@Test
public void testHazelcastConfigFactory_withSerializers() {
    LOG.info("hazelcastConfigFactory");
    String hazelcastInstanceName = "testHazelcastConfigFactory_withSerializers";
    final Set<SerializerConfig> serializerConfigs = ImmutableSet.of(
            new SerializerConfig().setImplementation(new JsonObjectSerializer()).setTypeClass(JsonObject.class)
    );
    final HazelcastConfigFactory factory1 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 1, serializerConfigs);
    final com.hazelcast.config.Config hazelcastConfig1 = factory1.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-1")));
    final HazelcastInstance hazelcast1 = Hazelcast.newHazelcastInstance(hazelcastConfig1);

    final HazelcastConfigFactory factory2 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 2, serializerConfigs);
    final com.hazelcast.config.Config hazelcastConfig2 = factory2.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-2")));
    final HazelcastInstance hazelcast2 = Hazelcast.newHazelcastInstance(hazelcastConfig2);

    test(hazelcast1, hazelcast2);

    final JsonObject json = Json.createObjectBuilder().add("a", 1).build();
    final String mapName = "testHazelcastConfigFactory_withSerializers_map";
    final Map<String, Object> map1 = hazelcast1.getMap(mapName);
    map1.put("json", json);

    final Map<String, Object> map2 = hazelcast2.getMap(mapName);
    final JsonObject json2 = (JsonObject) map2.get("json");
    assertThat(json2.getInt("a"), is(1));
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:30,代码来源:HazelcastConfigFactoryTest.java

示例12: createHazelcastInstance

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
private HazelcastInstance createHazelcastInstance() {
    ClientConfig config = new ClientConfig();
    config.getNetworkConfig().addAddress("localhost" + ":" + 5701);
    config.getGroupConfig().setName("distribution-app");
    final SerializerConfig dolphinEventSerializerConfig = new SerializerConfig().
            setImplementation(new CustomStreamSerializer()).setTypeClass(CustomEventFormat.class);
    config.getSerializationConfig().getSerializerConfigs().add(dolphinEventSerializerConfig);
    return HazelcastClient.newHazelcastClient(config);
}
 
开发者ID:canoo,项目名称:dolphin-platform,代码行数:10,代码来源:ExternalServer.java

示例13: getHazelcastInstance

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
public synchronized HazelcastInstance getHazelcastInstance(HazelcastConfig configuration) {
    if (hazelcastInstance == null) {
        final String serverName = configuration.getServerName();
        final String serverPort = configuration.getServerPort();
        final String groupName = configuration.getGroupName();

        LOG.debug("Hazelcast server name: {}", serverName);
        LOG.debug("Hazelcast server port: {}", serverPort);
        LOG.debug("Hazelcast group name: {}", groupName);

        final ClientConfig clientConfig = new ClientConfig();
        clientConfig.getNetworkConfig().setConnectionAttemptLimit(configuration.getConnectionAttemptLimit());
        clientConfig.getNetworkConfig().setConnectionAttemptPeriod(configuration.getConnectionAttemptPeriod());
        clientConfig.getNetworkConfig().setConnectionTimeout(configuration.getConnectionTimeout());
        clientConfig.getNetworkConfig().addAddress(serverName + ":" + serverPort);
        clientConfig.getGroupConfig().setName(groupName);
        clientConfig.setProperty(LOGGER_PROPERTY_NAME, LOGGER_PROPERTY_SLF4J_TYPE);

        final SerializerConfig dolphinEventSerializerConfig = new SerializerConfig().
                setImplementation(new EventStreamSerializer()).setTypeClass(DolphinEvent.class);

        clientConfig.getSerializationConfig().getSerializerConfigs().add(dolphinEventSerializerConfig);


        hazelcastInstance = HazelcastClient.newHazelcastClient(clientConfig);
    }
    return hazelcastInstance;
}
 
开发者ID:canoo,项目名称:dolphin-platform,代码行数:29,代码来源:DefaultHazelcastProvider.java

示例14: hazelcastInstance

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public HazelcastInstance hazelcastInstance() {
	Config config = new Config();

	int port = SocketUtils.findAvailableTcpPort();

	config.getNetworkConfig()
			.setPort(port);

	System.out.println("Hazelcast port #: " + port);

	SerializerConfig serializer = new SerializerConfig()
			.setImplementation(new ObjectStreamSerializer())
			.setTypeClass(Object.class);

	config.getSerializationConfig()
			.addSerializerConfig(serializer);

	MapAttributeConfig attributeConfig = new MapAttributeConfig()
			.setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
			.setExtractor(PrincipalNameExtractor.class.getName());

	config.getMapConfig(HazelcastSessionRepository.DEFAULT_SESSION_MAP_NAME)
			.addMapAttributeConfig(attributeConfig)
			.addMapIndexConfig(new MapIndexConfig(
					HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false));

	return Hazelcast.newHazelcastInstance(config);
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:30,代码来源:SessionConfig.java

示例15: create

import com.hazelcast.config.SerializerConfig; //导入依赖的package包/类
public Set<SerializerConfig> create() {
	Set<SerializerConfig> set = new HashSet<>();
	int id = 0;
	for (Class<?> c : classes) {
		id = id + 1;
		set.add(new SerializerConfig().setImplementation(new HzGsonSerializer(gson, id, c)).setTypeClass(c));
	}
	setupCustom(set, id);
	return set;
}
 
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:11,代码来源:InventoryItemSerializersConfigFactory.java


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