You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2008/02/14 18:54:04 UTC
svn commit: r627815 - in /incubator/pig/trunk: ./ src/org/apache/pig/
src/org/apache/pig/backend/datastorage/
src/org/apache/pig/backend/hadoop/datastorage/
src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/
src/org/apache/pig/backend/loc...
Author: gates
Date: Thu Feb 14 09:53:50 2008
New Revision: 627815
URL: http://svn.apache.org/viewvc?rev=627815&view=rev
Log:
PIG-80: In a number of places stack trace information was being lost byan exception being caught, and a different exception then thrown. All those locations have been changed so that the new exception now wraps the old.
Added:
incubator/pig/trunk/src/org/apache/pig/impl/util/WrappedIOException.java
Modified:
incubator/pig/trunk/CHANGES.txt
incubator/pig/trunk/src/org/apache/pig/EvalFunc.java
incubator/pig/trunk/src/org/apache/pig/Main.java
incubator/pig/trunk/src/org/apache/pig/PigServer.java
incubator/pig/trunk/src/org/apache/pig/backend/datastorage/DataStorageException.java
incubator/pig/trunk/src/org/apache/pig/backend/hadoop/datastorage/HDirectory.java
incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/MapReduceLauncher.java
incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java
incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalDir.java
incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalFile.java
incubator/pig/trunk/src/org/apache/pig/builtin/AVG.java
incubator/pig/trunk/src/org/apache/pig/builtin/COUNT.java
incubator/pig/trunk/src/org/apache/pig/builtin/MAX.java
incubator/pig/trunk/src/org/apache/pig/builtin/MIN.java
incubator/pig/trunk/src/org/apache/pig/data/DataAtom.java
incubator/pig/trunk/src/org/apache/pig/data/DefaultDataBag.java
incubator/pig/trunk/src/org/apache/pig/data/DistinctDataBag.java
incubator/pig/trunk/src/org/apache/pig/data/SortedDataBag.java
incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java
incubator/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java
incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java
incubator/pig/trunk/src/org/apache/pig/impl/util/ObjectSerializer.java
incubator/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
Modified: incubator/pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/CHANGES.txt?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/CHANGES.txt (original)
+++ incubator/pig/trunk/CHANGES.txt Thu Feb 14 09:53:50 2008
@@ -102,3 +102,8 @@
common logging abstraction instead of log4j. By default in grunt, log4j
still used as logging layer. Also converted all System.out/err.println
statements to use logging instead. (francisoud via gates)
+
+ PIG-80: In a number of places stack trace information was being lost by an
+ exception being caught, and a different exception then thrown. All those
+ locations have been changed so that the new exception now wraps the old.
+ (francisoud via gates).
Modified: incubator/pig/trunk/src/org/apache/pig/EvalFunc.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/EvalFunc.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/EvalFunc.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/EvalFunc.java Thu Feb 14 09:53:50 2008
@@ -98,7 +98,7 @@
}catch (IOException e){
throw new RuntimeException(e);
}catch (ClassCastException e){
- throw new RuntimeException(funcSpec + " does not specify an eval func");
+ throw new RuntimeException(funcSpec + " does not specify an eval func", e);
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/Main.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/Main.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/Main.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/Main.java Thu Feb 14 09:53:50 2008
@@ -154,7 +154,7 @@
try {
exectype = PigServer.parseExecType(opts.getValStr());
} catch (IOException e) {
- throw new RuntimeException("ERROR: Unrecognized exectype.");
+ throw new RuntimeException("ERROR: Unrecognized exectype.", e);
}
pigContext.setExecType(exectype);
break;
Modified: incubator/pig/trunk/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/PigServer.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/PigServer.java Thu Feb 14 09:53:50 2008
@@ -52,6 +52,7 @@
import org.apache.pig.impl.logicalLayer.parser.ParseException;
import org.apache.pig.impl.logicalLayer.parser.QueryParser;
import org.apache.pig.impl.logicalLayer.schema.TupleSchema;
+import org.apache.pig.impl.util.WrappedIOException;
/**
@@ -286,9 +287,7 @@
}
}
catch (ExecException e) {
- IOException ioe = new IOException("Unable to open iterator for alias: " + id);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to open iterator for alias: " + id, e);
}
}
@@ -333,9 +332,7 @@
pigContext.getExecutionEngine().execute(pp);
}
catch (ExecException e) {
- IOException ioe = new IOException("Unable to store alias " + readFrom.getAlias());
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to store alias " + readFrom.getAlias(), e);
}
}
@@ -370,9 +367,7 @@
catch (ExecException e) {
log.error("Failed to compile to physical plan: " + alias);
stream.println("Failed to compile the logical plan for " + alias + " into a physical plan");
- IOException ioe = new IOException("Failed to compile to phyiscal plan: " + alias);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to compile to phyiscal plan: " + alias, e);
}
}
@@ -415,48 +410,26 @@
* @throws IOException
*/
public long fileSize(String filename) throws IOException {
- try {
- DataStorage dfs = pigContext.getDfs();
- ElementDescriptor elem = dfs.asElement(filename);
- Map<String, Object> elemProps = elem.getStatistics();
- String length = (String) elemProps.get(ElementDescriptor.LENGTH_KEY);
-
- Properties dfsProps = dfs.getConfiguration();
- String replication = dfsProps.getProperty(DataStorage.DEFAULT_REPLICATION_FACTOR_KEY);
-
- return (new Long(length)).longValue() *
- (new Integer(replication)).intValue();
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get element descriptor for " + filename);
- ioe.initCause(e);
- throw ioe;
- }
+ DataStorage dfs = pigContext.getDfs();
+ ElementDescriptor elem = dfs.asElement(filename);
+ Map<String, Object> elemProps = elem.getStatistics();
+ String length = (String) elemProps.get(ElementDescriptor.LENGTH_KEY);
+
+ Properties dfsProps = dfs.getConfiguration();
+ String replication = dfsProps.getProperty(DataStorage.DEFAULT_REPLICATION_FACTOR_KEY);
+
+ return (new Long(length)).longValue() * (new Integer(replication)).intValue();
}
public boolean existsFile(String filename) throws IOException {
- try {
- ElementDescriptor elem = pigContext.getDfs().asElement(filename);
- return elem.exists();
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get element descriptor for " + filename);
- ioe.initCause(e);
- throw ioe;
- }
+ ElementDescriptor elem = pigContext.getDfs().asElement(filename);
+ return elem.exists();
}
public boolean deleteFile(String filename) throws IOException {
- try {
- ElementDescriptor elem = pigContext.getDfs().asElement(filename);
- elem.delete();
- return true;
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get element descriptor for " + filename);
- ioe.initCause(e);
- throw ioe;
- }
+ ElementDescriptor elem = pigContext.getDfs().asElement(filename);
+ elem.delete();
+ return true;
}
public boolean renameFile(String source, String target) throws IOException {
@@ -465,36 +438,22 @@
}
public boolean mkdirs(String dirs) throws IOException {
- try {
- ContainerDescriptor container = pigContext.getDfs().asContainer(dirs);
- container.create();
- return true;
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get container descriptor for " + dirs);
- ioe.initCause(e);
- throw ioe;
- }
+ ContainerDescriptor container = pigContext.getDfs().asContainer(dirs);
+ container.create();
+ return true;
}
public String[] listPaths(String dir) throws IOException {
- try {
- Collection<String> allPaths = new ArrayList<String>();
- ContainerDescriptor container = pigContext.getDfs().asContainer(dir);
- Iterator<ElementDescriptor> iter = container.iterator();
-
- while (iter.hasNext()) {
- ElementDescriptor elem = iter.next();
- allPaths.add(elem.toString());
- }
+ Collection<String> allPaths = new ArrayList<String>();
+ ContainerDescriptor container = pigContext.getDfs().asContainer(dir);
+ Iterator<ElementDescriptor> iter = container.iterator();
- return (String[])(allPaths.toArray());
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get container descriptor for " + dir);
- ioe.initCause(e);
- throw ioe;
+ while (iter.hasNext()) {
+ ElementDescriptor elem = iter.next();
+ allPaths.add(elem.toString());
}
+
+ return (String[])(allPaths.toArray());
}
public long totalHadoopTimeSpent() {
Modified: incubator/pig/trunk/src/org/apache/pig/backend/datastorage/DataStorageException.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/datastorage/DataStorageException.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/datastorage/DataStorageException.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/datastorage/DataStorageException.java Thu Feb 14 09:53:50 2008
@@ -1,11 +1,14 @@
package org.apache.pig.backend.datastorage;
-public class DataStorageException extends Exception {
+import java.io.IOException;
+
+public class DataStorageException extends IOException {
static final long serialVersionUID = 1;
public DataStorageException(String message, Throwable cause) {
- super(message, cause);
+ super(message);
+ initCause(cause);
}
public DataStorageException() {
Modified: incubator/pig/trunk/src/org/apache/pig/backend/hadoop/datastorage/HDirectory.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/hadoop/datastorage/HDirectory.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/hadoop/datastorage/HDirectory.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/hadoop/datastorage/HDirectory.java Thu Feb 14 09:53:50 2008
@@ -11,6 +11,7 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.pig.backend.datastorage.*;
+import org.apache.pig.impl.util.WrappedIOException;
public class HDirectory extends HPath
implements ContainerDescriptor {
@@ -94,9 +95,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to copy " + this + " to " + dstName);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to copy " + this + " to " + dstName, e);
}
if (removeSrc) {
@@ -137,8 +136,6 @@
}
}
catch (IOException e) {
- }
- catch (DataStorageException e) {
}
/*
Modified: incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/MapReduceLauncher.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/MapReduceLauncher.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/MapReduceLauncher.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/MapReduceLauncher.java Thu Feb 14 09:53:50 2008
@@ -46,6 +46,7 @@
import org.apache.pig.impl.io.PigFile;
import org.apache.pig.impl.util.JarManager;
import org.apache.pig.impl.util.ObjectSerializer;
+import org.apache.pig.impl.util.WrappedIOException;
/**
@@ -263,9 +264,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to obtain descriptor for " + outputFile.toString());
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to obtain descriptor for " + outputFile.toString(), e);
}
if (!success) {
@@ -292,8 +291,7 @@
}
catch (Exception e) {
// Do we need different handling for different exceptions
- e.printStackTrace();
- throw new IOException(e.getMessage());
+ throw WrappedIOException.wrap(e);
}
finally {
submitJarFile.delete();
Modified: incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java Thu Feb 14 09:53:50 2008
@@ -36,6 +36,7 @@
import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.eval.EvalSpec;
import org.apache.pig.impl.util.ObjectSerializer;
+import org.apache.pig.impl.util.WrappedIOException;
public class PigSplit implements InputSplit {
@@ -98,7 +99,7 @@
try {
loader = (LoadFunc) PigContext.instantiateFuncFromSpec(this.parser);
}catch(Exception exp) {
- throw new RuntimeException("can't instantiate " + parser);
+ throw new RuntimeException("can't instantiate " + parser, exp);
}
}
return loader;
@@ -161,9 +162,7 @@
try{
return ois.readObject();
}catch (ClassNotFoundException cnfe){
- IOException newE = new IOException(cnfe.getMessage());
- newE.initCause(cnfe);
- throw newE;
+ throw WrappedIOException.wrap(cnfe.getMessage(), cnfe);
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalDir.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalDir.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalDir.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalDir.java Thu Feb 14 09:53:50 2008
@@ -13,6 +13,7 @@
import org.apache.pig.backend.datastorage.DataStorageException;
import org.apache.pig.backend.datastorage.ImmutableOutputStream;
import org.apache.pig.backend.datastorage.SeekableInputStream;
+import org.apache.pig.impl.util.WrappedIOException;
public class LocalDir extends LocalPath
implements ContainerDescriptor {
@@ -64,9 +65,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to get container for " + dstName.toString());
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to get container for " + dstName.toString(), e);
}
copy((ContainerDescriptor) dstName,
@@ -122,9 +121,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to copy " + this + " to " + dstName);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to copy " + this + " to " + dstName, e);
}
if (removeSrc) {
Modified: incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalFile.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalFile.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalFile.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/backend/local/datastorage/LocalFile.java Thu Feb 14 09:53:50 2008
@@ -11,6 +11,7 @@
import java.util.Properties;
import org.apache.pig.backend.datastorage.*;
+import org.apache.pig.impl.util.WrappedIOException;
public class LocalFile extends LocalPath {
@@ -72,10 +73,8 @@
path.getName());
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to generate element name (src: " +
- this + ", dst: " + dstName + ")");
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to generate element name (src: " +
+ this + ", dst: " + dstName + ")", e);
}
}
}
@@ -116,9 +115,7 @@
return new LocalSeekableInputStream(this.path);
}
catch (FileNotFoundException e) {
- IOException ioe = new IOException("Unable to find " + this.path);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to find " + this.path, e);
}
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/builtin/AVG.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/AVG.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/AVG.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/AVG.java Thu Feb 14 09:53:50 2008
@@ -67,7 +67,7 @@
output.appendField(new DataAtom(count(input)));
// output.appendField(new DataAtom("processed by initial"));
} catch(RuntimeException t) {
- throw new RuntimeException(t.getMessage() + ": " + input);
+ throw new RuntimeException(t.getMessage() + ": " + input, t);
}
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/builtin/COUNT.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/COUNT.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/COUNT.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/COUNT.java Thu Feb 14 09:53:50 2008
@@ -29,6 +29,7 @@
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.schema.AtomSchema;
import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.util.WrappedIOException;
/**
* Generates the count of the values of the first field of a tuple. This class is Algebraic in
@@ -92,7 +93,7 @@
try {
sum += t.getAtomField(0).longVal();
} catch (NumberFormatException exp) {
- throw new IOException(exp.getClass().getName() + ":" + exp.getMessage());
+ throw WrappedIOException.wrap(exp.getClass().getName() + ":" + exp.getMessage(), exp);
}
}
return sum;
Modified: incubator/pig/trunk/src/org/apache/pig/builtin/MAX.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/MAX.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/MAX.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/MAX.java Thu Feb 14 09:53:50 2008
@@ -27,6 +27,7 @@
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.schema.AtomSchema;
import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.util.WrappedIOException;
/**
@@ -73,9 +74,7 @@
try {
curMax = java.lang.Math.max(curMax, t.getAtomField(0).numval());
}catch(RuntimeException exp) {
- IOException newE = new IOException("Error processing: " + t.toString() + exp.getMessage());
- newE.initCause(exp);
- throw newE;
+ throw WrappedIOException.wrap("Error processing: " + t.toString() + exp.getMessage(), exp);
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/builtin/MIN.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/MIN.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/MIN.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/MIN.java Thu Feb 14 09:53:50 2008
@@ -27,6 +27,7 @@
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.schema.AtomSchema;
import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.util.WrappedIOException;
/**
@@ -72,15 +73,13 @@
Tuple t = (Tuple) it.next();
try {
curMin = java.lang.Math.min(curMin, t.getAtomField(0).numval());
- }catch(RuntimeException exp) {
- IOException newE = new IOException("Error processing: " + t.toString() + exp.getMessage());
- newE.initCause(exp);
- throw newE;
+ } catch(RuntimeException exp) {
+ throw WrappedIOException.wrap("Error processing: " + t.toString() + exp.getMessage(), exp);
+ }
}
+ return curMin;
}
-
- return curMin;
-}
+
@Override
public Schema outputSchema(Schema input) {
return new AtomSchema("min" + count++);
Modified: incubator/pig/trunk/src/org/apache/pig/data/DataAtom.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/data/DataAtom.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/data/DataAtom.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/data/DataAtom.java Thu Feb 14 09:53:50 2008
@@ -132,7 +132,7 @@
data = strval().getBytes("UTF-8");
} catch (Exception e) {
long size = strval().length();
- throw new RuntimeException("Error dealing with DataAtom of size " + size);
+ throw new RuntimeException("Error dealing with DataAtom of size " + size, e);
}
Tuple.encodeInt(out, data.length);
out.write(data);
Modified: incubator/pig/trunk/src/org/apache/pig/data/DefaultDataBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/data/DefaultDataBag.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/data/DefaultDataBag.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/data/DefaultDataBag.java Thu Feb 14 09:53:50 2008
@@ -191,7 +191,7 @@
// didn't dump all of our tuples to disk.
log.fatal(
"Ran out of tuples too soon.", eof);
- throw new RuntimeException("Ran out of tuples to read prematurely.");
+ throw new RuntimeException("Ran out of tuples to read prematurely.", eof);
} catch (IOException ioe) {
log.fatal(
"Unable to read our spill file", ioe);
Modified: incubator/pig/trunk/src/org/apache/pig/data/DistinctDataBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/data/DistinctDataBag.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/data/DistinctDataBag.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/data/DistinctDataBag.java Thu Feb 14 09:53:50 2008
@@ -272,7 +272,7 @@
} catch (EOFException eof) {
// This should never happen, it means we
// didn't dump all of our tuples to disk.
- throw new RuntimeException("Ran out of tuples to read prematurely.");
+ throw new RuntimeException("Ran out of tuples to read prematurely.", eof);
} catch (IOException ioe) {
log.fatal(
"Unable to read our spill file", ioe);
Modified: incubator/pig/trunk/src/org/apache/pig/data/SortedDataBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/data/SortedDataBag.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/data/SortedDataBag.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/data/SortedDataBag.java Thu Feb 14 09:53:50 2008
@@ -274,7 +274,7 @@
// didn't dump all of our tuples to disk.
log.fatal(
"Ran out of tuples too soon.", eof);
- throw new RuntimeException("Ran out of tuples to read prematurely.");
+ throw new RuntimeException("Ran out of tuples to read prematurely.", eof);
} catch (IOException ioe) {
log.fatal(
"Unable to read our spill file", ioe);
Modified: incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java Thu Feb 14 09:53:50 2008
@@ -53,6 +53,7 @@
import org.apache.pig.backend.local.executionengine.LocalExecutionEngine;
import org.apache.pig.impl.logicalLayer.LogicalPlanBuilder;
import org.apache.pig.impl.util.JarManager;
+import org.apache.pig.impl.util.WrappedIOException;
public class PigContext implements Serializable, FunctionInstantiator {
private static final long serialVersionUID = 1L;
@@ -246,9 +247,7 @@
src = dfs.asElement(oldName);
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to rename " + oldName + " to " + newName);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to rename " + oldName + " to " + newName, e);
}
if (dst.exists()) {
@@ -274,9 +273,7 @@
dstElement = dstStorage.asElement(dst);
}
catch (DataStorageException e) {
- IOException ioe = new IOException ("Unable to copy " + src + " to " + dst + (localDst ? "locally" : ""));
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to copy " + src + " to " + dst + (localDst ? "locally" : ""), e);
}
srcElement.copy(dstElement, conf,false);
@@ -380,9 +377,7 @@
// create ClassNotFoundException exception and attach to IOException
// so that we don't need to buble interface changes throughout the code
ClassNotFoundException e = new ClassNotFoundException("Could not resolve " + name + " using imports: " + packageImportList);
- IOException newE = new IOException(e.getMessage());
- newE.initCause(e);
- throw newE;
+ throw WrappedIOException.wrap(e.getMessage(), e);
}
private static List<String> parseArguments(String argString){
@@ -424,9 +419,7 @@
ret = objClass.newInstance();
}
}catch(Throwable e){
- IOException newE = new IOException(e.getMessage());
- newE.initCause(e);
- throw newE;
+ throw WrappedIOException.wrap(e.getMessage(), e);
}
return ret;
}
Modified: incubator/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java Thu Feb 14 09:53:50 2008
@@ -36,6 +36,7 @@
import org.apache.pig.backend.datastorage.DataStorage;
import org.apache.pig.backend.datastorage.ElementDescriptor;
import org.apache.pig.impl.PigContext;
+import org.apache.pig.impl.util.WrappedIOException;
import org.apache.pig.backend.datastorage.*;
import org.apache.pig.backend.hadoop.datastorage.HDataStorage;
@@ -153,17 +154,9 @@
}
public static InputStream openDFSFile(String fileName, JobConf conf) throws IOException{
- try {
- DataStorage dds = new HDataStorage(conf);
- ElementDescriptor elem = dds.asElement(fileName);
-
- return openDFSFile(elem);
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to obtain descriptor for " + fileName);
- ioe.initCause(e);
- throw ioe;
- }
+ DataStorage dds = new HDataStorage(conf);
+ ElementDescriptor elem = dds.asElement(fileName);
+ return openDFSFile(elem);
}
private static InputStream openDFSFile(ElementDescriptor elem) throws IOException{
@@ -176,9 +169,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to determine if elem=" + elem + " is container");
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to determine if elem=" + elem + " is container", e);
}
ArrayList<ElementDescriptor> arrayList =
@@ -206,17 +197,10 @@
static public InputStream open(String fileSpec, PigContext pigContext) throws IOException {
fileSpec = checkDefaultPrefix(pigContext.getExecType(), fileSpec);
if (!fileSpec.startsWith(LOCAL_PREFIX)) {
- try {
- init(pigContext);
- ElementDescriptor elem = pigContext.getDfs().
- asElement(fullPath(fileSpec, pigContext));
- return openDFSFile(elem);
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to open " + fileSpec);
- ioe.initCause(e);
- throw ioe;
- }
+ init(pigContext);
+ ElementDescriptor elem = pigContext.getDfs().
+ asElement(fullPath(fileSpec, pigContext));
+ return openDFSFile(elem);
}
else {
fileSpec = fileSpec.substring(LOCAL_PREFIX.length());
@@ -232,16 +216,9 @@
static public OutputStream create(String fileSpec, boolean append, PigContext pigContext) throws IOException {
fileSpec = checkDefaultPrefix(pigContext.getExecType(), fileSpec);
if (!fileSpec.startsWith(LOCAL_PREFIX)) {
- try {
- init(pigContext);
- ElementDescriptor elem = pigContext.getDfs().asElement(fileSpec);
- return elem.create();
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to create " + fileSpec);
- ioe.initCause(e);
- throw ioe;
- }
+ init(pigContext);
+ ElementDescriptor elem = pigContext.getDfs().asElement(fileSpec);
+ return elem.create();
}
else {
fileSpec = fileSpec.substring(LOCAL_PREFIX.length());
@@ -286,24 +263,17 @@
public static synchronized ElementDescriptor
getTemporaryPath(ElementDescriptor relative,
PigContext pigContext) throws IOException {
- try {
- init(pigContext);
- if (relative == null) {
- relative = relativeRoot;
- }
- if (!relativeRoot.exists()) {
- relativeRoot.create();
- }
- ElementDescriptor elem=
- pigContext.getDfs().asElement(relative.toString(), "tmp" + r.nextInt());
- toDelete.push(elem);
- return elem;
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get elem descriptor for " + relative.toString());
- ioe.initCause(e);
- throw ioe;
- }
+ init(pigContext);
+ if (relative == null) {
+ relative = relativeRoot;
+ }
+ if (!relativeRoot.exists()) {
+ relativeRoot.create();
+ }
+ ElementDescriptor elem=
+ pigContext.getDfs().asElement(relative.toString(), "tmp" + r.nextInt());
+ toDelete.push(elem);
+ return elem;
}
public static String hadoopify(String filename, PigContext pigContext) throws IOException {
@@ -311,37 +281,30 @@
filename = filename.substring(LOCAL_PREFIX.length());
}
- try {
- ElementDescriptor localElem =
- pigContext.getLfs().asElement(filename);
+ ElementDescriptor localElem =
+ pigContext.getLfs().asElement(filename);
- if (!localElem.exists()) {
- throw new FileNotFoundException(filename);
- }
+ if (!localElem.exists()) {
+ throw new FileNotFoundException(filename);
+ }
- ElementDescriptor distribElem =
- getTemporaryPath(null, pigContext);
+ ElementDescriptor distribElem =
+ getTemporaryPath(null, pigContext);
- int suffixStart = filename.lastIndexOf('.');
- if (suffixStart != -1) {
- distribElem = pigContext.getDfs().asElement(distribElem.toString() +
- filename.substring(suffixStart));
- }
-
- // TODO: currently the copy method in Data Storage does not allow to specify overwrite
- // so the work around is to delete the dst file first, if it exists
- if (distribElem.exists()) {
- distribElem.delete();
- }
- localElem.copy(distribElem, null, false);
+ int suffixStart = filename.lastIndexOf('.');
+ if (suffixStart != -1) {
+ distribElem = pigContext.getDfs().asElement(distribElem.toString() +
+ filename.substring(suffixStart));
+ }
- return distribElem.toString();
+ // TODO: currently the copy method in Data Storage does not allow to specify overwrite
+ // so the work around is to delete the dst file first, if it exists
+ if (distribElem.exists()) {
+ distribElem.delete();
}
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to hadoopify " + filename);
- ioe.initCause(e);
- throw ioe;
- }
+ localElem.copy(distribElem, null, false);
+
+ return distribElem.toString();
}
public static String fullPath(String filename, PigContext pigContext) throws IOException {
@@ -397,9 +360,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Unable to get collect for pattern " + elem.toString());
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Unable to get collect for pattern " + elem.toString(), e);
}
}
Modified: incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java Thu Feb 14 09:53:50 2008
@@ -59,9 +59,11 @@
log.error("cause = " + cause.getClass().getName(), e);
cause = cause.getCause();
} if (cause != null) {
- throw new ParseException("Load function " +
+ ParseException pe = new ParseException("Load function " +
inputFileSpec.getFuncSpec() +
" not found");
+ pe.initCause(e);
+ throw pe;
} else {
throw e;
}
Modified: incubator/pig/trunk/src/org/apache/pig/impl/util/ObjectSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/util/ObjectSerializer.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/impl/util/ObjectSerializer.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/impl/util/ObjectSerializer.java Thu Feb 14 09:53:50 2008
@@ -36,8 +36,7 @@
objStream.close();
return encodeBytes(serialObj.toByteArray());
} catch (Exception e) {
- e.printStackTrace();
- throw new IOException("Serialization error: " + e.getMessage());
+ throw WrappedIOException.wrap("Serialization error: " + e.getMessage(), e);
}
}
@@ -48,8 +47,7 @@
ObjectInputStream objStream = new ObjectInputStream(serialObj);
return objStream.readObject();
} catch (Exception e) {
- e.printStackTrace();
- throw new IOException("Deserialization error: " + e.getMessage());
+ throw WrappedIOException.wrap("Deserialization error: " + e.getMessage(), e);
}
}
Added: incubator/pig/trunk/src/org/apache/pig/impl/util/WrappedIOException.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/util/WrappedIOException.java?rev=627815&view=auto
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/impl/util/WrappedIOException.java (added)
+++ incubator/pig/trunk/src/org/apache/pig/impl/util/WrappedIOException.java Thu Feb 14 09:53:50 2008
@@ -0,0 +1,20 @@
+package org.apache.pig.impl.util;
+
+import java.io.IOException;
+
+/**
+ * FIXME PIG-80 replace this code when pig will be java 6 compliant with "throw
+ * new IOException(e);"
+ */
+public class WrappedIOException {
+
+ public static IOException wrap(final Throwable e) {
+ return wrap(e.getMessage(), e);
+ }
+
+ public static IOException wrap(final String message, final Throwable e) {
+ final IOException wrappedException = new IOException(message);
+ wrappedException.initCause(e);
+ return wrappedException;
+ }
+}
Modified: incubator/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java?rev=627815&r1=627814&r2=627815&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java Thu Feb 14 09:53:50 2008
@@ -19,6 +19,7 @@
import org.apache.pig.backend.executionengine.ExecutionEngine;
import org.apache.pig.backend.hadoop.executionengine.HExecutionEngine;
import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.util.WrappedIOException;
import org.apache.pig.tools.pigscript.parser.ParseException;
import org.apache.pig.tools.pigscript.parser.PigScriptParser;
import org.apache.pig.tools.pigscript.parser.PigScriptParserTokenManager;
@@ -192,9 +193,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to Cat: " + path);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to Cat: " + path, e);
}
}
@@ -223,11 +222,9 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to change working directory to " +
+ throw WrappedIOException.wrap("Failed to change working directory to " +
((path == null) ? ("/user/" + System.getProperty("user.name"))
- : (path)));
- ioe.initCause(e);
- throw ioe;
+ : (path)), e);
}
}
@@ -303,9 +300,7 @@
}
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to LS on " + path);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to LS on " + path, e);
}
}
@@ -345,9 +340,7 @@
srcPath.rename(dstPath);
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to move " + src + " to " + dst);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to move " + src + " to " + dst, e);
}
}
@@ -360,9 +353,7 @@
srcPath.copy(dstPath, mConf, false);
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to copy " + src + " to " + dst);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to copy " + src + " to " + dst, e);
}
}
@@ -375,9 +366,7 @@
srcPath.copy(dstPath, false);
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to copy " + src + "to (locally) " + dst);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to copy " + src + "to (locally) " + dst, e);
}
}
@@ -390,24 +379,14 @@
srcPath.copy(dstPath, false);
}
catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to copy (loally) " + src + "to " + dst);
- ioe.initCause(e);
- throw ioe;
+ throw WrappedIOException.wrap("Failed to copy (loally) " + src + "to " + dst, e);
}
}
protected void processMkdir(String dir) throws IOException
{
- try {
- ContainerDescriptor dirDescriptor = mDfs.asContainer(dir);
-
- dirDescriptor.create();
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to create dir: " + dir);
- ioe.initCause(e);
- throw ioe;
- }
+ ContainerDescriptor dirDescriptor = mDfs.asContainer(dir);
+ dirDescriptor.create();
}
protected void processPig(String cmd) throws IOException
@@ -420,20 +399,13 @@
protected void processRemove(String path) throws IOException
{
- try {
- ElementDescriptor dfsPath = mDfs.asElement(path);
+ ElementDescriptor dfsPath = mDfs.asElement(path);
- if (!dfsPath.exists()) {
- throw new IOException("File or directory " + path + " does not exist.");
- }
-
- dfsPath.delete();
- }
- catch (DataStorageException e) {
- IOException ioe = new IOException("Failed to get descriptor for " + path);
- ioe.initCause(e);
- throw ioe;
+ if (!dfsPath.exists()) {
+ throw new IOException("File or directory " + path + " does not exist.");
}
+
+ dfsPath.delete();
}
private PigServer mPigServer;