Package org.apache.crunch

Examples of org.apache.crunch.CrunchRuntimeException


    FileSystem fs = null;
    try {
      fs = path.getFileSystem(conf);
    } catch (IOException e) {
      LOG.error("Could not retrieve FileSystem object to check for existing path", e);
      throw new CrunchRuntimeException(e);
    }
   
    boolean exists = false;
    boolean successful = false;
    long lastModForTarget = -1;
    try {
      exists = fs.exists(path);
      if (exists) {
        successful = fs.exists(getSuccessIndicator());
        lastModForTarget = SourceTargetHelper.getLastModifiedAt(fs, path);
      }
    } catch (IOException e) {
      LOG.error("Exception checking existence of path: " + path, e);
      throw new CrunchRuntimeException(e);
    }
   
    if (exists) {
      switch (strategy) {
      case DEFAULT:
        LOG.error("Path " + path + " already exists!");
        throw new CrunchRuntimeException("Path already exists: " + path);
      case OVERWRITE:
        LOG.info("Removing data at existing path: " + path);
        try {
          fs.delete(path, true);
        } catch (IOException e) {
          LOG.error("Exception thrown removing data at path: " + path, e);
        }
        break;
      case APPEND:
        LOG.info("Adding output files to existing path: " + path);
        break;
      case CHECKPOINT:
        if (successful && lastModForTarget > lastModForSource) {
          LOG.info("Re-starting pipeline from checkpoint path: " + path);
          break;
        } else {
          if (!successful) {
            LOG.info("_SUCCESS file not found, Removing data at existing checkpoint path: " + path);
          } else {
            LOG.info("Source data has recent updates. Removing data at existing checkpoint path: " + path);
          }
          try {
            fs.delete(path, true);
          } catch (IOException e) {
            LOG.error("Exception thrown removing data at checkpoint path: " + path, e);
          }
          return false;
        }
      default:
        throw new CrunchRuntimeException("Unknown WriteMode:  " + strategy);
      }
    } else {
      LOG.info("Will write output files to new path: " + path);
    }
    return exists;
View Full Code Here


    proxyFactory.setFilter(CCMethodHandler.FILTER);
    CCMethodHandler handler = new CCMethodHandler(c);
    try {
      return (Counters.Counter) proxyFactory.create(new Class[0], new Object[0], handler);
    } catch (Exception e) {
      throw new CrunchRuntimeException(e);
    }
  }
View Full Code Here

    if (conf == null) return;

    try {
      Writables.reloadWritableComparableCodes(conf);
    } catch (Exception e) {
      throw new CrunchRuntimeException("Error reloading writable comparable codes", e);
    }
  }
View Full Code Here

    Path p = fs.makeQualified(path);
    final ParquetReader reader;
    try {
      reader = new ParquetReader(p, new CrunchAvroReadSupport(avroType));
    } catch (IOException e) {
      throw new CrunchRuntimeException(e);
    }
    return new AutoClosingIterator<T>(reader, new UnmodifiableIterator<T>() {

      private T next;

      @Override
      public boolean hasNext() {
        if (next != null) {
          return true;
        }
        try {
          next = (T) reader.read();
        } catch (IOException e) {
          throw new CrunchRuntimeException(e);
        }
        return next != null;
      }

      @Override
View Full Code Here

            return cmp;
          }
        }
        return card1 - card2;
      } catch (IOException e) {
        throw new CrunchRuntimeException(e);
      }
    }
View Full Code Here

    }
    MSCRPlanner planner = new MSCRPlanner(this, outputTargets, toMaterialize, allPipelineCallables);
    try {
      return planner.plan(jarClass, getConfiguration());
    } catch (IOException e) {
      throw new CrunchRuntimeException(e);
    }
  }
View Full Code Here

        LOG.info("Writing jobplan to " + jobPlanPath);
        outputStream = fs.create(jobPlanPath, true);
        outputStream.write(dotFileContents.getBytes(Charsets.UTF_8));
      } catch (URISyntaxException e) {
        thrownException = e;
        throw new CrunchRuntimeException("Invalid dot file dir URI, job plan will not be written: " + dotFileDir, e);
      } catch (IOException e) {
        thrownException = e;
        throw new CrunchRuntimeException("Error writing dotfile contents to " + dotFileDir, e);
      } catch (RuntimeException e) {
        thrownException = e;
        throw e;
      } finally {
        if (outputStream != null) {
          try {
            outputStream.close();
          } catch (IOException e) {
            if (thrownException == null)
              throw new CrunchRuntimeException("Error closing dotfile", e);
          }
        }
      }
    }
  }
View Full Code Here

        binaryEncoder.flush();
        binaryDecoder = DecoderFactory.get()
            .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder);
        return datumReader.read(target, binaryDecoder);
      } catch (Exception e) {
        throw new CrunchRuntimeException("Error while deep copying avro value " + source, e);
      }
    }
View Full Code Here

    protected T createNewInstance(Class<T> targetClass) {
      try {
        return targetClass.newInstance();
      } catch (InstantiationException e) {
        throw new CrunchRuntimeException(e);
      } catch (IllegalAccessException e) {
        throw new CrunchRuntimeException(e);
      }
    }
View Full Code Here

    boolean exists = target.handleExisting(writeMode, ((PCollectionImpl) pcollection).getLastModifiedAt(),
        getConfiguration());
    if (exists && writeMode == Target.WriteMode.CHECKPOINT) {
      SourceTarget<?> st = target.asSourceTarget(pcollection.getPType());
      if (st == null) {
        throw new CrunchRuntimeException("Target " + target + " does not support checkpointing");
      } else {
        ((PCollectionImpl) pcollection).materializeAt(st);
      }
      return;
    } else if (writeMode != Target.WriteMode.APPEND && targetInCurrentRun(target)) {
      throw new CrunchRuntimeException("Target " + target + " is already written in current run." +
          " Use WriteMode.APPEND in order to write additional data to it.");
    }
    addOutput((PCollectionImpl<?>) pcollection, target);
  }
View Full Code Here

TOP

Related Classes of org.apache.crunch.CrunchRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.