Package org.apache.ambari.view.pig.utils

Examples of org.apache.ambari.view.pig.utils.ServiceFormattedException


      api = new HdfsApi(defaultFS, getHdfsUsername(context));
      LOG.info("HdfsApi connected OK");
    } catch (IOException e) {
      String message = "HdfsApi IO error: " + e.getMessage();
      LOG.error(message);
      throw new ServiceFormattedException(message, e);
    } catch (InterruptedException e) {
      String message = "HdfsApi Interrupted error: " + e.getMessage();
      LOG.error(message);
      throw new ServiceFormattedException(message, e);
    }
    return api;
  }
View Full Code Here


        LOG.debug("File already exists. Trying next id");
      } catch (IOException e) {
        try {
          delete(object.getId());
        } catch (ItemNotFound itemNotFound) {
          throw new ServiceFormattedException("Error in creation, during clean up: " + itemNotFound.toString(), itemNotFound);
        }
        throw new ServiceFormattedException("Error in creation: " + e.toString(), e);
      } catch (InterruptedException e) {
        try {
          delete(object.getId());
        } catch (ItemNotFound itemNotFound) {
          throw new ServiceFormattedException("Error in creation, during clean up: " + itemNotFound.toString(), itemNotFound);
        }
        throw new ServiceFormattedException("Error in creation: " + e.toString(), e);
      }
      checkId += 1;
    } while (!fileCreated);

    object.setPigScript(newFilePath);
View Full Code Here

      object.put("job", job);
      return Response.ok(object).build();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

      getResourceManager().killJob(job);
      return Response.status(204).build();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

      getResourceManager().retrieveJobStatus(job);
      return Response.ok().build();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

    } catch (IOException ex) {
      throw new NotFoundFormattedException(ex.getMessage(), ex);
    } catch (InterruptedException ex) {
      throw new NotFoundFormattedException(ex.getMessage(), ex);
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

      object.put("jobs", allJobs);
      return Response.ok(object).build();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

    } catch (WebApplicationException ex) {
      throw ex;
    } catch (IllegalArgumentException ex) {
      throw new BadRequestFormattedException(ex.getMessage(), ex);
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

        stream.close();
      } else {
        if (job.getSourceFile() != null && !job.getSourceFile().isEmpty()) {
          // otherwise, just copy original file
          if (!BaseService.getHdfsApi(context).copy(job.getSourceFile(), newSourceFilePath)) {
            throw new ServiceFormattedException("Can't copy source file from " + job.getSourceFile() +
                " to " + newPigScriptPath);
          }
        }
      }
    } catch (IOException e) {
      throw new ServiceFormattedException("Can't create/copy source file: " + e.toString(), e);
    } catch (InterruptedException e) {
      throw new ServiceFormattedException("Can't create/copy source file: " + e.toString(), e);
    }

    try {
      // content can be passed from front-end with substituted arguments
      if (job.getForcedContent() != null && !job.getForcedContent().isEmpty()) {
        String forcedContent = job.getForcedContent();
        // variable for sourceFile can be passed from front-ent
        forcedContent = forcedContent.replace("${sourceFile}",
            context.getProperties().get("dataworker.defaultFs") + newSourceFilePath);
        job.setForcedContent(null); // we should not store content in DB
        save(job);

        FSDataOutputStream stream = BaseService.getHdfsApi(context).create(newPigScriptPath, true);
        stream.writeBytes(forcedContent);
        stream.close();
      } else {
        // otherwise, just copy original file
        if (!BaseService.getHdfsApi(context).copy(job.getPigScript(), newPigScriptPath)) {
          throw new ServiceFormattedException("Can't copy pig script file from " + job.getPigScript() +
              " to " + newPigScriptPath);
        }
      }
    } catch (IOException e) {
      throw new ServiceFormattedException("Can't create/copy pig script file: " + e.toString(), e);
    } catch (InterruptedException e) {
      throw new ServiceFormattedException("Can't create/copy pig script file: " + e.toString(), e);
    }

    if (job.getPythonScript() != null && !job.getPythonScript().isEmpty()) {
      try {
        if (!BaseService.getHdfsApi(context).copy(job.getPythonScript(), newPythonScriptPath)) {
          throw new ServiceFormattedException("Can't copy python udf script file from " + job.getPythonScript() +
              " to " + newPythonScriptPath);
        }
      } catch (IOException e) {
        throw new ServiceFormattedException("Can't create/copy python udf file: " + e.toString(), e);
      } catch (InterruptedException e) {
        throw new ServiceFormattedException("Can't create/copy python udf file: " + e.toString(), e);
      }
    }

    try {
      FSDataOutputStream stream = BaseService.getHdfsApi(context).create(templetonParamsFilePath, true);
      if (job.getTempletonArguments() != null) {
        stream.writeBytes(job.getTempletonArguments());
      }
      stream.close();
    } catch (IOException e) {
      throw new ServiceFormattedException("Can't create params file: " + e.toString(), e);
    } catch (InterruptedException e) {
      throw new ServiceFormattedException("Can't create params file: " + e.toString(), e);
    }
    job.setPigScript(newPigScriptPath);

    job.setStatusDir(statusdir);
    job.setDateStarted(System.currentTimeMillis() / 1000L);

    TempletonApi.JobData data = null;
    try {
      data = getTempletonApi().runPigQuery(new File(job.getPigScript()), statusdir, job.getTempletonArguments());
    } catch (IOException templetonBadResponse) {
      String msg = String.format("Templeton bad response: %s", templetonBadResponse.toString());
      LOG.debug(msg);
      throw new ServiceFormattedException(msg, templetonBadResponse);
    }
    job.setJobId(data.id);

    JobPolling.pollJob(context, job);
  }
View Full Code Here

      TempletonApi api = connectToTempletonApi(context);
      api.status();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.ambari.view.pig.utils.ServiceFormattedException

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.