import org.apache.hadoop.fs.FSDataOutputStream; //導入方法依賴的package包/類

/**

* Test that the reorder algo works as we expect.

*/

@Test

public void testBlockLocation() throws Exception {

// We need to start HBase to get HConstants.HBASE_DIR set in conf

htu.startMiniZKCluster();

MiniHBaseCluster hbm = htu.startMiniHBaseCluster(1, 1);

conf = hbm.getConfiguration();

// The "/" is mandatory, without it we've got a null pointer exception on the namenode

final String fileName = "/helloWorld";

Path p = new Path(fileName);

final int repCount = 3;

Assert.assertTrue((short) cluster.getDataNodes().size() >= repCount);

// Let's write the file

FSDataOutputStream fop = dfs.create(p, (short) repCount);

final double toWrite = 875.5613;

fop.writeDouble(toWrite);

fop.close();

for (int i=0; i<10; i++){

// The interceptor is not set in this test, so we get the raw list at this point

LocatedBlocks l;

final long max = System.currentTimeMillis() + 10000;

do {

l = getNamenode(dfs.getClient()).getBlockLocations(fileName, 0, 1);

Assert.assertNotNull(l.getLocatedBlocks());

Assert.assertEquals(l.getLocatedBlocks().size(), 1);

Assert.assertTrue("Expecting " + repCount + " , got " + l.get(0).getLocations().length,

System.currentTimeMillis() < max);

} while (l.get(0).getLocations().length != repCount);

// Should be filtered, the name is different => The order won't change

Object originalList[] = l.getLocatedBlocks().toArray();

HFileSystem.ReorderWALBlocks lrb = new HFileSystem.ReorderWALBlocks();

lrb.reorderBlocks(conf, l, fileName);

Assert.assertArrayEquals(originalList, l.getLocatedBlocks().toArray());

// Should be reordered, as we pretend to be a file name with a compliant stuff

Assert.assertNotNull(conf.get(HConstants.HBASE_DIR));

Assert.assertFalse(conf.get(HConstants.HBASE_DIR).isEmpty());

String pseudoLogFile = conf.get(HConstants.HBASE_DIR) + "/" +

HConstants.HREGION_LOGDIR_NAME + "/" + host1 + ",6977,6576" + "/mylogfile";

// Check that it will be possible to extract a ServerName from our construction

Assert.assertNotNull("log= " + pseudoLogFile,

DefaultWALProvider.getServerNameFromWALDirectoryName(dfs.getConf(), pseudoLogFile));

// And check we're doing the right reorder.

lrb.reorderBlocks(conf, l, pseudoLogFile);

Assert.assertEquals(host1, l.get(0).getLocations()[2].getHostName());

// Check again, it should remain the same.

lrb.reorderBlocks(conf, l, pseudoLogFile);

Assert.assertEquals(host1, l.get(0).getLocations()[2].getHostName());

}

}

java writedouble_Java FSDataOutputStream.writeDouble方法代碼示例相关推荐

  1. java servicefactory_Java DirectoryServiceFactory.getDirectoryService方法代碼示例

    本文整理匯總了Java中org.apache.directory.server.core.factory.DirectoryServiceFactory.getDirectoryService方法的典 ...

  2. java getstringarray_Java AnnotationAttributes.getStringArray方法代碼示例

    本文整理匯總了Java中org.springframework.core.annotation.AnnotationAttributes.getStringArray方法的典型用法代碼示例.如果您正苦 ...

  3. java getselecteditem_Java JComboBox.getSelectedItem方法代碼示例

    本文整理匯總了Java中javax.swing.JComboBox.getSelectedItem方法的典型用法代碼示例.如果您正苦於以下問題:Java JComboBox.getSelectedIt ...

  4. java setlocation_Java Point.setLocation方法代碼示例

    本文整理匯總了Java中java.awt.Point.setLocation方法的典型用法代碼示例.如果您正苦於以下問題:Java Point.setLocation方法的具體用法?Java Poin ...

  5. java setpriority_Java TaskEntity.setPriority方法代碼示例

    本文整理匯總了Java中org.activiti.engine.impl.persistence.entity.TaskEntity.setPriority方法的典型用法代碼示例.如果您正苦於以下問題 ...

  6. java importgeopoint_Java GeoPoint.project方法代碼示例

    本文整理匯總了Java中com.nextgis.maplib.datasource.GeoPoint.project方法的典型用法代碼示例.如果您正苦於以下問題:Java GeoPoint.proje ...

  7. java hssffont_Java HSSFFont.setColor方法代碼示例

    本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFFont.setColor方法的典型用法代碼示例.如果您正苦於以下問題:Java HSSFFont.setC ...

  8. java disconnect_Java BlockingConnection.disconnect方法代碼示例

    本文整理匯總了Java中org.fusesource.mqtt.client.BlockingConnection.disconnect方法的典型用法代碼示例.如果您正苦於以下問題:Java Bloc ...

  9. java dofinal_Java Mac.doFinal方法代碼示例

    本文整理匯總了Java中javax.crypto.Mac.doFinal方法的典型用法代碼示例.如果您正苦於以下問題:Java Mac.doFinal方法的具體用法?Java Mac.doFinal怎 ...

最新文章

  1. pb更新oracle表格,PB自定义retrieve刷新函数、PB导入excel表、打印
  2. 框架:Spring事务的隔离级别
  3. SpiderData 2019年2月22日 DApp数据排行榜
  4. Learn Blockchains by Building One
  5. 多项式快速插值学习小记
  6. 两条信号之间加电容_上海贴片电阻电容厂家地址-华腾电子
  7. Markdown列表
  8. python程序-30分钟学会用Python编写简单程序
  9. MikroTik RouterOS 3.30 安装+免SSH全自动算号+自动注册L6图文全过程
  10. 瑞星:愚人节Conficker蠕虫未在我国爆发
  11. matlab 画光束等相面,拉盖尔高斯光束_厄米高斯光束MATLAB仿真 - 范文中心
  12. java输出long最大值_Java调用long的最大值和最小值
  13. 解决zabbix自动发现主机后主机名称是IP地址的问题
  14. HTML5期末大作业:个人网页设计——作家三毛6页(代码质量好) 学生DW网页设计作业源码 web课程设计网页规划与设计
  15. View控件获得焦点,TextView获得焦点(focusable),自定义TextView使得其获得焦点,View的onFocusChange()
  16. 虚拟机vn登陆服务器系统,虚拟机搭建windows服务器
  17. 正点原子stm32F407学习笔记3——蜂鸣器实验
  18. VFB组件:ListBox控件(列表框)
  19. 林大ACM培训day2心得
  20. GB18030与GBK、GB2312字节对照

热门文章

  1. 飞鸽推广的由咪商务微博
  2. 163相册密码破解 - 简单版
  3. BOOT.INI文件的目的[微软提供]
  4. C++工程师面试题大全
  5. 前端进阶必备技能:Vue中如何定制动画效果
  6. ​面试官口述:我是这样面试web前端开发求职者(有干货)
  7. Java制作一个盒子程序_编写一个简单的Java程序,模拟计算器的功能。
  8. mysql 索引 测试_mysql的索引测试
  9. python装饰器_Python基础-装饰器
  10. ftpclient读取服务器文件能获得文件名文件大小0_Spring WEB工程整合使用FTP,ftp文本文件解析入库,文件上传下载