diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java index 9e8d0bb..c9d4d39 100755 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java +++ b/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; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/RedisUtils.java b/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/RedisUtils.java similarity index 99% rename from nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/RedisUtils.java rename to nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/RedisUtils.java index 5ead947..1e6e0de 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/modules/common/utils/RedisUtils.java +++ b/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 redisTemplate; - /* @Value("${jwt.online-key}")*/ - private String onlineKey; + private String onlineKey = "online-key"; public RedisUtils(RedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; @@ -697,9 +697,9 @@ public class RedisUtils { */ public void delByKeys(String prefix, Set ids) { Set 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("--------------------------------------------"); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelProperties.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelProperties.java deleted file mode 100755 index 791ba8b..0000000 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelProperties.java +++ /dev/null @@ -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 settings = new ArrayList(); - - } - -} diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java index c0329df..47f13b4 100755 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java +++ b/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); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/endpoint/ArthasEndpoint.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/endpoint/ArthasEndpoint.java index dd8d2fc..62d695b 100755 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/endpoint/ArthasEndpoint.java +++ b/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; diff --git a/nladmin-system/nlsso-server/src/main/resources/config/application.yml b/nladmin-system/nlsso-server/src/main/resources/config/application.yml index e65fcbe..2b953ef 100644 --- a/nladmin-system/nlsso-server/src/main/resources/config/application.yml +++ b/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