本文整理汇总了Java中org.apache.pig.tools.pigstats.JobStats.isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:Java JobStats.isSuccessful方法的具体用法?Java JobStats.isSuccessful怎么用?Java JobStats.isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.tools.pigstats.JobStats
的用法示例。
在下文中一共展示了JobStats.isSuccessful方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJobs
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
/**
* Retrieves a list of Job objects from the PigStats object
* @param stats
* @return A list of ExecJob objects
*/
protected List<ExecJob> getJobs(PigStats stats) {
LinkedList<ExecJob> jobs = new LinkedList<ExecJob>();
JobGraph jGraph = stats.getJobGraph();
Iterator<JobStats> iter = jGraph.iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
for (OutputStats output : js.getOutputs()) {
if (js.isSuccessful()) {
jobs.add(new HJob(HJob.JOB_STATUS.COMPLETED, pigContext, output
.getPOStore(), output.getAlias(), stats));
} else {
HJob hjob = new HJob(HJob.JOB_STATUS.FAILED, pigContext, output
.getPOStore(), output.getAlias(), stats);
hjob.setException(js.getException());
jobs.add(hjob);
}
}
}
return jobs;
}
示例2: executePlan
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
private boolean executePlan(PhysicalPlan pp) throws IOException {
boolean failed = true;
MapReduceLauncher launcher = new MapReduceLauncher();
PigStats stats = null;
try {
stats = launcher.launchPig(pp, "execute", myPig.getPigContext());
} catch (Exception e) {
e.printStackTrace(System.out);
throw new IOException(e);
}
Iterator<JobStats> iter = stats.getJobGraph().iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
failed = !js.isSuccessful();
if (failed) {
break;
}
}
return !failed;
}
示例3: executeBatch
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
private void executeBatch() throws IOException {
if (mPigServer.isBatchOn()) {
if (mExplain != null) {
explainCurrentBatch();
}
if (!mLoadOnly) {
mPigServer.executeBatch();
PigStats stats = PigStats.get();
JobGraph jg = stats.getJobGraph();
Iterator<JobStats> iter = jg.iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
if (!js.isSuccessful()) {
mNumFailedJobs++;
Exception exp = (js.getException() != null) ? js.getException()
: new ExecException(
"Job failed, hadoop does not return any error message",
2244);
LogUtils.writeLog(exp,
mPigServer.getPigContext().getProperties().getProperty("pig.logfile"),
log,
"true".equalsIgnoreCase(mPigServer.getPigContext().getProperties().getProperty("verbose")),
"Pig Stack Trace");
} else {
mNumSucceededJobs++;
}
}
}
}
}
示例4: testStopOnFailure
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
/**
* PIG-2780: In this test case, Pig submits three jobs at the same time and
* one of them will fail due to nonexistent input file. If users enable
* stop.on.failure, then Pig should immediately stop if anyone of the three
* jobs has failed.
*/
@Test
public void testStopOnFailure() throws Exception {
PrintWriter w1 = new PrintWriter(new FileWriter(PIG_FILE));
w1.println("A1 = load '" + INPUT_FILE + "';");
w1.println("B1 = load 'nonexist';");
w1.println("C1 = load '" + INPUT_FILE + "';");
w1.println("A2 = distinct A1;");
w1.println("B2 = distinct B1;");
w1.println("C2 = distinct C1;");
w1.println("ret = union A2,B2,C2;");
w1.println("store ret into 'tmp/output';");
w1.close();
try {
String[] args = { "-F", PIG_FILE };
PigStats stats = PigRunner.run(args, new TestNotificationListener());
assertTrue(!stats.isSuccessful());
int successfulJobs = 0;
Iterator<Operator> it = stats.getJobGraph().getOperators();
while (it.hasNext()){
JobStats js = (JobStats)it.next();
if (js.isSuccessful())
successfulJobs++;
}
// we should have less than 2 successful jobs
assertTrue("Should have less than 2 successful jobs", successfulJobs < 2);
} finally {
new File(PIG_FILE).delete();
Util.deleteFile(cluster, OUTPUT_FILE);
Util.deleteFile(cluster, "tmp/output");
}
}
示例5: executeBatch
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
private void executeBatch() throws IOException {
if (mPigServer.isBatchOn()) {
if (mExplain != null) {
explainCurrentBatch();
}
if (!mLoadOnly) {
mPigServer.executeBatch();
PigStats stats = PigStats.get();
JobGraph jg = stats.getJobGraph();
Iterator<JobStats> iter = jg.iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
if (!js.isSuccessful()) {
mNumFailedJobs++;
Exception exp = (js.getException() != null) ? js.getException()
: new ExecException(
"Job " + (js.getJobId() == null ? "" : js.getJobId() + " ") +
"failed, hadoop does not return any error message",
2244);
LogUtils.writeLog(exp,
mPigServer.getPigContext().getProperties().getProperty("pig.logfile"),
log,
"true".equalsIgnoreCase(mPigServer.getPigContext().getProperties().getProperty("verbose")),
"Pig Stack Trace");
} else {
mNumSucceededJobs++;
}
}
}
}
}
示例6: getJobs
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
/**
* Retrieves a list of Job objects from the PigStats object
* @param stats
* @return A list of ExecJob objects
*/
protected List<ExecJob> getJobs(PigStats stats) {
LinkedList<ExecJob> jobs = new LinkedList<ExecJob>();
if (stats instanceof EmptyPigStats) {
HJob job = new HJob(HJob.JOB_STATUS.COMPLETED, pigContext, stats.result(null)
.getPOStore(), null);
jobs.add(job);
return jobs;
}
JobGraph jGraph = stats.getJobGraph();
Iterator<JobStats> iter = jGraph.iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
for (OutputStats output : js.getOutputs()) {
if (js.isSuccessful()) {
jobs.add(new HJob(HJob.JOB_STATUS.COMPLETED, pigContext, output
.getPOStore(), output.getAlias(), stats));
} else {
HJob hjob = new HJob(HJob.JOB_STATUS.FAILED, pigContext, output
.getPOStore(), output.getAlias(), stats);
hjob.setException(js.getException());
jobs.add(hjob);
}
}
}
return jobs;
}
示例7: testStopOnFailure
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
/**
* PIG-2780: In this test case, Pig submits three jobs at the same time and
* one of them will fail due to nonexistent input file. If users enable
* stop.on.failure, then Pig should immediately stop if anyone of the three
* jobs has failed.
*/
@Test
public void testStopOnFailure() throws Exception {
PrintWriter w1 = new PrintWriter(new FileWriter(PIG_FILE));
w1.println("A1 = load '" + INPUT_FILE + "';");
w1.println("B1 = load 'nonexist';");
w1.println("C1 = load '" + INPUT_FILE + "';");
w1.println("A2 = distinct A1;");
w1.println("B2 = distinct B1;");
w1.println("C2 = distinct C1;");
w1.println("ret = union A2,B2,C2;");
w1.println("store ret into 'tmp/output';");
w1.close();
try {
String[] args = { "-x", execType, "-F", PIG_FILE };
PigStats stats = PigRunner.run(args, new TestNotificationListener(execType));
assertTrue(!stats.isSuccessful());
int successfulJobs = 0;
Iterator<Operator> it = stats.getJobGraph().getOperators();
while (it.hasNext()){
JobStats js = (JobStats)it.next();
if (js.isSuccessful())
successfulJobs++;
}
// we should have less than 2 successful jobs
assertTrue("Should have less than 2 successful jobs", successfulJobs < 2);
} finally {
new File(PIG_FILE).delete();
Util.deleteFile(cluster, OUTPUT_FILE);
Util.deleteFile(cluster, "tmp/output");
}
}
示例8: executeBatch
import org.apache.pig.tools.pigstats.JobStats; //导入方法依赖的package包/类
private void executeBatch() throws IOException {
if (mPigServer.isBatchOn()) {
if (mExplain != null) {
explainCurrentBatch();
}
if (!mLoadOnly) {
mPigServer.executeBatch();
PigStats stats = PigStats.get();
JobGraph jg = stats.getJobGraph();
Iterator<JobStats> iter = jg.iterator();
while (iter.hasNext()) {
JobStats js = iter.next();
if (!js.isSuccessful()) {
mNumFailedJobs++;
Exception exp = (js.getException() != null) ? js.getException()
: new ExecException(
"Job failed, hadoop does not return any error message",
2244);
LogUtils.writeLog(exp,
mPigServer.getPigContext().getProperties().getProperty("pig.logfile"),
log,
"true".equalsIgnoreCase(mPigServer.getPigContext().getProperties().getProperty("verbose")),
"Pig Stack Trace");
} else {
mNumSucceededJobs++;
}
}
}
}
}