diff options
Diffstat (limited to 'controlloop/common/guard/src/main/java')
-rw-r--r-- | controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java | 8 | ||||
-rw-r--r-- | controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java | 84 |
2 files changed, 92 insertions, 0 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java index fabc48511..b35ec5a9f 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java @@ -26,6 +26,7 @@ import java.util.UUID; import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.guard.impl.PNFTargetLock; import org.onap.policy.guard.impl.VMTargetLock; +import org.onap.policy.guard.impl.VNFTargetLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,6 +79,13 @@ public class PolicyGuard { // lock = new VMTargetLock(targetType, targetInstance, requestID, callback); break; + case VNF: + // + // Create the Lock object + // + lock = new VNFTargetLock(targetType, targetInstance, requestID, callback); + break; + default: return LockResult.createLockResult(GuardResult.LOCK_EXCEPTION, null); } diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java new file mode 100644 index 000000000..1350d5c54 --- /dev/null +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * guard + * ================================================================================ + * Copyright (C) 2017 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.guard.impl; + +import java.io.Serializable; +import java.util.UUID; + +import org.onap.policy.controlloop.policy.TargetType; +import org.onap.policy.guard.LockCallback; +import org.onap.policy.guard.TargetLock; + +public class VNFTargetLock implements TargetLock, Serializable { + + /** + * + */ + private static final long serialVersionUID = 2335897394577202732L; + + private final UUID lockID; + private final TargetType targetType; + private final String target; + private final UUID requestID; + private final LockCallback callback; + + public VNFTargetLock (TargetType type, String target, UUID requestID, LockCallback callback) { + this.lockID = UUID.randomUUID(); + this.targetType = type; + this.target = target; + this.requestID = requestID; + this.callback = callback; + } + + @Override + public UUID getLockID() { + return this.lockID; + } + + + @Override + public TargetType getTargetType() { + return targetType; + } + + @Override + public String getTargetInstance() { + return target; + } + + @Override + public UUID getRequestID() { + return this.requestID; + } + + public LockCallback getCallback() { + return this.callback; + } + + @Override + public String toString() { + return "VNFTargetLock [lockID=" + lockID + ", targetType=" + targetType + ", target=" + target + ", requestID=" + + requestID + "]"; + } + + + +} |