You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by selvaganesang <gi...@git.apache.org> on 2018/06/07 20:35:45 UTC

[GitHub] trafodion pull request #1532: [TRAFODION-3026] add create option storage pol...

Github user selvaganesang commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1532#discussion_r193875770
  
    --- Diff: core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java ---
    @@ -3226,5 +3260,65 @@ public RecoveryRequestResponse call(TrxRegionService instance) throws IOExceptio
     
             return resultArray[0].getResultList();
         }
    +
    +    public void setStoragePolicy(String tblName, String policy)
    +      throws IOException {
    +
    +      int retryCount = 0;
    +      int retrySleep = TM_SLEEP;
    +      boolean retry = false;
    +      try {
    +        Table tbl = connection.getTable(TableName.valueOf(tblName));
    +        String rowkey = "0";
    +        CoprocessorRpcChannel channel = tbl.coprocessorService(rowkey.getBytes());
    +        org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrxRegionService.BlockingInterface service =
    +          org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrxRegionService.newBlockingStub(channel);
    +        org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrafSetStoragePolicyRequest.Builder request =
    +         org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrafSetStoragePolicyRequest.newBuilder();
    +        String hbaseRoot = config.get("hbase.rootdir");
    +        FileSystem fs = FileSystem.get(config);
    +      //Construct the HDFS dir
    +      //find out if namespace is there
    +      String[] parts = tblName.split(":");
    +      String namespacestr="";
    +      String fullPath = hbaseRoot + "/data/" ;
    +      String fullPath2 = hbaseRoot + "/data/default/";
    +      if(fs.exists(new Path(fullPath2)))
    +        fullPath = fullPath2;
    +
    +      if(parts.length >1) //have namespace
    +        fullPath = fullPath + parts[0] + "/" + parts[1];
    +      else
    +        fullPath = fullPath + tblName;
    +
    +      request.setPath(fullPath);
    +      request.setPolicy(policy);
    +        
    +      do {
    +          org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrafSetStoragePolicyResponse ret =
    +            service.setStoragePolicy(null,request.build());
    +
    +          //handle result and error
    +          if( ret == null)
    +          {
    +            LOG.error("setStoragePolicy Response ret null ");
    +          }
    +          else if (ret.getStatus() == false)
    +          {
    +            LOG.error("setStoragePolicy Response ret false: " + ret.getException());
    +            throw new IOException(ret.getException());
    +          }
    +          if(retryCount == RETRY_ATTEMPTS)
    +          {
    +            throw new IOException("coprocessor not response");
    +          }
    +          if (retry) 
    +              retrySleep = retry(retrySleep);
    +        } while (retry && retryCount++ < RETRY_ATTEMPTS);
    +      }
    +      catch (Exception e) {
    +         throw new IOException(e);
    +      }
    +  }
    --- End diff --
    
    retry is never set to true. So, it is not clear when the request would be retried


---