Search in sources :

Example 26 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalShutdownIntegrationTest method reproduceAndCheckState.

/**
   * Reproduce the journal and check if the state is correct.
   */
private void reproduceAndCheckState(int successFiles) throws Exception {
    Assert.assertNotEquals(successFiles, 0);
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    int actualFiles = fsMaster.listStatus(new AlluxioURI(TEST_FILE_DIR), ListStatusOptions.defaults()).size();
    Assert.assertTrue((successFiles == actualFiles) || (successFiles + 1 == actualFiles));
    for (int f = 0; f < successFiles; f++) {
        Assert.assertTrue(fsMaster.getFileId(new AlluxioURI(TEST_FILE_DIR + f)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI)

Example 27 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class MasterFaultToleranceIntegrationTest method killStandby.

@Test
public void killStandby() throws Exception {
    // If standby masters are killed(or node failure), current leader should not be affected and the
    // cluster should run properly.
    int leaderIndex = mMultiMasterLocalAlluxioCluster.getLeaderIndex();
    Assert.assertNotEquals(-1, leaderIndex);
    List<Pair<Long, AlluxioURI>> answer = new ArrayList<>();
    for (int k = 0; k < 5; k++) {
        faultTestDataCreation(new AlluxioURI("/data" + k), answer);
    }
    faultTestDataCheck(answer);
    for (int kills = 0; kills < MASTERS - 1; kills++) {
        Assert.assertTrue(mMultiMasterLocalAlluxioCluster.stopStandby());
        CommonUtils.sleepMs(Constants.SECOND_MS * 2);
        // Leader should not change.
        Assert.assertEquals(leaderIndex, mMultiMasterLocalAlluxioCluster.getLeaderIndex());
        // Cluster should still work.
        faultTestDataCheck(answer);
        faultTestDataCreation(new AlluxioURI("/data_kills_" + kills), answer);
    }
}
Also used : ArrayList(java.util.ArrayList) Pair(alluxio.collections.Pair) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 28 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientIntegrationTest method openClose.

@Test
public void openClose() throws AlluxioException, IOException {
    FileSystemMasterClient fsMasterClient = FileSystemMasterClient.Factory.create(mLocalAlluxioClusterResource.get().getMaster().getAddress());
    AlluxioURI file = new AlluxioURI("/file");
    Assert.assertFalse(fsMasterClient.isConnected());
    fsMasterClient.connect();
    Assert.assertTrue(fsMasterClient.isConnected());
    fsMasterClient.createFile(file, CreateFileOptions.defaults());
    Assert.assertNotNull(fsMasterClient.getStatus(file));
    fsMasterClient.disconnect();
    Assert.assertFalse(fsMasterClient.isConnected());
    fsMasterClient.connect();
    Assert.assertTrue(fsMasterClient.isConnected());
    Assert.assertNotNull(fsMasterClient.getStatus(file));
    fsMasterClient.close();
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 29 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientIntegrationTest method masterUnavailable.

@Test(timeout = 300000)
public void masterUnavailable() throws Exception {
    FileSystem fileSystem = mLocalAlluxioClusterResource.get().getClient();
    mLocalAlluxioClusterResource.get().getMaster().stop();
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                Thread.sleep(3000);
                mLocalAlluxioClusterResource.get().getMaster().start();
            } catch (InterruptedException e) {
                throw Throwables.propagate(e);
            }
        }
    });
    thread.start();
    fileSystem.listStatus(new AlluxioURI("/"));
    thread.join();
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 30 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method mountEntryCheckpointTest.

/**
   * Tests the situation where a checkpoint mount entry is replayed by a standby master.
   *
   * @throws Exception on error
   */
@Test
public void mountEntryCheckpointTest() throws Exception {
    final AlluxioURI mountUri = new AlluxioURI("/local_mnt/");
    final AlluxioURI ufsUri = new AlluxioURI(mTestFolder.newFolder("test_ufs").getAbsolutePath());
    // Create a mount point, which will journal a mount entry.
    mFileSystem.mount(mountUri, ufsUri);
    mLocalAlluxioCluster.stopFS();
    // Start a leader master, which will create a new checkpoint, with a mount entry.
    MasterTestUtils.createLeaderFileSystemMasterFromJournal().stop();
    // Start a standby master, which will replay the mount entry from the checkpoint.
    final FileSystemMaster fsMaster = MasterTestUtils.createStandbyFileSystemMasterFromJournal();
    try {
        CommonUtils.waitFor("standby journal checkpoint replay", new Function<Void, Boolean>() {

            @Override
            public Boolean apply(Void input) {
                try {
                    fsMaster.listStatus(mountUri, ListStatusOptions.defaults());
                    return true;
                } catch (Exception e) {
                    return false;
                }
            }
        }, WaitForOptions.defaults().setTimeout(60 * Constants.SECOND_MS));
    } finally {
        fsMaster.stop();
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) InvalidPathException(alluxio.exception.InvalidPathException) IOException(java.io.IOException) AccessControlException(alluxio.exception.AccessControlException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62