Java 类org.apache.hadoop.hdfs.server.common.Storage.StorageDirType 实例源码

项目:hadoop    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:aliyun-oss-hadoop-fs    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:big-c    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-EAR    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-plus    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:FlexMap    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-TCP    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hardfs    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-on-lustre2    文件:FSImageTestUtil.java   
/**
 * Make a mock storage directory that returns some set of file contents.
 * @param type type of storage dir
 * @param previousExists should we mock that the previous/ dir exists?
 * @param fileNames the names of files contained in current/
 */
static StorageDirectory mockStorageDirectory(
    StorageDirType type,
    boolean previousExists,
    String...  fileNames) {
  StorageDirectory sd = mock(StorageDirectory.class);

  doReturn(type).when(sd).getStorageDirType();

  // Version file should always exist
  doReturn(mockFile(true)).when(sd).getVersionFile();
  doReturn(mockFile(true)).when(sd).getRoot();

  // Previous dir optionally exists
  doReturn(mockFile(previousExists))
    .when(sd).getPreviousDir();   

  // Return a mock 'current' directory which has the given paths
  File[] files = new File[fileNames.length];
  for (int i = 0; i < fileNames.length; i++) {
    files[i] = new File(fileNames[i]);
  }

  File mockDir = Mockito.spy(new File("/dir/current"));
  doReturn(files).when(mockDir).listFiles();
  doReturn(mockDir).when(sd).getCurrentDir();


  return sd;
}
项目:hadoop-EAR    文件:FSImage.java   
public Iterator<StorageDirectory> dirIterator(StorageDirType dirType) {
  return storage.dirIterator(dirType);
}