• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SwiftUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: uploadFilePartAttempt

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private long uploadFilePartAttempt(int attempt) throws IOException {
  long uploadLen = backupFile.length();
  SwiftUtils.debug(LOG, "Uploading part %d of file %s;" +
                        " localfile=%s of length %d  - attempt %d",
                   partNumber,
                   key,
                   backupFile,
                   uploadLen,
                   attempt);
  nativeStore.uploadFilePart(new Path(key),
                             partNumber,
                             new FileInputStream(backupFile),
                             uploadLen);
  return uploadLen;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:SwiftNativeOutputStream.java


示例2: read

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@Override
public synchronized int read(byte[] b, int off, int len) throws IOException {
  SwiftUtils.debug(LOG, "read(buffer, %d, %d)", off, len);
  SwiftUtils.validateReadArgs(b, off, len);
  int result = -1;
  try {
    verifyOpen();
    result = httpStream.read(b, off, len);
  } catch (IOException e) {
    //other IO problems are viewed as transient and re-attempted
    LOG.info("Received IOException while reading '" + path +
             "', attempting to reopen: " + e);
    LOG.debug("IOE on read()" + e, e);
    if (reopenBuffer()) {
      result = httpStream.read(b, off, len);
    }
  }
  if (result > 0) {
    incPos(result);
    if (statistics != null) {
      statistics.incrementBytesRead(result);
    }
  }

  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:SwiftNativeInputStream.java


示例3: uploadFilePart

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
/**
 * Upload part of a larger file.
 *
 * @param path        destination path
 * @param partNumber  item number in the path
 * @param inputStream input data
 * @param length      length of the data
 * @throws IOException on a problem
 */
public void uploadFilePart(Path path, int partNumber,
                           InputStream inputStream, long length)
        throws IOException {

  String stringPath = path.toUri().toString();
  String partitionFilename = SwiftUtils.partitionFilenameFromNumber(
    partNumber);
  if (stringPath.endsWith("/")) {
    stringPath = stringPath.concat(partitionFilename);
  } else {
    stringPath = stringPath.concat("/").concat(partitionFilename);
  }

  swiftRestClient.upload(
    new SwiftObjectPath(toDirPath(path).getContainer(), stringPath),
          inputStream,
          length);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:SwiftNativeFileSystemStore.java


示例4: testDeleteSmallPartitionedFile

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@Test(timeout = SWIFT_BULK_IO_TEST_TIMEOUT)
public void testDeleteSmallPartitionedFile() throws Throwable {
  final Path path = new Path("/test/testDeleteSmallPartitionedFile");

  final int len1 = 1024;
  final byte[] src1 = SwiftTestUtils.dataset(len1, 'A', 'Z');
  SwiftTestUtils.writeDataset(fs, path, src1, len1, 1024, false);
  assertExists("Exists", path);

  Path part_0001 = new Path(path, SwiftUtils.partitionFilenameFromNumber(1));
  Path part_0002 = new Path(path, SwiftUtils.partitionFilenameFromNumber(2));
  String ls = SwiftTestUtils.ls(fs, path);
  assertExists("Partition 0001 Exists in " + ls, part_0001);
  assertPathDoesNotExist("partition 0002 found under " + ls, part_0002);
  assertExists("Partition 0002 Exists in " + ls, part_0001);
  fs.delete(path, false);
  assertPathDoesNotExist("deleted file still there", path);
  ls = SwiftTestUtils.ls(fs, path);
  assertPathDoesNotExist("partition 0001 file still under " + ls, part_0001);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestSwiftFileSystemPartitionedUploads.java


示例5: testDeletePartitionedFile

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@Test(timeout = SWIFT_BULK_IO_TEST_TIMEOUT)
public void testDeletePartitionedFile() throws Throwable {
  final Path path = new Path("/test/testDeletePartitionedFile");

  SwiftTestUtils.writeDataset(fs, path, data, data.length, 1024, false);
  assertExists("Exists", path);

  Path part_0001 = new Path(path, SwiftUtils.partitionFilenameFromNumber(1));
  Path part_0002 = new Path(path, SwiftUtils.partitionFilenameFromNumber(2));
  String ls = SwiftTestUtils.ls(fs, path);
  assertExists("Partition 0001 Exists in " + ls, part_0001);
  assertExists("Partition 0002 Exists in " + ls, part_0001);
  fs.delete(path, false);
  assertPathDoesNotExist("deleted file still there", path);
  ls = SwiftTestUtils.ls(fs, path);
  assertPathDoesNotExist("partition 0001 file still under " + ls, part_0001);
  assertPathDoesNotExist("partition 0002 file still under " + ls, part_0002);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestSwiftFileSystemPartitionedUploads.java


示例6: uploadFilePart

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
/**
 * Upload part of a larger file.
 *
 * @param path        destination path
 * @param partNumber  item number in the path
 * @param inputStream input data
 * @param length      length of the data
 * @throws IOException on a problem
 */
public void uploadFilePart(Path path, int partNumber,
                           InputStream inputStream, long length)
        throws IOException {

  String stringPath = path.toUri().getPath();
  String partitionFilename = SwiftUtils.partitionFilenameFromNumber(
    partNumber);
  if (stringPath.endsWith("/")) {
    stringPath = stringPath.concat(partitionFilename);
  } else {
    stringPath = stringPath.concat("/").concat(partitionFilename);
  }

  swiftRestClient.upload(
    new SwiftObjectPath(toDirPath(path).getContainer(), stringPath),
          inputStream,
          length);
}
 
开发者ID:openstack,项目名称:sahara-extra,代码行数:28,代码来源:SwiftNativeFileSystemStore.java


示例7: deleteObject

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
/**
 * deletes object from Swift
 *
 * @param status FileStatus to delete
 * @return true if the path was deleted by this specific operation.
 * @throws IOException on a failure
 */
public boolean deleteObject(FileStatus status) throws IOException {
  SwiftObjectPath swiftObjectPath;
  if (status.isDir()) {
    swiftObjectPath = toDirPath(status.getPath());
  } else {
    swiftObjectPath = toObjectPath(status.getPath());
  }
  if (!SwiftUtils.isRootDir(swiftObjectPath)) {
    return swiftRestClient.delete(swiftObjectPath);
  } else {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Not deleting root directory entry");
    }
    return true;
  }
}
 
开发者ID:openstack,项目名称:sahara-extra,代码行数:24,代码来源:SwiftNativeFileSystemStore.java


示例8: pathToURI

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
/**
 * Converts Swift path to URI to make request.
 * This is public for unit testing
 *
 * @param path path to object
 * @param endpointURI damain url e.g. http://domain.com
 * @return valid URI for object
 * @throws SwiftException
 */
public static URI pathToURI(SwiftObjectPath path,
                            URI endpointURI) throws SwiftException {
  checkNotNull(endpointURI, "Null Endpoint -client is not authenticated");

  String dataLocationURI = endpointURI.toString();
  try {

    dataLocationURI = SwiftUtils.joinPaths(dataLocationURI, encodeUrl(path.toUriPath()));
    return new URI(dataLocationURI);
  } catch (URISyntaxException e) {
    throw new SwiftException("Failed to create URI from " + dataLocationURI, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:SwiftRestClient.java


示例9: isFile

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@Override
public boolean isFile(Path f) throws IOException {
  try {
    FileStatus fileStatus = getFileStatus(f);
    return !SwiftUtils.isDirectory(fileStatus);
  } catch (FileNotFoundException e) {
    return false;               // f does not exist
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:SwiftNativeFileSystem.java


示例10: isDirectory

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@Override
public boolean isDirectory(Path f) throws IOException {

  try {
    FileStatus fileStatus = getFileStatus(f);
    return SwiftUtils.isDirectory(fileStatus);
  } catch (FileNotFoundException e) {
    return false;               // f does not exist
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:SwiftNativeFileSystem.java


示例11: uploadFileAttempt

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private long uploadFileAttempt(Path keypath, int attempt) throws IOException {
  long uploadLen = backupFile.length();
  SwiftUtils.debug(LOG, "Closing write of file %s;" +
                        " localfile=%s of length %d - attempt %d",
                   key,
                   backupFile,
                   uploadLen,
                   attempt);

  nativeStore.uploadFile(keypath,
                         new FileInputStream(backupFile),
                         uploadLen);
  return uploadLen;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:SwiftNativeOutputStream.java


示例12: delete

import org.apache.hadoop.fs.swift.util.SwiftUtils; //导入依赖的package包/类
private void delete(File file) {
  if (file != null) {
    SwiftUtils.debug(LOG, "deleting %s", file);
    if (!file.delete()) {
      LOG.warn("Could not delete " + file);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:SwiftNativeOutputStream.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TWSDLParserContextImpl类代码示例发布时间:2022-05-23
下一篇:
Java HttpBodyContent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap