本文整理汇总了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;未经允许,请勿转载。 |
请发表评论