Browse Source

init

master
zhangzhiqiang 2 years ago
parent
commit
ab2b7bd476
  1. 3
      nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java
  2. 10
      nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/RedisUtils.java
  3. 53
      nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelProperties.java
  4. 16
      nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java
  5. 4
      nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/endpoint/ArthasEndpoint.java
  6. 4
      nladmin-system/nlsso-server/src/main/resources/config/application.yml

3
nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java

@ -26,7 +26,6 @@ import java.util.Enumeration;
* @author hengyunabc 2020-10-27
*
*/
@Slf4j
public class InetAddressUtil {
/**
@ -212,7 +211,7 @@ public class InetAddressUtil {
try {
ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
return ip;

10
nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/RedisUtils.java → nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/RedisUtils.java

@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.utils;
package org.nl.common.utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.Cursor;
@ -38,8 +39,7 @@ import java.util.concurrent.TimeUnit;
public class RedisUtils {
private static final Logger log = LoggerFactory.getLogger(RedisUtils.class);
private RedisTemplate<Object, Object> redisTemplate;
/* @Value("${jwt.online-key}")*/
private String onlineKey;
private String onlineKey = "online-key";
public RedisUtils(RedisTemplate<Object, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
@ -697,9 +697,9 @@ public class RedisUtils {
*/
public void delByKeys(String prefix, Set<Long> ids) {
Set<Object> keys = new HashSet<>();
/* for (String id : ids) {
for (Long id : ids) {
keys.addAll(redisTemplate.keys(new StringBuffer(prefix).append(id).toString()));
}*/
}
long count = redisTemplate.delete(keys);
// 此处提示可自行删除
log.debug("--------------------------------------------");

53
nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelProperties.java

@ -1,53 +0,0 @@
package org.nl.config.arthas;
import lombok.Data;
import org.nl.common.utils.InetAddressUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author hengyunabc 2019-08-29
*
*/
@Component
@ConfigurationProperties(prefix = "arthas")
@Data
public class TunnelProperties {
private Server server;
private EmbeddedRedis embeddedRedis;
/**
* supoort apps.html/agents.html
*/
private boolean enableDetailPages = false;
@Data
public static class Server {
/**
* tunnel server listen host
*/
private String host;
private int port;
private boolean ssl;
private String path = ArthasConstants.DEFAULT_WEBSOCKET_PATH;
/**
* 客户端连接的地址也用于保存到redis里当部署tunnel server集群里需要不配置则会自动获取
*/
private String clientConnectHost = InetAddressUtil.getInetAddress();
}
@Data
public static class EmbeddedRedis {
private boolean enabled = false;
private String host = "127.0.0.1";
private int port = 6379;
private List<String> settings = new ArrayList<String>();
}
}

16
nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java

@ -1,11 +1,15 @@
package org.nl.config.arthas;
import com.alibaba.arthas.spring.ArthasProperties;
import org.nl.common.utils.InetAddressUtil;
import org.nl.monitor.server.arthas.TunnelServer;
import org.nl.monitor.server.arthas.cluster.TunnelClusterStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -19,18 +23,18 @@ import org.springframework.context.annotation.Configuration;
public class TunnelServerConfiguration {
@Autowired
TunnelProperties tunnelProperties;
ArthasProperties arthasProperties;
@Bean(initMethod = "start", destroyMethod = "stop")
@ConditionalOnMissingBean
public TunnelServer tunnelServer(@Autowired(required = false) TunnelClusterStore tunnelClusterStore) {
TunnelServer tunnelServer = new TunnelServer();
tunnelServer.setHost(tunnelProperties.getHost());
tunnelServer.setPort(tunnelProperties.getPort());
tunnelServer.setSsl(tunnelProperties.isSsl());
tunnelServer.setPath(tunnelProperties.getPath());
tunnelServer.setClientConnectHost(TunnelProperties.clientConnectHost);
tunnelServer.setHost(arthasProperties.getIp());
tunnelServer.setPort(arthasProperties.getHttpPort());
tunnelServer.setSsl(false);
tunnelServer.setPath(ArthasConstants.DEFAULT_WEBSOCKET_PATH);
tunnelServer.setClientConnectHost(InetAddressUtil.getInetAddress());
if (tunnelClusterStore != null) {
tunnelServer.setTunnelClusterStore(tunnelClusterStore);
}

4
nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/endpoint/ArthasEndpoint.java

@ -3,7 +3,7 @@ package org.nl.config.arthas.endpoint;
import java.util.HashMap;
import java.util.Map;
import org.nl.config.arthas.TunnelProperties;
import com.alibaba.arthas.spring.ArthasProperties;
import org.nl.monitor.server.arthas.TunnelServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@ -13,7 +13,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
public class ArthasEndpoint {
@Autowired
TunnelProperties arthasProperties;
ArthasProperties arthasProperties;
@Autowired
TunnelServer tunnelServer;

4
nladmin-system/nlsso-server/src/main/resources/config/application.yml

@ -80,7 +80,7 @@ arthas:
agent-id: hsehdfsfghhwertyfad
tunnel-server: ws://127.0.0.1:7777/ws
enable-detail-pages: true
host: 127.0.0.1
port: 7777
ip: 127.0.0.1
telnetPort: 7777

Loading…
Cancel
Save