Package com.dp.nebula.wormhole.common.interfaces

Examples of com.dp.nebula.wormhole.common.interfaces.IParam


    SftpDirSplitter s = new SftpDirSplitter();
    HashMap<String, String> paramMap = new HashMap<String, String>();
    paramMap.put(ParamKey.dir,
        "sftp://hadoop@192.168.7.80:58422/home/hadoop/wormhole-sftp-test/test*");
    paramMap.put(ParamKey.password, "hadoopdev");
    IParam params = new DefaultParam(paramMap);
    s.init(params);
    s.split();
  }
View Full Code Here


        logger.info(String.format(
            "HBaseReader split job into %d sub-jobs .",
            regionRanges.getFirst().length));

        for (int i = 0; i < regionRanges.getFirst().length; i++) {
          IParam paramSplitted = param.clone();

          String thisStartKey = null;
          if (null != userStartKey
              && 0 != regionRanges.getFirst()[i].length) {
            if (Bytes.compareTo(userStartKey.getBytes(),
                regionRanges.getFirst()[i]) < 0) {
              thisStartKey = Bytes.toString(regionRanges
                  .getFirst()[i]);
            } else {
              thisStartKey = userStartKey;
            }
          } else if (null == userStartKey
              && 0 == regionRanges.getFirst()[i].length) {
            thisStartKey = null;
          } else if (0 != regionRanges.getFirst()[i].length) {
            thisStartKey = Bytes
                .toString(regionRanges.getFirst()[i]);
          } else {
            thisStartKey = userStartKey;
          }

          String thisEndKey = null;
          if (null != userEndKey
              && 0 != regionRanges.getSecond()[i].length) {
            if (Bytes.compareTo(userEndKey.getBytes(),
                regionRanges.getSecond()[i]) > 0) {
              thisEndKey = Bytes.toString(regionRanges
                  .getSecond()[i]);
            } else {
              thisEndKey = userEndKey;
            }
          } else if (null == userEndKey
              && 0 == regionRanges.getSecond()[i].length) {
            thisEndKey = null;
          } else if (null != userEndKey) {
            thisEndKey = userEndKey;
          } else {
            thisEndKey = Bytes
                .toString(regionRanges.getSecond()[i]);
          }

          paramSplitted.putValue(ParamKey.rowkey_range,
              (thisStartKey == null ? "" : thisStartKey) + ","
                  + (thisEndKey == null ? "" : thisEndKey));
         
          paramList.add(paramSplitted);
        }
View Full Code Here

  @Override
  public List<IParam> split() {
    if(!needSplit) {
      List<IParam> paramList = new ArrayList<IParam>() ;
      IParam paramNoSplitted = param.clone();
      if(sql.isEmpty()&&!tableName.isEmpty()&&!columns.isEmpty()){
        String noSplitSql = "";
        if(!where.isEmpty()) {
          noSplitSql = String.format(SIMPLE_SQL_WITH_WHERE_PATTEN, columns, tableName, where);
        } else {
          noSplitSql = String.format(SIMPLE_SQL_WITHOUT_WHERE_PATTEN, columns, tableName);
        }
        noSplitSql = String.format(COPY_SQL,noSplitSql);
        paramNoSplitted.putValue(ParamKey.sql, noSplitSql);
        paramList.add(paramNoSplitted);

      } else {
        sql = String.format(COPY_SQL,sql);
        paramNoSplitted.putValue(ParamKey.sql, sql);
        paramList.add(paramNoSplitted);
      }
      return paramList;
    }
    if(partitionName.isEmpty() || partitionValue.isEmpty() || tableName.isEmpty()){
      return super.split();
    }
    logger.info("Greenplum reader start to split");
    List<IParam> paramList = new ArrayList<IParam>() ;
    List<String> partitionList = getPartitionValueList();
    StringBuilder []sqlArray = new StringBuilder[concurrency];
    for(int i = 0; i < partitionList.size(); i++){
      String sqlSplitted = null;
      if(!where.isEmpty()) {
        sqlSplitted = String.format(SQL_WITH_WHERE_PATTEN, columns, tableName, where, partitionName,partitionList.get(i));
      } else {
        sqlSplitted = String.format(SQL_WITHOUT_WHERE_PATTEN, columns, tableName, partitionName,partitionList.get(i));
      }
      sqlSplitted = String.format(COPY_SQL,sqlSplitted);
      int index = (int) (i%concurrency);
      if(sqlArray[index] == null){
        sqlArray[index] new StringBuilder();
      }
      sqlArray[index].append(sqlSplitted).append(";") ;
    }
    for(int j = 0; j < concurrency; j++){
      if(sqlArray[j] == null) {
        continue;
      }
      IParam paramSplitted = param.clone();
      paramSplitted.putValue(ParamKey.sql, sqlArray[j].toString());
      logger.info(sqlArray[j].toString());
      paramList.add(paramSplitted);
    }
    logger.info("Greenplum reader is splitted successfully");
    return paramList;
View Full Code Here

        Map<String,String> params = new HashMap<String,String>();
        params.put(ParamKey.dir, "sftp://username@localhost:58424" + rootName);
        params.put(ParamKey.password, "password");
        params.put(ParamKey.colFilter, "#0,#1");
       
        IParam param = new DefaultParam(params);
       
        SftpDirSplitter splitter = new SftpDirSplitter();
        splitter.init(param);
        List<IParam> list = splitter.split();
        BufferedLineExchanger exchanger=BufferedLineExchangerTest.getLineExchanger();
View Full Code Here

      for (int i = 0; i < concurrency; i++) {
        absolutePath = dir + "/" + prefixname + "-" + i;
        if (!StringUtils.isBlank(suffix)){
          absolutePath = absolutePath + "." + suffix;
        }
        IParam oParams = param.clone();
        oParams.putValue(ParamKey.dir, absolutePath);
        v.add(oParams);
      }
    }   
    return v;
  }
