Search in sources :

Example 31 with FileSystem

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

the class ClusterInitializationIntegrationTest method recoverClusterSuccess.

/**
 * When a user starts a cluster with journal logs, which are generated by previous running
 * cluster owned by the same user, it should succeed.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterSuccess() throws Exception {
    FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
    fs.createFile(new AlluxioURI("/testFile")).close();
    mLocalAlluxioClusterResource.get().stopFS();
    // user alluxio can recover master from journal
    try (FsMasterResource masterResource = MasterTestUtils.createLeaderFileSystemMasterFromJournal()) {
        FileSystemMaster fileSystemMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        AuthenticatedClientUser.set(SUPER_USER);
        assertEquals(SUPER_USER, fileSystemMaster.getFileInfo(new AlluxioURI("/testFile"), GetStatusContext.defaults()).getOwner());
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 32 with FileSystem

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

the class ClusterInitializationIntegrationTest method startCluster.

/**
 * When a user starts a new cluster, an empty root dir is created and owned by the user.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void startCluster() throws Exception {
    FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
    URIStatus status = fs.getStatus(ROOT);
    assertEquals(SUPER_USER, status.getOwner());
    assertEquals(0755, status.getMode());
    assertEquals(0, fs.listStatus(new AlluxioURI("/")).size());
}
Also used : FileSystem(alluxio.client.file.FileSystem) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 33 with FileSystem

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

the class EmbeddedJournalIntegrationTestFaultTolerance method failover.

@Test
public void failover() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_FAILOVER).setClusterName("EmbeddedJournalFaultTolerance_failover").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
    mCluster.start();
    AlluxioURI testDir = new AlluxioURI("/dir");
    FileSystem fs = mCluster.getFileSystemClient();
    fs.createDirectory(testDir);
    mCluster.waitForAndKillPrimaryMaster(MASTER_INDEX_WAIT_TIME);
    assertTrue(fs.exists(testDir));
    mCluster.notifySuccess();
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 34 with FileSystem

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

the class EmbeddedJournalIntegrationTestFaultTolerance method restartStress.

@Test
public void restartStress() throws Throwable {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_RESTART_STRESS).setClusterName("EmbeddedJournalFaultTolerance_restartStress").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
    mCluster.start();
    // Run and verify operations while restarting the cluster multiple times.
    AtomicReference<Throwable> failure = new AtomicReference<>();
    AtomicInteger successes = new AtomicInteger(0);
    FileSystem fs = mCluster.getFileSystemClient();
    List<EmbeddedJournalIntegrationTestFaultTolerance.OperationThread> threads = new ArrayList<>();
    try {
        for (int i = 0; i < 10; i++) {
            EmbeddedJournalIntegrationTestFaultTolerance.OperationThread t = new EmbeddedJournalIntegrationTestFaultTolerance.OperationThread(fs, i, failure, successes);
            t.start();
            threads.add(t);
        }
        for (int i = 0; i < 2; i++) {
            restartMasters();
            successes.set(0);
            CommonUtils.waitFor("11 successes", () -> successes.get() >= 11, WaitForOptions.defaults().setTimeoutMs(RESTART_TIMEOUT_MS));
            if (failure.get() != null) {
                throw failure.get();
            }
        }
    } finally {
        threads.forEach(Thread::interrupt);
        for (Thread t : threads) {
            t.join();
        }
    }
    mCluster.notifySuccess();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FileSystem(alluxio.client.file.FileSystem) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.Test)

Example 35 with FileSystem

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

the class EmbeddedJournalIntegrationTestResizing method resizeCluster.

@Test
public void resizeCluster() throws Exception {
    final int NUM_MASTERS = 5;
    final int NUM_WORKERS = 0;
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_RESIZE).setClusterName("EmbeddedJournalResizing_resizeCluster").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
    mCluster.start();
    assertEquals(5, mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().size());
    AlluxioURI testDir = new AlluxioURI("/" + CommonUtils.randomAlphaNumString(10));
    FileSystem fs = mCluster.getFileSystemClient();
    fs.createDirectory(testDir);
    assertTrue(fs.exists(testDir));
    // Stop 2 masters. Now cluster can't tolerate any loss.
    mCluster.stopMaster(0);
    mCluster.stopMaster(1);
    // Verify cluster is still serving requests.
    assertTrue(fs.exists(testDir));
    waitForQuorumPropertySize(info -> info.getServerState() == QuorumServerState.UNAVAILABLE, 2);
    // Get and verify list of unavailable masters.
    List<NetAddress> unavailableMasters = new LinkedList<>();
    for (QuorumServerInfo serverState : mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList()) {
        if (serverState.getServerState().equals(QuorumServerState.UNAVAILABLE)) {
            unavailableMasters.add(serverState.getServerAddress());
        }
    }
    assertEquals(2, unavailableMasters.size());
    // Remove unavailable masters from quorum.
    for (NetAddress unavailableMasterAddress : unavailableMasters) {
        mCluster.getJournalMasterClientForMaster().removeQuorumServer(unavailableMasterAddress);
    }
    // Verify quorum is down to 3 masters.
    assertEquals(3, mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().size());
    // Validate that cluster can tolerate one more master failure after resizing.
    mCluster.stopMaster(2);
    assertTrue(fs.exists(testDir));
    mCluster.notifySuccess();
}
Also used : FileSystem(alluxio.client.file.FileSystem) QuorumServerInfo(alluxio.grpc.QuorumServerInfo) LinkedList(java.util.LinkedList) AlluxioURI(alluxio.AlluxioURI) NetAddress(alluxio.grpc.NetAddress) MasterNetAddress(alluxio.multi.process.MasterNetAddress) Test(org.junit.Test)

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