feat():before testRunner
parent
a412e584db
commit
40ab1e3859
|
@ -18,17 +18,17 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@RequestMapping("fluxmq/")
|
@RequestMapping("/fluxmq")
|
||||||
public class FluxGetInfoController {
|
public class FluxGetInfoController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FluxGetInfoService fluxGetInfoService;
|
private FluxGetInfoService fluxGetInfoService;
|
||||||
|
|
||||||
@GetMapping("/getInfo/")
|
@GetMapping("/getInfo")
|
||||||
public Result getInfo(){
|
public Result getInfo(){
|
||||||
return fluxGetInfoService.getInfo(null);
|
return fluxGetInfoService.getInfo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("getIps/")
|
@GetMapping("/getIps")
|
||||||
public Result<List<MqttServerModel>> getIps(){
|
public Result<List<MqttServerModel>> getIps(){
|
||||||
return fluxGetInfoService.getIps();
|
return fluxGetInfoService.getIps();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,14 @@ public class SelectInstances {
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
//自己的
|
||||||
.setAccessKeyId("LTAI5t7vsLXtqTJKve7JipnX")
|
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
// .setAccessKeyId("LTAI5t7vsLXtqTJKve7JipnX")
|
||||||
.setAccessKeySecret("AIyMaSTKQtsB1V5sVqlNAGbQzxgXnS");
|
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
|
// .setAccessKeySecret("AIyMaSTKQtsB1V5sVqlNAGbQzxgXnS");
|
||||||
|
// 杜云飞
|
||||||
|
.setAccessKeyId("LTAI5tPTk3MFkmCGBbnQgmrM")
|
||||||
|
.setAccessKeySecret("q7rLjxrI0SLBXlvNT4VmYcHCNCY2p6");
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
config.endpoint = "ecs.cn-zhangjiakou.aliyuncs.com";
|
config.endpoint = "ecs.cn-zhangjiakou.aliyuncs.com";
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
return new com.aliyun.ecs20140526.Client(config);
|
||||||
|
@ -84,7 +88,7 @@ public class SelectInstances {
|
||||||
}
|
}
|
||||||
|
|
||||||
//1分钟
|
//1分钟
|
||||||
@Scheduled(cron = "* 0/5 * * * ? ")
|
@Scheduled(cron = "0 0/5 * * * ? ")
|
||||||
//10秒
|
//10秒
|
||||||
// @Scheduled(cron = "0/10 * * * * ? ")
|
// @Scheduled(cron = "0/10 * * * * ? ")
|
||||||
public void saveIps() {
|
public void saveIps() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.mobai.domain.*;
|
||||||
import com.mobai.domain.flux.ApifoxModel;
|
import com.mobai.domain.flux.ApifoxModel;
|
||||||
import com.mobai.openApi.SelectInstances;
|
import com.mobai.openApi.SelectInstances;
|
||||||
import com.mobai.service.FluxGetInfoService;
|
import com.mobai.service.FluxGetInfoService;
|
||||||
|
import lombok.Synchronized;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
@ -19,6 +20,7 @@ import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,29 +82,34 @@ public class FluxGetInfoServiceImpl implements FluxGetInfoService {
|
||||||
// "timestamp": "11111" new Date().getMillis()
|
// "timestamp": "11111" new Date().getMillis()
|
||||||
// "username": "你好" Vin + timestamp
|
// "username": "你好" Vin + timestamp
|
||||||
// "nonce": "33" 随机
|
// "nonce": "33" 随机
|
||||||
|
|
||||||
log.warn("参数为:{}", req);
|
log.warn("参数为:{}", req);
|
||||||
// String string = redis.opsForList().range("fluxMq", 0, -1).get(0);
|
// String string = redis.opsForList().range("fluxMq", 0, -1).get(0);
|
||||||
// List<MqttServerModel> mqtts = JSON.parseArray(string, MqttServerModel.class);
|
// List<MqttServerModel> mqtts = JSON.parseArray(string, MqttServerModel.class);
|
||||||
// log.info("集合:{}",mqtts);
|
// log.info("集合:{}",mqtts);
|
||||||
// tcp://192.168.1.1:1883
|
// tcp://192.168.1.1:1883
|
||||||
if (redis.hasKey("fluxMqIndex")) {
|
synchronized(this){
|
||||||
redis.opsForValue().increment("fluxMqIndex", 1);
|
if (redis.hasKey("fluxMqIndex")) {
|
||||||
} else {
|
redis.opsForValue().increment("fluxMqIndex", 1);
|
||||||
redis.opsForValue().set("fluxMqIndex", 0 + "");
|
} else {
|
||||||
}
|
redis.opsForValue().set("fluxMqIndex", 0 + "");
|
||||||
int index = Integer.valueOf(redis.opsForValue().get("fluxMqIndex"));
|
}
|
||||||
log.info("下标:{}", index);
|
int index = Integer.valueOf(redis.opsForValue().get("fluxMqIndex"));
|
||||||
|
log.info("下标:{}", index);
|
||||||
// List<String> fluxmq = redis.opsForList().range("mqttIp", 0, 5);
|
// List<String> fluxmq = redis.opsForList().range("mqttIp", 0, 5);
|
||||||
String mqttIp = redis.opsForList().index("mqttIp", index);
|
String mqttIp = redis.opsForList().index("mqttIp", index);
|
||||||
|
|
||||||
// log.info(fluxmq);
|
// log.info(fluxmq);
|
||||||
log.info(mqttIp);
|
log.info(mqttIp);
|
||||||
MqttServerModel mqttServerModel = JSON.parseObject(mqttIp, MqttServerModel.class);
|
MqttServerModel mqttServerModel = JSON.parseObject(mqttIp, MqttServerModel.class);
|
||||||
if (index + 1 == 100) {
|
if (index + 1 >= 80) {
|
||||||
redis.opsForValue().set("fluxMqIndex", 0 + "");
|
redis.opsForValue().set("fluxMqIndex", 0 + "");
|
||||||
|
}
|
||||||
|
log.info("已获取到对象:{}", mqttServerModel);
|
||||||
|
|
||||||
|
return Result.success(mqttServerModel);
|
||||||
}
|
}
|
||||||
log.info("已获取到对象:{}", mqttServerModel);
|
|
||||||
return Result.success(mqttServerModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mobai.util;
|
package com.mobai.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -16,6 +17,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
**/
|
**/
|
||||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||||
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
@Lazy
|
@Lazy
|
||||||
public class RedisService {
|
public class RedisService {
|
||||||
|
@ -270,7 +272,7 @@ public class RedisService {
|
||||||
public void increment(String s,int i) {
|
public void increment(String s,int i) {
|
||||||
if (Boolean.TRUE.equals(stringRedisTemplate.hasKey(s))){
|
if (Boolean.TRUE.equals(stringRedisTemplate.hasKey(s))){
|
||||||
String o = stringRedisTemplate.opsForValue().get(s);
|
String o = stringRedisTemplate.opsForValue().get(s);
|
||||||
System.out.println(o);
|
log.info("当前游标::"+o);
|
||||||
stringRedisTemplate.opsForValue().increment(s,i);
|
stringRedisTemplate.opsForValue().increment(s,i);
|
||||||
}else {
|
}else {
|
||||||
stringRedisTemplate.opsForValue().set(s,i+"");
|
stringRedisTemplate.opsForValue().set(s,i+"");
|
||||||
|
|
|
@ -2,7 +2,7 @@ server:
|
||||||
port: 8081
|
port: 8081
|
||||||
spring:
|
spring:
|
||||||
redis:
|
redis:
|
||||||
host: 175.24.138.82
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password:
|
password:
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
|
|
Loading…
Reference in New Issue