summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher')
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml10
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java3
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml19
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java28
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java27
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java3
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java53
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties27
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties28
-rw-r--r--appc-dispatcher/appc-dispatcher-common/appc-data-access-lib/pom.xml21
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/openecomp/appc/domainmodel/lcm/VNFOperation.java5
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/pom.xml7
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceFactory.java15
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-features/src/main/resources/features.xml4
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/pom.xml11
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/Messages.java1
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/optimistic/SqlLockManager.java2
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/LockRecord.java62
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManager.java85
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/SqlLockManager.java251
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManagerMock.java150
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/TestMySqlLockManager.java121
-rw-r--r--appc-dispatcher/appc-dispatcher-installer/pom.xml2
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/pom.xml8
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/Constants.java1
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/LicenseManager.java1
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/pom.xml14
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseDataAccessServiceImpl.java26
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseManagerImpl.java3
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml12
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/org/openecomp/appc/default.properties29
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-core/src/test/java/org/openecomp/appc/licmgr/LicenseServiceMock.java1
-rw-r--r--appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/pom.xml7
-rw-r--r--appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/java/org/openecomp/appc/lifecyclemanager/helper/MetadataReader.java98
-rw-r--r--appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/resources/org/openecomp/appc/default.properties26
-rw-r--r--appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/test/java/org/openecomp/appc/TestLifecycleManager.java13
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-api/pom.xml12
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/LCMStateManager.java42
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/RequestHandler.java6
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml32
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java (renamed from appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java)61
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java144
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java36
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java33
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java11
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java4
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java33
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java62
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java47
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java38
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml4
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties21
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java55
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java65
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java69
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java51
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties28
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-features/src/main/resources/features.xml5
-rw-r--r--appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml13
-rw-r--r--appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/java/org/openecomp/appc/workflow/impl/WorkFlowManagerImpl.java12
-rw-r--r--appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/resources/org/openecomp/appc/default.properties26
-rw-r--r--appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/test/resources/org/openecomp/appc/default.properties29
-rw-r--r--appc-dispatcher/appc-workflow-management/appc-workflow-management-features/src/main/resources/features.xml6
-rw-r--r--appc-dispatcher/pom.xml1
64 files changed, 1673 insertions, 447 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml
index 6841b8224..7e6f01b32 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml
@@ -30,13 +30,13 @@
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-common</artifactId>
<version>${project.version}</version>
+ <scope>compile</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.commons</groupId>-->
<!--<artifactId>commons-lang3</artifactId>-->
<!--<version>3.4</version>-->
<!--<scope>provided</scope>-->
- <!--<type>bundle</type>-->
<!--</dependency>-->
</dependencies>
<build>
@@ -49,9 +49,13 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>org.openecomp.appc.executor,org.openecomp.appc.executor.objects,org.openecomp.appc.executor.conv,org.openecomp.appc.executor.helper</Export-Package>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic,javax.json;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Dependency>
+ javax.json;scope=compile|runtime;inline=false
+ </Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
- <Import-Package>!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ <Import-Package>
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
index 14bd8152c..6b1b67481 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java
@@ -41,7 +41,7 @@ public enum LCMCommandStatus {
MISSING_MANDATORY_PARAMETER(302,"MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ),
REQUEST_PARSING_FAILED(303,"REQUEST PARSING FAILED - ${errorMsg}"),
NO_TRANSITION_DEFINE(304,"ACTION IS NOT ALLOWED - Action ${actionName} is not allowed for VNF in state ${currentState}"),
- ACTION_NOT_SUPPORTED(305,"ACTION NOT SUPPORTED - ${actionName} action is not supported" ),
+ INVALID_VNF_STATE(305,"Request rejected because VNF status in A&AI is - ${currentState}" ),
VNF_NOT_FOUND(306,"VNF NOT FOUND - VNF with ID ${vnfId} was not found" ),
DG_WORKFLOW_NOT_FOUND(307,"DG WORKFLOW NOT FOUND - No DG workflow found for the combination of ${dgModule} module ${dgName} name and ${dgVersion} version"),//TODO need to support it
WORKFLOW_NOT_FOUND(308,"WORKFLOW NOT FOUND - No workflow found for VNF type ${vnfTypeVersion} and ${actionName} action"),
@@ -49,6 +49,7 @@ public enum LCMCommandStatus {
LOCKING_FAILURE(310,"LOCKING FAILURE - ${errorMsg}" ),
EXPIRED_REQUEST(311,"EXPIRED REQUEST"),
DUPLICATE_REQUEST(312,"DUPLICATE REQUEST"),
+ MISSING_VNF_DATA_IN_AAI(313,"MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"),
SUCCESS(400,"SUCCESS - request has been processed successfully"),
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml
index ef73055f8..d827fba8b 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml
@@ -40,7 +40,6 @@
<dependency>
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-command-executor-api</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecomp.appc</groupId>
@@ -92,14 +91,28 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Dependency>eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Service>org.openecomp.appc.executor.CommandExecutor</Export-Service>
- <Import-Package>org.openecomp.appc.executionqueue.*,org.openecomp.appc.executor,org.openecomp.appc.executor.objects,!groovy.lang,!javax.jms,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*;resolution:=optional</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.executionqueue.*,
+ org.openecomp.appc.executor,
+ org.openecomp.appc.executor.objects,
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-command-executor-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java
index fcc4f9156..7e1281ac4 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java
@@ -87,6 +87,34 @@ public class CommandExecutorImpl implements CommandExecutor {
}
}
+ private RuntimeContext getCommandRequest(RuntimeContext commandExecutorInput){
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getCommandRequest with CommandExecutorInput = "+ ObjectUtils.toString(commandExecutorInput));
+ }
+ RuntimeContext commandRequest;
+ commandRequest = commandExecutorInput;
+ /*
+ CommandRequest commandRequest;
+
+ switch(commandExecutorInput.getRequestContext().getAction()){
+ case Sync:
+ case Audit:
+ case ConfigBackup:
+ case ConfigBackupDelete:
+ case ConfigExport:
+ commandRequest = new LCMReadOnlyCommandRequest(commandExecutorInput);
+ break;
+ default:
+ commandRequest = new LCMCommandRequest(commandExecutorInput);
+ break;
+ }
+ */
+ if (logger.isTraceEnabled()) {
+ logger.trace("Exiting from getCommandRequest with (CommandRequest = "+ ObjectUtils.toString(commandRequest)+")");
+ }
+ return commandRequest;
+ }
+
@SuppressWarnings("unchecked")
private void enqueRequest(RuntimeContext request) throws APPCException{
if (logger.isTraceEnabled()) {
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
index 21a00861e..66b98bb28 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java
@@ -21,29 +21,17 @@
package org.openecomp.appc.executor.impl;
-import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
-import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
-
-import java.net.InetAddress;
-
-import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
import org.openecomp.appc.domainmodel.lcm.Status;
import org.openecomp.appc.executor.objects.CommandResponse;
import org.openecomp.appc.executor.objects.LCMCommandStatus;
import org.openecomp.appc.executor.objects.Params;
-import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.requesthandler.RequestHandler;
+import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
import org.openecomp.appc.workflow.WorkFlowManager;
import org.openecomp.appc.workflow.objects.WorkflowRequest;
import org.openecomp.appc.workflow.objects.WorkflowResponse;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.slf4j.MDC;
/**
* This abstract class is base class for all Command tasks. All command task must inherit this class.
@@ -80,19 +68,6 @@ public abstract class CommandTask implements Runnable {
public void execute() {
final RuntimeContext runtimeContext = commandRequest;
- MDC.put(MDC_KEY_REQUEST_ID, runtimeContext.getRequestContext().getCommonHeader().getRequestId());
- if (runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId() != null)
- MDC.put(MDC_SERVICE_INSTANCE_ID, runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId());
- MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, runtimeContext.getRequestContext().getCommonHeader().getOriginatorId());
- MDC.put(MDC_SERVICE_NAME, runtimeContext.getRequestContext().getAction().name());
- try {
- MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName()); //Don't change it to a .getLocalHostName() again please. It's wrong!
- MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
- }catch(Exception e){
- logger.debug(e.getMessage());
- }
- MDC.put(MDC_INSTANCE_UUID, ""); //TODO make instanse_UUID generation once during APPC-instanse deploying
-
WorkflowRequest workflowRequest = new WorkflowRequest();
workflowRequest.setRequestContext(runtimeContext.getRequestContext());
workflowRequest.setResponseContext(runtimeContext.getResponseContext());
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java
index 2f9d2c970..5e47860a7 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java
@@ -51,7 +51,8 @@ public class CommandTaskFactory {
public synchronized CommandTask getExecutionTask(String action, RuntimeContext commandRequest){
- if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action)){
+ if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action) || VNFOperation.ConfigBackup.toString().equals(action) ||
+ VNFOperation.ConfigBackupDelete.toString().equals(action) || VNFOperation.ConfigExport.toString().equals(action)){
return new LCMReadonlyCommandTask(commandRequest, requestHandler,workflowManager);
}else {
return new LCMCommandTask(commandRequest, requestHandler,workflowManager,
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
index ef25c67bc..be9f94f68 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java
@@ -28,6 +28,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.appc.domainmodel.lcm.CommonHeader;
import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
+import org.openecomp.appc.domainmodel.lcm.Status;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
import org.openecomp.appc.executor.UnstableVNFException;
import org.openecomp.appc.executor.objects.CommandResponse;
@@ -38,6 +39,7 @@ import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.lifecyclemanager.objects.VNFOperationOutcome;
+import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.requesthandler.RequestHandler;
import org.openecomp.appc.workflow.WorkFlowManager;
import org.openecomp.appc.workflow.objects.WorkflowResponse;
@@ -48,10 +50,16 @@ import org.openecomp.sdnc.sli.aai.AAIService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
+import org.slf4j.MDC;
+import java.net.InetAddress;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import static com.att.eelf.configuration.Configuration.*;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
+
public class LCMCommandTask extends CommandTask {
@@ -103,9 +111,15 @@ public class LCMCommandTask extends CommandTask {
isAAIUpdated = updateAAI(request.getVnfContext().getId() , false, isSuccess);
}
logger.debug("isAAIUpdated = " + isAAIUpdated);
+ if(!isAAIUpdated){
+ throw new Exception();
+ }
}
catch(Exception e1) {
logger.error("Exception = " + e1);
+ // In case of any errors we are updating the response status code and message
+ Status updatedStatus = new Status(401, "Fail to update VNF status in A&AI");
+ request.getResponseContext().setStatus(updatedStatus);
throw new RuntimeException(e1);
}
finally {
@@ -115,8 +129,9 @@ public class LCMCommandTask extends CommandTask {
@Override
public void run() {
- final RuntimeContext request = commandRequest;
- boolean isAAIUpdated = false;
+ final RuntimeContext request = commandRequest;
+ setInitialLogProperties(request);
+ boolean isAAIUpdated = false;
final String vnfId = request.getVnfContext().getId();
final String vnfType = request.getVnfContext().getType();
try {
@@ -163,11 +178,12 @@ public class LCMCommandTask extends CommandTask {
CommandResponse commandResponse = super.buildCommandResponse(response);
this.onRequestCompletion(commandResponse);
}
- }
+ clearRequestLogProperties();
+ }
- private boolean updateAAI(String vnf_id , boolean isTTLEnd , boolean executionStatus)
+ private boolean updateAAI(String vnf_id, boolean isTTLEnd, boolean executionStatus)
{
String orchestrationStatus = null;
String nextState;
@@ -203,7 +219,7 @@ public class LCMCommandTask extends CommandTask {
private SvcLogicContext getVnfdata(String vnf_id, String prefix,SvcLogicContext ctx) {
- String key="vnf-id = '"+ vnf_id+"'";
+ String key="generic-vnf.vnf-id = '"+ vnf_id+"'"+" AND http-header.Real-Time = 'true'";
logger.debug("inside getVnfdata=== "+key);
try {
SvcLogicResource.QueryStatus response = aaiService.query("generic-vnf", false, null, key,prefix, null, ctx);
@@ -245,4 +261,31 @@ public class LCMCommandTask extends CommandTask {
return false;
}
+ protected void setInitialLogProperties(RuntimeContext request)
+ {
+ MDC.put(MDC_KEY_REQUEST_ID, request.getRequestContext().getCommonHeader().getRequestId());
+ if (request.getRequestContext().getActionIdentifiers().getServiceInstanceId() != null)
+ MDC.put(MDC_SERVICE_INSTANCE_ID, request.getRequestContext().getActionIdentifiers().getServiceInstanceId());
+ MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, request.getRequestContext().getCommonHeader().getOriginatorId());
+ MDC.put(MDC_SERVICE_NAME, request.getRequestContext().getAction().name());
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ logger.debug(e.getMessage());
+ }
+ MDC.put(MDC_INSTANCE_UUID, ""); //TODO make instanse_UUID generation once during APPC-instanse deploying
+ }
+
+ protected void clearRequestLogProperties()
+ {
+ try {
+ MDC.remove(MDC_KEY_REQUEST_ID);
+ MDC.remove(MDC_SERVICE_INSTANCE_ID);
+ MDC.remove(MDC_SERVICE_NAME);
+ MDC.remove(LoggingConstants.MDCKeys.PARTNER_NAME);
+ } catch (Exception e) {
+
+ }
+ }
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties
index 2e5f26a0f..b4cdae5e6 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties
@@ -24,25 +24,12 @@
org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=2
-dmaap.threads.poolsize.max=2
-
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties
index 74552a9d7..fc0330d75 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties
@@ -76,27 +76,13 @@ org.openecomp.appc.db.url.%s", schema), "");
org.openecomp.appc.db.user.%s", schema), "");
org.openecomp.appc.db.pass.%s", schema), "");
-
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-TEST
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=2
-dmaap.threads.poolsize.max=2
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-TEST
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-dispatcher-common/appc-data-access-lib/pom.xml b/appc-dispatcher/appc-dispatcher-common/appc-data-access-lib/pom.xml
index cae7eedb1..94a45e31a 100644
--- a/appc-dispatcher/appc-dispatcher-common/appc-data-access-lib/pom.xml
+++ b/appc-dispatcher/appc-dispatcher-common/appc-data-access-lib/pom.xml
@@ -6,7 +6,7 @@
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>appc-data-access-lib</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<name>appc-data-access-lib</name>
<url>http://maven.apache.org</url>
@@ -35,7 +35,24 @@
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-common</artifactId>
<version>${project.version}</version>
- <scope>compile</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dao.util</Export-Package>
+ <Import-Package>org.openecomp.appc.configuration,*;resolution:=optional</Import-Package>
+ <Embed-Dependency>mysql-connector-java</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/openecomp/appc/domainmodel/lcm/VNFOperation.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/openecomp/appc/domainmodel/lcm/VNFOperation.java
index c61901eb3..904722fae 100644
--- a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/openecomp/appc/domainmodel/lcm/VNFOperation.java
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/openecomp/appc/domainmodel/lcm/VNFOperation.java
@@ -23,8 +23,9 @@ package org.openecomp.appc.domainmodel.lcm;
public enum VNFOperation {
- Configure, Test, HealthCheck, Start, Terminate, Restart, Rebuild, Stop, ModifyConfig, Backup, Snapshot,
- SoftwareUpload, LiveUpgrade, Rollback, Sync, Audit, Test_lic, Migrate, Evacuate,
+ Configure, Test, HealthCheck, Start, Terminate, Restart, Rebuild, Stop, ConfigModify,
+ ConfigScaleOut,ConfigRestore,Backup, Snapshot,
+ SoftwareUpload, LiveUpgrade, Rollback, Sync, Audit, Test_lic, Migrate, Evacuate,ConfigBackup,ConfigBackupDelete,ConfigExport,
Lock(true), Unlock(true), CheckLock(true);
private boolean builtIn;
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/pom.xml b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/pom.xml
index f8b1e5631..d20759f30 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/pom.xml
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/pom.xml
@@ -26,7 +26,7 @@
<artifactId>eelf-core</artifactId>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
@@ -36,10 +36,11 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>org.openecomp.appc.executionqueue,org.openecomp.appc.executionqueue.impl</Export-Package>
- <Import-Package>!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.apache.commons.lang3,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ <Import-Package>
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceFactory.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceFactory.java
index 01e4358e9..29de597b1 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceFactory.java
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceFactory.java
@@ -25,16 +25,11 @@ import org.openecomp.appc.executionqueue.ExecutionQueueService;
public class ExecutionQueueServiceFactory {
- private static ExecutionQueueService executionQueueService =null;
-
- public static ExecutionQueueService getExecutionQueueService(){
- if(executionQueueService == null){
- synchronized (ExecutionQueueServiceFactory.class){
- if(executionQueueService == null)
- executionQueueService = new ExecutionQueueServiceImpl();
- }
- }
- return executionQueueService;
+ private static class ExecutionQueueServiceHolder {
+ public static final ExecutionQueueService executionQueueService = new ExecutionQueueServiceImpl();
}
+ public static ExecutionQueueService getExecutionQueueService() {
+ return ExecutionQueueServiceHolder.executionQueueService;
+ }
}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-features/src/main/resources/features.xml b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-features/src/main/resources/features.xml
index ed51ca775..8b2131829 100644
--- a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-features/src/main/resources/features.xml
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-features/src/main/resources/features.xml
@@ -26,6 +26,10 @@
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name='lock-manager' description="lock-manager" version='${project.version}'>
+ <!-- appc-common and appc-data-access-lib bundles are flagged as being a dependency -->
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-common/${project.version}</bundle>
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-data-access-lib/${project.version}</bundle>
+
<bundle start-level="80" start="true">mvn:org.openecomp.appc/lock-manager-api/${project.version}</bundle>
<bundle start-level="85" start="true">mvn:org.openecomp.appc/lock-manager-impl/${project.version}</bundle>
</feature>
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/pom.xml b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/pom.xml
index 48befceb8..8da65195d 100644
--- a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/pom.xml
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/pom.xml
@@ -28,7 +28,6 @@
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-data-access-lib</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>com.att.eelf</groupId>
@@ -49,16 +48,16 @@
<configuration>
<instructions>
<Export-Service>org.openecomp.appc.lockmanager.api.LockManager</Export-Service>
- <Import-Package>org.openecomp.appc.lockmanager.api.*,*</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.lockmanager.api.*,
+ org.openecomp.appc.dao.util,com.att.eelf.configuration, *;resolution:=optional
+ </Import-Package>
<Private-Package>org.openecomp.appc.lockmanager.impl.*</Private-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!javax.mail.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
- <Embed-Dependency>appc-common,appc-data-access-lib,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
-</project> \ No newline at end of file
+</project>
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/Messages.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/Messages.java
index 0399726b5..62181d4c6 100644
--- a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/Messages.java
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/Messages.java
@@ -28,6 +28,7 @@ public enum Messages {
ERR_UNLOCK_NOT_LOCKED("Error unlocking resource [%s]: resource is not locked"),
ERR_UNLOCK_LOCKED_BY_OTHER("Error unlocking resource [%s] by [%s]: resource is locked by [%s]"),
EXP_LOCK("Error locking resource [%s]."),
+ EXP_CHECK_LOCK("Error check locking resource [%s]."),//for checklock operation
EXP_UNLOCK("Error unlocking resource [%s]."),
;
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/optimistic/SqlLockManager.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/optimistic/SqlLockManager.java
index 52c75d2b2..54622c422 100644
--- a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/optimistic/SqlLockManager.java
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/optimistic/SqlLockManager.java
@@ -91,7 +91,7 @@ abstract class SqlLockManager extends JdbcLockManager {
}
}
} catch (SQLException e) {
- throw new LockRuntimeException(Messages.EXP_LOCK.format(resource));
+ throw new LockRuntimeException(Messages.EXP_CHECK_LOCK.format(resource));
}finally {
closeDbConnection(connection);
}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/LockRecord.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/LockRecord.java
new file mode 100644
index 000000000..7d537379b
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/LockRecord.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.lockmanager.impl.sql.pessimistic;
+
+class LockRecord {
+
+ private String resource;
+ private String owner;
+ private long updated;
+ private long timeout;
+
+ LockRecord(String resource) {
+ this.resource = resource;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public long getUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(long updated) {
+ this.updated = updated;
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManager.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManager.java
new file mode 100644
index 000000000..79d0f6cca
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManager.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.lockmanager.impl.sql.pessimistic;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.openecomp.appc.lockmanager.api.LockRuntimeException;
+
+public class MySqlLockManager extends SqlLockManager {
+
+ private static final int DEF_CRITICAL_SECTION_WAIT_TIMEOUT = 3;
+
+ protected int criticalSectionWaitTimeoutSecs = DEF_CRITICAL_SECTION_WAIT_TIMEOUT;
+
+ public void setCriticalSectionWaitTimeoutSecs(int criticalSectionWaitTimeoutSecs) {
+ this.criticalSectionWaitTimeoutSecs = criticalSectionWaitTimeoutSecs;
+ }
+
+ @Override
+ protected void enterCriticalSection(Connection connection, String resource) {
+ try {
+ CallableStatement statement = connection.prepareCall("SELECT COALESCE(GET_LOCK(?,?),0)");
+ try {
+ statement.setString(1, resource);
+ statement.setInt(2, criticalSectionWaitTimeoutSecs);
+ boolean execRes = statement.execute();
+ int result = 0;
+ if(execRes) {
+ ResultSet resultSet = statement.getResultSet();
+ try {
+ if(resultSet.next()) {
+ result = resultSet.getInt(1);
+ }
+ } finally {
+ resultSet.close();
+ }
+ }
+ if(result != 1) { // lock is not obtained
+ throw new LockRuntimeException("Cannot obtain critical section lock for resource [" + resource + "].");
+ }
+ } finally {
+ statement.close();
+ }
+ } catch(SQLException e) {
+ throw new LockRuntimeException("Cannot obtain critical section lock for resource [" + resource + "].", e);
+ }
+ }
+
+ @Override
+ protected void leaveCriticalSection(Connection connection, String resource) {
+ try {
+ CallableStatement statement = connection.prepareCall("SELECT RELEASE_LOCK(?)");
+ try {
+ statement.setString(1, resource);
+ statement.execute();
+ } finally {
+ statement.close();
+ }
+ } catch(SQLException e) {
+ throw new LockRuntimeException("Error releasing critical section lock.", e);
+ }
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/SqlLockManager.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/SqlLockManager.java
new file mode 100644
index 000000000..71f649274
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/main/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/SqlLockManager.java
@@ -0,0 +1,251 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.lockmanager.impl.sql.pessimistic;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.openecomp.appc.lockmanager.api.LockException;
+import org.openecomp.appc.lockmanager.api.LockRuntimeException;
+import org.openecomp.appc.lockmanager.impl.sql.JdbcLockManager;
+import org.openecomp.appc.lockmanager.impl.sql.Messages;
+
+abstract class SqlLockManager extends JdbcLockManager {
+
+ private static final String SQL_LOAD_LOCK_RECORD = "SELECT * FROM %s WHERE RESOURCE_ID=?";
+ private static final String SQL_INSERT_LOCK_RECORD = "INSERT INTO %s (RESOURCE_ID, OWNER_ID, UPDATED, TIMEOUT) VALUES (?, ?, ?, ?)";
+ private static final String SQL_UPDATE_LOCK_RECORD = "UPDATE %s SET OWNER_ID=?, UPDATED=?, TIMEOUT=? WHERE RESOURCE_ID=?";
+ private static final String SQL_CURRENT_TIMESTAMP = "SELECT CURRENT_TIMESTAMP()";
+
+ private String sqlLoadLockRecord;
+ private String sqlInsertLockRecord;
+ private String sqlUpdateLockRecord;
+
+ @Override
+ public boolean acquireLock(String resource, String owner) throws LockException {
+ return acquireLock(resource, owner, 0);
+ }
+
+ @Override
+ public boolean acquireLock(String resource, String owner, long timeout) throws LockException {
+ if(owner == null) {
+ throw new LockRuntimeException(Messages.ERR_NULL_LOCK_OWNER.format(resource));
+ }
+ boolean res = false;
+ Connection connection = openDbConnection();
+ try {
+ enterCriticalSection(connection, resource);
+ try {
+ res = lockResource(connection, resource, owner, timeout);
+ } finally {
+ leaveCriticalSection(connection, resource);
+ }
+ } finally {
+ closeDbConnection(connection);
+ }
+ return res;
+ }
+
+ @Override
+ public void releaseLock(String resource, String owner) throws LockException {
+ Connection connection = openDbConnection();
+ try {
+ enterCriticalSection(connection, resource);
+ try {
+ unlockResource(connection, resource, owner);
+ } finally {
+ leaveCriticalSection(connection, resource);
+ }
+ } finally {
+ closeDbConnection(connection);
+ }
+ }
+
+ @Override
+ public boolean isLocked(String resource) {
+ Connection connection=openDbConnection();
+ try {
+ LockRecord lockRecord=loadLockRecord(connection,resource);
+ if(lockRecord==null){
+ return false;
+ }else{
+ if(lockRecord.getOwner()==null){
+ return false;
+ }else if(isLockExpired(lockRecord, connection)){
+ return false;
+ }else{
+ return true;
+ }
+ }
+ } catch (SQLException e) {
+ throw new LockRuntimeException(Messages.EXP_CHECK_LOCK.format(resource));
+ }finally {
+ closeDbConnection(connection);
+ }
+ }
+
+ private boolean lockResource(Connection connection, String resource, String owner, long timeout) throws LockException {
+ try {
+ boolean res = false;
+ LockRecord lockRecord = loadLockRecord(connection, resource);
+ if(lockRecord != null) {
+ // lock record already exists
+ String currentOwner = lockRecord.getOwner();
+ if(currentOwner != null) {
+ if(isLockExpired(lockRecord, connection)) {
+ currentOwner = null;
+ } else if(!owner.equals(currentOwner)) {
+ throw new LockException(Messages.ERR_LOCK_LOCKED_BY_OTHER.format(resource, owner, currentOwner));
+ }
+ }
+ // set new owner on the resource lock record
+ updateLockRecord(connection, resource, owner, timeout);
+ if(currentOwner == null) {
+ // no one locked the resource before
+ res = true;
+ }
+ } else {
+ // resource record does not exist in lock table => create new record
+ addLockRecord(connection, resource, owner, timeout);
+ res = true;
+ }
+ return res;
+ } catch(SQLException e) {
+ throw new LockRuntimeException(Messages.EXP_LOCK.format(resource), e);
+ }
+ }
+
+ private void unlockResource(Connection connection, String resource, String owner) throws LockException {
+ try {
+ LockRecord lockRecord = loadLockRecord(connection, resource);
+ if(lockRecord != null) {
+ // check if expired
+ if(isLockExpired(lockRecord, connection)) {
+ // lock is expired => no lock
+ lockRecord = null;
+ }
+ }
+ if((lockRecord == null) || (lockRecord.getOwner() == null)) {
+ // resource is not locked
+ throw new LockException(Messages.ERR_UNLOCK_NOT_LOCKED.format(resource));
+ }
+ String currentOwner = lockRecord.getOwner();
+ if(!owner.equals(currentOwner)) {
+ throw new LockException(Messages.ERR_UNLOCK_LOCKED_BY_OTHER.format(resource, owner, currentOwner));
+ }
+ updateLockRecord(connection, resource, null, 0);
+ // TODO delete record from table on lock release?
+// deleteLockRecord(connection, resource);
+ } catch(SQLException e) {
+ throw new LockRuntimeException(Messages.EXP_UNLOCK.format(resource), e);
+ }
+ }
+
+ protected abstract void enterCriticalSection(Connection connection, String resource);
+
+ protected abstract void leaveCriticalSection(Connection connection, String resource);
+
+ protected LockRecord loadLockRecord(Connection connection, String resource) throws SQLException {
+ LockRecord res = null;
+ if(sqlLoadLockRecord == null) {
+ sqlLoadLockRecord = String.format(SQL_LOAD_LOCK_RECORD, tableName);
+ }
+ try(PreparedStatement statement = connection.prepareStatement(sqlLoadLockRecord)) {
+ statement.setString(1, resource);
+ try(ResultSet resultSet = statement.executeQuery()) {
+ if(resultSet.next()) {
+ res = new LockRecord(resource);
+ res.setOwner(resultSet.getString(2));
+ res.setUpdated(resultSet.getLong(3));
+ res.setTimeout(resultSet.getLong(4));
+ }
+ }
+ }
+ return res;
+ }
+
+ protected void addLockRecord(Connection connection, String resource, String owner, long timeout) throws SQLException {
+ if(sqlInsertLockRecord == null) {
+ sqlInsertLockRecord = String.format(SQL_INSERT_LOCK_RECORD, tableName);
+ }
+ try(PreparedStatement statement = connection.prepareStatement(sqlInsertLockRecord)) {
+ statement.setString(1, resource);
+ statement.setString(2, owner);
+ statement.setLong(3, getCurrentTime(connection));
+ statement.setLong(4, timeout);
+ statement.executeUpdate();
+ }
+ }
+
+ protected void updateLockRecord(Connection connection, String resource, String owner, long timeout) throws SQLException {
+ if(sqlUpdateLockRecord == null) {
+ sqlUpdateLockRecord = String.format(SQL_UPDATE_LOCK_RECORD, tableName);
+ }
+ try(PreparedStatement statement = connection.prepareStatement(sqlUpdateLockRecord)) {
+ statement.setString(1, owner);
+ statement.setLong(2, getCurrentTime(connection));
+ statement.setLong(3, timeout);
+ statement.setString(4, resource);
+ statement.executeUpdate();
+ }
+ }
+
+// protected void deleteLockRecord(Connection connection, String resource) throws SQLException {
+// if(sqlDeleteLockRecord == null) {
+// sqlDeleteLockRecord = String.format(SQL_DELETE_LOCK_RECORD, tableName);
+// }
+// try(PreparedStatement statement = connection.prepareStatement(sqlDeleteLockRecord)) {
+// statement.setString(1, resource);
+// statement.executeUpdate();
+// }
+// }
+
+ private boolean isLockExpired(LockRecord lockRecord, Connection connection) throws SQLException {
+ long timeout = lockRecord.getTimeout();
+ if(timeout == 0) {
+ return false;
+ }
+ long updated = lockRecord.getUpdated();
+ long now = getCurrentTime(connection);
+ long expiration = updated + timeout;
+ return (now > expiration);
+ }
+
+ private long getCurrentTime(Connection connection) throws SQLException {
+ long res = -1;
+ if(connection != null) {
+ try(PreparedStatement statement = connection.prepareStatement(SQL_CURRENT_TIMESTAMP)) {
+ try(ResultSet resultSet = statement.executeQuery()) {
+ if(resultSet.next()) {
+ res = resultSet.getTimestamp(1).getTime();
+ }
+ }
+ }
+ }
+ if(res == -1) {
+ res = System.currentTimeMillis();
+ }
+ return res;
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManagerMock.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManagerMock.java
new file mode 100644
index 000000000..a94dc18e4
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/MySqlLockManagerMock.java
@@ -0,0 +1,150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.lockmanager.impl.sql.pessimistic;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.openecomp.appc.lockmanager.api.LockRuntimeException;
+import org.openecomp.appc.lockmanager.impl.sql.Synchronizer;
+import org.openecomp.appc.lockmanager.impl.sql.SynchronizerReceiver;
+import org.openecomp.appc.lockmanager.impl.sql.pessimistic.LockRecord;
+import org.openecomp.appc.lockmanager.impl.sql.pessimistic.MySqlLockManager;
+
+class MySqlLockManagerMock extends MySqlLockManager implements SynchronizerReceiver {
+
+ private final Map<String, LockRecord> locks = new HashMap<>();
+ private final Lock lock = new ReentrantLock();
+ private boolean useReal;
+ private Synchronizer synchronizer;
+
+ MySqlLockManagerMock(boolean useReal) {
+ this.useReal = useReal;
+ }
+
+ @Override
+ public void setSynchronizer(Synchronizer synchronizer) {
+ this.synchronizer = synchronizer;
+ }
+
+ @Override
+ protected Connection openDbConnection() {
+ if(useReal) {
+ return super.openDbConnection();
+ }
+ return null;
+ }
+
+ @Override
+ protected void closeDbConnection(Connection connection) {
+ if(useReal) {
+ super.closeDbConnection(connection);
+ }
+ }
+
+ @Override
+ protected LockRecord loadLockRecord(Connection connection, String resource) throws SQLException {
+ LockRecord res;
+ if(useReal) {
+ res = super.loadLockRecord(connection, resource);
+ } else {
+ res = locks.get(resource);
+ }
+ if(synchronizer != null) {
+ synchronizer.postLoadLockRecord(resource, (res == null) ? null : res.getOwner());
+ }
+ return res;
+ }
+
+ @Override
+ protected void addLockRecord(Connection connection, String resource, String owner, long timeout) throws SQLException {
+ if(synchronizer != null) {
+ synchronizer.preAddLockRecord(resource, owner);
+ }
+ try {
+ if(useReal) {
+ super.addLockRecord(connection, resource, owner, timeout);
+ return;
+ }
+ LockRecord lockRecord = new LockRecord(resource);
+ lockRecord.setOwner(owner);
+ lockRecord.setUpdated(System.currentTimeMillis());
+ lockRecord.setTimeout(timeout);
+ locks.put(resource, lockRecord);
+ } finally {
+ if(synchronizer != null) {
+ synchronizer.postAddLockRecord(resource, owner);
+ }
+ }
+ }
+
+ @Override
+ protected void updateLockRecord(Connection connection, String resource, String owner, long timeout) throws SQLException {
+ if(synchronizer != null) {
+ synchronizer.preUpdateLockRecord(resource, owner);
+ }
+ try {
+ if(useReal) {
+ super.updateLockRecord(connection, resource, owner, timeout);
+ return;
+ }
+ LockRecord lockRecord = loadLockRecord(connection, resource);
+ lockRecord.setOwner(owner);
+ lockRecord.setUpdated(System.currentTimeMillis());
+ lockRecord.setTimeout(timeout);
+ locks.put(resource, lockRecord);
+ } finally {
+ if(synchronizer != null) {
+ synchronizer.postUpdateLockRecord(resource, owner);
+ }
+ }
+ }
+
+ @Override
+ protected void enterCriticalSection(Connection connection, String resource) {
+ if(useReal) {
+ super.enterCriticalSection(connection, resource);
+ return;
+ }
+ try {
+ if(!lock.tryLock(criticalSectionWaitTimeoutSecs, TimeUnit.SECONDS)) {
+ throw new LockRuntimeException("Cannot obtain critical section lock for resource [" + resource + "].");
+ }
+ } catch(InterruptedException e) {
+ throw new LockRuntimeException("Cannot obtain critical section lock.", e);
+ }
+ }
+
+ @Override
+ protected void leaveCriticalSection(Connection connection, String resource) {
+ if(useReal) {
+ super.leaveCriticalSection(connection, resource);
+ return;
+ }
+ lock.unlock();
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/TestMySqlLockManager.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/TestMySqlLockManager.java
new file mode 100644
index 000000000..cf8781b13
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/openecomp/appc/lockmanager/impl/sql/pessimistic/TestMySqlLockManager.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.lockmanager.impl.sql.pessimistic;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.lockmanager.api.LockException;
+import org.openecomp.appc.lockmanager.api.LockRuntimeException;
+import org.openecomp.appc.lockmanager.impl.sql.JdbcLockManager;
+import org.openecomp.appc.lockmanager.impl.sql.MySqlLockManagerBaseTests;
+import org.openecomp.appc.lockmanager.impl.sql.Synchronizer;
+import org.openecomp.appc.lockmanager.impl.sql.pessimistic.MySqlLockManager;
+
+import java.util.concurrent.*;
+
+public class TestMySqlLockManager extends MySqlLockManagerBaseTests {
+
+ private static int CRITICAL_SECTION_WAIT_TIMEOUT = 1; // in secs
+
+ @Override
+ protected JdbcLockManager createJdbcLockManager(boolean useReal) {
+ return new MySqlLockManagerMock(useReal);
+ }
+
+ @Test
+ public void testConcurrentLock() throws LockException, InterruptedException, ExecutionException, TimeoutException {
+ try {
+ callConcurrentTest(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ try {
+ Assert.assertTrue(lockManager.acquireLock(Resource.Resource1.name(), Owner.A.name()));
+ return true;
+ } catch(LockRuntimeException e) {
+ Assert.assertEquals("Cannot obtain critical section lock for resource [" + Resource.Resource1.name() + "].", e.getMessage());
+ return false;
+ }
+ }
+ });
+ } finally {
+ lockManager.releaseLock(Resource.Resource1.name(), Owner.A.name());
+ }
+ }
+
+ @Test
+ public void testConcurrentUnlock() throws LockException, InterruptedException, ExecutionException, TimeoutException {
+ lockManager.acquireLock(Resource.Resource1.name(), Owner.A.name());
+ callConcurrentTest(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ try {
+ lockManager.releaseLock(Resource.Resource1.name(), Owner.A.name());
+ return true;
+ } catch(LockRuntimeException e) {
+ Assert.assertEquals("Cannot obtain critical section lock for resource [" + Resource.Resource1.name() + "].", e.getMessage());
+ return false;
+ }
+ }
+ });
+ }
+
+ private void callConcurrentTest(Callable<Boolean> callable) throws LockException, InterruptedException, ExecutionException, TimeoutException {
+ final int participantsNo = 2;
+ Synchronizer synchronizer = new Synchronizer(participantsNo) {
+
+ @Override
+ protected void waitForAllParticipants(Object waitObj, int totalParticipantsNo, int currentParticipantsNo) {
+ waitOn(this, TimeUnit.MILLISECONDS.convert(1 + CRITICAL_SECTION_WAIT_TIMEOUT, TimeUnit.SECONDS)); // add 1 sec to make sure timeout occured
+ }
+ };
+ if(!setSynchronizer(synchronizer)) {
+ return;
+ }
+ ((MySqlLockManager)lockManager).setCriticalSectionWaitTimeoutSecs(CRITICAL_SECTION_WAIT_TIMEOUT);
+ ExecutorService executor = Executors.newFixedThreadPool(participantsNo);
+ Future<Boolean> future1 = executor.submit(callable);
+ try {
+ for(int i = 0; i < 10; i++) {
+ Thread.sleep(100);
+ if(synchronizer.getParticipantCount() > 0) {
+ break;
+ }
+ }
+ // make sure 1st thread gets inside critical section
+ if(synchronizer.getParticipantCount() < 1) {
+ Assert.fail(getClass().getName() + " first thread failed to acquireLock()");
+ }
+ Future<Boolean> future2 = executor.submit(callable);
+ try {
+ // 1st thread should acquire the lock
+ Assert.assertTrue(future1.get(3 + CRITICAL_SECTION_WAIT_TIMEOUT, TimeUnit.SECONDS));
+ // 2nd thread should fail waiting for critical section
+ Assert.assertFalse(future2.get(2 + CRITICAL_SECTION_WAIT_TIMEOUT, TimeUnit.SECONDS));
+ } finally {
+ future2.cancel(true);
+ }
+ } finally {
+ future1.cancel(true);
+ setSynchronizer(null);
+ }
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-installer/pom.xml b/appc-dispatcher/appc-dispatcher-installer/pom.xml
index a9000454a..29b09f458 100644
--- a/appc-dispatcher/appc-dispatcher-installer/pom.xml
+++ b/appc-dispatcher/appc-dispatcher-installer/pom.xml
@@ -17,7 +17,7 @@
<features.boot.licenseManager>appc-license-manager</features.boot.licenseManager>
<!--<features.repositories>mvn:org.openecomp.appc/appc-dispatcher-features/${project.version}/xml/features,mvn:org.openecomp.appc/appc-request-handler-features/${project.version}/xml/features,mvn:org.openecomp.appc/appc-command-executor-features/${project.version}/xml/features,mvn:org.openecomp.appc/appc-lifecycle-management-features/${project.version}/xml/features,mvn:org.openecomp.appc/appc-license-manager-features/${project.version}/xml/features,mvn:org.openecomp.appc/appc-workflow-management-features/${project.version}/xml/features,mvn:org.openecomp.appc/lock-manager-features/${project.version}/xml/features</features.repositories>-->
- <!-- SEPARATING FEATURE INSTALLS -->
+ <!-- SEPARATED FEATURE INSTALLS -->
<features.repo.dispatcher>mvn:org.openecomp.appc/appc-dispatcher-features/${project.version}/xml/features</features.repo.dispatcher>
<features.repo.requestHandler>mvn:org.openecomp.appc/appc-request-handler-features/${project.version}/xml/features</features.repo.requestHandler>
<features.repo.commandExecutor>mvn:org.openecomp.appc/appc-command-executor-features/${project.version}/xml/features</features.repo.commandExecutor>
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/pom.xml b/appc-dispatcher/appc-license-manager/appc-license-manager-api/pom.xml
index d4da50767..635e1fc12 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-api/pom.xml
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/pom.xml
@@ -17,11 +17,6 @@
<dependencies>
<dependency>
- <groupId>org.openecomp.appc</groupId>
- <artifactId>appc-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.openecomp.sdnc.core</groupId>
<artifactId>dblib-provider</artifactId>
</dependency>
@@ -36,9 +31,6 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>org.openecomp.appc.licmgr,org.openecomp.appc.licmgr.exception,org.openecomp.appc.licmgr.objects</Export-Package>
- <Embed-Dependency>!dblib-provider,appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
- <Import-Package>!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/Constants.java b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/Constants.java
index 81ce0e713..5f758e7ae 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/Constants.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/Constants.java
@@ -68,7 +68,6 @@ public class Constants {
public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
public static final String UPGRADE_VERSION = "upgrade-version";
public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
- public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
public static final String RESOURCEKEY = "resourceKey";
public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/LicenseManager.java b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/LicenseManager.java
index 40c7d8bb6..547b8c4f9 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/LicenseManager.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/openecomp/appc/licmgr/LicenseManager.java
@@ -27,6 +27,7 @@ import org.openecomp.appc.licmgr.exception.DataAccessException;
import org.openecomp.appc.licmgr.objects.LicenseModel;
+@SuppressWarnings("JavaDoc")
public interface LicenseManager {
/**
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/pom.xml b/appc-dispatcher/appc-license-manager/appc-license-manager-core/pom.xml
index 66b314798..99ab538ca 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/pom.xml
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/pom.xml
@@ -58,10 +58,18 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>!dblib-provider,appc-common,eelf-core,logback-core,logback-classic,javax.mail;scope=compile|runtime;inline=false</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
<Export-Service>org.openecomp.appc.licmgr.LicenseManager</Export-Service>
- <Import-Package>org.openecomp.appc.licmgr,org.openecomp.appc.licmgr.exception,org.openecomp.appc.licmgr.objects,javax.mail.internet,!javax.mail,!groovy.lang,!javax.jms,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+
+ <Embed-Dependency>
+ artifactId=!dblib-provider|slf4j-api|jcl-over-slf4j;scope=compile|runtime;inline=false
+ </Embed-Dependency>
+
+ <Import-Package>
+ org.openecomp.appc.licmgr,org.openecomp.appc.licmgr.exception,org.openecomp.appc.licmgr.objects,
+ *;resolution:=optional
+ </Import-Package>
+
+ <Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseDataAccessServiceImpl.java b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseDataAccessServiceImpl.java
index 2aff1ffb9..2eaf79062 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseDataAccessServiceImpl.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseDataAccessServiceImpl.java
@@ -21,17 +21,14 @@
package org.openecomp.appc.licmgr.impl;
+import javax.sql.rowset.CachedRowSet;
+
import org.openecomp.appc.licmgr.Constants;
import org.openecomp.appc.licmgr.LicenseDataAccessService;
import org.openecomp.appc.licmgr.exception.DataAccessException;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-
-import javax.sql.rowset.CachedRowSet;
import static org.openecomp.appc.licmgr.Constants.ASDC_ARTIFACTS_FIELDS;
@@ -42,7 +39,7 @@ import java.util.Map;
@SuppressWarnings("JavaDoc")
-class LicenseDataAccessServiceImpl implements LicenseDataAccessService {
+public class LicenseDataAccessServiceImpl implements LicenseDataAccessService {
private static EELFLogger logger = EELFManager.getInstance().getLogger(LicenseDataAccessServiceImpl.class);
@@ -52,17 +49,12 @@ class LicenseDataAccessServiceImpl implements LicenseDataAccessService {
private String schema;
- private DbLibService dbLibService;
-
- private void checkDbLibService() throws DataAccessException {
- if (null != dbLibService) {return;}
+ public void setDbLibService(DbLibService dbLibService) {
+ this.dbLibService = dbLibService;
+ }
- //get dblib service and send it to DAService
- BundleContext bctx = FrameworkUtil.getBundle(LicenseManagerImpl.class).getBundleContext();
- ServiceReference sref = bctx.getServiceReference(DbLibService.class.getName());
- dbLibService = (DbLibService)bctx.getService(sref);
+ private DbLibService dbLibService;
- }
/**
* empty constructor
@@ -73,8 +65,6 @@ class LicenseDataAccessServiceImpl implements LicenseDataAccessService {
public Map<String,String> retrieveLicenseModelData(String vnfType, String vnfVersion, String... fields) throws
DataAccessException {
- checkDbLibService();
-
Map<String,String> result = new HashMap<>();
if (null == fields || 0 == fields.length) fields = new String[]{ASDC_ARTIFACTS_FIELDS.ARTIFACT_CONTENT.name()};
@@ -119,8 +109,6 @@ class LicenseDataAccessServiceImpl implements LicenseDataAccessService {
@Override
public void storeArtifactPayload(Map<String, String> parameters) throws RuntimeException {
- checkDbLibService();
-
if(parameters == null || parameters.isEmpty()) {
throw new RuntimeException("No parameters for insert are provided");
}
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseManagerImpl.java b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseManagerImpl.java
index 815bb02ab..86d1eddd9 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseManagerImpl.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/java/org/openecomp/appc/licmgr/impl/LicenseManagerImpl.java
@@ -25,7 +25,6 @@ import static org.openecomp.appc.licmgr.Constants.ASDC_ARTIFACTS_FIELDS.ARTIFACT
import java.util.Map;
-import org.openecomp.appc.licmgr.Constants;
import org.openecomp.appc.licmgr.LicenseDataAccessService;
import org.openecomp.appc.licmgr.LicenseManager;
import org.openecomp.appc.licmgr.exception.DataAccessException;
@@ -42,8 +41,6 @@ public class LicenseManagerImpl implements LicenseManager {
}
public LicenseManagerImpl() {
- DAService = new LicenseDataAccessServiceImpl();
- DAService.setSchema(Constants.SDNCTL_SCHEMA);
}
@Override
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index c8efb8390..45ef4f179 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -27,7 +27,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
- <bean id="licenseServiceBean" class="org.openecomp.appc.licmgr.impl.LicenseManagerImpl" scope="singleton" activation="lazy"/>
- <service id="licenseService" interface="org.openecomp.appc.licmgr.LicenseManager" ref="licenseServiceBean"/>
+ <reference id="dbLibServiceRef" availability="mandatory" activation="eager" interface="org.openecomp.sdnc.sli.resource.dblib.DbLibService" />
+
+ <bean id="licenseDataServiceBean" class="org.openecomp.appc.licmgr.impl.LicenseDataAccessServiceImpl" scope="singleton" activation="eager">
+ <property name="dbLibService" ref="dbLibServiceRef" />
+ <property name="schema" value="sdnctl" />
+ </bean>
+ <bean id="licenseServiceBean" class="org.openecomp.appc.licmgr.impl.LicenseManagerImpl" scope="singleton" activation="lazy">
+ <property name="DAService" ref="licenseDataServiceBean"/>
+ </bean>
+ <service id="licenseService" interface="org.openecomp.appc.licmgr.LicenseManager" ref="licenseServiceBean"/>
</blueprint>
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/org/openecomp/appc/default.properties
index 9d9e1d787..a3b064f90 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/main/resources/org/openecomp/appc/default.properties
@@ -23,27 +23,12 @@
# to supply configuration options
org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
-
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-LIC-MGR-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-LIC-MGR-TEST
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=2
-dmaap.threads.poolsize.max=2
-
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/test/java/org/openecomp/appc/licmgr/LicenseServiceMock.java b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/test/java/org/openecomp/appc/licmgr/LicenseServiceMock.java
index e496da7b5..9760cef54 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/test/java/org/openecomp/appc/licmgr/LicenseServiceMock.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-core/src/test/java/org/openecomp/appc/licmgr/LicenseServiceMock.java
@@ -20,7 +20,6 @@
*/
package org.openecomp.appc.licmgr;
-
import java.util.HashMap;
import java.util.Map;
diff --git a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/pom.xml b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/pom.xml
index e2231e8a6..859e4a514 100644
--- a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/pom.xml
+++ b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/pom.xml
@@ -25,7 +25,6 @@
<artifactId>appc-lifecycle-management</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.appc</groupId>
<artifactId>appc-lifecycle-management-core</artifactId>
<packaging>bundle</packaging>
@@ -69,10 +68,12 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Service>org.openecomp.appc.lifecyclemanager.LifecycleManager</Export-Service>
- <Import-Package>org.openecomp.appc.lifecyclemanager.*,!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.apache.commons.lang3,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.lifecyclemanager.*,
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/java/org/openecomp/appc/lifecyclemanager/helper/MetadataReader.java b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/java/org/openecomp/appc/lifecyclemanager/helper/MetadataReader.java
index 82c497d58..965d61a7b 100644
--- a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/java/org/openecomp/appc/lifecyclemanager/helper/MetadataReader.java
+++ b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/java/org/openecomp/appc/lifecyclemanager/helper/MetadataReader.java
@@ -32,8 +32,22 @@ import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
public class MetadataReader {
private enum VNFStates {
- Not_Instantiated, Instantiated, Configuring, Configured, Testing, Tested, Rebuilding, Restarting, Error, Running, Unknown, Terminating, Stopping, Stopped,
- Backing_Up, Snapshotting, Software_Uploading, Upgrading, Rollbacking, Licensing, Migrating, Evacuating;
+ Not_Instantiated, Instantiated, Configuring, Configured, Testing, Tested, Rebuilding, Restarting, Starting, Error, Running, Unknown, Terminating, Stopping, Stopped,
+ Backing_Up, Snapshotting, Software_Uploading, Upgrading, Rollbacking, Licensing, Migrating, Evacuating , NOT_ORCHESTRATED("NOT ORCHESTRATED");
+
+ String stateName;
+
+ VNFStates(String name){
+ this.stateName = name;
+ }
+
+ VNFStates(){
+ this.stateName = name();
+ }
+
+ public String toString(){
+ return this.stateName;
+ }
}
@SuppressWarnings("unused")
@@ -46,12 +60,14 @@ public class MetadataReader {
State TESTED = new State(VNFStates.Tested.toString());
State REBUILDING = new State(VNFStates.Rebuilding.toString());
State RESTARTING = new State(VNFStates.Restarting.toString());
+ State STARTING = new State(VNFStates.Starting.toString());
State ERROR = new State(VNFStates.Error.toString());
State RUNNING = new State(VNFStates.Running.toString());
State UNKNOWN = new State(VNFStates.Unknown.toString());
State TERMINATING = new State(VNFStates.Terminating.toString());
State STOPPING = new State(VNFStates.Stopping.toString());
State STOPPED = new State(VNFStates.Stopped.toString());
+ State NOT_ORCHESTRATED = new State(VNFStates.NOT_ORCHESTRATED.toString());
State BACKING_UP = new State(VNFStates.Backing_Up.toString());
State SNAPSHOTTING = new State(VNFStates.Snapshotting.toString());
@@ -70,7 +86,9 @@ public class MetadataReader {
Event RESTART = new Event(VNFOperation.Restart.toString());
Event REBUILD = new Event(VNFOperation.Rebuild.toString());
Event STOP = new Event(VNFOperation.Stop.toString());
- Event MODIFY_CONFIG = new Event(VNFOperation.ModifyConfig.toString());
+ Event CONFIG_MODIFY = new Event(VNFOperation.ConfigModify.toString());
+ Event CONFIG_SCALEOUT = new Event(VNFOperation.ConfigScaleOut.toString());
+ Event CONFIG_RESTORE = new Event(VNFOperation.ConfigRestore.toString());
Event BACKUP = new Event(VNFOperation.Backup.toString());
Event SNAPSHOT = new Event(VNFOperation.Snapshot.toString());
Event SOFTWARE_UPLOAD = new Event(VNFOperation.SoftwareUpload.toString());
@@ -80,6 +98,9 @@ public class MetadataReader {
Event AUDIT = new Event(VNFOperation.Audit.toString());
Event MIGRATE = new Event(VNFOperation.Migrate.toString());
Event EVACUATE = new Event(VNFOperation.Evacuate.toString());
+ Event CONFIG_BACKUP = new Event(VNFOperation.ConfigBackup.toString());
+ Event CONFIG_BACKUP_DELETE = new Event(VNFOperation.ConfigBackupDelete.toString());
+ Event CONFIG_EXPORT = new Event(VNFOperation.ConfigExport.toString());
Event LOCK = new Event(VNFOperation.Lock.toString());
Event UNLOCK = new Event(VNFOperation.Unlock.toString());
@@ -99,6 +120,7 @@ public class MetadataReader {
builder = builder.addState(TESTED);
builder = builder.addState(REBUILDING);
builder = builder.addState(RESTARTING);
+ builder = builder.addState(STARTING);
builder = builder.addState(ERROR);
builder = builder.addState(RUNNING);
builder = builder.addState(UNKNOWN);
@@ -112,6 +134,7 @@ public class MetadataReader {
builder = builder.addState(ROLLBACKING);
builder = builder.addState(MIGRATING);
builder = builder.addState(EVACUATING);
+ builder = builder.addState(NOT_ORCHESTRATED);
builder = builder.addEvent(CONFIGURE);
builder = builder.addEvent(TEST);
@@ -122,7 +145,9 @@ public class MetadataReader {
builder = builder.addEvent(SUCCESS);
builder = builder.addEvent(FAILURE);
builder = builder.addEvent(STOP);
- builder = builder.addEvent(MODIFY_CONFIG);
+ builder = builder.addEvent(CONFIG_MODIFY);
+ builder = builder.addEvent(CONFIG_SCALEOUT);
+ builder = builder.addEvent(CONFIG_RESTORE);
builder = builder.addEvent(HEALTHCHECK);
builder = builder.addEvent(BACKUP);
builder = builder.addEvent(SNAPSHOT);
@@ -136,15 +161,22 @@ public class MetadataReader {
builder = builder.addEvent(LOCK);
builder = builder.addEvent(UNLOCK);
builder = builder.addEvent(CHECKLOCK);
+ builder = builder.addEvent(CONFIG_BACKUP);
+ builder = builder.addEvent(CONFIG_BACKUP_DELETE);
+ builder = builder.addEvent(CONFIG_EXPORT);
+
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIGURE,CONFIGURING);
builder = builder.addTransition(INSTANTIATED,CONFIGURE,CONFIGURING);
builder = builder.addTransition(INSTANTIATED,TEST,TESTING);
- builder = builder.addTransition(INSTANTIATED,START,RESTARTING);
+ builder = builder.addTransition(INSTANTIATED,START,STARTING);
builder = builder.addTransition(INSTANTIATED,TERMINATE,TERMINATING);
builder = builder.addTransition(INSTANTIATED,RESTART,RESTARTING);
builder = builder.addTransition(INSTANTIATED,REBUILD,REBUILDING);
builder = builder.addTransition(INSTANTIATED,STOP,STOPPING);
- builder = builder.addTransition(INSTANTIATED,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(INSTANTIATED,HEALTHCHECK,TESTING);
builder = builder.addTransition(INSTANTIATED,BACKUP,BACKING_UP);
builder = builder.addTransition(INSTANTIATED,SNAPSHOT,SNAPSHOTTING);
@@ -159,12 +191,14 @@ public class MetadataReader {
builder = builder.addTransition(CONFIGURED,CONFIGURE,CONFIGURING);
builder = builder.addTransition(CONFIGURED,TEST,TESTING);
- builder = builder.addTransition(CONFIGURED,START,RESTARTING);
+ builder = builder.addTransition(CONFIGURED,START,STARTING);
builder = builder.addTransition(CONFIGURED,TERMINATE,TERMINATING);
builder = builder.addTransition(CONFIGURED,RESTART,RESTARTING);
builder = builder.addTransition(CONFIGURED,REBUILD,REBUILDING);
builder = builder.addTransition(CONFIGURED,STOP,STOPPING);
- builder = builder.addTransition(CONFIGURED,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(CONFIGURED,HEALTHCHECK,TESTING);
builder = builder.addTransition(CONFIGURED,BACKUP,BACKING_UP);
builder = builder.addTransition(CONFIGURED,SNAPSHOT,SNAPSHOTTING);
@@ -178,15 +212,20 @@ public class MetadataReader {
builder = builder.addTransition(CONFIGURED,LOCK,CONFIGURED);
builder = builder.addTransition(CONFIGURED,UNLOCK,CONFIGURED);
builder = builder.addTransition(CONFIGURED,CHECKLOCK,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP_DELETE,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_EXPORT,CONFIGURED);
builder = builder.addTransition(TESTED,CONFIGURE,CONFIGURING);
builder = builder.addTransition(TESTED,TEST,TESTING);
- builder = builder.addTransition(TESTED,START,RESTARTING);
+ builder = builder.addTransition(TESTED,START,STARTING);
builder = builder.addTransition(TESTED,TERMINATE,TERMINATING);
builder = builder.addTransition(TESTED,RESTART,RESTARTING);
builder = builder.addTransition(TESTED,REBUILD,REBUILDING);
builder = builder.addTransition(TESTED,STOP,STOPPING);
- builder = builder.addTransition(TESTED,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(TESTED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(TESTED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(TESTED,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(TESTED,HEALTHCHECK,TESTING);
builder = builder.addTransition(TESTED,BACKUP,BACKING_UP);
builder = builder.addTransition(TESTED,SNAPSHOT,SNAPSHOTTING);
@@ -200,15 +239,20 @@ public class MetadataReader {
builder = builder.addTransition(TESTED,LOCK,TESTED);
builder = builder.addTransition(TESTED,UNLOCK,TESTED);
builder = builder.addTransition(TESTED,CHECKLOCK,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_BACKUP,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_BACKUP_DELETE,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_EXPORT,TESTED);
builder = builder.addTransition(RUNNING,CONFIGURE,CONFIGURING);
builder = builder.addTransition(RUNNING,TEST,TESTING);
- builder = builder.addTransition(RUNNING,START,RESTARTING);
+ builder = builder.addTransition(RUNNING,START,STARTING);
builder = builder.addTransition(RUNNING,TERMINATE,TERMINATING);
builder = builder.addTransition(RUNNING,RESTART,RESTARTING);
builder = builder.addTransition(RUNNING,REBUILD,REBUILDING);
builder = builder.addTransition(RUNNING,STOP,STOPPING);
- builder = builder.addTransition(RUNNING,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(RUNNING,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(RUNNING,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(RUNNING,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(RUNNING,HEALTHCHECK,TESTING);
builder = builder.addTransition(RUNNING,BACKUP,BACKING_UP);
builder = builder.addTransition(RUNNING,SNAPSHOT,SNAPSHOTTING);
@@ -222,15 +266,20 @@ public class MetadataReader {
builder = builder.addTransition(RUNNING,LOCK,RUNNING);
builder = builder.addTransition(RUNNING,UNLOCK,RUNNING);
builder = builder.addTransition(RUNNING,CHECKLOCK,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_BACKUP,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_BACKUP_DELETE,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_EXPORT,RUNNING);
builder = builder.addTransition(ERROR,CONFIGURE,CONFIGURING);
builder = builder.addTransition(ERROR,TEST,TESTING);
- builder = builder.addTransition(ERROR,START,RESTARTING);
+ builder = builder.addTransition(ERROR,START,STARTING);
builder = builder.addTransition(ERROR,TERMINATE,TERMINATING);
builder = builder.addTransition(ERROR,RESTART,RESTARTING);
builder = builder.addTransition(ERROR,REBUILD,REBUILDING);
builder = builder.addTransition(ERROR,STOP,STOPPING);
- builder = builder.addTransition(ERROR,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(ERROR,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(ERROR,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(ERROR,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(ERROR,HEALTHCHECK,TESTING);
builder = builder.addTransition(ERROR,BACKUP,BACKING_UP);
builder = builder.addTransition(ERROR,SNAPSHOT,SNAPSHOTTING);
@@ -244,15 +293,20 @@ public class MetadataReader {
builder = builder.addTransition(ERROR,LOCK,ERROR);
builder = builder.addTransition(ERROR,UNLOCK,ERROR);
builder = builder.addTransition(ERROR,CHECKLOCK,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_BACKUP,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_BACKUP_DELETE,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_EXPORT,ERROR);
builder = builder.addTransition(UNKNOWN,CONFIGURE,CONFIGURING);
builder = builder.addTransition(UNKNOWN,TEST,TESTING);
- builder = builder.addTransition(UNKNOWN,START,RESTARTING);
+ builder = builder.addTransition(UNKNOWN,START,STARTING);
builder = builder.addTransition(UNKNOWN,TERMINATE,TERMINATING);
builder = builder.addTransition(UNKNOWN,RESTART,RESTARTING);
builder = builder.addTransition(UNKNOWN,REBUILD,REBUILDING);
builder = builder.addTransition(UNKNOWN,STOP,STOPPING);
- builder = builder.addTransition(UNKNOWN,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(UNKNOWN,HEALTHCHECK,TESTING);
builder = builder.addTransition(UNKNOWN,BACKUP,BACKING_UP);
builder = builder.addTransition(UNKNOWN,SNAPSHOT,SNAPSHOTTING);
@@ -266,14 +320,19 @@ public class MetadataReader {
builder = builder.addTransition(UNKNOWN,LOCK,UNKNOWN);
builder = builder.addTransition(UNKNOWN,UNLOCK,UNKNOWN);
builder = builder.addTransition(UNKNOWN,CHECKLOCK,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP_DELETE,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_EXPORT,UNKNOWN);
builder = builder.addTransition(STOPPED,CONFIGURE,CONFIGURING);
builder = builder.addTransition(STOPPED,TEST,TESTING);
- builder = builder.addTransition(STOPPED,START,RESTARTING);
+ builder = builder.addTransition(STOPPED,START,STARTING);
builder = builder.addTransition(STOPPED,TERMINATE,TERMINATING);
builder = builder.addTransition(STOPPED,RESTART,RESTARTING);
builder = builder.addTransition(STOPPED,REBUILD,REBUILDING);
- builder = builder.addTransition(STOPPED,MODIFY_CONFIG,CONFIGURING);
+ builder = builder.addTransition(STOPPED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(STOPPED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(STOPPED,CONFIG_RESTORE,CONFIGURING);
builder = builder.addTransition(STOPPED,HEALTHCHECK,TESTING);
builder = builder.addTransition(STOPPED,BACKUP,BACKING_UP);
builder = builder.addTransition(STOPPED,SNAPSHOT,SNAPSHOTTING);
@@ -295,6 +354,9 @@ public class MetadataReader {
builder = builder.addTransition(RESTARTING,SUCCESS,RUNNING);
builder = builder.addTransition(RESTARTING,FAILURE,ERROR);
+ builder = builder.addTransition(STARTING,SUCCESS,RUNNING);
+ builder = builder.addTransition(STARTING,FAILURE,ERROR);
+
builder = builder.addTransition(TERMINATING,SUCCESS,NOT_INSTANTIATED);
builder = builder.addTransition(TERMINATING,FAILURE,ERROR);
diff --git a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/resources/org/openecomp/appc/default.properties
index 63711c27f..2fbb0daab 100644
--- a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/main/resources/org/openecomp/appc/default.properties
@@ -25,24 +25,12 @@ org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-LC-MGMT-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-LC-MGMT-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
-
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/test/java/org/openecomp/appc/TestLifecycleManager.java b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/test/java/org/openecomp/appc/TestLifecycleManager.java
index 4c14e90bd..50b434956 100644
--- a/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/test/java/org/openecomp/appc/TestLifecycleManager.java
+++ b/appc-dispatcher/appc-lifecycle-management/appc-lifecycle-management-core/src/test/java/org/openecomp/appc/TestLifecycleManager.java
@@ -103,6 +103,19 @@ public class TestLifecycleManager {
}
}
+ @Test
+ public void testNotOrchestratedState() throws LifecycleException, NoTransitionDefinedException {
+ LifecycleManager lifecycleManager = new LifecycleManagerImpl();
+ String nextState = lifecycleManager.getNextState(null,"NOT ORCHESTRATED",VNFOperation.Configure.toString());
+ Assert.assertEquals(nextState,"Configuring");
+ }
+
+ @Test(expected = NoTransitionDefinedException.class)
+ public void testBakckingUpState() throws LifecycleException, NoTransitionDefinedException {
+ LifecycleManager lifecycleManager = new LifecycleManagerImpl();
+ String nextState = lifecycleManager.getNextState(null,"Software_Uploading",VNFOperation.Configure.toString());
+ }
+
private List<Event> getNegativeEvents(State state,Set<Event> events) {
List<Event> negativeEventList = new ArrayList<>();
negativeEventList.addAll(events);
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-api/pom.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-api/pom.xml
index 62d046501..e4008a605 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-api/pom.xml
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-api/pom.xml
@@ -17,9 +17,8 @@
<dependencies>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
+ <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
-<!-- <version>${jackson.version}</version> -->
</dependency>
<dependency>
@@ -48,9 +47,14 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>org.openecomp.appc.requesthandler,org.openecomp.appc.requesthandler.objects,org.openecomp.appc.transactionrecorder,org.openecomp.appc.message</Export-Package>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic,appc-data-access-lib,javax.json;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Dependency>
+ javax.json;scope=compile|runtime;inline=false
+ </Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
- <Import-Package>com.fasterxml.jackson.annotation,org.apache.commons.lang3,!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.domainmodel.lcm,
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/LCMStateManager.java b/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/LCMStateManager.java
new file mode 100644
index 000000000..6a63b1050
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/LCMStateManager.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.requesthandler;
+
+/**
+ */
+public interface LCMStateManager {
+ /**
+ * This method checks if the LCM operations are enabled or not
+ * * @return true if enabled else false
+ */
+ boolean isLCMOperationEnabled();
+
+ /**
+ * This method disables the LCM operations
+ */
+ void disableLCMOperations();
+
+ /**
+ * This method disables the LCM operations
+ */
+ void enableLCMOperations();
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/RequestHandler.java b/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/RequestHandler.java
index d0d54c9db..23b5d372f 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/RequestHandler.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-api/src/main/java/org/openecomp/appc/requesthandler/RequestHandler.java
@@ -74,4 +74,10 @@ public interface RequestHandler {
* @param updateAAI boolean flag which indicate AAI upodate status after request completion.
*/
void onRequestTTLEnd(RuntimeContext runtimeContext, boolean updateAAI);
+
+ /**
+ * This method returns the count of in progress requests
+ * * @return in progress requests count
+ */
+ int getInprogressRequestCount();
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml
index dcc73f2f1..da223089b 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/pom.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with this
@@ -40,6 +39,19 @@
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-dmaap-adapter-bundle</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-message-adapter-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-message-adapter-factory</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -97,6 +109,11 @@
<artifactId>transaction-recorder</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -108,10 +125,15 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>appc-provider-model,appc-dmaap-adapter-bundle,appc-metric-bundle,appc-common,eelf-core,logback-core,logback-classic,appc-data-access-lib;scope=compile|runtime;inline=false</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
<Export-Service>org.openecomp.appc.requesthandler.RequestHandler</Export-Service>
- <Import-Package>org.openecomp.appc.lockmanager.api.*,org.openecomp.appc.requesthandler,org.openecomp.appc.requesthandler.objects,org.openecomp.appc.transactionrecorder,org.openecomp.appc.transactionrecorder.objects,!groovy.lang,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.apache.commons.lang3,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*;resolution:=optional</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.adapter.messaging.*,
+ org.openecomp.appc.adapter.message.*,
+ org.openecomp.appc.adapter.factory.*,
+ org.openecomp.appc.lockmanager.api.*,org.openecomp.appc.requesthandler,org.openecomp.appc.requesthandler.objects,org.openecomp.appc.transactionrecorder,
+ org.openecomp.appc.transactionrecorder.objects, org.openecomp.appc.dao.util,
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java
index 21c21db93..676c62871 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java
@@ -21,26 +21,33 @@
package org.openecomp.appc.messageadapter.impl;
-import java.util.HashSet;
-import java.util.Properties;
-import org.apache.commons.lang.ObjectUtils;
-import org.openecomp.appc.adapter.dmaap.Producer;
-import org.openecomp.appc.adapter.dmaap.DmaapProducer;
+import org.openecomp.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
+import org.openecomp.appc.adapter.factory.MessageService;
+import org.openecomp.appc.adapter.message.MessageAdapterFactory;
+import org.openecomp.appc.adapter.message.Producer;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.commons.lang.ObjectUtils;
import org.openecomp.appc.domainmodel.lcm.ResponseContext;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
import org.openecomp.appc.messageadapter.MessageAdapter;
import org.openecomp.appc.requesthandler.conv.Converter;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
-import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.HashSet;
+import java.util.Properties;
-public class MessageAdapterDmaapImpl implements MessageAdapter{
+public class MessageAdapterImpl implements MessageAdapter{
- private Producer dmaapProducer;
+ private MessageService messageService;
+ private Producer producer;
private String partition ;
private Configuration configuration;
private HashSet<String> pool;
@@ -48,21 +55,28 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
private String apiKey;
private String apiSecret;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterDmaapImpl.class);
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterImpl.class);
/**
- * Initialize dmaapProducer client to post messages using configuration properties
+ * Initialize producer client to post messages using configuration properties
*/
@Override
public void init(){
- this.dmaapProducer = getDmaapProducer();
+ this.producer = getProducer();
}
- private Producer getDmaapProducer() {
+
+ private Producer getProducer() {
configuration = ConfigurationFactory.getConfiguration();
Properties properties=configuration.getProperties();
updateProperties(properties);
- Producer producer=new DmaapProducer(pool,writeTopic);
- producer.updateCredentials(apiKey, apiSecret);
+
+ BundleContext ctx = FrameworkUtil.getBundle(MessageAdapterImpl.class).getBundleContext();
+ if (ctx != null) {
+ ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
+ if (svcRef != null) {
+ producer = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopic,apiKey, apiSecret);
+ }
+ }
return producer;
}
@@ -73,10 +87,13 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
}
pool = new HashSet<>();
if (props != null) {
- writeTopic = props.getProperty("dmaap.topic.write");
- apiKey = props.getProperty("dmaap.client.key");
- apiSecret = props.getProperty("dmaap.client.secret");
- String hostnames = props.getProperty("dmaap.poolMembers");
+ // readTopic = props.getProperty("dmaap.topic.read");
+ writeTopic = props.getProperty("appc.LCM.topic.write");
+ apiKey = props.getProperty("appc.LCM.client.key");
+ apiSecret = props.getProperty("appc.LCM.client.secret");
+ messageService = MessageService.parse(props.getProperty("message.service.type"));
+ // READ_TIMEOUT = Integer.valueOf(props.getProperty("dmaap.topic.read.timeout", String.valueOf(READ_TIMEOUT)));
+ String hostnames = props.getProperty("appc.LCM.poolMembers");
if (hostnames != null && !hostnames.isEmpty()) {
for (String name : hostnames.split(",")) {
pool.add(name);
@@ -103,9 +120,9 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
if (logger.isDebugEnabled()) {
logger.debug("DMaaP Response = " + jsonMessage);
}
- success = dmaapProducer.post(this.partition, jsonMessage);
+ success = producer.post(this.partition, jsonMessage);
} catch (JsonProcessingException e1) {
- logger.error("Error generating Jason from DMaaP message "+ e1.getMessage());
+ logger.error("Error generating Json from DMaaP message "+ e1.getMessage());
success= false;
}catch (Exception e){
logger.error("Error sending message to DMaaP "+e.getMessage());
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
index 3513516ae..272e02bca 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
@@ -21,38 +21,6 @@
package org.openecomp.appc.requesthandler.conv;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Payload;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ZULU;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeaderBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.FlagsBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.openecomp.appc.domainmodel.lcm.ResponseContext;
-import org.openecomp.appc.domainmodel.lcm.VNFOperation;
-import org.openecomp.appc.requesthandler.impl.DmaapOutgoingMessage;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -65,6 +33,23 @@ import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.*;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.FlagsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.StatusBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.openecomp.appc.domainmodel.lcm.ResponseContext;
+import org.openecomp.appc.domainmodel.lcm.VNFOperation;
+import org.openecomp.appc.requesthandler.impl.DmaapOutgoingMessage;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
public class Converter {
@@ -90,6 +75,7 @@ public class Converter {
Action action = Action.valueOf(vnfOperation.name());
CommonHeader commonHeader = convAsyncResponseTorev160108CommonHeader(response);
Status status = convAsyncResponseTorev160108Status(response);
+ Payload payload = convAsyncResponseTorev160108Payload(response);
switch (action){
case Rollback:
outObj = new RollbackOutputBuilder();
@@ -110,6 +96,7 @@ public class Converter {
outObj = new AuditOutputBuilder();
((AuditOutputBuilder)outObj).setCommonHeader(commonHeader);
((AuditOutputBuilder)outObj).setStatus(status);
+ ((AuditOutputBuilder)outObj).setPayload(payload);
return outObj;
case HealthCheck:
outObj = new HealthCheckOutputBuilder();
@@ -126,10 +113,29 @@ public class Converter {
((LockOutputBuilder)outObj).setCommonHeader(commonHeader);
((LockOutputBuilder)outObj).setStatus(status);
return outObj;
- case ModifyConfig:
- outObj = new ModifyConfigOutputBuilder();
- ((ModifyConfigOutputBuilder)outObj).setCommonHeader(commonHeader);
- ((ModifyConfigOutputBuilder)outObj).setStatus(status);
+ case Configure:
+ outObj = new ConfigureOutputBuilder();
+ ((ConfigureOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigureOutputBuilder)outObj).setStatus(status);
+ ((ConfigureOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigModify:
+ outObj = new ConfigModifyOutputBuilder();
+ ((ConfigModifyOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigModifyOutputBuilder)outObj).setStatus(status);
+ ((ConfigModifyOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigScaleOut:
+ outObj = new ConfigScaleoutOutputBuilder();
+ ((ConfigScaleoutOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigScaleoutOutputBuilder)outObj).setStatus(status);
+ ((ConfigScaleoutOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigRestore:
+ outObj = new ConfigRestoreOutputBuilder();
+ ((ConfigRestoreOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigRestoreOutputBuilder)outObj).setStatus(status);
+ ((ConfigRestoreOutputBuilder)outObj).setPayload(payload);
return outObj;
case SoftwareUpload:
outObj = new SoftwareUploadOutputBuilder();
@@ -145,6 +151,7 @@ public class Converter {
outObj = new SyncOutputBuilder();
((SyncOutputBuilder)outObj).setCommonHeader(commonHeader);
((SyncOutputBuilder)outObj).setStatus(status);
+ ((SyncOutputBuilder)outObj).setPayload(payload);
return outObj;
case Terminate:
outObj = new TerminateOutputBuilder();
@@ -161,12 +168,54 @@ public class Converter {
((UnlockOutputBuilder)outObj).setCommonHeader(commonHeader);
((UnlockOutputBuilder)outObj).setStatus(status);
return outObj;
+ case Restart:
+ outObj = new RestartOutputBuilder();
+ ((RestartOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((RestartOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Rebuild:
+ outObj = new RebuildOutputBuilder();
+ ((RebuildOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((RebuildOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Migrate:
+ outObj = new MigrateOutputBuilder();
+ ((MigrateOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((MigrateOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Evacuate:
+ outObj = new EvacuateOutputBuilder();
+ ((EvacuateOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((EvacuateOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case ConfigBackup:
+ outObj = new ConfigBackupOutputBuilder();
+ ((ConfigBackupOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigBackupOutputBuilder)outObj).setStatus(status);
+ ((ConfigBackupOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigBackupDelete:
+ outObj = new ConfigBackupDeleteOutputBuilder();
+ ((ConfigBackupDeleteOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigBackupDeleteOutputBuilder)outObj).setStatus(status);
+ ((ConfigBackupDeleteOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigExport:
+ outObj = new ConfigExportOutputBuilder();
+ ((ConfigExportOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigExportOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Start:
+ outObj = new StartOutputBuilder();
+ ((StartOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((StartOutputBuilder)outObj).setStatus(status);
+ return outObj;
default:
throw new IllegalArgumentException(action+" action is not supported");
}
}
- public static Payload convAsyncResponseTorev160108Payload(ResponseContext inObj) throws ParseException {
+ public static Payload convAsyncResponseTorev160108Payload(ResponseContext inObj) {
Payload payload = null;
if(inObj.getPayload() != null) {
payload = new Payload(inObj.getPayload());
@@ -208,7 +257,7 @@ public class Converter {
}
CommonHeaderBuilder commonHeaderBuilder = new CommonHeaderBuilder();
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags commonHeaderFlags = null;
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags commonHeaderFlags = null;
if(inObj.getCommonHeader().getFlags() != null){
commonHeaderFlags = Converter.convFlagsMapTorev160108Flags(inObj.getCommonHeader().getFlags());
commonHeaderBuilder.setFlags(commonHeaderFlags);
@@ -239,7 +288,7 @@ public class Converter {
return isoFormatter.format(timeStamp);
}
- public static org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags
+ public static org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags
convFlagsMapTorev160108Flags(org.openecomp.appc.domainmodel.lcm.Flags flags) {
Flags rev160108flags = null;
boolean anyFlag = false;
@@ -249,14 +298,14 @@ public class Converter {
*/
/*
if(flags.containsKey(FORCE_FLAG)){
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Force force =
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Force.valueOf(flags.get(FORCE_FLAG).toString());
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Force force =
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Force.valueOf(flags.get(FORCE_FLAG).toString());
flagsBuilder.setForce(force);
anyFlag = true;
}
if(flags.containsKey(MODE_FLAG)){
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Mode mode =
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Mode.valueOf(flags.get(MODE_FLAG).toString());
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Mode mode =
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Mode.valueOf(flags.get(MODE_FLAG).toString());
flagsBuilder.setMode(mode);
anyFlag = true;
}
@@ -307,6 +356,9 @@ public class Converter {
public static DmaapOutgoingMessage convAsyncResponseToDmaapOutgoingMessage(VNFOperation vnfOperation, String rpcName, ResponseContext asyncResponse) throws JsonProcessingException {
DmaapOutgoingMessage outObj = new DmaapOutgoingMessage();
+ String correlationID = getCorrelationID(asyncResponse);
+ outObj.setCorrelationID(correlationID);
+ outObj.setType("response");
outObj.setRpcName(rpcName);
Builder<?> builder = Converter.convAsyncResponseToBuilder(vnfOperation, rpcName, asyncResponse);
Object messageBody = builder.build();
@@ -315,6 +367,12 @@ public class Converter {
return outObj;
}
+ private static String getCorrelationID(ResponseContext context) {
+ return context.getCommonHeader().getRequestId()
+ + (context.getCommonHeader().getSubRequestId() == null ?
+ "":"-" + context.getCommonHeader().getSubRequestId());
+ }
+
abstract class MixIn {
@JsonIgnore
abstract Class<? extends DataContainer> getImplementedInterface(); // to be removed during serialization
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java
new file mode 100644
index 000000000..c067f303f
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.requesthandler.exceptions;
+
+/**
+ */
+public class LCMOperationsDisabledException extends Exception {
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public LCMOperationsDisabledException(String message) {
+ super(message);
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java
new file mode 100644
index 000000000..7ffdb3801
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.requesthandler.exceptions;
+
+public class MissingVNFDataInAAIException extends Exception {
+ String missingAttributeName;
+ public MissingVNFDataInAAIException(String attributeName) {
+ this.missingAttributeName = attributeName;
+ }
+
+ public String getMissingAttributeName() {
+ return missingAttributeName;
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
index 874626c78..e51d4b978 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
@@ -76,4 +76,15 @@ public class RequestRegistry {
set.remove(requestIdentifier);
}
+ /**
+ * This method returns the count of currently registered requests
+ * in the request registry
+ * * @return currently registered requests count
+ */
+ public int getRegisteredRequestCount() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getRegisteredRequestCount");
+ }
+ return set.size();
+ }
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
index 4f2986d74..a4a2beee5 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
@@ -28,10 +28,12 @@ import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
+import org.openecomp.appc.requesthandler.exceptions.LCMOperationsDisabledException;
+import org.openecomp.appc.requesthandler.exceptions.MissingVNFDataInAAIException;
import org.openecomp.appc.requesthandler.exceptions.RequestExpiredException;
import org.openecomp.appc.requesthandler.exceptions.VNFNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.WorkflowNotFoundException;
public interface RequestValidator {
- public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException,DGWorkflowNotFoundException;
+ public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException;
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
index 4546726e9..c2455a3b4 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
@@ -36,6 +36,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonIgnoreProperties(ignoreUnknown = true)
public class DmaapOutgoingMessage {
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("correlation-id")
+ private String correlationID;
+
private final static String defaultCambriaPartition = "MSO";
@JsonProperty("cambria.partition")
private String cambriaPartition = defaultCambriaPartition;
@@ -49,6 +58,30 @@ public class DmaapOutgoingMessage {
public DmaapOutgoingMessage() {
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCorrelationID() {
+ return correlationID;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
public String getCambriaPartition() {
return cambriaPartition;
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
new file mode 100644
index 000000000..0c97ebcbe
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.requesthandler.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.openecomp.appc.requesthandler.LCMStateManager;
+
+public class LCMStateManagerImpl implements LCMStateManager {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LCMStateManagerImpl.class);
+ private static AtomicBoolean isLCMEnabled = new AtomicBoolean(true);
+
+ /**
+ * This method checks if the LCM operations are enabled or not
+ * * @return true if enabled else false
+ */
+ public boolean isLCMOperationEnabled() {
+ return isLCMEnabled.get();
+ }
+
+ /**
+ * This method disables the LCM operations
+ */
+ public void disableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to disableLCMOperations");
+ }
+ isLCMEnabled.set(false);
+ }
+
+ /**
+ * This method enables the LCM operations
+ */
+ public void enableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to enableLCMOperations");
+ }
+ isLCMEnabled.set(true);
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
index d63cb8bb8..e6f7452c9 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
@@ -40,7 +40,7 @@ import org.openecomp.appc.lockmanager.api.LockManager;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
import org.openecomp.appc.messageadapter.MessageAdapter;
-import org.openecomp.appc.messageadapter.impl.MessageAdapterDmaapImpl;
+import org.openecomp.appc.messageadapter.impl.MessageAdapterImpl;
import org.openecomp.appc.metricservice.MetricRegistry;
import org.openecomp.appc.metricservice.MetricService;
import org.openecomp.appc.metricservice.metric.DispatchingFuntionMetric;
@@ -133,7 +133,7 @@ public class RequestHandlerImpl implements RequestHandler {
public RequestHandlerImpl() {
requestRegistry = new RequestRegistry();
- messageAdapter = new MessageAdapterDmaapImpl();
+ messageAdapter = new MessageAdapterImpl();
messageAdapter.init();
Properties properties = configuration.getProperties();
if (properties != null && properties.getProperty("metric.enabled") != null) {
@@ -215,7 +215,7 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (LifecycleException e) {
errorMessage = e.getMessage();
params = new Params().addParam("actionName", input.getRequestContext().getAction()).addParam("currentState", e.currentState);
- output = buildRequestHandlerOutput(LCMCommandStatus.ACTION_NOT_SUPPORTED, params);
+ output = buildRequestHandlerOutput(LCMCommandStatus.INVALID_VNF_STATE, params);
} catch (UnstableVNFException e) {
errorMessage = e.getMessage();
params = new Params().addParam("vnfId", vnfId);
@@ -246,6 +246,15 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (DuplicateRequestException e) {
errorMessage = e.getMessage();
output = buildRequestHandlerOutput(LCMCommandStatus.DUPLICATE_REQUEST, null);
+ } catch (MissingVNFDataInAAIException e) {
+ params = new Params().addParam("attributeName",e.getMissingAttributeName())
+ .addParam("vnfId",vnfId);
+ output = buildRequestHandlerOutput(LCMCommandStatus.MISSING_VNF_DATA_IN_AAI,params);
+ errorMessage = output.getResponseContext().getStatus().getMessage();
+ } catch (LCMOperationsDisabledException e) {
+ errorMessage = e.getMessage();
+ params = new Params().addParam("errorMsg", errorMessage);
+ output = buildRequestHandlerOutput(LCMCommandStatus.REJECTED, params);
} catch (Exception e) {
storeErrorMessageToLog(runtimeContext, "", "", "Exception = " + e.getMessage());
errorMessage = e.getMessage() != null ? e.getMessage() : e.toString();
@@ -261,7 +270,11 @@ public class RequestHandlerImpl implements RequestHandler {
runtimeContext.setResponseContext(output.getResponseContext());
if ((null == output) || !(output.getResponseContext().getStatus().getCode() == LCMCommandStatus.ACCEPTED.getResponseCode())) {
if (isMetricEnabled) {
- ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ if((output.getResponseContext().getStatus().getCode() == LCMCommandStatus.SUCCESS.getResponseCode())) {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementAcceptedRequest();
+ }else {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ }
}
removeRequestFromRegistry(input.getRequestContext().getCommonHeader());
}
@@ -580,14 +593,18 @@ public class RequestHandlerImpl implements RequestHandler {
if (logger.isTraceEnabled()) {
logger.trace("Entering to onRequestExecutionStart with vnfId = " + vnfId + "and requestIdentifierString = " + requestIdentifierString);
}
- try {
- boolean updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+
+ if(!readOnlyActivity || !forceFlag || workingStateManager.isVNFStable(vnfId)) {
+ boolean updated = false;
+ try {
+ updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+ } catch (Exception e) {
+ logger.error("Error updating working state for vnf " + vnfId + e);
+ throw new RuntimeException(e);
+ }
if (!updated) {
throw new UnstableVNFException("VNF is not stable for vnfID = " + vnfId);
}
- } catch (Exception e) {
- logger.error("Error updating working state for vnf " + vnfId + e);
- throw new RuntimeException(e);
}
if (logger.isTraceEnabled())
@@ -805,4 +822,16 @@ public class RequestHandlerImpl implements RequestHandler {
return null;
}
}
+
+ /**
+ * This method returns the count of in progress requests
+ * * @return in progress requests count
+ */
+ @Override
+ public int getInprogressRequestCount() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getInprogressRequestCount");
+ }
+ return requestRegistry.getRegisteredRequestCount();
+ }
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
index 509c351ea..8499937c7 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
@@ -24,6 +24,7 @@ package org.openecomp.appc.requesthandler.impl;
import java.time.Instant;
import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
import org.openecomp.appc.common.constant.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
@@ -40,6 +41,8 @@ import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
+import org.openecomp.appc.requesthandler.LCMStateManager;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
@@ -74,6 +77,7 @@ public class RequestValidatorImpl implements RequestValidator {
private WorkFlowManager workflowManager;
private WorkingStateManager workingStateManager;
+ private LCMStateManager lcmStateManager;
private final RequestRegistry requestRegistry = new RequestRegistry();
@@ -93,14 +97,26 @@ public class RequestValidatorImpl implements RequestValidator {
this.workingStateManager = workingStateManager;
}
+ public void setLcmStateManager(LCMStateManager lcmStateManager) {
+ this.lcmStateManager = lcmStateManager;
+ }
+
public RequestValidatorImpl() {
}
@Override
- public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
if (logger.isTraceEnabled()){
logger.trace("Entering to validateRequest with RequestHandlerInput = "+ ObjectUtils.toString(runtimeContext));
}
+ if(!lcmStateManager.isLCMOperationEnabled()) {
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.REQUEST_VALIDATOR,
+ EELFResourceManager.format(Msg.LCM_OPERATIONS_DISABLED),
+ this.getClass().getCanonicalName());
+ throw new LCMOperationsDisabledException("APPC LCM operations have been administratively disabled");
+ }
+
getAAIservice();
validateInput(runtimeContext.getRequestContext());
checkVNFWorkingState(runtimeContext);
@@ -114,9 +130,9 @@ public class RequestValidatorImpl implements RequestValidator {
// for built-in operations skip WF presence check
queryWFM(vnfContext, runtimeContext.getRequestContext());
}
- }
+ }
- private boolean isValidTTL(String ttl) {
+ private boolean isValidTTL(String ttl) {
if (logger.isTraceEnabled()){
logger.trace("Entering to isValidTTL where ttl = "+ ObjectUtils.toString(ttl));
}
@@ -206,7 +222,7 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private VNFContext queryAAI(String vnfId) throws VNFNotFoundException {
+ private VNFContext queryAAI(String vnfId) throws VNFNotFoundException, MissingVNFDataInAAIException {
SvcLogicContext ctx = new SvcLogicContext();
ctx = getVnfdata(vnfId, "vnf", ctx);
@@ -267,9 +283,17 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) {
- vnfContext.setType(ctx.getAttribute("vnf.vnf-type"));
- vnfContext.setStatus(ctx.getAttribute("vnf.orchestration-status"));
+ private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) throws MissingVNFDataInAAIException {
+ String vnfType = ctx.getAttribute("vnf.vnf-type");
+ String orchestrationStatus = ctx.getAttribute("vnf.orchestration-status");
+ if(StringUtils.isEmpty(vnfType)){
+ throw new MissingVNFDataInAAIException("vnf-type");
+ }
+ else if(StringUtils.isEmpty(orchestrationStatus)){
+ throw new MissingVNFDataInAAIException("orchestration-status");
+ }
+ vnfContext.setType(vnfType);
+ vnfContext.setStatus(orchestrationStatus);
vnfContext.setId(ctx.getAttribute("vnf.vnf-id"));
// TODO: Uncomment once A&AI supports VNF version
//vnfContext.setVersion(ctx.getAttribute("vnf.vnf-version"));
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 785b6cb04..984de9878 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -39,9 +39,13 @@
<property name="lifecyclemanager" ref="lifecyclemanagerRef" />
<property name="workflowManager" ref="workflowManagerRef" />
<property name="workingStateManager" ref="workingStateManagerBean" />
+ <property name="lcmStateManager" ref="lcmStateManagerBean" />
</bean>
+ <bean id="lcmStateManagerBean" class="org.openecomp.appc.requesthandler.impl.LCMStateManagerImpl" scope="singleton" />
+
<service id="requestHandlerService" interface="org.openecomp.appc.requesthandler.RequestHandler" ref="requestHandlerBean"/>
+ <service id="lcmStateManagerService" interface="org.openecomp.appc.requesthandler.LCMStateManager" ref="lcmStateManagerBean"/>
<reference id="lifecyclemanagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.lifecyclemanager.LifecycleManager" />
<reference id="workflowManagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.workflow.WorkFlowManager" />
<reference id="commandExecutorRef" availability="optional" activation="eager" interface="org.openecomp.appc.executor.CommandExecutor" />
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
index 2e2763f9a..ba24304f9 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
@@ -25,21 +25,14 @@ org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-REQ-HLDR-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-REQ-HDLR-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
org.openecomp.appc.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
org.openecomp.appc.db.user.sdnctl=test
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java
new file mode 100644
index 000000000..2c8d56e51
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.openecomp.appc.requesthandler;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.requesthandler.impl.LCMStateManagerImpl;
+
+public class LCMStateManagerImplTest {
+
+ LCMStateManager lcmStateManager;
+
+ @Before
+ public void init() throws Exception {
+ lcmStateManager = new LCMStateManagerImpl();
+ }
+
+ /**
+ * Test to check the disable LCM operations method
+ */
+ @Test
+ public void disableLCMOperations() throws Exception {
+ lcmStateManager.disableLCMOperations();
+ Assert.assertFalse(lcmStateManager.isLCMOperationEnabled());
+ }
+
+ /**
+ * Test to check the enable LCM operations method
+ */
+ @Test
+ public void enableLCMOperations() throws Exception {
+ lcmStateManager.enableLCMOperations();
+ Assert.assertTrue(lcmStateManager.isLCMOperationEnabled());
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
index c54f94750..17a62b17f 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
@@ -28,7 +28,6 @@ import org.openecomp.appc.domainmodel.lcm.*;
import org.openecomp.appc.executor.objects.LCMCommandStatus;
import org.openecomp.appc.requesthandler.conv.Converter;
-import javax.ws.rs.container.AsyncResponse;
import java.text.ParseException;
import java.time.Instant;
import java.util.Date;
@@ -37,19 +36,20 @@ import java.util.HashMap;
public class TestConverter {
private String expectedJsonBodyStr ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
- private String expectedDmaapOutgoingMessageJsonStringTest ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"test\"}";
- private String expectedDmaapOutgoingMessageJsonStringRollback ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"rollback\"}";
- private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"snapshot\"}";
- private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"audit\"}";
- private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"health-check\"}";
- private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"live-upgrade\"}";
- private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"lock\"}";
- private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"modify-config\"}";
- private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"software-upload\"}";
- private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"stop\"}";
- private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"sync\"}";
- private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"terminate\"}";
- private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"unlock\"}";
+ private String expectedDmaapOutgoingMessageJsonStringTest ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"test\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringRollback ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"rollback\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"snapshot\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"audit\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"health-check\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"live-upgrade\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"lock\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"config-modify\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"software-upload\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"sync\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"terminate\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"unlock\",\"type\":\"response\"}";
+ private String expectedJsonBodyStrwithPayload ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
@Test
public void convDateToZuluStringTest(){
@@ -126,16 +126,16 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderAuditTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Audit;
String rpcName = action.name().toLowerCase();
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringAuditTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Audit;
String rpcName = action.name().toLowerCase();
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
@@ -199,17 +199,17 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderModifyConfigTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
- VNFOperation action = VNFOperation.ModifyConfig;
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
+ VNFOperation action = VNFOperation.ConfigModify;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringModifyConfigTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
- VNFOperation action = VNFOperation.ModifyConfig;
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
+ VNFOperation action = VNFOperation.ConfigModify;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
System.out.println("jsonStr = " + jsonStr);
@@ -254,17 +254,17 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderSync() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringSync() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
@@ -273,11 +273,11 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderTerminateTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
@@ -334,6 +334,17 @@ public class TestConverter {
return asyncResponse;
}
+ private ResponseContext buildAsyncResponsewithPayload() {
+ ResponseContext asyncResponse = createResponseContextWithSubObjects();
+ asyncResponse.setStatus(LCMCommandStatus.SUCCESS.toStatus(null));
+ asyncResponse.getCommonHeader().setOriginatorId("oid");
+ asyncResponse.getCommonHeader().setApiVer("2.0.0");
+ asyncResponse.getCommonHeader().setRequestId("reqid");
+ asyncResponse.getCommonHeader().setTimestamp(Instant.ofEpochMilli(1000L));
+ asyncResponse.setPayload("{}");
+ return asyncResponse;
+ }
+
private ResponseContext createResponseContextWithSubObjects() {
ResponseContext responseContext = new ResponseContext();
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
index 1af658f0a..112965575 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
@@ -38,6 +38,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
+import org.openecomp.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
+import org.openecomp.appc.adapter.message.MessageAdapterFactory;
+import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.domainmodel.lcm.*;
+import org.openecomp.appc.domainmodel.lcm.Flags.Mode;
import org.openecomp.appc.domainmodel.lcm.ActionIdentifiers;
import org.openecomp.appc.domainmodel.lcm.CommonHeader;
import org.openecomp.appc.domainmodel.lcm.Flags;
@@ -56,6 +63,8 @@ import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.lockmanager.api.LockException;
import org.openecomp.appc.lockmanager.api.LockManager;
import org.openecomp.appc.messageadapter.MessageAdapter;
+import org.openecomp.appc.messageadapter.impl.MessageAdapterImpl;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
@@ -73,7 +82,15 @@ import org.openecomp.appc.workflow.objects.WorkflowExistsOutput;
import org.openecomp.appc.workflow.objects.WorkflowRequest;
import org.openecomp.appc.workingstatemanager.WorkingStateManager;
import org.openecomp.appc.workingstatemanager.objects.VNFWorkingState;
+import org.openecomp.sdnc.sli.aai.AAIService;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -82,7 +99,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@RunWith(PowerMockRunner.class)
-@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class})
+@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class, MessageAdapterImpl.class})
public class TestRequestHandler {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestRequestHandler.class);
@@ -92,10 +109,29 @@ public class TestRequestHandler {
private WorkFlowManager workflowManager;
private WorkingStateManager workingStateManager ;
private LockManager lockManager;
+ private Configuration configuration;
+ private final BundleContext bundleContext=Mockito.mock(BundleContext.class);
+ private final Bundle bundleService=Mockito.mock(Bundle.class);
+ private final ServiceReference sref=Mockito.mock(ServiceReference.class);
+ MessageAdapterFactory factory = new DmaapMessageAdapterFactoryImpl();
+
+
@Before
public void init() throws Exception {
-
+ configuration = ConfigurationFactory.getConfiguration();
+
+ configuration.setProperty("appc.LCM.topic.write" , "TEST");
+ configuration.setProperty("appc.LCM.client.key" , "TEST");
+ configuration.setProperty("appc.LCM.client.secret" , "TEST");
+
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(MessageAdapterImpl.class)).thenReturn(bundleService);
+ PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ PowerMockito.when(bundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(sref);
+ PowerMockito.when(bundleContext.getService(sref)).thenReturn(factory);
+
+
requestHandler = new RequestHandlerImpl();
LifecycleManager lifecyclemanager= mock(LifecycleManager.class);
workflowManager= mock(WorkFlowManager.class);
@@ -161,7 +197,7 @@ public class TestRequestHandler {
}
@Test
- public void testInvalidVNFExceptionRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testInvalidVNFExceptionRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -174,7 +210,7 @@ public class TestRequestHandler {
}
@Test
- public void testLifecycleException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testLifecycleException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -183,12 +219,12 @@ public class TestRequestHandler {
RequestHandlerInput input = this.getRequestHandlerInput("3009", VNFOperation.Configure,0,false,originatorID, requestID, subRequestID, Instant.now());
PowerMockito.doThrow(new LifecycleException(new Exception(),"Configured","test event")).when(requestValidator).validateRequest(Matchers.any(RuntimeContext.class));
RequestHandlerOutput output = requestHandler.handleRequest(input);
- Assert.assertEquals(LCMCommandStatus.ACTION_NOT_SUPPORTED.getResponseCode(), output.getResponseContext().getStatus().getCode());
+ Assert.assertEquals(LCMCommandStatus.INVALID_VNF_STATE.getResponseCode(), output.getResponseContext().getStatus().getCode());
}
@Test
- public void testRequestExpiredException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testRequestExpiredException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -200,7 +236,19 @@ public class TestRequestHandler {
}
@Test
- public void testWorkflowNotFoundException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testMissingVNFdata() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
+ String originatorID = UUID.randomUUID().toString();
+ String requestID = UUID.randomUUID().toString();
+ String subRequestID = UUID.randomUUID().toString();
+
+ RequestHandlerInput input = this.getRequestHandlerInput("3009", VNFOperation.Configure,0,false,originatorID, requestID, subRequestID,Instant.now());
+ PowerMockito.doThrow(new MissingVNFDataInAAIException("vnf-type")).when(requestValidator).validateRequest(Matchers.any(RuntimeContext.class));
+ RequestHandlerOutput output = requestHandler.handleRequest(input);
+ Assert.assertEquals(LCMCommandStatus.MISSING_VNF_DATA_IN_AAI.getResponseCode(), output.getResponseContext().getStatus().getCode());
+ }
+
+ @Test
+ public void testWorkflowNotFoundException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -224,7 +272,7 @@ public class TestRequestHandler {
}
@Test
- public void testInvalidInputException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testInvalidInputException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID1 = UUID.randomUUID().toString();
String requestID1 = UUID.randomUUID().toString();
String subRequestID1 = UUID.randomUUID().toString();
@@ -236,7 +284,7 @@ public class TestRequestHandler {
}
@Test
- public void testNoTransitionDefinedException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNoTransitionDefinedException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -249,7 +297,7 @@ public class TestRequestHandler {
}
@Test
- public void rejectInvalidRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void rejectInvalidRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -331,7 +379,6 @@ public class TestRequestHandler {
}
-
@Test
public void testOnRequestExecutionEndFailureForWorkingState() throws Exception {
logger.debug("=====================testOnRequestExecutionEndFailureForWorkingState=============================");
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
index 16caf5860..6d2b4a168 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
@@ -34,31 +34,17 @@ import java.util.Map;
import java.util.UUID;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.appc.domainmodel.lcm.ActionIdentifiers;
-import org.openecomp.appc.domainmodel.lcm.CommonHeader;
-import org.openecomp.appc.domainmodel.lcm.Flags;
-import org.openecomp.appc.domainmodel.lcm.RequestContext;
-import org.openecomp.appc.domainmodel.lcm.ResponseContext;
-import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
-import org.openecomp.appc.domainmodel.lcm.Status;
-import org.openecomp.appc.domainmodel.lcm.VNFContext;
-import org.openecomp.appc.domainmodel.lcm.VNFOperation;
+import org.openecomp.appc.domainmodel.lcm.*;
import org.openecomp.appc.executor.UnstableVNFException;
import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
-import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
-import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
-import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
-import org.openecomp.appc.requesthandler.exceptions.RequestExpiredException;
-import org.openecomp.appc.requesthandler.exceptions.VNFNotFoundException;
-import org.openecomp.appc.requesthandler.exceptions.WorkflowNotFoundException;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.impl.RequestHandlerImpl;
import org.openecomp.appc.requesthandler.impl.RequestValidatorImpl;
import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
@@ -84,7 +70,6 @@ import com.att.eelf.configuration.EELFManager;
@RunWith(PowerMockRunner.class)
@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class})
-@Ignore
public class TestRequestValidator {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestRequestHandler.class);
@@ -97,6 +82,7 @@ public class TestRequestValidator {
LifecycleManager lifecyclemanager;
WorkFlowManager workflowManager;
WorkingStateManager workingStateManager ;
+ LCMStateManager lcmStateManager;
// AppcDAOImpl dao ;
private final BundleContext bundleContext= Mockito.mock(BundleContext.class);
@@ -147,6 +133,7 @@ public class TestRequestValidator {
lifecyclemanager= Mockito.mock(LifecycleManager.class);
workflowManager= Mockito.mock(WorkFlowManager.class);
workingStateManager = Mockito.mock(WorkingStateManager.class);
+ lcmStateManager = Mockito.mock(LCMStateManager.class);
// transactionRecorder= spy(TransactionRecorder.class);
requestValidator = new RequestValidatorImpl();
@@ -154,8 +141,9 @@ public class TestRequestValidator {
requestValidator.setWorkflowManager(workflowManager);
requestValidator.setLifecyclemanager(lifecyclemanager);
requestValidator.setWorkingStateManager(workingStateManager);
+ requestValidator.setLcmStateManager(lcmStateManager);
-
+ Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(true);
/* Mockito.when(workingStateManager.isVNFStable("1")).thenReturn(true);
Mockito.when(aaiAdapter.requestGenericVnfData("1")).thenReturn(getGenericVnf("FIREWALL","INSTNATIATED"));*/
// Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(true);
@@ -254,7 +242,7 @@ public class TestRequestValidator {
return input;
}
@Test
- public void testNullVnfID() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNullVnfID() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullVnfID=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput(null, VNFOperation.Configure, 30,
@@ -309,8 +297,8 @@ public class TestRequestValidator {
- @Test
- public void testNullCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ @Test
+ public void testNullCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullCommand=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput("7", null,30,
@@ -327,7 +315,7 @@ public class TestRequestValidator {
}
@Test
- public void testNullVnfIDAndCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNullVnfIDAndCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullVnfIDAndCommand=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput(null, null,30,
@@ -545,45 +533,50 @@ public class TestRequestValidator {
}
@Test
- public void testLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Lock);
}
@Test
- public void testUnlockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testUnlockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Unlock);
}
@Test
- public void testCheckLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testCheckLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.CheckLock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Lock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Lock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testUnlockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testUnlockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Unlock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Unlock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testCheckLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testCheckLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.CheckLock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.CheckLock);
}
- private void testOperation(String resource, VNFOperation operation) throws WorkflowNotFoundException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, InvalidInputException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, RequestExpiredException {
+ @Test(expected = LCMOperationsDisabledException.class)
+ public void testLCMOperationsDisabled() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
+ Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(false);
+ testOperation("no-matter", VNFOperation.Configure);
+ }
+ private void testOperation(String resource, VNFOperation operation) throws WorkflowNotFoundException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, InvalidInputException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, RequestExpiredException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
index 2d75df419..0659d4dc5 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
@@ -77,27 +77,15 @@ org.openecomp.appc.db.pass.%s", schema), "");
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-REQ-HDLR-TEST
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-REQ-HDLR-TEST
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
+
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
mysqlIp=127.0.0.1
org.openecomp.appc.db.url.sdnctl=jdbc:mysql://${mysqlIp}:3306/test
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-features/src/main/resources/features.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-features/src/main/resources/features.xml
index cc8fe1192..f2e79ed43 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-features/src/main/resources/features.xml
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-features/src/main/resources/features.xml
@@ -27,10 +27,15 @@
<feature name='appc-request-handler' description="appc-request-handler" version='${project.version}'>
<bundle>mvn:org.openecomp.appc/transaction-recorder/${project.version}</bundle>
+
+ <!-- appc-data-access-lib bundle is flagged as being a dependency -->
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-data-access-lib/${project.version}</bundle>
+
<bundle dependency="true">mvn:org.openecomp.appc/domain-model-lib/${project.version}</bundle>
<bundle start-level="75" start="true">mvn:org.openecomp.appc/appc-command-executor-api/${project.version}</bundle>
<bundle start-level="80" start="true">mvn:org.openecomp.appc/appc-request-handler-api/${project.version}</bundle>
<bundle start-level="85" start="true">mvn:org.openecomp.appc/appc-request-handler-core/${project.version}</bundle>
+
</feature>
</features>
diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml
index 33c83974c..c3ced2131 100644
--- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml
+++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/pom.xml
@@ -52,6 +52,11 @@
<artifactId>appc-ranking-framework-lib</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -63,10 +68,14 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
- <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic,appc-data-access-lib,javax.json;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Dependency>javax.json;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Service>org.openecomp.appc.workflow.WorkFlowManager</Export-Service>
- <Import-Package>org.openecomp.appc.workflow,org.openecomp.appc.workflow.objects,!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package>
+ <Import-Package>
+ org.openecomp.appc.workflow,org.openecomp.appc.workflow.objects, org.openecomp.appc.configuration,
+ org.openecomp.appc.util,com.att.eelf.configuration, org.openecomp.appc.dao.util,
+ *;resolution:=optional
+ </Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/java/org/openecomp/appc/workflow/impl/WorkFlowManagerImpl.java b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/java/org/openecomp/appc/workflow/impl/WorkFlowManagerImpl.java
index 4ed575567..e40dc6254 100644
--- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/java/org/openecomp/appc/workflow/impl/WorkFlowManagerImpl.java
+++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/java/org/openecomp/appc/workflow/impl/WorkFlowManagerImpl.java
@@ -21,11 +21,6 @@
package org.openecomp.appc.workflow.impl;
-import java.text.SimpleDateFormat;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Properties;
-
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.appc.common.constant.Constants;
@@ -44,6 +39,11 @@ import com.att.eelf.configuration.EELFManager;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.provider.SvcLogicService;
+import java.text.SimpleDateFormat;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+
public class WorkFlowManagerImpl implements WorkFlowManager{
private SvcLogicService svcLogic = null;
@@ -166,7 +166,7 @@ public class WorkFlowManagerImpl implements WorkFlowManager{
workflowParams.put("input.common-header.api-ver",workflowRequest.getRequestContext().getCommonHeader().getApiVer());
workflowParams.put("input.common-header.request-id",workflowRequest.getRequestContext().getCommonHeader().getRequestId());
workflowParams.put("input.common-header.originator-id",workflowRequest.getRequestContext().getCommonHeader().getOriginatorId());
- workflowParams.put("input.common-header.sub-request-id",workflowRequest.getRequestContext().getCommonHeader().getSubRequestId());
+ workflowParams.put("input.common-header.sub-request-id",workflowRequest.getRequestContext().getCommonHeader().getSubRequestId()!=null ? workflowRequest.getRequestContext().getCommonHeader().getSubRequestId():"");
workflowParams.put("input.action",workflowRequest.getRequestContext().getAction().toString());
workflowParams.put("input.payload",null != workflowRequest.getRequestContext().getPayload() ? workflowRequest.getRequestContext().getPayload() : "");
workflowParams.put("input.action-identifiers.vnf-id",workflowRequest.getVnfContext().getId());
diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/resources/org/openecomp/appc/default.properties
index 44745d049..947e81ccd 100644
--- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/main/resources/org/openecomp/appc/default.properties
@@ -24,29 +24,17 @@
org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-WF-MGMT-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-WF-MGMT-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
# Tolerance interval (in seconds) between invalidation of DG resolver configuration
org.openecomp.appc.workflow.resolver.refresh_interval=300
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/test/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/test/resources/org/openecomp/appc/default.properties
index 713e03430..14200d668 100644
--- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/test/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-core/src/test/resources/org/openecomp/appc/default.properties
@@ -76,25 +76,12 @@ org.openecomp.appc.db.url.%s", schema), "");
org.openecomp.appc.db.user.%s", schema), "");
org.openecomp.appc.db.pass.%s", schema), "");
-# This value is provided in appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=2
-dmaap.threads.poolsize.max=2
+#Property below provided by appc.properties
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-WF-MGMT-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
diff --git a/appc-dispatcher/appc-workflow-management/appc-workflow-management-features/src/main/resources/features.xml b/appc-dispatcher/appc-workflow-management/appc-workflow-management-features/src/main/resources/features.xml
index ae1105d2b..dc50a4c6f 100644
--- a/appc-dispatcher/appc-workflow-management/appc-workflow-management-features/src/main/resources/features.xml
+++ b/appc-dispatcher/appc-workflow-management/appc-workflow-management-features/src/main/resources/features.xml
@@ -23,9 +23,11 @@
<features name="appc-workflow-management-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
-
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
<feature name='appc-workflow-management' description="application executor" version='${project.version}'>
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-data-access-lib/${project.version}</bundle>
+
<bundle>mvn:org.openecomp.appc/appc-workflow-management-api/${project.version}</bundle>
<bundle>mvn:org.openecomp.appc/appc-workflow-management-core/${project.version}</bundle>
<bundle start="true" dependency="true">mvn:org.openecomp.appc/appc-ranking-framework-lib/${project.version}</bundle>
diff --git a/appc-dispatcher/pom.xml b/appc-dispatcher/pom.xml
index 58bfd5bec..e54c5a744 100644
--- a/appc-dispatcher/pom.xml
+++ b/appc-dispatcher/pom.xml
@@ -55,7 +55,6 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>