本文整理汇总了Java中org.jets3t.service.model.S3Object.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java S3Object.getMetadata方法的具体用法?Java S3Object.getMetadata怎么用?Java S3Object.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jets3t.service.model.S3Object
的用法示例。
在下文中一共展示了S3Object.getMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMetadata
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private void checkMetadata(S3Object object) throws S3FileSystemException,
S3ServiceException {
String name = (String) object.getMetadata(FILE_SYSTEM_NAME);
if (!FILE_SYSTEM_VALUE.equals(name)) {
throw new S3FileSystemException("Not a Hadoop S3 file.");
}
String type = (String) object.getMetadata(FILE_SYSTEM_TYPE_NAME);
if (!FILE_SYSTEM_TYPE_VALUE.equals(type)) {
throw new S3FileSystemException("Not a block file.");
}
String dataVersion = (String) object.getMetadata(FILE_SYSTEM_VERSION_NAME);
if (!FILE_SYSTEM_VERSION_VALUE.equals(dataVersion)) {
throw new VersionMismatchException(FILE_SYSTEM_VERSION_VALUE,
dataVersion);
}
}
示例2: run
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public int run(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("Usage: MigrationTool <S3 file system URI>");
System.err.println("\t<S3 file system URI>\tfilesystem to migrate");
ToolRunner.printGenericCommandUsage(System.err);
return -1;
}
URI uri = URI.create(args[0]);
initialize(uri);
FileSystemStore newStore = new Jets3tFileSystemStore();
newStore.initialize(uri, getConf());
if (get("%2F") != null) {
System.err.println("Current version number is [unversioned].");
System.err.println("Target version number is " +
newStore.getVersion() + ".");
Store oldStore = new UnversionedStore();
migrate(oldStore, newStore);
return 0;
} else {
S3Object root = get("/");
if (root != null) {
String version = (String) root.getMetadata("fs-version");
if (version == null) {
System.err.println("Can't detect version - exiting.");
} else {
String newVersion = newStore.getVersion();
System.err.println("Current version number is " + version + ".");
System.err.println("Target version number is " + newVersion + ".");
if (version.equals(newStore.getVersion())) {
System.err.println("No migration required.");
return 0;
}
// use version number to create Store
//Store oldStore = ...
//migrate(oldStore, newStore);
System.err.println("Not currently implemented.");
return 0;
}
}
System.err.println("Can't detect version - exiting.");
return 0;
}
}
示例3: run
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public int run(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("Usage: MigrationTool <S3 file system URI>");
System.err.println("\t<S3 file system URI>\tfilesystem to migrate");
ToolRunner.printGenericCommandUsage(System.err);
return -1;
}
URI uri = URI.create(args[0]);
initialize(uri);
FileSystemStore newStore = new Jets3tFileSystemStore();
newStore.initialize(uri, getConf());
if (get("%2F") != null) {
System.err.println("Current version number is [unversioned].");
System.err.println("Target version number is " +
newStore.getVersion() + ".");
Store oldStore = new UnversionedStore();
migrate(oldStore, newStore);
return 0;
} else {
S3Object root = get("/");
if (root != null) {
String version = (String) root.getMetadata("fs-version");
if (version == null) {
System.err.println("Can't detect version - exiting.");
} else {
String newVersion = newStore.getVersion();
System.err.println("Current version number is " + version + ".");
System.err.println("Target version number is " + newVersion + ".");
if (version.equals(newStore.getVersion())) {
System.err.println("No migration required.");
return 0;
}
// use version number to create Store
//Store oldStore = ...
//migrate(oldStore, newStore);
System.err.println("Not currently implemented.");
return 0;
}
}
System.err.println("Can't detect version - exiting.");
return 0;
}
}
示例4: createPackageForDownload
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
* Creates a download package representing an S3Object that will be downloaded, and the
* target file the downloaded data will be written to.
* <p>
* Downloaded data may be transformed if the S3Object is encrypted or gzipped and the
* appropriate options are set.
*
* @param object
* the object
* @param fileTarget
* the file to which downloaded (and possibly transformed) data will be written.
* @param automaticUnzip
* if true, gzipped objects will be decrypted on-the-fly as they are downloaded.
* @param automaticDecrypt
* if true, encrypted files will be decrypted on-the-fly as they are downloaded (in which
* case the encryptionPassword must be correct)
* @param encryptionPassword
* the password required to decrypt encrypted objects.
*
* @deprecated 0.8.0 use
* {@link #createPackageForDownload(StorageObject, File, boolean, boolean, String)} instead.
*
* @return
* a download package representing an S3Object and a taret file for the object's data.
* @throws Exception
*/
@Deprecated
public static org.jets3t.service.multithread.DownloadPackage createPackageForDownload(
S3Object object, File fileTarget, boolean automaticUnzip, boolean automaticDecrypt,
String encryptionPassword) throws Exception
{
// Recognize directory place-holder objects and ignore them
if (object.isDirectoryPlaceholder()) {
return null;
}
else {
boolean isZipped = false;
EncryptionUtil encryptionUtil = null;
if (automaticUnzip &&
("gzip".equalsIgnoreCase(object.getContentEncoding())
|| object.containsMetadata(Constants.METADATA_JETS3T_COMPRESSED)))
{
// Object data is gzipped.
isZipped = true;
}
if (automaticDecrypt
&& object.containsMetadata(Constants.METADATA_JETS3T_CRYPTO_ALGORITHM))
{
// Object is encrypted.
if (encryptionPassword == null) {
throw new ServiceException(
"One or more objects are encrypted, and cannot be downloaded unless "
+ " the encyption password is provided");
}
String algorithm = (String) object.getMetadata(
Constants.METADATA_JETS3T_CRYPTO_ALGORITHM);
String version = (String) object.getMetadata(
Constants.METADATA_JETS3T_CRYPTO_VERSION);
if (version == null) {
version = EncryptionUtil.DEFAULT_VERSION;
}
encryptionUtil = new EncryptionUtil(encryptionPassword, algorithm, version);
}
return new org.jets3t.service.multithread.DownloadPackage(
object, fileTarget, isZipped, encryptionUtil);
}
}