gtj 2 жил өмнө
parent
commit
2f7af0cc4f

+ 4 - 4
other/gpload/pm_lte_gpload.sh

@@ -1,18 +1,18 @@
 #!/bin/bash
 
-source /data/xxl-job/greenplum_loaders_path.sh
+source /usr/local/greenplum-db-clients/greenplum_loaders_path.sh
 
 new_date=$1
 
 # 修改gpload配置文件
-sed -i 's/\/data\/xxl-job\/distinct\/pm_4g_hour_[0-9]\{10\}.csv/\/data\/xxl-job\/distinct\/pm_4g_hour_'${new_date}'.csv/' /data/xxl-job/pm_lte_gpload2.yml
+sed -i 's/\/data1\/pm\/pm_4g\/distinct\/pm_4g_hour_[0-9]\{10\}.csv/\/data1\/pm\/distinct\/pm_4g_hour_'${new_date}'.csv/' /data1/pm/pm_4g/pm_lte_gpload2.yml
 
 # 由于gpload需要输入密码,这里需要使用expect执行
-password=Richr00t#
+password=sqmdb_1QAZ
 
 expect -c "
 set timeout 300
-spawn gpload -f /data/xxl-job/pm_lte_gpload2.yml
+spawn gpload -f /data1/pm/pm_4g/pm_lte_gpload2.yml
 expect {
 \"connecting (yes/no)?\" { send \"yes\n\";exp_continue }
 \"Password:\" { send \"${password}\n\"; exp_continue}

+ 6 - 6
other/gpload/pm_lte_gpload2.yml

@@ -1,16 +1,16 @@
 VERSION: 1.0.0.1
 DATABASE: sqmmt
-USER: gpadmin
-HOST: 192.168.10.7
-PORT: 22
+USER: sqmdb
+HOST: 192.168.50.5
+PORT: 5432
 GPLOAD:
   INPUT:
     - SOURCE:
         LOCAL_HOSTNAME:
-          - 192.168.50.5
-        PORT: 5432
+          - 192.168.50.3
+        PORT: 54321
         FILE:
-          - /data/xxl-job/distinct/pm_4g_hour_2022052409.csv
+          - /data1/pm/pm_4g/distinct/pm_4g_hour_2022052409.csv
     - FORMAT: csv
     - DELIMITER: ','
     - HEADER: true

+ 77 - 77
src/main/java/com/nokia/config/XxlJobConfig.java

@@ -1,77 +1,77 @@
-package com.nokia.config;
-
-import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * xxl-job config
- *
- * @author xuxueli 2017-04-28
- */
-@Configuration
-public class XxlJobConfig {
-    private Logger logger = LoggerFactory.getLogger(com.nokia.config.XxlJobConfig.class);
-
-    @Value("${xxl.job.admin.addresses}")
-    private String adminAddresses;
-
-    @Value("${xxl.job.accessToken}")
-    private String accessToken;
-
-    @Value("${xxl.job.executor.appname}")
-    private String appname;
-
-    @Value("${xxl.job.executor.address}")
-    private String address;
-
-    @Value("${xxl.job.executor.ip}")
-    private String ip;
-
-    @Value("${xxl.job.executor.port}")
-    private int port;
-
-    @Value("${xxl.job.executor.logpath}")
-    private String logPath;
-
-    @Value("${xxl.job.executor.logretentiondays}")
-    private int logRetentionDays;
-
-
-    @Bean
-    public XxlJobSpringExecutor xxlJobExecutor() {
-        logger.info(">>>>>>>>>>> xxl-job config init.");
-        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
-        xxlJobSpringExecutor.setAppname(appname);
-        xxlJobSpringExecutor.setAddress(address);
-        xxlJobSpringExecutor.setIp(ip);
-        xxlJobSpringExecutor.setPort(port);
-        xxlJobSpringExecutor.setAccessToken(accessToken);
-        xxlJobSpringExecutor.setLogPath(logPath);
-        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
-        return xxlJobSpringExecutor;
-    }
-
-    /**
-     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
-     *
-     *      1、引入依赖:
-     *          <dependency>
-     *             <groupId>org.springframework.cloud</groupId>
-     *             <artifactId>spring-cloud-commons</artifactId>
-     *             <version>${version}</version>
-     *         </dependency>
-     *
-     *      2、配置文件,或者容器启动变量
-     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
-     *
-     *      3、获取IP
-     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
-     */
-
-
-}
+//package com.nokia.config;
+//
+//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//
+///**
+// * xxl-job config
+// *
+// * @author xuxueli 2017-04-28
+// */
+//@Configuration
+//public class XxlJobConfig {
+//    private Logger logger = LoggerFactory.getLogger(com.nokia.config.XxlJobConfig.class);
+//
+//    @Value("${xxl.job.admin.addresses}")
+//    private String adminAddresses;
+//
+//    @Value("${xxl.job.accessToken}")
+//    private String accessToken;
+//
+//    @Value("${xxl.job.executor.appname}")
+//    private String appname;
+//
+//    @Value("${xxl.job.executor.address}")
+//    private String address;
+//
+//    @Value("${xxl.job.executor.ip}")
+//    private String ip;
+//
+//    @Value("${xxl.job.executor.port}")
+//    private int port;
+//
+//    @Value("${xxl.job.executor.logpath}")
+//    private String logPath;
+//
+//    @Value("${xxl.job.executor.logretentiondays}")
+//    private int logRetentionDays;
+//
+//
+//    @Bean
+//    public XxlJobSpringExecutor xxlJobExecutor() {
+//        logger.info(">>>>>>>>>>> xxl-job config init.");
+//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+//        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
+//        xxlJobSpringExecutor.setAppname(appname);
+//        xxlJobSpringExecutor.setAddress(address);
+//        xxlJobSpringExecutor.setIp(ip);
+//        xxlJobSpringExecutor.setPort(port);
+//        xxlJobSpringExecutor.setAccessToken(accessToken);
+//        xxlJobSpringExecutor.setLogPath(logPath);
+//        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+//        return xxlJobSpringExecutor;
+//    }
+//
+//    /**
+//     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+//     *
+//     *      1、引入依赖:
+//     *          <dependency>
+//     *             <groupId>org.springframework.cloud</groupId>
+//     *             <artifactId>spring-cloud-commons</artifactId>
+//     *             <version>${version}</version>
+//     *         </dependency>
+//     *
+//     *      2、配置文件,或者容器启动变量
+//     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+//     *
+//     *      3、获取IP
+//     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+//     */
+//
+//
+//}

+ 3 - 2
src/main/java/com/nokia/task/LtePmTask.java

@@ -51,8 +51,9 @@ public class LtePmTask {
     }
 */
 
-    @XxlJob("execHandler")
+    @XxlJob("execHandlerPm4G")
     public void cronTask() throws JSchException, SSHUtilException, IOException, SftpException {
+        System.out.println("已触发pm4G");
         // 创建文件夹
         Files.createDirectories(Paths.get(downloadTargetDir));
         Files.createDirectories(Paths.get(distinctTargetDir));
@@ -125,7 +126,7 @@ public class LtePmTask {
     }
 
     public void gpload(String hourString) {
-        String gploadCommand = "sh /data/xxl-job/pm_lte_gpload.sh " + hourString;
+        String gploadCommand = "sh /data1/pm/pm_4g/pm_lte_gpload.sh " + hourString;
         GploadResult gpload = GploadUtil.gpload(gploadCommand);
         if (Boolean.TRUE.equals(gpload.getTaskStatus())) {
             log.debug("gpload完成: {}", gpload);

+ 4 - 4
src/main/resources/application.properties

@@ -3,7 +3,7 @@ logging.level.root=info
 logging.level.com.nokia=debug
 logging.file.name=log/ops.log
 # web服务端口号
-server.port=8082
+server.port=8089
 # 数据源
 #spring.datasource.driver-class-name=org.postgresql.Driver
 #spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
@@ -24,13 +24,13 @@ xxl.job.admin.addresses=http://192.168.10.7:8087/xxl-job-admin
 xxl.job.accessToken=
 
 ### xxl-job executor appname
-xxl.job.executor.appname=xxl-job-executor-sample2
+xxl.job.executor.appname=xxl-job-executor-sample
 ### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
 xxl.job.executor.address=
 ### xxl-job executor server-info
 xxl.job.executor.ip=
-xxl.job.executor.port=8888
+xxl.job.executor.port=9090
 ### xxl-job executor log-path
-xxl.job.executor.logpath=/data/xxl-job/logs
+xxl.job.executor.logpath=/data1/pm/pm_4g/log
 ### xxl-job executor log-retention-days
 xxl.job.executor.logretentiondays=30

+ 10 - 3
src/test/java/com/nokia/task/LtePmTaskTest.java

@@ -1,6 +1,7 @@
 package com.nokia.task;
 
 import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.SftpException;
 import com.nokia.PmInterfaceApplication;
 import com.nokia.common.ssh.exception.SSHUtilException;
 import org.junit.jupiter.api.Test;
@@ -14,10 +15,10 @@ import static org.junit.jupiter.api.Assertions.*;
 @SpringBootTest(classes = {PmInterfaceApplication.class})
 class LtePmTaskTest {
 
-    /*@Autowired
+    @Autowired
     private LtePmTask task;
 
-    @Test
+ /*   @Test
     void download() throws JSchException, SSHUtilException, IOException {
         task.download("2022053007");
     }
@@ -25,5 +26,11 @@ class LtePmTaskTest {
     @Test
     void distinct() throws IOException {
         task.distinct("2022053007");
-    }*/
+    }
+    */
+
+    @Test
+    public void Test4g() throws SftpException, SSHUtilException, JSchException, IOException {
+        task.cronTask();
+    }
 }