You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2012/01/03 06:37:33 UTC
svn commit: r1226662 - in /pig/branches/branch-0.10: ./
src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/
test/org/apache/pig/test/ test/org/apache/pig/test/utils/
Author: daijy
Date: Tue Jan 3 05:37:33 2012
New Revision: 1226662
URL: http://svn.apache.org/viewvc?rev=1226662&view=rev
Log:
PIG-2426: ProgressableReporter.progress(String msg) is an empty function
Added:
pig/branches/branch-0.10/test/org/apache/pig/test/TestPigProgressReporting.java
pig/branches/branch-0.10/test/org/apache/pig/test/utils/ReportingUDF.java
Modified:
pig/branches/branch-0.10/CHANGES.txt
pig/branches/branch-0.10/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ProgressableReporter.java
Modified: pig/branches/branch-0.10/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/CHANGES.txt?rev=1226662&r1=1226661&r2=1226662&view=diff
==============================================================================
--- pig/branches/branch-0.10/CHANGES.txt (original)
+++ pig/branches/branch-0.10/CHANGES.txt Tue Jan 3 05:37:33 2012
@@ -158,6 +158,8 @@ PIG-2228: support partial aggregation in
BUG FIXES
+PIG-2426: ProgressableReporter.progress(String msg) is an empty function (vivekp via daijy)
+
PIG-2363: _logs for streaming commands bug in new parser (vivekp via daijy)
PIG-2427: getSchemaFromString throws away the name of the tuple that is in a bag (jcoveney via dvryaboy)
Modified: pig/branches/branch-0.10/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ProgressableReporter.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ProgressableReporter.java?rev=1226662&r1=1226661&r2=1226662&view=diff
==============================================================================
--- pig/branches/branch-0.10/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ProgressableReporter.java (original)
+++ pig/branches/branch-0.10/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ProgressableReporter.java Tue Jan 3 05:37:33 2012
@@ -17,17 +17,19 @@
*/
package org.apache.pig.backend.hadoop.executionengine.mapReduceLayer;
-import org.apache.hadoop.util.Progressable;
+import java.io.IOException;
+
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PigProgressable;
public class ProgressableReporter implements PigProgressable {
- Progressable rep;
+ TaskAttemptContext rep;
public ProgressableReporter(){
}
- public ProgressableReporter(Progressable rep) {
+ public ProgressableReporter(TaskAttemptContext rep) {
super();
this.rep = rep;
}
@@ -38,10 +40,14 @@ public class ProgressableReporter implem
}
public void progress(String msg) {
-
+ try {
+ rep.setStatus(msg);
+ }catch (IOException e) {
+ rep.progress();
+ }
}
- public void setRep(Progressable rep) {
+ public void setRep(TaskAttemptContext rep) {
this.rep = rep;
}
Added: pig/branches/branch-0.10/test/org/apache/pig/test/TestPigProgressReporting.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/test/org/apache/pig/test/TestPigProgressReporting.java?rev=1226662&view=auto
==============================================================================
--- pig/branches/branch-0.10/test/org/apache/pig/test/TestPigProgressReporting.java (added)
+++ pig/branches/branch-0.10/test/org/apache/pig/test/TestPigProgressReporting.java Tue Jan 3 05:37:33 2012
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig.test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import junit.framework.TestCase;
+
+import org.apache.pig.ExecType;
+import org.apache.pig.PigServer;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestPigProgressReporting extends TestCase {
+
+ static MiniCluster cluster = MiniCluster.buildCluster();
+
+ @Test
+ public void testProgressReportingWithStatusMessage() throws Exception {
+
+ // Get the default time out value
+ String taskTimeout = cluster.getProperties().getProperty("mapred.task.timeout");
+
+ try{
+ // Override the timeout as 10 secs
+ cluster.setProperty("mapred.task.timeout", "10000");
+
+ Util.createInputFile(cluster, "a.txt", new String[] { "dummy"});
+
+ PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+
+ String filename = prepareTempFile();
+ filename = filename.replace("\\", "\\\\");
+
+
+ pig.registerQuery("A = load 'a.txt' as (f1:chararray);");
+ pig.registerQuery("B = foreach A generate org.apache.pig.test.utils.ReportingUDF();");
+
+ assertEquals("(100)", pig.openIterator("B").next().toString());
+
+ }catch (Exception e) {
+ Assert.fail (e.getMessage());
+ }finally{
+ // Set back the orginal value
+ cluster.setProperty("mapred.task.timeout", taskTimeout);
+ }
+
+ }
+
+
+ private String prepareTempFile() throws IOException {
+ File inputFile = File.createTempFile("test", "txt");
+ inputFile.deleteOnExit() ;
+ PrintStream ps = new PrintStream(new FileOutputStream(inputFile));
+ ps.println("bbb") ;
+ ps.close();
+ return inputFile.getPath() ;
+ }
+
+
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
+}
Added: pig/branches/branch-0.10/test/org/apache/pig/test/utils/ReportingUDF.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/test/org/apache/pig/test/utils/ReportingUDF.java?rev=1226662&view=auto
==============================================================================
--- pig/branches/branch-0.10/test/org/apache/pig/test/utils/ReportingUDF.java (added)
+++ pig/branches/branch-0.10/test/org/apache/pig/test/utils/ReportingUDF.java Tue Jan 3 05:37:33 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.test.utils;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+
+public class ReportingUDF extends EvalFunc<Integer> {
+
+ @Override
+ public Integer exec(Tuple input) throws IOException {
+
+ try {
+ Thread.sleep(7500);
+ getReporter().progress("Progressing");
+ Thread.sleep(7500);
+ } catch (InterruptedException e) {
+ }
+
+ return 100;
+ }
+
+}