summaryrefslogtreecommitdiffstats
path: root/aai-failover
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:35:37 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:38:19 +0000
commitfbb02159b84435cf37221ae8ae5e0045167be15a (patch)
tree78196f6a3e5e4d0b1e5ca6ecadec0f9e9a623303 /aai-failover
parent58f0fd2f6ef58de52e1f9a73540c1bb895c0d6e6 (diff)
Reduce the number of problems in aai-common by removing unused imports
- run mvn spotless:apply across aai-commmon to remove unused imports - run mvn formatter:format across aai-common Issue-ID: AAI-3583 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I2dfeb395eafa2824ce8369bba3a18db3e1845522
Diffstat (limited to 'aai-failover')
-rw-r--r--aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java22
-rw-r--r--aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java11
2 files changed, 16 insertions, 17 deletions
diff --git a/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java b/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
index ee21d167..660cac91 100644
--- a/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
+++ b/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
@@ -17,8 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.failover;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -27,9 +31,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicLong;
-
@Aspect
@Component
public class FailoverAspect {
@@ -39,7 +40,7 @@ public class FailoverAspect {
private final FailoverMonitor failoverMonitor;
private final AtomicLong atomicLong;
- public FailoverAspect(FailoverMonitor failoverMonitor){
+ public FailoverAspect(FailoverMonitor failoverMonitor) {
this.failoverMonitor = failoverMonitor;
this.atomicLong = new AtomicLong(1l);
}
@@ -69,25 +70,22 @@ public class FailoverAspect {
@Around("@annotation(org.springframework.scheduling.annotation.Scheduled)")
public void preSchedule(ProceedingJoinPoint pointcut) throws Throwable {
- Object target = pointcut.getTarget();
+ Object target = pointcut.getTarget();
MethodSignature signature = (MethodSignature) pointcut.getSignature();
- String method = signature.getMethod().getName();
+ String method = signature.getMethod().getName();
- if(failoverMonitor.shouldRun()){
+ if (failoverMonitor.shouldRun()) {
atomicLong.set(1l);
pointcut.proceed();
} else {
long currentTime = new Date().getTime();
long lastMessageTime = atomicLong.get();
- if((currentTime - lastMessageTime) > 120000){
+ if ((currentTime - lastMessageTime) > 120000) {
atomicLong.compareAndSet(lastMessageTime, new Date().getTime());
LOGGER.debug("Not proceeding the task {}#{} due to is_primary set to false in failover.properties",
- target.getClass(),
- method
- );
+ target.getClass(), method);
}
}
}
}
-
diff --git a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
index cadddc24..731abe7c 100644
--- a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
+++ b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.failover;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
+package org.onap.aai.failover;
import java.io.IOException;
import java.io.InputStream;
@@ -29,6 +27,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
@Component
public class FailoverMonitor {
@@ -43,9 +44,9 @@ public class FailoverMonitor {
Path failoverPath = Paths.get(failoverPropertiesPath);
- if(Files.exists(failoverPath)){
+ if (Files.exists(failoverPath)) {
Properties properties = new Properties();
- try (InputStream is = Files.newInputStream(failoverPath)){
+ try (InputStream is = Files.newInputStream(failoverPath)) {
properties.load(is);
// If the property is_primary is missing then it should proceed
return TRUE.equals(properties.getProperty(IS_PRIMARY, DEFAULT_FOR_PRIMARY));