Search in sources :

Example 6 with SleepProcessorConfig

use of org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig in project tez by apache.

the class TestMRRJobsDAGApi method testHistoryLogging.

// Submits a simple 5 stage sleep job using tez session. Then kills it.
@Test(timeout = 60000)
public void testHistoryLogging() throws IOException, InterruptedException, TezException, ClassNotFoundException, YarnException {
    SleepProcessorConfig spConf = new SleepProcessorConfig(1);
    DAG dag = DAG.create("TezSleepProcessorHistoryLogging");
    Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create(SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 2, Resource.newInstance(1024, 1));
    dag.addVertex(vertex);
    TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
    Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random.nextInt(100000))));
    remoteFs.mkdirs(remoteStagingDir);
    tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString());
    FileSystem localFs = FileSystem.getLocal(tezConf);
    Path historyLogDir = new Path(TEST_ROOT_DIR, "testHistoryLogging");
    localFs.mkdirs(historyLogDir);
    tezConf.set(TezConfiguration.TEZ_SIMPLE_HISTORY_LOGGING_DIR, localFs.makeQualified(historyLogDir).toString());
    tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, false);
    TezClient tezSession = TezClient.create("TezSleepProcessorHistoryLogging", tezConf);
    tezSession.start();
    DAGClient dagClient = tezSession.submitDAG(dag);
    DAGStatus dagStatus = dagClient.getDAGStatus(null);
    while (!dagStatus.isCompleted()) {
        LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState());
        Thread.sleep(500l);
        dagStatus = dagClient.getDAGStatus(null);
    }
    assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
    FileStatus historyLogFileStatus = null;
    for (FileStatus fileStatus : localFs.listStatus(historyLogDir)) {
        if (fileStatus.isDirectory()) {
            continue;
        }
        Path p = fileStatus.getPath();
        if (p.getName().startsWith(SimpleHistoryLoggingService.LOG_FILE_NAME_PREFIX)) {
            historyLogFileStatus = fileStatus;
            break;
        }
    }
    Assert.assertNotNull(historyLogFileStatus);
    Assert.assertTrue(historyLogFileStatus.getLen() > 0);
    tezSession.stop();
}
Also used : Path(org.apache.hadoop.fs.Path) Vertex(org.apache.tez.dag.api.Vertex) FileStatus(org.apache.hadoop.fs.FileStatus) SleepProcessorConfig(org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig) FileSystem(org.apache.hadoop.fs.FileSystem) SleepProcessor(org.apache.tez.runtime.library.processor.SleepProcessor) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAG(org.apache.tez.dag.api.DAG) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Example 7 with SleepProcessorConfig

use of org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig in project tez by apache.

the class TestATSHistoryWithMiniCluster method testDisabledACls.

@Test(timeout = 50000)
public void testDisabledACls() throws Exception {
    TezClient tezSession = null;
    try {
        SleepProcessorConfig spConf = new SleepProcessorConfig(1);
        DAG dag = DAG.create("TezSleepProcessor");
        Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create(SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1));
        dag.addVertex(vertex);
        TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
        tezConf.setBoolean(TezConfiguration.TEZ_AM_ALLOW_DISABLED_TIMELINE_DOMAINS, true);
        tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName());
        Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random.nextInt(100000))));
        remoteFs.mkdirs(remoteStagingDir);
        tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString());
        tezSession = TezClient.create("TezSleepProcessor", tezConf, true);
        tezSession.start();
        DAGClient dagClient = tezSession.submitDAG(dag);
        DAGStatus dagStatus = dagClient.getDAGStatus(null);
        while (!dagStatus.isCompleted()) {
            LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState());
            Thread.sleep(500l);
            dagStatus = dagClient.getDAGStatus(null);
        }
        Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
    } finally {
        if (tezSession != null) {
            tezSession.stop();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Vertex(org.apache.tez.dag.api.Vertex) SleepProcessorConfig(org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig) SleepProcessor(org.apache.tez.runtime.library.processor.SleepProcessor) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAG(org.apache.tez.dag.api.DAG) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TezClient(org.apache.tez.client.TezClient) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 8 with SleepProcessorConfig

use of org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig in project tez by apache.

the class TestATSHistoryWithACLs method testSimpleAMACls.

@Test(timeout = 50000)
public void testSimpleAMACls() throws Exception {
    TezClient tezSession = null;
    ApplicationId applicationId;
    String viewAcls = "nobody nobody_group";
    try {
        SleepProcessorConfig spConf = new SleepProcessorConfig(1);
        DAG dag = DAG.create("TezSleepProcessor");
        Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create(SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1));
        dag.addVertex(vertex);
        TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
        tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls);
        tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName());
        Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random.nextInt(100000))));
        remoteFs.mkdirs(remoteStagingDir);
        tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString());
        tezSession = TezClient.create("TezSleepProcessor", tezConf, true);
        tezSession.start();
        applicationId = tezSession.getAppMasterApplicationId();
        DAGClient dagClient = tezSession.submitDAG(dag);
        DAGStatus dagStatus = dagClient.getDAGStatus(null);
        while (!dagStatus.isCompleted()) {
            LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState());
            Thread.sleep(500l);
            dagStatus = dagClient.getDAGStatus(null);
        }
        assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
    } finally {
        if (tezSession != null) {
            tezSession.stop();
        }
    }
    TimelineDomain timelineDomain = getDomain(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString());
    verifyDomainACLs(timelineDomain, Collections.singleton("nobody"), Collections.singleton("nobody_group"));
    verifyEntityDomains(applicationId, true);
}
Also used : Path(org.apache.hadoop.fs.Path) Vertex(org.apache.tez.dag.api.Vertex) SleepProcessorConfig(org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig) SleepProcessor(org.apache.tez.runtime.library.processor.SleepProcessor) DAG(org.apache.tez.dag.api.DAG) ATSHistoryLoggingService(org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService) TezClient(org.apache.tez.client.TezClient) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 9 with SleepProcessorConfig

