zoukankan      html  css  js  c++  java
  • java 复制SDS表为一个新表

    package com.huami.devops;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    import com.xiaomi.infra.galaxy.sds.client.ClientFactory;
    import com.xiaomi.infra.galaxy.sds.thrift.AdminService;
    import com.xiaomi.infra.galaxy.sds.thrift.CommonConstants;
    import com.xiaomi.infra.galaxy.sds.thrift.Credential;
    import com.xiaomi.infra.galaxy.sds.thrift.ServiceException;
    import com.xiaomi.infra.galaxy.sds.thrift.TableSpec;
    import com.xiaomi.infra.galaxy.sds.thrift.UserType;
    
    import libthrift091.TException;
    
    public class CopySDSTable {
            private static ClientFactory clientFactory;
            private static AdminService.Iface adminClient;
            private static String secretKeyId = "";
            private static String secretKey = "";
            private static UserType userType = UserType.APP_SECRET;
            private String endpoint;
            private static final Logger LOG = LoggerFactory.getLogger(CopySDSTable.class);
            private static String tableName = "srctable";
            private static String tableName1 = "tartable1";
            private static String tableName2 = "tartable-02";
    
            public CopySDSTable(String endpoint){
                this.endpoint = endpoint;
                init();
                
            }
            private  void init() {
                Credential credential = new Credential().setSecretKey(secretKey).setSecretKeyId(secretKeyId).setType(userType);
    
                clientFactory = new ClientFactory().setCredential(credential);
                adminClient = clientFactory.newAdminClient(endpoint + CommonConstants.ADMIN_SERVICE_PATH, 50000, 30000);
              }
            
            private void CopyTable(String OldTable,String NewTable){
                TableSpec tableSpec = null;
                try {
                    tableSpec = adminClient.describeTable(OldTable);
                    LOG.debug("get tablespec.");
                    LOG.info("aaaaaaaaaaa");
                } catch (TException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    LOG.error(e.getMessage(), e.getCause());
                }
                try {
                    adminClient.createTable(NewTable, tableSpec);
                } catch (ServiceException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (TException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    LOG.error(e.getMessage(), e.getCause());
                }
            }
            
    public static void main(String[] args){
        CopySDSTable ct = new CopySDSTable("https://awsbj0.sds.api.xiaomi.com");
        ct.CopyTable(tableName, tableName1);
        
        
    } 
    }
  • 相关阅读:
    QTP中选中页面提示ActiveX无法显示
    今天的突然奇想——我想自己做个bug管理工具
    问题解决:Target runtime Apache Tomcat v6.0 is not defined
    java异常类子类和父类的关系
    android与后台服务器连接:android.os.NetworkOnMainThreadException
    struts初探
    eclipse启动Tomcat问题:严重: Socket accept failed
    eclipse启动报错:java was started but returned code=13
    console.log是异步么?
    字符串函数 replace() 方法妙用
  • 原文地址:https://www.cnblogs.com/husbandmen/p/7132570.html
Copyright © 2011-2022 走看看