java - 在Hadoop中使用BlazingCache开源会降低性能

标签 java performance hadoop

我尝试使用开放源代码BlazingCache http://blazingcache.org/为我的应用程序实现协调器缓存的想法。

因此,我仅使用WordCount示例https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Example:_WordCount_v2.0来测试此缓存库。这是我的整个代码:

public class WordCount2 {

  public static class TokenizerMapper
       extends Mapper<Object, Text, Text, IntWritable>{

    //...
    private static Cache<String, String> cache;
    @Override
    public void setup(Context context) throws IOException,
        InterruptedException {
      //...
      initCache();
    }

    private void initCache() {
         CachingProvider provider = Caching.getCachingProvider();
         Properties properties = new Properties();
         properties.put("blazingcache.mode","clustered");        
         properties.put("blazingcache.zookeeper.connectstring","localhost:1281");
         properties.put("blazingcache.zookeeper.sessiontimeout","40000");        
         properties.put("blazingcache.zookeeper.path","/blazingcache");           
         CacheManager cacheManager = provider.getCacheManager(provider.getDefaultURI(), provider.getDefaultClassLoader(), properties);
         MutableConfiguration<String, String> cacheConfiguration = new MutableConfiguration<>();
         cache = cacheManager.createCache("example", cacheConfiguration);
    }

    @Override
    public void map(Object key, Text value, Context context
                    ) throws IOException, InterruptedException {
        //...
        cache.put(word.toString(), one.toString());
      }
    }
  }

  //...
}

问题在于:
cache.put(word.toString(), one.toString());

在 map 功能中。

当将此行插入代码时,整个作业的性能突然下降。 (我正在使用Eclipse在本地模式下运行WordCount示例)。
为什么会发生这种情况,我该如何解决?

最佳答案

如果您在本地模式(单个JVM)下进行测试,则最好删除这些行,然后重试:

properties.put("blazingcache.mode","clustered");        
properties.put("blazingcache.zookeeper.connectstring","localhost:1281");
properties.put("blazingcache.zookeeper.sessiontimeout","40000");        
properties.put("blazingcache.zookeeper.path","/blazingcache");

关于java - 在Hadoop中使用BlazingCache开源会降低性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37725470/

相关文章:

java - 我收到 HTTPS URL 的 java.io.FileNotFoundException

java - 在单独的文件中保存和加载 iCalendar 事件数据

java - 用辅音计算元音

php - 从数据库表 MYSQL 中选择 2 个随机成员

bash - 如何存储/*url* 的实际名称?

mysql - Sqoop 导入失败,出现 'on clause' 中的未知列

java - 使用Mybatis和不同DB进行集成测试和开发时如何进行集成测试

java - 获取集合子集的策略

c# - 如何在不在 WPF 中创建新的 Point 对象的情况下设置 shape.Position?

hadoop - 资源管理器如何将容器分配给提交的作业?