當前位置: 首頁>>代碼示例>>Java>>正文


Java FileStatus.getAccessTime方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:BaseTestHttpFSWith.java

示例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);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:16,代碼來源:S3FileSystem.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:59,代碼來源:ShowFileHandler.java

示例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;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:59,代碼來源:ShowFileHandler.java

示例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();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:TestHFileCleaner.java


注:本文中的org.apache.hadoop.fs.FileStatus.getAccessTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。