From 44d88722bf59f9d39b54a1aac3f59def61133b29 Mon Sep 17 00:00:00 2001 From: ramverma Date: Wed, 3 Apr 2019 14:58:57 +0000 Subject: Changing PAP model as per discussion 1) Changing PAP models to use ToscaPolicyIdentifier instead of actual ToscaPolicy itself. 2) Deleting unused PdpHealthCheck message. As we decided to return heath check based on DB state. 3) Updating PdpStatus message to use ToscaPolicyIdentifier instead of actual ToscaPolicy itself. Pdp don't need to send the whole ToscaPolicy everytime in heartbeat to PAP. Instead the identifier is sufficient. Change-Id: I50ead8d8b6af118fd1da08071a2b0fc50584d4aa Issue-ID: POLICY-1443 Signed-off-by: ramverma --- .../policy/models/pdp/concepts/PdpHealthCheck.java | 50 ------------------- .../onap/policy/models/pdp/concepts/PdpStatus.java | 7 +-- .../policy/models/pdp/concepts/PdpSubGroup.java | 18 +++---- .../policy/models/pdp/concepts/PolicyIdent.java | 50 ------------------- .../models/pdp/concepts/PolicyIdentOptVersion.java | 58 ---------------------- .../models/pdp/concepts/PolicyTypeIdent.java | 50 ------------------- .../models/pdp/concepts/ToscaPolicyIdentifier.java | 50 +++++++++++++++++++ .../concepts/ToscaPolicyIdentifierOptVersion.java | 58 ++++++++++++++++++++++ .../pdp/concepts/ToscaPolicyTypeIdentifier.java | 50 +++++++++++++++++++ .../pdp/persistence/concepts/JpaPdpSubGroup.java | 21 ++++---- 10 files changed, 182 insertions(+), 230 deletions(-) delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java create mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java create mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java create mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java (limited to 'models-pdp/src/main/java') diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java deleted file mode 100644 index b82af0225..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.models.pdp.enums.PdpMessageType; - -/** - * Class to represent the PDP_HEALTH_CHECK message that PAP will send to either PDPGroup/Subgroup or a PDP. - * - * @author Ram Krishna Verma (ram.krishna.verma@est.tech) - */ -@Getter -@Setter -@ToString -public class PdpHealthCheck extends PdpMessage { - - private String name; - private String pdpGroup; - private String pdpSubgroup; - - /** - * Constructor for instantiating PdpHealthCheck class with message name. - * - */ - public PdpHealthCheck() { - super(PdpMessageType.PDP_HEALTH_CHECK); - } -} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java index eb0758e61..d0fef4503 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java @@ -22,13 +22,14 @@ package org.onap.policy.models.pdp.concepts; import java.util.List; + import lombok.Getter; import lombok.Setter; import lombok.ToString; + import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpMessageType; import org.onap.policy.models.pdp.enums.PdpState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to represent the PDP_STATUS message that all the PDP's will send to PAP. @@ -48,8 +49,8 @@ public class PdpStatus extends PdpMessage { private String description; private String pdpGroup; private String pdpSubgroup; - private List supportedPolicyTypes; - private List policies; + private List supportedPolicyTypes; + private List policies; private String instance; private String deploymentInstanceInfo; private String properties; diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java index b4539ec3e..b4f469388 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java @@ -1,4 +1,4 @@ -/* +/*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. @@ -24,16 +24,16 @@ package org.onap.policy.models.pdp.concepts; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import lombok.Getter; import lombok.NonNull; import lombok.Setter; import lombok.ToString; + import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** - * Class to represent a group of all PDP's of the same pdp type running for a particular - * domain. + * Class to represent a group of all PDP's of the same pdp type running for a particular domain. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ @@ -42,8 +42,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @ToString public class PdpSubGroup { private String pdpType; - private List supportedPolicyTypes; - private List policies; + private List supportedPolicyTypes; + private List policies; private int currentInstanceCount; private int desiredInstanceCount; private Map properties; @@ -61,10 +61,10 @@ public class PdpSubGroup { * * @param source source from which to copy fields */ - public PdpSubGroup(@NonNull PdpSubGroup source) { + public PdpSubGroup(@NonNull final PdpSubGroup source) { this.pdpType = source.pdpType; - this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, PolicyTypeIdent::new); - this.policies = PfUtils.mapList(source.policies, ToscaPolicy::new); + this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, ToscaPolicyTypeIdentifier::new); + this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new); this.currentInstanceCount = source.currentInstanceCount; this.desiredInstanceCount = source.desiredInstanceCount; this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties)); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java deleted file mode 100644 index a62d90090..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; - -/** - * Identifies a policy. Both the name and version must be non-null. - */ -@Data -@NoArgsConstructor -public class PolicyIdent { - - @NonNull - private String name; - - @NonNull - private String version; - - - public PolicyIdent(@NonNull String name, @NonNull String version) { - this.name = name; - this.version = version; - } - - public PolicyIdent(PolicyIdent source) { - this.name = source.name; - this.version = source.version; - } -} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java deleted file mode 100644 index f86a3c46d..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; - -/** - * Policy identifier with an optional version; only the "name" is required. - */ -@Data -@NoArgsConstructor -public class PolicyIdentOptVersion { - - @NonNull - private String name; - - private String version; - - - public PolicyIdentOptVersion(@NonNull String name, String version) { - this.name = name; - this.version = version; - } - - public PolicyIdentOptVersion(PolicyIdentOptVersion source) { - this.name = source.name; - this.version = source.version; - } - - /** - * Determines if the version is null/missing. - * - * @return {@code true} if the version is null/missing, {@code false} - */ - public boolean isNullVersion() { - return (version == null); - } -} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java deleted file mode 100644 index 44ca168f5..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; - -/** - * Identifies a policy type. Both the name and version must be non-null. - */ -@Data -@NoArgsConstructor -public class PolicyTypeIdent { - - @NonNull - private String name; - - @NonNull - private String version; - - - public PolicyTypeIdent(@NonNull String name, @NonNull String version) { - this.name = name; - this.version = version; - } - - public PolicyTypeIdent(PolicyTypeIdent source) { - this.name = source.name; - this.version = source.version; - } -} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java new file mode 100644 index 000000000..245806c71 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +/** + * Identifies a policy. Both the name and version must be non-null. + */ +@Data +@NoArgsConstructor +public class ToscaPolicyIdentifier { + + @NonNull + private String name; + + @NonNull + private String version; + + + public ToscaPolicyIdentifier(@NonNull String name, @NonNull String version) { + this.name = name; + this.version = version; + } + + public ToscaPolicyIdentifier(ToscaPolicyIdentifier source) { + this.name = source.name; + this.version = source.version; + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java new file mode 100644 index 000000000..bd6b26ede --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +/** + * Policy identifier with an optional version; only the "name" is required. + */ +@Data +@NoArgsConstructor +public class ToscaPolicyIdentifierOptVersion { + + @NonNull + private String name; + + private String version; + + + public ToscaPolicyIdentifierOptVersion(@NonNull String name, String version) { + this.name = name; + this.version = version; + } + + public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifierOptVersion source) { + this.name = source.name; + this.version = source.version; + } + + /** + * Determines if the version is null/missing. + * + * @return {@code true} if the version is null/missing, {@code false} + */ + public boolean isNullVersion() { + return (version == null); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java new file mode 100644 index 000000000..cf989f3ae --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +/** + * Identifies a policy type. Both the name and version must be non-null. + */ +@Data +@NoArgsConstructor +public class ToscaPolicyTypeIdentifier { + + @NonNull + private String name; + + @NonNull + private String version; + + + public ToscaPolicyTypeIdentifier(@NonNull String name, @NonNull String version) { + this.name = name; + this.version = version; + } + + public ToscaPolicyTypeIdentifier(ToscaPolicyTypeIdentifier source) { + this.name = source.name; + this.version = source.version; + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java index 5164d3418..7020b4596 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java @@ -58,7 +58,8 @@ import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.base.PfValidationResult.ValidationResult; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.pdp.concepts.PolicyTypeIdent; +import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** @@ -161,17 +162,17 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative()); for (PfConceptKey supportedPolicyTypeKey : supportedPolicyTypes) { - PolicyTypeIdent supportedPolicyTypeIdent = - new PolicyTypeIdent(supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); + ToscaPolicyTypeIdentifier supportedPolicyTypeIdent = new ToscaPolicyTypeIdentifier( + supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent); } pdpSubgroup.setPolicies(new ArrayList<>()); for (PfConceptKey policyKey : policies) { - ToscaPolicy toscaPolicy = new ToscaPolicy(); - toscaPolicy.setName(policyKey.getName()); - toscaPolicy.setVersion(policyKey.getVersion()); - pdpSubgroup.getPolicies().add(toscaPolicy); + ToscaPolicyIdentifier toscaPolicyIdentifier = new ToscaPolicyIdentifier(); + toscaPolicyIdentifier.setName(policyKey.getName()); + toscaPolicyIdentifier.setVersion(policyKey.getVersion()); + pdpSubgroup.getPolicies().add(toscaPolicyIdentifier); } pdpSubgroup.setCurrentInstanceCount(currentInstanceCount); @@ -194,15 +195,15 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative(); - for (PolicyTypeIdent supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) { + for (ToscaPolicyTypeIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) { this.supportedPolicyTypes .add(new PfConceptKey(supportedPolicyType.getName(), supportedPolicyType.getVersion())); } this.policies = new ArrayList<>(); - for (ToscaPolicy toscaPolicy : pdpSubgroup.getPolicies()) { - this.policies.add(new PfConceptKey(toscaPolicy.getName(), toscaPolicy.getVersion())); + for (ToscaPolicyIdentifier toscaPolicyIdentifier : pdpSubgroup.getPolicies()) { + this.policies.add(new PfConceptKey(toscaPolicyIdentifier.getName(), toscaPolicyIdentifier.getVersion())); } this.currentInstanceCount = pdpSubgroup.getCurrentInstanceCount(); -- cgit 1.2.3-korg