diff options
author | tang peng <tang.peng5@zte.com.cn> | 2020-08-14 02:50:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-08-14 02:50:12 +0000 |
commit | c9741cd13332a64a2aec32b72bd81f90c456107d (patch) | |
tree | d2919b1756fb2fe39c7997f6c7330ebe4c9f09bc /rulemgt/src/main/java | |
parent | a041fdb31505fc086e9416126e43f03e7cd50442 (diff) | |
parent | ce764eb74e8c3cb143ddb31cce8b0af785d1b8a2 (diff) |
Merge "Tried to Fix Some Vulnerability Issues"
Diffstat (limited to 'rulemgt/src/main/java')
3 files changed, 33 insertions, 58 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java index 21855f8..c839b5a 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java @@ -51,7 +51,6 @@ public class RuleActiveApp extends IOCApplication<RuleAppConfig> { public void run(RuleAppConfig configuration, Environment environment) throws Exception { super.run(configuration, environment); - environment.jersey().register(new RuleMgtResources()); try { new MSBRegisterUtil().register2Msb(createMicroServiceInfo()); } catch (CorrelationException e) { diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/MsbQuery.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/MsbQuery.java index 51ed0f2..df0783d 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/MsbQuery.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/MsbQuery.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 ZTE Corporation. + * Copyright 2017-2020 ZTE Corporation. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,73 +15,55 @@ */ package org.onap.holmes.rulemgt.msb; -import lombok.extern.slf4j.Slf4j; -import org.glassfish.hk2.api.ServiceLocator; import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder; -import org.onap.holmes.rulemgt.send.RuleAllocator; import org.onap.holmes.rulemgt.send.Ip4AddingRule; -import org.onap.holmes.rulemgt.wrapper.RuleMgtWrapper; +import org.onap.holmes.rulemgt.send.RuleAllocator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; import java.util.Timer; import java.util.TimerTask; +import static java.util.concurrent.TimeUnit.SECONDS; -@Slf4j public class MsbQuery { - private RuleAllocator ruleAllocator; - + static final private Logger log = LoggerFactory.getLogger(MsbQuery.class); + final private RuleAllocator ruleAllocator; private Ip4AddingRule ip4AddingRule; - private EngineInsQueryTool engineInsQueryTool; - private RuleMgtWrapper ruleMgtWrapper; - - private List<String> timerIpList; - public MsbQuery() { ruleAllocator = new RuleAllocator(); - - ServiceLocator locator = ServiceLocatorHolder.getLocator(); - ip4AddingRule = locator.getService(Ip4AddingRule.class); - engineInsQueryTool = locator.getService(EngineInsQueryTool.class); - ruleMgtWrapper = locator.getService(RuleMgtWrapper.class); + ip4AddingRule = ServiceLocatorHolder.getLocator().getService(Ip4AddingRule.class); + engineInsQueryTool = ServiceLocatorHolder.getLocator().getService(EngineInsQueryTool.class); } public void startTimer() { try { - timer(); + new Timer().schedule(new TimerTask() { + + public void run() { + try { + List<String> timerIpList = engineInsQueryTool.getInstanceList(); + log.info(String.format("There are %d engine instance(s) running currently.", timerIpList.size())); + + ip4AddingRule.setIpList(timerIpList); + ruleAllocator.allocateRules(timerIpList); + } catch (Exception e) { + log.error("The timing query engine instance failed ", e); + } + } + + }, SECONDS.toMillis(10), SECONDS.toMillis(30)); } catch (Exception e) { log.error("MSBQuery startTimer timer task failed !" + e.getMessage(), e); try { - Thread.sleep(30000); + SECONDS.sleep(30); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } } - - - } - - public void timer() throws Exception { - Timer timer = new Timer(); - timer.schedule(new TimerTask() { - - public void run() { - try { - timerIpList = engineInsQueryTool.getInstanceList(); - log.info(String.format("There are %d engine instance(s) running currently.", timerIpList.size())); - - ip4AddingRule.setIpList(timerIpList); - ruleAllocator.allocateRules(timerIpList); - } catch (Exception e) { - log.error("The timing query engine instance failed ", e); - } - } - - }, 10000, 30000); - } - } diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java index 8e5b7a0..445c2f9 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java @@ -1,5 +1,5 @@ /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2020 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -18,19 +18,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.SwaggerDefinition;
-import java.util.Locale;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
import lombok.extern.slf4j.Slf4j;
import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.exception.CorrelationException;
@@ -47,6 +34,13 @@ import org.onap.holmes.rulemgt.bean.response.RuleQueryListResponse; import org.onap.holmes.rulemgt.constant.RuleMgtConstant;
import org.onap.holmes.rulemgt.wrapper.RuleMgtWrapper;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import java.util.Locale;
+
@Service
@SwaggerDefinition
@Path("/rule")
|