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


Java Shell.isJava7OrAbove方法代码示例

本文整理汇总了Java中org.apache.hadoop.util.Shell.isJava7OrAbove方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.isJava7OrAbove方法的具体用法?Java Shell.isJava7OrAbove怎么用?Java Shell.isJava7OrAbove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.util.Shell的用法示例。


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

示例1: link

import org.apache.hadoop.util.Shell; //导入方法依赖的package包/类
@Override
protected void link(Path src, Path dst) throws IOException {
  File srcFile = new File(src.toUri().getPath());
  String srcFileStr = srcFile.getPath();
  String dstFileStr = new File(dst.toString()).getPath();
  // If not on Java7+ on Windows, then copy file instead of symlinking.
  // See also FileUtil#symLink for full explanation.
  if (!Shell.isJava7OrAbove() && srcFile.isFile()) {
    lineWithLenCheck(String.format("@copy \"%s\" \"%s\"", srcFileStr, dstFileStr));
    errorCheck();
  } else {
    lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"", Shell.WINUTILS,
      dstFileStr, srcFileStr));
    errorCheck();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ContainerLaunch.java

示例2: testSymlinkLength

import org.apache.hadoop.util.Shell; //导入方法依赖的package包/类
/**
 * Test that length on a symlink works as expected.
 */
@Test (timeout = 30000)
public void testSymlinkLength() throws Exception {
  Assert.assertFalse(del.exists());
  del.mkdirs();

  byte[] data = "testSymLinkData".getBytes();

  File file = new File(del, FILE);
  File link = new File(del, "_link");

  // write some data to the file
  FileOutputStream os = new FileOutputStream(file);
  os.write(data);
  os.close();

  Assert.assertEquals(0, link.length());

  // create the symlink
  FileUtil.symLink(file.getAbsolutePath(), link.getAbsolutePath());

  // ensure that File#length returns the target file and link size
  Assert.assertEquals(data.length, file.length());
  Assert.assertEquals(data.length, link.length());

  file.delete();
  Assert.assertFalse(file.exists());

  if (Shell.WINDOWS && !Shell.isJava7OrAbove()) {
    // On Java6 on Windows, we copied the file
    Assert.assertEquals(data.length, link.length());
  } else {
    // Otherwise, the target file size is zero
    Assert.assertEquals(0, link.length());
  }

  link.delete();
  Assert.assertFalse(link.exists());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:TestFileUtil.java

示例3: emulatingSymlinksOnWindows

import org.apache.hadoop.util.Shell; //导入方法依赖的package包/类
@Override
protected boolean emulatingSymlinksOnWindows() {
  // Java 6 on Windows has very poor symlink support. Specifically
  // Specifically File#length and File#renameTo do not work as expected.
  // (see HADOOP-9061 for additional details)
  // Hence some symlink tests will be skipped.
  //
  return (Shell.WINDOWS && !Shell.isJava7OrAbove());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestSymlinkLocalFS.java


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