本文整理汇总了Java中org.apache.hadoop.fs.FileStatus.getAccessTime方法的典型用法代码示例。如果您正苦于以下问题:Java FileStatus.getAccessTime方法的具体用法?Java FileStatus.getAccessTime怎么用?Java FileStatus.getAccessTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.fs.FileStatus
的用法示例。
在下文中一共展示了FileStatus.getAccessTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetTimes
import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private void testSetTimes() throws Exception {
if (!isLocalFS()) {
FileSystem fs = FileSystem.get(getProxiedFSConf());
Path path = new Path(getProxiedFSTestDir(), "foo.txt");
OutputStream os = fs.create(path);
os.write(1);
os.close();
FileStatus status1 = fs.getFileStatus(path);
fs.close();
long at = status1.getAccessTime();
long mt = status1.getModificationTime();
fs = getHttpFSFileSystem();
fs.setTimes(path, mt - 10, at - 20);
fs.close();
fs = FileSystem.get(getProxiedFSConf());
status1 = fs.getFileStatus(path);
fs.close();
long atNew = status1.getAccessTime();
long mtNew = status1.getModificationTime();
Assert.assertEquals(mtNew, mt - 10);
Assert.assertEquals(atNew, at - 20);
}
}
示例2: transform
import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
private static FileStatus transform(FileStatus input, String bucket) {
String relativePath = removeLeadingSlash(Path.getPathWithoutSchemeAndAuthority(input.getPath()).toString());
Path bucketPath = new Path(Path.SEPARATOR + bucket);
Path fullPath = Strings.isEmpty(relativePath) ? bucketPath : new Path(bucketPath, relativePath);
return new FileStatus(input.getLen(),
input.isDirectory(),
input.getReplication(),
input.getBlockSize(),
input.getModificationTime(),
input.getAccessTime(),
input.getPermission(),
input.getOwner(),
input.getGroup(),
fullPath);
}
示例3: getPlan
import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
SqlIdentifier from = ((SqlShowFiles) sqlNode).getDb();
DrillFileSystem fs = null;
String defaultLocation = null;
String fromDir = "./";
SchemaPlus defaultSchema = context.getNewDefaultSchema();
SchemaPlus drillSchema = defaultSchema;
// Show files can be used without from clause, in which case we display the files in the default schema
if (from != null) {
// We are not sure if the full from clause is just the schema or includes table name,
// first try to see if the full path specified is a schema
drillSchema = SchemaUtilites.findSchema(defaultSchema, from.names);
if (drillSchema == null) {
// Entire from clause is not a schema, try to obtain the schema without the last part of the specified clause.
drillSchema = SchemaUtilites.findSchema(defaultSchema, from.names.subList(0, from.names.size() - 1));
fromDir = fromDir + from.names.get((from.names.size() - 1));
}
if (drillSchema == null) {
throw UserException.validationError()
.message("Invalid FROM/IN clause [%s]", from.toString())
.build(logger);
}
}
WorkspaceSchema wsSchema;
try {
wsSchema = (WorkspaceSchema) drillSchema.unwrap(AbstractSchema.class).getDefaultSchema();
} catch (ClassCastException e) {
throw UserException.validationError()
.message("SHOW FILES is supported in workspace type schema only. Schema [%s] is not a workspace schema.",
SchemaUtilites.getSchemaPath(drillSchema))
.build(logger);
}
// Get the file system object
fs = wsSchema.getFS();
// Get the default path
defaultLocation = wsSchema.getDefaultLocation();
List<ShowFilesCommandResult> rows = new ArrayList<>();
for (FileStatus fileStatus : fs.list(false, new Path(defaultLocation, fromDir))) {
ShowFilesCommandResult result = new ShowFilesCommandResult(fileStatus.getPath().getName(), fileStatus.isDir(),
!fileStatus.isDir(), fileStatus.getLen(),
fileStatus.getOwner(), fileStatus.getGroup(),
fileStatus.getPermission().toString(),
fileStatus.getAccessTime(), fileStatus.getModificationTime());
rows.add(result);
}
return DirectPlan.createDirectPlan(context.getCurrentEndpoint(), rows.iterator(), ShowFilesCommandResult.class);
}
示例4: toResult
import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
@Override
public List<ShowFilesCommandResult> toResult(String sql, SqlNode sqlNode) throws ValidationException, RelConversionException,
IOException, ForemanSetupException {
SqlIdentifier from = ((SqlShowFiles) sqlNode).getDb();
List<ShowFilesCommandResult> rows = new ArrayList<>();
FileSystemWrapper fs = null;
String defaultLocation = null;
String fromDir = "./";
SchemaPlus schemaPlus = defaultSchema;
// Show files can be used without from clause, in which case we display the files in the default schema
if (from != null) {
// We are not sure if the full from clause is just the schema or includes table name,
// first try to see if the full path specified is a schema
schemaPlus = SchemaUtilities.findSchema(defaultSchema, from.names);
if (schemaPlus == null) {
// Entire from clause is not a schema, try to obtain the schema without the last part of the specified clause.
schemaPlus = SchemaUtilities.findSchema(defaultSchema, from.names.subList(0, from.names.size() - 1));
fromDir = fromDir + from.names.get((from.names.size() - 1));
}
if (schemaPlus == null) {
throw UserException.validationError()
.message("Invalid FROM/IN clause [%s]", from.toString())
.build(logger);
}
}
SimpleSchema schema;
try {
schema = schemaPlus.unwrap(SimpleSchema.class);
} catch (ClassCastException e) {
throw UserException.validationError()
.message("SHOW FILES is supported in workspace type schema only. Schema [%s] is not a workspace schema.",
SchemaUtilities.getSchemaPath(schemaPlus))
.build(logger);
}
// Get the file system object
fs = schema.getFileSystem();
// Get the default path
defaultLocation = schema.getDefaultLocation();
for (FileStatus fileStatus : fs.list(new Path(defaultLocation, fromDir), false)) {
ShowFilesCommandResult result = new ShowFilesCommandResult(fileStatus.getPath().getName(), fileStatus.isDir(),
!fileStatus.isDirectory(), fileStatus.getLen(),
fileStatus.getOwner(), fileStatus.getGroup(),
fileStatus.getPermission().toString(),
fileStatus.getAccessTime(), fileStatus.getModificationTime());
rows.add(result);
}
return rows;
}
示例5: getFileStats
import org.apache.hadoop.fs.FileStatus; //导入方法依赖的package包/类
/**
* @param file to check
* @return loggable information about the file
*/
private String getFileStats(Path file, FileSystem fs) throws IOException {
FileStatus status = fs.getFileStatus(file);
return "File" + file + ", mtime:" + status.getModificationTime() + ", atime:"
+ status.getAccessTime();
}