Java Code Examples for org.apache.pig.tools.pigstats.PigStats#getPigProperties()

The following examples show how to use org.apache.pig.tools.pigstats.PigStats#getPigProperties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPigRunner.java    From spork with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorLogFile() throws Exception {
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = foreach A generate StringSize(a0);");
    w.println("store B into '" + OUTPUT_FILE + "';");
    w.close();

    try {
        String[] args = { "-x", "local", PIG_FILE };
        PigStats stats = PigRunner.run(args, null);

        assertTrue(!stats.isSuccessful());

        Properties props = stats.getPigProperties();
        String logfile = props.getProperty("pig.logfile");
        File f = new File(logfile);
        assertTrue(f.exists());
    } finally {
        new File(PIG_FILE).delete();
    }
}
 
Example 2
Source File: TestPigRunner.java    From spork with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorLogFile2() throws Exception {
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = foreach A generate StringSize(a0);");
    w.println("store B into '" + OUTPUT_FILE + "';");
    w.close();

    try {
        String[] args = { "-M", "-x", "local", PIG_FILE };
        PigStats stats = PigRunner.run(args, null);

        assertTrue(!stats.isSuccessful());

        Properties props = stats.getPigProperties();
        // If test on nfs, the pig script complaining "output" exists
        // and does not actually launch the job. This could due to a mapreduce
        // bug which removing file before closing it.
        // If this happens, props is null because we only set pigContext before
        // launching job.
        if (props!=null) {
            String logfile = props.getProperty("pig.logfile");
            File f = new File(logfile);
            assertTrue(f.exists());
        }
    } finally {
        new File(PIG_FILE).delete();
    }
}