Package com.dp.nebula.wormhole.common

Examples of com.dp.nebula.wormhole.common.WormholeException


      if (null != rs) {
          try {
          DBUtils.closeResultSet(rs);
        } catch (SQLException e) {
          logger.error("SqlserverReader close resultset error ");
          throw new WormholeException(e,JobStatus.READ_FAILED.getStatus()+SqlserverReader.ERROR_CODE_ADD)
        }
            }
          try {
          conn.close();
        } catch (SQLException e) {
View Full Code Here


    } catch (IllegalStateException e) {
        sender.flush();
        getMonitor().increaseSuccessLine(sucLineCounter);
    } catch (Exception e) {
      logger.error("Reader copy data failed:",e);
      throw new WormholeException(e,JobStatus.READ_FAILED.getStatus());
    }  

//        byte[] bufferArray = new byte[BUFFER_LENGTH];
//        ILine line = new DefaultLine();
//      StringBuffer field = new StringBuffer();
View Full Code Here

  @Override
  public void read(ILineSender lineSender){
    PGCopyInputStream inputStream = null;
    if(sql.isEmpty()){
      logger.error("Sql for GreenplumReader is empty.");
      throw new WormholeException("Sql for GreenplumReader is empty.",JobStatus.READ_FAILED.getStatus()+ERROR_CODE_ADD)
    }
    logger.info(String.format("GreenplumReader start to query %s .", sql));
    for(String sqlItem:sql.split(";")){
      sqlItem = sqlItem.trim();
      if(sqlItem.isEmpty()) {
        continue;
      }
      try {
        inputStream = new PGCopyInputStream((PGConnection) ((DelegatingConnection) conn).getInnermostDelegate(), sqlItem);
        fetchData(lineSender,inputStream);
      } catch (Exception e) {       
        logger.error("GreenplumReader error");
        WormholeException ex = new WormholeException(e,JobStatus.READ_FAILED.getStatus());
        if(e instanceof WormholeException) {
          ex = (WormholeException) e;
        }
        else if(e instanceof PSQLException) {
          ErrorCodeUtils.psqlReaderWrapper((PSQLException)e,ex);
        }
        ex.setStatusCode(ex.getStatusCode() + ERROR_CODE_ADD);
        throw ex;
      }
    }
  }
View Full Code Here

    needSplit = param.getBooleanValue(ParamKey.needSplit,true);
    if(!autoIncKey.isEmpty() || !tableName.isEmpty()){
      try {
        conn = DBSource.getConnection(SqlserverReader.class, ip, port, dbname);
      } catch (Exception e) {
        throw new WormholeException(e, JobStatus.READ_CONNECTION_FAILED.getStatus() + SqlserverReader.ERROR_CODE_ADD);
      }
    }
  }
View Full Code Here

        .toLowerCase();
    this.operation = getParam().getValue(ParamKey.OPERATION, "").trim();
    if (!"insert".equalsIgnoreCase(operation)
        && !"replace".equalsIgnoreCase(operation)
        && !"update".equalsIgnoreCase(operation)) {
      throw new WormholeException("operation " + operation
          + " not supported when using mysqlwriter",
          JobStatus.WRITE_FAILED.getStatus());
    }

    this.writerID = getParam().getValue(AbstractPlugin.PLUGINID, "");
View Full Code Here

      min = rs.getInt(1);
      max = rs.getInt(2);
      rs.close();
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
      throw new WormholeException(e,JobStatus.READ_FAILED.getStatus()+SqlserverReader.ERROR_CODE_ADD);
    }
    long start = min - 1;
    long end = min - 1 + blockSize;
    StringBuilder []sqlArray = new StringBuilder[concurrency];
    for(long i = 0; i <= (max-min)/blockSize; i++){
View Full Code Here

    }
    try {
      conn = DBSource
          .getConnection(this.getClass(), ip, writerID, dbname);
    } catch (Exception e) {
      throw new WormholeException(e,
          JobStatus.WRITE_CONNECTION_FAILED.getStatus()
              + errorCodeAdd);
    }
  }
View Full Code Here

          count = 0;
        }
        if (getMonitor().getFailedLines() > failedLinesThreshold) {
          logger.error(writerID
              + " Mysqlwriter :Failed lines threshold is larger than expect");
          throw new WormholeException(
              "Mysqlwriter :Failed lines threshold is larger than expect",
              JobStatus.WRITE_FAILED.getStatus(), writerID);
        }

      }
      if (count != 0) {
        if ("update".equalsIgnoreCase(operation)) {
          builder.append(updateOpAppendStr);
        }
        updateOneBlock(builder.toString(), count);
      }
      logger.info(writerID + ": Write to mysql ends .");

    } catch (WormholeException e) {
      e.setStatusCode(e.getStatusCode() + errorCodeAdd);
      throw e;
    } catch (Exception e) {
      throw new WormholeException(e, JobStatus.WRITE_FAILED.getStatus()
          + errorCodeAdd, writerID);
    } finally {
      if (null != this.conn) {
        try {
          conn.close();
        } catch (SQLException e1) {
          logger.error(writerID + " close failed");
          throw new WormholeException(e1,
              JobStatus.WRITE_FAILED.getStatus() + errorCodeAdd,
              writerID);
        }
      }
    }
View Full Code Here

        j++;
      } else {
        logger.error(writerID + " write failed");
        logger.error("num:" + num + " len:" + len);
        logger.error(line.toString(','));
        throw new WormholeException(
            "MysqlWriter: Fields number is less than column number ",
            JobStatus.WRITE_FAILED.getStatus(), writerID);
      }
      if (i != 0) {
        builder.append(",");
View Full Code Here

  @Override
  public void connection() {
    try {
      conn = DBSource.getConnection(this.getClass(), ip, port, dbname);
    } catch (Exception e) {
      throw new WormholeException(e, JobStatus.READ_CONNECTION_FAILED.getStatus() + ERROR_CODE_ADD);
    }
  }
View Full Code Here

TOP

Related Classes of com.dp.nebula.wormhole.common.WormholeException

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.