修改配置文件;添加文件上传到Minio服务器

This commit is contained in:
zhangdongxu
2018-09-29 20:56:17 +08:00
parent 51e88c9239
commit bafa001514
7 changed files with 53 additions and 31 deletions

View File

@@ -203,5 +203,8 @@ public final class Constants {
* 样例文件存放目录 * 样例文件存放目录
*/ */
public static final String MM_SAMPLE_DST_PATH = Configurations.getStringProperty("mmSampleDstPath", "/home/mesasoft/{tableType}/full/{fileName}"); public static final String MM_SAMPLE_DST_PATH = Configurations.getStringProperty("mmSampleDstPath", "/home/mesasoft/{tableType}/full/{fileName}");
/**
*是否使用Minio
*/
public static final Boolean IS_USE_MINIO = Configurations.getBooleanProperty("isUseMinio", true);
} }

View File

@@ -29,6 +29,7 @@ import com.nis.restful.RestServiceException;
import com.nis.restful.ServiceRuntimeException; import com.nis.restful.ServiceRuntimeException;
import com.nis.util.Constants; import com.nis.util.Constants;
import com.nis.util.FileUtils; import com.nis.util.FileUtils;
import com.nis.util.MinioUtil;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
import com.nis.util.StringUtils; import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController; import com.nis.web.controller.BaseRestController;
@@ -289,16 +290,20 @@ public class ConfigSourcesController extends BaseRestController {
throw new RestServiceException("checksum与文件MD5值不一致", RestBusinessCode.CheckSumIsWrong.getValue()); throw new RestServiceException("checksum与文件MD5值不一致", RestBusinessCode.CheckSumIsWrong.getValue());
} }
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
// NameValuePair[] meta_list = new NameValuePair[5];
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
// meta_list[1] = new NameValuePair("fileLength",
// String.valueOf(file.getSize()));
// meta_list[2] = new NameValuePair("fileExt", ext);
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
// meta_list[4] = new NameValuePair("fileMd5", md5);
logger.info("-----------------调用接口上传文件---------------"); logger.info("-----------------调用接口上传文件---------------");
filePath = FileManager.upload(fdsfile, null); if(Constants.IS_USE_MINIO){
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(), ext);
}else{
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
// NameValuePair[] meta_list = new NameValuePair[5];
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
// meta_list[1] = new NameValuePair("fileLength",
// String.valueOf(file.getSize()));
// meta_list[2] = new NameValuePair("fileExt", ext);
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
// meta_list[4] = new NameValuePair("fileMd5", md5);
filePath = FileManager.upload(fdsfile, null);
}
} }
}catch (IOException e) { }catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@@ -337,6 +342,7 @@ public class ConfigSourcesController extends BaseRestController {
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
file, null); file, null);
JSONObject resultObject = new JSONObject(); JSONObject resultObject = new JSONObject();
String filePath="";
try { try {
if (file == null) { if (file == null) {
throw new RestServiceException("请上传获取摘要的文件到file参数", RestBusinessCode.FileIsNull.getValue()); throw new RestServiceException("请上传获取摘要的文件到file参数", RestBusinessCode.FileIsNull.getValue());
@@ -353,9 +359,20 @@ public class ConfigSourcesController extends BaseRestController {
RestBusinessCode.CheckSumIsWrong.getValue()); RestBusinessCode.CheckSumIsWrong.getValue());
} }
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
logger.info("-----------------调用接口上传文件---------------"); logger.info("-----------------调用接口上传文件---------------");
String filePath = FileManager.upload(fdsfile, null); if(Constants.IS_USE_MINIO){
filePath = MinioUtil.uploadFile(file.getInputStream(), file.getOriginalFilename(), ext);
}else{
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
// NameValuePair[] meta_list = new NameValuePair[5];
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
// meta_list[1] = new NameValuePair("fileLength",
// String.valueOf(file.getSize()));
// meta_list[2] = new NameValuePair("fileExt", ext);
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
// meta_list[4] = new NameValuePair("fileMd5", md5);
filePath = FileManager.upload(fdsfile, null);
}
resultObject.put("accessUrl", filePath); resultObject.put("accessUrl", filePath);
} }
}catch (IOException e) { }catch (IOException e) {

View File

@@ -482,7 +482,7 @@ public class ConfigSourcesService extends BaseService {
maatTableName.substring(maatTableName.lastIndexOf("_") + 1)); maatTableName.substring(maatTableName.lastIndexOf("_") + 1));
dstStr = dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/") + 1)); dstStr = dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/") + 1));
} else if ("file_id".equals(commonSourceFieldCfg.getDstName())) { } else if ("file_id".equals(commonSourceFieldCfg.getDstName())) {
dstStr = dstStr.substring(dstStr.indexOf("group")); //dstStr = dstStr.substring(dstStr.indexOf("group"));
} }
} }
switch (commonSourceFieldCfg.getFieldType()) { switch (commonSourceFieldCfg.getFieldType()) {

View File

@@ -10,11 +10,11 @@ fastdfs.http_secret_key = FastDFS1234567890
fastdfs.http_tracker_http_port = 80 fastdfs.http_tracker_http_port = 80
#元辰鑫内网 #元辰鑫内网
fastdfs.tracker_servers = 10.0.6.249:22122 #fastdfs.tracker_servers = 10.0.6.249:22122
fastDfsHttpAddr= 10.0.6.249 #fastDfsHttpAddr= 10.0.6.249
#元辰鑫外网 #元辰鑫外网
#fastdfs.tracker_servers=192.168.10.205:22122 fastdfs.tracker_servers=192.168.10.205:22122
#fastDfsHttpAddr=192.168.10.205 fastDfsHttpAddr=192.168.10.205
#亦庄演示环境 #亦庄演示环境
#fastdfs.tracker_servers = 10.3.34.1:22122 #fastdfs.tracker_servers = 10.3.34.1:22122
#fastDfsHttpAddr = 10.3.34.1 #fastDfsHttpAddr = 10.3.34.1

View File

@@ -7,8 +7,8 @@ http.secret_key = FastDFS1234567890
#元辰鑫内网 #元辰鑫内网
tracker_server=10.0.6.249:22122 #tracker_server=10.0.6.249:22122
#元辰鑫外网 #元辰鑫外网
#tracker_server=192.168.10.205:22122 tracker_server=192.168.10.205:22122
#亦庄演示环境 #亦庄演示环境
#tracker_server=10.3.34.1:22122 #tracker_server=10.3.34.1:22122

View File

@@ -1,11 +1,11 @@
#==========日志库 Mysql======================= #==========日志库 Mysql=======================
jdbc.log.driver=com.mysql.jdbc.Driver jdbc.log.driver=com.mysql.jdbc.Driver
#元辰鑫内网 #元辰鑫内网
jdbc.log.url=jdbc:mysql://10.0.6.249:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull #jdbc.log.url=jdbc:mysql://10.0.6.249:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#华严 #华严
#jdbc.log.url=jdbc:mysql://192.168.11.242:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull #jdbc.log.url=jdbc:mysql://192.168.11.242:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#元辰鑫外网 #元辰鑫外网
#jdbc.log.url=jdbc:mysql://192.168.10.204:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull jdbc.log.url=jdbc:mysql://192.168.10.204:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#亦庄演示环境 #亦庄演示环境
#jdbc.log.url=jdbc:mysql://10.3.48.5:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull #jdbc.log.url=jdbc:mysql://10.3.48.5:3306/galaxy?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc.log.username=root jdbc.log.username=root
@@ -42,11 +42,11 @@ jdbc.hive.DBName=maat
#A版日志库 #A版日志库
jdbc.hive.driver=org.apache.hive.jdbc.HiveDriver jdbc.hive.driver=org.apache.hive.jdbc.HiveDriver
#元辰鑫内网 #元辰鑫内网
jdbc.hive.url=jdbc:hive2://10.0.6.202:10000/maat #jdbc.hive.url=jdbc:hive2://10.0.6.202:10000/maat
#华严 #华严
#jdbc.hive.url=jdbc:hive2://192.168.11.243:2181,192.168.10.76:2181,192.168.10.77:2181/maat;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 #jdbc.hive.url=jdbc:hive2://192.168.11.243:2181,192.168.10.76:2181,192.168.10.77:2181/maat;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
#元辰鑫外网 #元辰鑫外网
#jdbc.hive.url=jdbc:hive2://192.168.10.22:10000/maat jdbc.hive.url=jdbc:hive2://192.168.10.22:10000/maat
#亦庄演示环境高可用集群连接,注意使用此种方法需要配置hosts,主机名与ip的对应关系 #亦庄演示环境高可用集群连接,注意使用此种方法需要配置hosts,主机名与ip的对应关系
#jdbc.hive.url=jdbc:hive2://10.3.48.2:2181,10.3.48.3:2181,10.3.48.4:2181/maat;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 #jdbc.hive.url=jdbc:hive2://10.3.48.2:2181,10.3.48.3:2181,10.3.48.4:2181/maat;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
jdbc.hive.username=xa_z2_mesa jdbc.hive.username=xa_z2_mesa
@@ -75,7 +75,7 @@ jdbc.clickhouse.driver=ru.yandex.clickhouse.ClickHouseDriver
#域名测试环境 #域名测试环境
#jdbc.clickhouse.url=jdbc:clickhouse://clickhouse.baifendian.com:80/k18_ods #jdbc.clickhouse.url=jdbc:clickhouse://clickhouse.baifendian.com:80/k18_ods
#亦庄演示环境 #亦庄演示环境
jdbc.clickhouse.url=jdbc:clickhouse://10.3.45.5:8123/k18_ods?socket_timeout=600000 jdbc.clickhouse.url=jdbc:clickhouse://10.3.45.5:8123/k18_ods
jdbc.clickhouse.username= jdbc.clickhouse.username=
jdbc.clickhouse.key= jdbc.clickhouse.key=
jdbc.clickhouse.password= jdbc.clickhouse.password=
@@ -122,13 +122,13 @@ druid.log.filters=stat
##minio地址 ##minio地址
######################################################################### #########################################################################
##minio的地址,注意前面的http://不要忘记写 ##minio的地址,注意前面的http://不要忘记写
minioUrl=http://192.168.10.61:9000 minio_url=http://192.168.10.205:9000
##minio的accessKey ##minio的accessKey
minio_accessKey= minio_accessKey=minio
##minio的secretKey ##minio的secretKey
minio_secretKey= minio_secretKey=123456789
##minio的bucketName ##minio的bucketName
minio_bucketName=test minio_bucketName=maat-redis
@@ -136,11 +136,11 @@ minio_bucketName=test
##redis连接 ##redis连接
##################################################################################################################################### #####################################################################################################################################
#元辰鑫内网 #元辰鑫内网
redis.host=10.0.6.249 #redis.host=10.0.6.249
#华严 #华严
#redis.host=192.168.11.243 #redis.host=192.168.11.243
#元辰鑫外网 #元辰鑫外网
#redis.host=192.168.10.205 redis.host=192.168.10.205
#亦庄测试环境 #亦庄测试环境
#redis.host=192.168.10.215 #redis.host=192.168.10.215
#亦庄演示环境 #亦庄演示环境

View File

@@ -202,4 +202,6 @@ maatTestLogPath=c:/maat/mmat.log
mmSampleDstPath=/home/mesasoft/{tableType}/full/{fileName} mmSampleDstPath=/home/mesasoft/{tableType}/full/{fileName}
##定时将redis主从库的实时统计数据同步到redis集群中 ##定时将redis主从库的实时统计数据同步到redis集群中
syncRedisToClusterCron=0/10 * * * * ? syncRedisToClusterCron=0/10 * * * * ?
#文件服务器是否使用Minio
isUseMinio=true