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

项目:reactive-data    文件:HazelcastInstanceProxy.java   
void addMapConfig(Class<?> c)
{
  if(!c.isAnnotationPresent(HzMapConfig.class))
    throw new IllegalArgumentException(c+" not annotated with @"+HzMapConfig.class.getSimpleName());

  HzMapConfig hc = c.getAnnotation(HzMapConfig.class);
   MapConfig mapC = new MapConfig(hc.name());
   if(hzConfig.getMapConfigs().containsKey(hc.name()))
   {
     mapC = hzConfig.getMapConfig(hc.name());
   }

   mapC.setAsyncBackupCount(hc.asyncBackupCount());
   mapC.setBackupCount(hc.backupCount());
   mapC.setEvictionPercentage(hc.evictPercentage());
   mapC.setEvictionPolicy(EvictionPolicy.valueOf(hc.evictPolicy()));
   mapC.setInMemoryFormat(InMemoryFormat.valueOf(hc.inMemoryFormat()));
   mapC.setMaxIdleSeconds(hc.idleSeconds());
   mapC.setMergePolicy(hc.evictPolicy());
   mapC.setMinEvictionCheckMillis(hc.evictCheckMillis());
   mapC.setTimeToLiveSeconds(hc.ttlSeconds());
   mapC.setMaxSizeConfig(new MaxSizeConfig(hc.maxSize(), MaxSizePolicy.valueOf(hc.maxSizePolicy())));
   mapC.setStatisticsEnabled(hc.statisticsOn());

   hzConfig.getMapConfigs().put(mapC.getName(), mapC);
}
项目:hazelcast-demo    文件:StaticMapConfig.java   
public static void main(String[] args) {
    MapConfig mapConfig = new MapConfig();
    mapConfig.setName("cacheMap")// 设置Map名称
            .setInMemoryFormat(InMemoryFormat.BINARY)// 设置内存格式
            .setBackupCount(1);// 设置副本个数

    mapConfig.getMapStoreConfig()//
            .setWriteDelaySeconds(60)//
            .setWriteBatchSize(1000);// 设置缓存格式

    mapConfig.addMapIndexConfig(new MapIndexConfig().setAttribute("id").setOrdered(true));// 增加索引
    mapConfig.addMapIndexConfig(new MapIndexConfig().setAttribute("name").setOrdered(true));
}
项目:hazelcast-rest    文件:HazelcastMapServlet.java   
public void createBucket(String map, int ttl, int backups, int mib)
        throws IOException
{
    if (bucketCreation.containsKey(map)) {
        throw new FileAlreadyExistsException(null, null,
                "Bucket already exists: " + map);
    }

    Map<String, MapConfig> mapConfigs = hazelcast.getConfig()
            .getMapConfigs();
    MapConfig config = new MapConfig(map);
    config.setTimeToLiveSeconds(ttl);
    config.setEvictionPolicy(EvictionPolicy.LRU);
    config.setInMemoryFormat(InMemoryFormat.BINARY);
    config.setBackupCount(backups);

    int nodes = hazelcast.getCluster().getMembers().size();
    MaxSizeConfig max = new MaxSizeConfig(mib / nodes,
            MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE);
    config.setMaxSizeConfig(max);
    mapConfigs.put(map, config);

    // pre-fill local map configuration timestamp...
    bucketCreation.putIfAbsent(map, System.currentTimeMillis());

    // this should always be the first call to the map...
    hazelcast.getMap(map);
}
项目:eet.osslite.cz    文件:HazelcastConfiguration.java   
private void setCacheConfig(Config config, String name, int timeToLive) {
    HotRestartConfig hotRestart = new HotRestartConfig();
    hotRestart.setEnabled(true);
    config.getMapConfig(name)//
            .setTimeToLiveSeconds(timeToLive)//
            .setMaxIdleSeconds(timeToLive)//
            .setEvictionPolicy(EvictionPolicy.LRU)//
            .setMaxSizeConfig(new MaxSizeConfig(5000, MaxSizePolicy.PER_NODE))//
            .setBackupCount(1)//
            .setHotRestartConfig(hotRestart)//
            .setInMemoryFormat(InMemoryFormat.BINARY)//
            .setStatisticsEnabled(true)//
    // .setWanReplicationRef(null)//
    ;
}
项目:bagri    文件:DocumentManagementImpl.java   
public void setRepository(SchemaRepositoryImpl repo) {
    this.repo = repo;
    this.factory = repo.getFactory();
    //this.model = repo.getModelManagement();
    this.txManager = (TransactionManagementImpl) repo.getTxManagement();
    this.triggerManager = (TriggerManagementImpl) repo.getTriggerManagement();
    binaryDocs = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_DOCUMENT).getInMemoryFormat();
    binaryElts = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_ELEMENT).getInMemoryFormat();
    binaryContent = InMemoryFormat.BINARY == repo.getHzInstance().getConfig().getMapConfig(CN_XDM_CONTENT).getInMemoryFormat();

    //keyCache = repo.getHzInstance().getMap(CN_XDM_KEY);
}
项目:spring-boot-admin    文件:AdminApplicationHazelcastTest.java   
@Bean
public Config hazelcastConfig() {
    Config config = new Config();
    config.addMapConfig(new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
                                                                      .setBackupCount(1)
                                                                      .setEvictionPolicy(EvictionPolicy.NONE));

    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.setMembers(singletonList("127.0.0.1"));
    return config;
}
项目:foxtrot    文件:DistributedCache.java   
public static void setupConfig(HazelcastConnection hazelcastConnection) {
    MapConfig mapConfig = hazelcastConnection.getHazelcastConfig().getMapConfig(NAME_PREFIX + "*");
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setTimeToLiveSeconds(10);
    mapConfig.setMaxIdleSeconds(10);
    mapConfig.setBackupCount(0);
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setTimeToLiveSeconds(10);
    nearCacheConfig.setInvalidateOnChange(true);
    nearCacheConfig.setMaxIdleSeconds(10);
    mapConfig.setNearCacheConfig(nearCacheConfig);
}
项目:apgas    文件:Transport.java   
/**
 * 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);
}