Search in sources :

Example 36 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class SecondaryMasterTest method secondaryShouldCreateCheckpoints.

@Test
public void secondaryShouldCreateCheckpoints() throws Exception {
    FileSystem fs = mClusterResource.get().getClient();
    // Create a bunch of directories to trigger a checkpoint.
    for (int i = 0; i < 10; i++) {
        fs.createDirectory(new AlluxioURI("/dir" + i));
    }
    IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME);
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 37 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class JournalMigrationIntegrationTest method migration.

@Test
public void migration() throws Exception {
    MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.JOURNAL_MIGRATION).setClusterName("journalMigration").setNumMasters(3).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS.toString()).addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec").build();
    try {
        cluster.start();
        FileSystem fs = cluster.getFileSystemClient();
        MetaMasterClient metaClient = new RetryHandlingMetaMasterClient(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).setMasterInquireClient(cluster.getMasterInquireClient()).build());
        for (int i = 0; i < NUM_DIRS; i++) {
            fs.createDirectory(new AlluxioURI("/dir" + i));
        }
        File backupsDir = AlluxioTestDirectory.createTemporaryDirectory("backups");
        AlluxioURI zkBackup = metaClient.backup(BackupPRequest.newBuilder().setTargetDirectory(backupsDir.getAbsolutePath()).setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()).getBackupUri();
        cluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, zkBackup.toString());
        // Migrate to embedded journal HA.
        cluster.stopMasters();
        cluster.formatJournal();
        cluster.updateDeployMode(DeployMode.EMBEDDED);
        cluster.startMasters();
        assertEquals(NUM_DIRS, fs.listStatus(new AlluxioURI("/")).size());
        // Migrate back to Zookeeper HA.
        cluster.stopMasters();
        cluster.formatJournal();
        cluster.updateDeployMode(DeployMode.ZOOKEEPER_HA);
        cluster.startMasters();
        assertEquals(NUM_DIRS, fs.listStatus(new AlluxioURI("/")).size());
        cluster.notifySuccess();
    } finally {
        cluster.destroy();
    }
}
Also used : RetryHandlingMetaMasterClient(alluxio.client.meta.RetryHandlingMetaMasterClient) MetaMasterClient(alluxio.client.meta.MetaMasterClient) FileSystem(alluxio.client.file.FileSystem) RetryHandlingMetaMasterClient(alluxio.client.meta.RetryHandlingMetaMasterClient) MultiProcessCluster(alluxio.multi.process.MultiProcessCluster) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 38 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class JournalShutdownIntegrationTest method singleMasterJournalStopIntegration.

@Test
public void singleMasterJournalStopIntegration() throws Exception {
    MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.JOURNAL_STOP_SINGLE_MASTER).setClusterName("singleMasterJournalStopIntegration").setNumWorkers(0).setNumMasters(1).build();
    try {
        cluster.start();
        FileSystem fs = cluster.getFileSystemClient();
        runCreateFileThread(fs);
        cluster.waitForAndKillPrimaryMaster(10 * Constants.SECOND_MS);
        awaitClientTermination();
        cluster.startMaster(0);
        int actualFiles = fs.listStatus(new AlluxioURI(TEST_FILE_DIR)).size();
        int successFiles = mCreateFileThread.getSuccessNum();
        assertTrue(String.format("successFiles: %s, actualFiles: %s", successFiles, actualFiles), (successFiles == actualFiles) || (successFiles + 1 == actualFiles));
        cluster.notifySuccess();
    } finally {
        cluster.destroy();
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) SleepingUnderFileSystem(alluxio.testutils.underfs.sleeping.SleepingUnderFileSystem) MultiProcessCluster(alluxio.multi.process.MultiProcessCluster) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 39 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MultiMasterJournalTest method triggerAndWaitForCheckpoint.

private void triggerAndWaitForCheckpoint() throws Exception {
    FileSystem client = mCluster.getClient();
    for (int i = 0; i < 10; i++) {
        client.createFile(new AlluxioURI("/triggerCheckpoint" + i)).close();
    }
    IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME);
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI)

Example 40 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MultiMasterJournalTest method testTtl.

@Test
public void testTtl() throws Exception {
    // Test that ttls are still applied after restart.
    AlluxioURI file = new AlluxioURI("/file");
    mCluster.getClient().createFile(file).close();
    int ttl = 5 * Constants.SECOND_MS;
    mCluster.getClient().setAttribute(file, SetAttributePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl).setTtlAction(TtlAction.DELETE)).build());
    triggerAndWaitForCheckpoint();
    mCluster.restartMasters();
    FileSystem client = mCluster.getClient();
    CommonUtils.waitFor("file to be deleted", () -> {
        try {
            return !client.exists(file);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, WaitForOptions.defaults().setTimeoutMs(30 * Constants.SECOND_MS));
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Aggregations

FileSystem (alluxio.client.file.FileSystem)122 AlluxioURI (alluxio.AlluxioURI)90 Test (org.junit.Test)75 URIStatus (alluxio.client.file.URIStatus)42 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)22 FileInStream (alluxio.client.file.FileInStream)13 IOException (java.io.IOException)12 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)11 ArrayList (java.util.ArrayList)11 FileOutStream (alluxio.client.file.FileOutStream)10 AlluxioException (alluxio.exception.AlluxioException)9 File (java.io.File)9 Path (javax.ws.rs.Path)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)8 HashMap (java.util.HashMap)8 FileSystemContext (alluxio.client.file.FileSystemContext)7 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)6 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)6 TestUserState (alluxio.security.user.TestUserState)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)5