Search in sources :

Example 1 with MetricsMasterClient

use of alluxio.client.metrics.MetricsMasterClient in project alluxio by Alluxio.

the class MultiProcessCheckpointTest method test.

@Test
public void test() throws Exception {
    MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.CHECKPOINT).setClusterName("CheckpointTest").addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS.toString()).addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "2sec").addProperty(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT, "1sec").addProperty(PropertyKey.MASTER_METASTORE, "ROCKS").addProperty(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, "100").addProperty(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, "500").addProperty(PropertyKey.MASTER_JOURNAL_TAILER_SHUTDOWN_QUIET_WAIT_TIME_MS, "500").setNumMasters(2).setNumWorkers(0).build();
    try {
        cluster.start();
        cluster.waitForAllNodesRegistered(20 * Constants.SECOND_MS);
        String journal = cluster.getJournalDir();
        FileSystem fs = cluster.getFileSystemClient();
        int numFiles = 100;
        for (int i = 0; i < numFiles; i++) {
            fs.createFile(new AlluxioURI("/file" + i)).close();
        }
        MetricsMasterClient metricsClient = cluster.getMetricsMasterClient();
        assertEquals(numFiles + 1, (long) metricsClient.getMetrics().get(MetricKey.MASTER_TOTAL_PATHS.getName()).getDoubleValue());
        IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME, new URI(journal));
        cluster.stopMasters();
        cluster.startMasters();
        cluster.waitForAllNodesRegistered(60 * Constants.SECOND_MS);
        fs = cluster.getFileSystemClient();
        assertEquals(numFiles, fs.listStatus(new AlluxioURI("/")).size());
        assertEquals(numFiles + 1, (long) metricsClient.getMetrics().get(MetricKey.MASTER_TOTAL_PATHS.getName()).getDoubleValue());
        cluster.notifySuccess();
    } finally {
        cluster.destroy();
    }
}
Also used : MetricsMasterClient(alluxio.client.metrics.MetricsMasterClient) FileSystem(alluxio.client.file.FileSystem) MultiProcessCluster(alluxio.multi.process.MultiProcessCluster) AlluxioURI(alluxio.AlluxioURI) URI(java.net.URI) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with MetricsMasterClient

use of alluxio.client.metrics.MetricsMasterClient in project alluxio by Alluxio.

the class TriggeredCheckpointTest method createFiles.

/**
 * Creates files in the cluster.
 *
 * @param cluster the cluster inside which to create files
 * @param numFiles num of files to create
 */
private void createFiles(MultiProcessCluster cluster, int numFiles) throws Exception {
    FileSystem fs = cluster.getFileSystemClient();
    for (int i = 0; i < numFiles; i++) {
        fs.createFile(new AlluxioURI("/file" + i)).close();
    }
    MetricsMasterClient metricsMasterClient = cluster.getMetricsMasterClient();
    assertEquals(numFiles + 1, (long) metricsMasterClient.getMetrics().get(MetricKey.MASTER_TOTAL_PATHS.getName()).getDoubleValue());
}
Also used : MetricsMasterClient(alluxio.client.metrics.MetricsMasterClient) FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioURI (alluxio.AlluxioURI)2 FileSystem (alluxio.client.file.FileSystem)2 MetricsMasterClient (alluxio.client.metrics.MetricsMasterClient)2 MultiProcessCluster (alluxio.multi.process.MultiProcessCluster)1 URI (java.net.URI)1 Test (org.junit.Test)1