@@ -0,0 +1,2696 @@
+/*%0A * Licensed to the University of California, Berkeley under one or more contributor license%0A * agreements. See the NOTICE file distributed with this work for additional information regarding%0A * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance with the License. You may obtain a%0A * copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0Apackage tachyon;%0A%0Aimport org.powermock.reflect.Whitebox;%0A%0Aimport tachyon.util.CommonUtils;%0Aimport tachyon.worker.file.FileDataManager;%0Aimport tachyon.worker.file.FileSystemWorker;%0A%0A/**%0A * Util methods for writing integration tests.%0A */%0Apublic final class IntegrationTestUtils %7B%0A%0A  /**%0A   * Convenience method for calling%0A   * %7B@link #waitForPersist(LocalTachyonClusterResource, long, long)%7D with a timeout of 5%0A   * seconds.%0A   *%0A   * @param localTachyonClusterResource the cluster for the worker that will persist the file%0A   * @param fileId the file id to wait to be persisted%0A   */%0A  public static void waitForPersist(LocalTachyonClusterResource localTachyonClusterResource,%0A      long fileId) %7B%0A    waitForPersist(localTachyonClusterResource, fileId, 5 * Constants.SECOND_MS);%0A  %7D%0A%0A  /**%0A   * Blocks until the specified file is persisted or a timeout occurs.%0A   *%0A   * @param localTachyonClusterResource the cluster for the worker that will persist the file%0A   * @param fileId the file id to wait to be persisted%0A   * @param timeoutMs the number of milliseconds to wait before giving up and throwing an exception%0A   */%0A  public static void waitForPersist(LocalTachyonClusterResource localTachyonClusterResource,%0A      long fileId, int timeoutMs) %7B%0A    long start = System.currentTimeMillis();%0A    FileSystemWorker fileSystemWorker = Whitebox%0A        .getInternalState(localTachyonClusterResource.get().getWorker(), %22mFileSystemWorker%22);%0A    FileDataManager fileDataManager =%0A        Whitebox.getInternalState(fileSystemWorker, %22mFileDataManager%22);%0A    while (!fileDataManager.isFilePersisted(fileId)) %7B%0A      if (System.currentTimeMillis() - start %3E timeoutMs) %7B%0A        throw new RuntimeException(%22Timed out waiting for %22 + fileId + %22 to be persisted%22);%0A      %7D%0A      CommonUtils.sleepMs(20);%0A    %7D%0A  %7D%0A%0A  private IntegrationTestUtils() %7B%7D // This is a utils class not intended for instantiation%0A%7D%0A

Add method for blocking on file persist in tests