Search in sources :

Example 1 with MasterContext

use of alluxio.master.MasterContext in project alluxio by Alluxio.

the class BackupCommandStateLockingIntegrationTest method timeoutWhenStateLockAcquired.

@Test
public void timeoutWhenStateLockAcquired() throws Exception {
    // Grab the master state-lock-manager via reflection.
    MasterProcess masterProcess = Whitebox.getInternalState(mLocalAlluxioCluster.getLocalAlluxioMaster(), "mMasterProcess");
    MasterContext masterCtx = Whitebox.getInternalState(masterProcess, "mContext");
    StateLockManager stateLockManager = masterCtx.getStateLockManager();
    // Lock the state-change lock on the master before initiating the backup.
    try (LockResource lr = stateLockManager.lockExclusive(StateLockOptions.defaults())) {
        // Prepare for a backup.
        Path dir = Paths.get(ServerConfiguration.getString(PropertyKey.MASTER_BACKUP_DIRECTORY));
        Files.createDirectories(dir);
        assertEquals(0, Files.list(dir).count());
        // Initiate backup. It should fail.
        int errCode = mFsAdminShell.run("backup");
        assertTrue(mOutput.toString().contains(ExceptionMessage.STATE_LOCK_TIMED_OUT.getMessage(3000)));
        assertNotEquals(0, errCode);
    }
}
Also used : Path(java.nio.file.Path) LockResource(alluxio.resource.LockResource) StateLockManager(alluxio.master.StateLockManager) MasterProcess(alluxio.master.MasterProcess) MasterContext(alluxio.master.MasterContext) Test(org.junit.Test)

Example 2 with MasterContext

use of alluxio.master.MasterContext in project alluxio by Alluxio.

the class JobMasterTest method before.

@Before
public void before() throws Exception {
    // Can't use ConfigurationRule due to conflicts with PowerMock.
    ServerConfiguration.set(PropertyKey.JOB_MASTER_JOB_CAPACITY, TEST_JOB_MASTER_JOB_CAPACITY);
    mJobMaster = new JobMaster(new MasterContext<>(new NoopJournalSystem(), new NoopUfsManager()), mock(FileSystem.class), mock(FileSystemContext.class), mock(UfsManager.class));
    mJobMaster.start(true);
}
Also used : NoopUfsManager(alluxio.master.NoopUfsManager) MasterContext(alluxio.master.MasterContext) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) Before(org.junit.Before)

Example 3 with MasterContext

use of alluxio.master.MasterContext in project alluxio by Alluxio.

the class BackupCommandStateLockingIntegrationTest method takeBackupDuringExclusiveOnlyPhase.

@Test
public void takeBackupDuringExclusiveOnlyPhase() throws Exception {
    // Grab the master state-lock-manager via reflection.
    MasterProcess masterProcess = Whitebox.getInternalState(mLocalAlluxioCluster.getLocalAlluxioMaster(), "mMasterProcess");
    MasterContext masterCtx = Whitebox.getInternalState(masterProcess, "mContext");
    StateLockManager stateLockManager = masterCtx.getStateLockManager();
    // Activate exclusive-only phase via reflection.
    // Cannot make via cluster property due to lack of support from test utilities.
    long exclusiveOnlyDurationMs = 30000;
    Whitebox.setInternalState(stateLockManager, "mExclusiveOnlyDeadlineMs", System.currentTimeMillis() + exclusiveOnlyDurationMs);
    try {
        // getStatus() should fail during exclusive-only phase.
        mException.expect(AlluxioException.class);
        mLocalAlluxioCluster.getClient().getStatus(new AlluxioURI("/"));
        // Prepare for a backup.
        Path dir = Paths.get(ServerConfiguration.getString(PropertyKey.MASTER_BACKUP_DIRECTORY));
        Files.createDirectories(dir);
        assertEquals(0, Files.list(dir).count());
        // Take the backup. It should be allowed.
        int errCode = mFsAdminShell.run("backup");
        assertEquals("", mErrOutput.toString());
        assertEquals(0, errCode);
        assertEquals(1, Files.list(dir).count());
    } finally {
        // Reset exclusive-only phase.
        Whitebox.setInternalState(stateLockManager, "mExclusiveOnlyDeadlineMs", -1);
    }
}
Also used : Path(java.nio.file.Path) StateLockManager(alluxio.master.StateLockManager) MasterProcess(alluxio.master.MasterProcess) MasterContext(alluxio.master.MasterContext) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

MasterContext (alluxio.master.MasterContext)3 MasterProcess (alluxio.master.MasterProcess)2 StateLockManager (alluxio.master.StateLockManager)2 Path (java.nio.file.Path)2 Test (org.junit.Test)2 AlluxioURI (alluxio.AlluxioURI)1 NoopUfsManager (alluxio.master.NoopUfsManager)1 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)1 LockResource (alluxio.resource.LockResource)1 Before (org.junit.Before)1