diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-25 17:29:21 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-25 17:30:39 -0400 |
commit | 296fc9c47661e2b9e7d4e5293f1b25fc0cfc7d28 (patch) | |
tree | 92bfc1047a58c6eae029a50c008736271df752a8 /utils/src/main/java | |
parent | e9d9563417fed07db98a4b18b854cbe4d916c376 (diff) |
Add name generator for PAP and PDPs
Added a method that PAPs and PDPs can use to generate a unique name or
identifier to be used in PAP-PDP messages.
Issue-ID: POLICY-3410
Change-Id: I22b075b123f79ba05e0884f743296c4bc64842b9
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils/src/main/java')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java index e3539fb7..6698d7cf 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java +++ b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java @@ -26,6 +26,7 @@ import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; +import java.util.UUID; import javax.net.ssl.TrustManager; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -170,4 +171,15 @@ public final class NetworkUtil { return "127.0.0.1"; } + + /** + * Generates a globally unique name, typically for use in PDP messages, to uniquely + * identify a PDP (or PAP), regardless on what cluster it resides. + * + * @param prefix text to be prepended to the generated value + * @return a globally unique name + */ + public static String genUniqueName(String prefix) { + return prefix + "-" + UUID.randomUUID(); + } } |