use of org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig in project tez by apache.

the class TestATSHistoryWithACLs method testDAGACls.

@Test(timeout = 50000)
public void testDAGACls() throws Exception {
    TezClient tezSession = null;
    ApplicationId applicationId;
    String viewAcls = "nobody nobody_group";
    try {
        SleepProcessorConfig spConf = new SleepProcessorConfig(1);
        DAG dag = DAG.create("TezSleepProcessor");
        Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create(SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1));
        dag.addVertex(vertex);
        DAGAccessControls accessControls = new DAGAccessControls();
        accessControls.setUsersWithViewACLs(Collections.singleton("nobody2"));
        accessControls.setGroupsWithViewACLs(Collections.singleton("nobody_group2"));
        dag.setAccessControls(accessControls);
        TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
        tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls);
        tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName());
        Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random.nextInt(100000))));
        remoteFs.mkdirs(remoteStagingDir);
        tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString());
        tezSession = TezClient.create("TezSleepProcessor", tezConf, true);
        tezSession.start();
        applicationId = tezSession.getAppMasterApplicationId();
        DAGClient dagClient = tezSession.submitDAG(dag);
        DAGStatus dagStatus = dagClient.getDAGStatus(null);
        while (!dagStatus.isCompleted()) {
            LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState());
            Thread.sleep(500l);
            dagStatus = dagClient.getDAGStatus(null);
        }
        assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
    } finally {
        if (tezSession != null) {
            tezSession.stop();
        }
    }
    TimelineDomain timelineDomain = getDomain(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString());
    verifyDomainACLs(timelineDomain, Collections.singleton("nobody"), Collections.singleton("nobody_group"));
    timelineDomain = getDomain(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString() + "_1");
    verifyDomainACLs(timelineDomain, Sets.newHashSet("nobody", "nobody2"), Sets.newHashSet("nobody_group", "nobody_group2"));
    verifyEntityDomains(applicationId, false);
}
Also used : Path(org.apache.hadoop.fs.Path) Vertex(org.apache.tez.dag.api.Vertex) SleepProcessorConfig(org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig) SleepProcessor(org.apache.tez.runtime.library.processor.SleepProcessor) DAG(org.apache.tez.dag.api.DAG) ATSHistoryLoggingService(org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService) TezClient(org.apache.tez.client.TezClient) DAGAccessControls(org.apache.tez.common.security.DAGAccessControls) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Aggregations

Path (org.apache.hadoop.fs.Path)9 TezClient (org.apache.tez.client.TezClient)9 DAG (org.apache.tez.dag.api.DAG)9 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)9 Vertex (org.apache.tez.dag.api.Vertex)9 DAGClient (org.apache.tez.dag.api.client.DAGClient)9 DAGStatus (org.apache.tez.dag.api.client.DAGStatus)9 SleepProcessor (org.apache.tez.runtime.library.processor.SleepProcessor)9 SleepProcessorConfig (org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig)9 Test (org.junit.Test)9 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)4 ATSHistoryLoggingService (org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService)3 FileSystem (org.apache.hadoop.fs.FileSystem)2 TimelineDomain (org.apache.hadoop.yarn.api.records.timeline.TimelineDomain)2 DAGAccessControls (org.apache.tez.common.security.DAGAccessControls)2 ATSV15HistoryLoggingService (org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService)2 FileStatus (org.apache.hadoop.fs.FileStatus)1