X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Frepository%2FService.java;h=f0863a5ee7e44f709f47da111f612ee2540def6a;hb=dede1d28c8f37bb21fae806f00f8315b923670c1;hp=512d065ba5e4d48bc0ff339808025e165f6028f4;hpb=dfbd081159b02601a48162a647848223a9303ebf;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/Service.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/Service.java index 512d065b..f0863a5e 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/repository/Service.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/Service.java @@ -23,23 +23,23 @@ package org.oransc.policyagent.repository; import java.time.Duration; import java.time.Instant; +import lombok.Getter; + public class Service { + @Getter private final String name; private final Duration keepAliveInterval; private Instant lastPing; - // private final String callbackUrl1; // TBD + private final String callbackUrl; - public Service(String name, Duration keepAliveInterval) { + public Service(String name, Duration keepAliveInterval, String callbackUrl) { this.name = name; this.keepAliveInterval = keepAliveInterval; + this.callbackUrl = callbackUrl; ping(); } - public String getName() { - return this.name; - } - - public Duration getKeepAliveInterval() { + public synchronized Duration getKeepAliveInterval() { return this.keepAliveInterval; } @@ -48,11 +48,15 @@ public class Service { } public synchronized boolean isExpired() { - return timeSinceLastPing().compareTo(this.keepAliveInterval) > 0; + return this.keepAliveInterval.getSeconds() > 0 && timeSinceLastPing().compareTo(this.keepAliveInterval) > 0; } public synchronized Duration timeSinceLastPing() { return Duration.between(this.lastPing, Instant.now()); } + public synchronized String getCallbackUrl() { + return this.callbackUrl; + } + }