View Full Code Here

        Map<String,String> params = new HashMap<String,String>();
        params.put(ParamKey.dir, "sftp://username@localhost:58424" + rootName);
        params.put(ParamKey.password, "password");
        params.put(ParamKey.concurrency, "3");

        IParam param = new DefaultParam(params);
        periphery.prepare(param, null);
        splitter.init(param);
        List<IParam> paramList = splitter.split();
      BufferedLineExchanger exchanger=BufferedLineExchangerTest.getLineExchanger();
      for(ILine line:datas) {
View Full Code Here

       
        if (!state.isDir()) {
          String file = state.getPath().toString();
          logger.info(ParamKey.dir + " split filename:" + file + "\tlength:" + state.getLen());
         
          IParam oParams = param.clone();
          oParams.putValue(ParamKey.dir, file);
          paramsList.add(oParams);
        } else {
          splitFilesRecursively(state.getPath());
        }
      }
View Full Code Here

    else{
      s_logger.error("Usage: ./wormhole.sh job.xml .");
      System.exit(JobStatus.FAILED.getStatus());
    }
    JobConf jobConf = null;
    IParam engineConf = null;
    Map<String, IParam> pluginConfs = null;
    try{
      //read configurations from XML for engine & plugins
      jobConf = ParseXMLUtil.loadJobConf(jobDescriptionXML);
      engineConf = ParseXMLUtil.loadEngineConfig();
View Full Code Here

  private static Testdb db = null;
  private final static String DB_NAME = "hivedb";
 
  public static BufferedLineExchanger getBufferedLineExchangerInstance(){
    IParam engineConf = null;
    engineConf = ParseXMLUtil.loadEngineConfig();
    List<StorageConf> result = new ArrayList<StorageConf>();
   
    for(int i = 0; i< 5; i++){
      StorageConf storageConf = new StorageConf();
      storageConf.setId(String.valueOf(i));
      storageConf.setStorageClassName(
          engineConf.getValue(EngineConfParamKey.STORAGE_CLASS_NAME));
      storageConf.setLineLimit(
          engineConf.getIntValue(EngineConfParamKey.STORAGE_LINE_LIMIT));
      storageConf.setByteLimit(
          engineConf.getIntValue(EngineConfParamKey.STORAGE_BYTE_LIMIT));
      storageConf.setDestructLimit(
          engineConf.getIntValue(EngineConfParamKey.STORAGE_DESTRUCT_LIMIT));
      storageConf.setPeriod(
          engineConf.getIntValue(EngineConfParamKey.MONITOR_INFO_DISPLAY_PERIOD));
      storageConf.setWaitTime(
          engineConf.getIntValue(EngineConfParamKey.STORAGE_WAIT_TIME));
      result.add(storageConf);
    }
    StorageManager manager = new StorageManager(result);
    BufferedLineExchanger exchanger = new BufferedLineExchanger(manager.getStorageForWriter("1"), manager.getStorageForReader());
    return exchanger;
View Full Code Here

   
    Map<String, String> params = new HashMap<String, String>();
    params.put(ParamKey.path, "jdbc:hsqldb:mem:" + DB_NAME);
    params.put(ParamKey.username, "sa");
    params.put(ParamKey.sql, "SELECT str_col, num_col FROM sample_table WHERE num_col < 250");
    IParam iParam = new DefaultParam(params);
    hiveReader.setParam(iParam);
    BufferedLineExchanger bufLineExchanger = HiveReaderTest.getBufferedLineExchangerInstance();
   
    IPluginMonitor pluginMonitor = mock(IPluginMonitor.class);
    hiveReader.setMonitor(pluginMonitor);
View Full Code Here

TOP

Related Classes of com.dp.nebula.wormhole.common.interfaces.IParam

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.