Return-Path: X-Original-To: apmail-crunch-commits-archive@www.apache.org Delivered-To: apmail-crunch-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 725DFCB13 for ; Sat, 29 Jun 2013 15:36:07 +0000 (UTC) Received: (qmail 5177 invoked by uid 500); 29 Jun 2013 15:36:07 -0000 Delivered-To: apmail-crunch-commits-archive@crunch.apache.org Received: (qmail 5134 invoked by uid 500); 29 Jun 2013 15:36:04 -0000 Mailing-List: contact commits-help@crunch.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@crunch.apache.org Delivered-To: mailing list commits@crunch.apache.org Received: (qmail 5125 invoked by uid 99); 29 Jun 2013 15:36:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jun 2013 15:36:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D29533C9DC; Sat, 29 Jun 2013 15:36:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jwills@apache.org To: commits@crunch.apache.org Message-Id: <502e9daf35a94afdb417828375f2693d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: CRUNCH-229: Better error handling for incompatible Target/PType combinations. Date: Sat, 29 Jun 2013 15:36:02 +0000 (UTC) Updated Branches: refs/heads/master 38a97e54c -> 246109962 CRUNCH-229: Better error handling for incompatible Target/PType combinations. Project: http://git-wip-us.apache.org/repos/asf/crunch/repo Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/24610996 Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/24610996 Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/24610996 Branch: refs/heads/master Commit: 2461099628d83b8f4693c562e7f961eeab941c22 Parents: 38a97e5 Author: Josh Wills Authored: Fri Jun 28 17:00:05 2013 -0700 Committer: Josh Wills Committed: Fri Jun 28 17:00:05 2013 -0700 ---------------------------------------------------------------------- .../org/apache/crunch/io/avro/TextToAvroIT.java | 41 ++++++++++++++++++++ .../crunch/impl/mr/plan/MSCROutputHandler.java | 6 ++- 2 files changed, 46 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/crunch/blob/24610996/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java ---------------------------------------------------------------------- diff --git a/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java b/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java new file mode 100644 index 0000000..d285939 --- /dev/null +++ b/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java @@ -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.crunch.io.avro; + +import org.apache.crunch.CrunchRuntimeException; +import org.apache.crunch.Pipeline; +import org.apache.crunch.impl.mr.MRPipeline; +import org.apache.crunch.io.From; +import org.apache.crunch.io.To; +import org.apache.crunch.test.TemporaryPath; +import org.apache.crunch.test.TemporaryPaths; +import org.junit.Rule; +import org.junit.Test; + +public class TextToAvroIT { + @Rule + public transient TemporaryPath tmpDir = TemporaryPaths.create(); + + @Test(expected=CrunchRuntimeException.class) + public void testTextToAvro() throws Exception { + String shakes = tmpDir.copyResourceFileName("shakes.txt"); + Pipeline pipeline = new MRPipeline(TextToAvroIT.class, tmpDir.getDefaultConfiguration()); + pipeline.read(From.textFile(shakes)).write(To.avroFile("output")); + pipeline.run(); + } +} http://git-wip-us.apache.org/repos/asf/crunch/blob/24610996/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java ---------------------------------------------------------------------- diff --git a/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java b/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java index 36c565e..24090e7 100644 --- a/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java +++ b/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java @@ -19,6 +19,7 @@ package org.apache.crunch.impl.mr.plan; import java.util.Map; +import org.apache.crunch.CrunchRuntimeException; import org.apache.crunch.Target; import org.apache.crunch.io.MapReduceTarget; import org.apache.crunch.io.OutputHandler; @@ -48,7 +49,10 @@ public class MSCROutputHandler implements OutputHandler { public void configureNode(DoNode node, Target target) { workingNode = node; - target.accept(this, node.getPType()); + if (!target.accept(this, node.getPType())) { + throw new CrunchRuntimeException("Target " + target + " cannot serialize PType of class: " + + node.getPType().getClass()); + } } public boolean configure(Target target, PType ptype) {