Search in sources :

Example 1 with ExponentialTimer

use of alluxio.time.ExponentialTimer in project alluxio by Alluxio.

the class PersistJobTest method fields.

/**
 * Tests getting and setting fields.
 */
@Test
public void fields() {
    Random random = new Random();
    long jobId = random.nextLong();
    long fileId = random.nextLong();
    AlluxioURI uri = new AlluxioURI(CommonUtils.randomAlphaNumString(random.nextInt(10)));
    String tempUfsPath = CommonUtils.randomAlphaNumString(random.nextInt(10));
    ExponentialTimer timer = new ExponentialTimer(0, 0, 0, 0);
    PersistJob.CancelState cancelState = PersistJob.CancelState.values()[random.nextInt(PersistJob.CancelState.values().length)];
    PersistJob persistJob = new PersistJob(jobId, fileId, uri, tempUfsPath, timer);
    persistJob.setCancelState(cancelState);
    Assert.assertEquals(jobId, persistJob.getId());
    Assert.assertEquals(fileId, persistJob.getFileId());
    Assert.assertEquals(uri, persistJob.getUri());
    Assert.assertEquals(tempUfsPath, persistJob.getTempUfsPath());
    Assert.assertEquals(timer, persistJob.getTimer());
    Assert.assertEquals(cancelState, persistJob.getCancelState());
}
Also used : Random(java.util.Random) ExponentialTimer(alluxio.time.ExponentialTimer) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with ExponentialTimer

use of alluxio.time.ExponentialTimer in project alluxio by Alluxio.

the class PersistenceTest method checkPersistenceRequested.

private void checkPersistenceRequested(AlluxioURI testFile) throws Exception {
    FileInfo fileInfo = mFileSystemMaster.getFileInfo(testFile, GET_STATUS_CONTEXT);
    Map<Long, ExponentialTimer> persistRequests = getPersistRequests();
    Assert.assertEquals(1, persistRequests.size());
    Assert.assertEquals(0, getPersistJobs().size());
    Assert.assertTrue(persistRequests.containsKey(fileInfo.getFileId()));
    Assert.assertEquals(PersistenceState.TO_BE_PERSISTED.toString(), fileInfo.getPersistenceState());
}
Also used : FileInfo(alluxio.wire.FileInfo) ExponentialTimer(alluxio.time.ExponentialTimer)

Example 3 with ExponentialTimer

use of alluxio.time.ExponentialTimer in project alluxio by Alluxio.

the class PersistenceTestUtils method pauseScheduler.

/**
 * A convenience method to pause scheduling persist jobs.
 *
 * @param resource the local cluster resource to pause the service for
 */
public static void pauseScheduler(LocalAlluxioClusterResource resource) {
    FileSystemMaster nestedMaster = getFileSystemMaster(resource);
    Map<Long, ExponentialTimer> persistRequests = Whitebox.getInternalState(nestedMaster, "mPersistRequests");
    Whitebox.setInternalState(nestedMaster, "mPersistRequests", new BlackHoleMap<>(persistRequests));
}
Also used : ExponentialTimer(alluxio.time.ExponentialTimer) FileSystemMaster(alluxio.master.file.FileSystemMaster)

Example 4 with ExponentialTimer

use of alluxio.time.ExponentialTimer in project alluxio by Alluxio.

the class PersistenceTestUtils method resumeScheduler.

/**
 * A convenience method to resume scheduling persist jobs.
 *
 * @param resource the local cluster resource to resume the service for
 */
public static void resumeScheduler(LocalAlluxioClusterResource resource) {
    FileSystemMaster nestedMaster = getFileSystemMaster(resource);
    BlackHoleMap<Long, ExponentialTimer> persistRequests = Whitebox.getInternalState(nestedMaster, "mPersistRequests");
    Whitebox.setInternalState(nestedMaster, "mPersistRequests", persistRequests.getInnerMap());
}
Also used : ExponentialTimer(alluxio.time.ExponentialTimer) FileSystemMaster(alluxio.master.file.FileSystemMaster)

Aggregations

ExponentialTimer (alluxio.time.ExponentialTimer)4 FileSystemMaster (alluxio.master.file.FileSystemMaster)2 AlluxioURI (alluxio.AlluxioURI)1 FileInfo (alluxio.wire.FileInfo)1 Random (java.util.Random)1 Test (org.junit.Test)1