aboutsummaryrefslogtreecommitdiffstats
path: root/resource-assignment
diff options
context:
space:
mode:
Diffstat (limited to 'resource-assignment')
-rwxr-xr-xresource-assignment/lighty/pom.xml58
-rw-r--r--resource-assignment/lighty/src/main/java/org/onap/ccsdk/sli/adaptors/resource/lighty/ResourceModule.java152
-rwxr-xr-xresource-assignment/pom.xml1
3 files changed, 211 insertions, 0 deletions
diff --git a/resource-assignment/lighty/pom.xml b/resource-assignment/lighty/pom.xml
new file mode 100755
index 00000000..6807c225
--- /dev/null
+++ b/resource-assignment/lighty/pom.xml
@@ -0,0 +1,58 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>resource-assignment-lighty</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>ccsdk-sli-adaptors :: resource-assignment :: ${project.artifactId}</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>ccsdk-lighty-dependency-versions</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.lighty.core</groupId>
+ <artifactId>lighty-controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>resource-assignment-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/resource-assignment/lighty/src/main/java/org/onap/ccsdk/sli/adaptors/resource/lighty/ResourceModule.java b/resource-assignment/lighty/src/main/java/org/onap/ccsdk/sli/adaptors/resource/lighty/ResourceModule.java
new file mode 100644
index 00000000..b9090599
--- /dev/null
+++ b/resource-assignment/lighty/src/main/java/org/onap/ccsdk/sli/adaptors/resource/lighty/ResourceModule.java
@@ -0,0 +1,152 @@
+/*
+ * ============LICENSE_START==========================================
+ * Copyright (c) 2019 PANTHEON.tech s.r.o.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ */
+package org.onap.ccsdk.sli.adaptors.resource.lighty;
+
+import io.lighty.core.controller.api.AbstractLightyModule;
+import java.util.Collections;
+import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelperImpl;
+import org.onap.ccsdk.sli.adaptors.lock.dao.ResourceLockDaoImpl;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceLockNode;
+import org.onap.ccsdk.sli.adaptors.ra.alloc.DbAllocationRule;
+import org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocatorImpl;
+import org.onap.ccsdk.sli.adaptors.ra.rule.dao.RangeRuleDaoImpl;
+import org.onap.ccsdk.sli.adaptors.ra.rule.dao.ResourceRuleDaoImpl;
+import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManagerImpl;
+import org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.AllocationItemJdbcDaoImpl;
+import org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.ResourceDaoImpl;
+import org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.ResourceJdbcDaoImpl;
+import org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.ResourceLoadJdbcDaoImpl;
+import org.onap.ccsdk.sli.adaptors.util.db.CachedDataSourceWrap;
+import org.onap.ccsdk.sli.adaptors.util.db.DataSourceWrap;
+import org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+/**
+ * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from
+ * the resource-assignment-provider artifact.
+ */
+public class ResourceModule extends AbstractLightyModule {
+
+ private final DbLibService dbLibService;
+
+ private DataSourceWrap dataSourceWrap;
+ private CachedDataSourceWrap cachedDataSourceWrap;
+ private JdbcTemplate rmJdbcTemplate;
+ private JdbcTemplate lockJdbcTemplate;
+ private ResourceLockDaoImpl resourceLockDao;
+ private LockHelperImpl lockHelper;
+ private ResourceJdbcDaoImpl resourceJdbcDao;
+ private AllocationItemJdbcDaoImpl allocationItemJdbcDao;
+ private ResourceLoadJdbcDaoImpl resourceLoadJdbcDao;
+ private ResourceDaoImpl resourceDao;
+ private ResourceManagerImpl resourceManager;
+ private ResourceRuleDaoImpl resourceRuleDao;
+ private RangeRuleDaoImpl rangeRuleDao;
+ private ResourceAllocator resourceAllocator;
+ private ResourceLockNode resourceLockNode;
+ private SpeedUtil speedUtil;
+ private EndPointAllocatorImpl endPointAllocator;
+ private DbAllocationRule dbAllocationRule;
+
+ public ResourceModule(final DbLibService dbLibService) {
+ this.dbLibService = dbLibService;
+ }
+
+ @Override
+ protected boolean initProcedure() {
+ this.dataSourceWrap = new DataSourceWrap();
+ this.dataSourceWrap.setDataSource(dbLibService);
+
+ this.cachedDataSourceWrap = new CachedDataSourceWrap();
+ this.cachedDataSourceWrap.setDataSource(dataSourceWrap);
+
+ this.rmJdbcTemplate = new JdbcTemplate();
+ this.rmJdbcTemplate.setDataSource(dataSourceWrap);
+
+ this.lockJdbcTemplate = new JdbcTemplate();
+ this.lockJdbcTemplate.setDataSource(cachedDataSourceWrap);
+
+ this.resourceLockDao = new ResourceLockDaoImpl();
+ this.resourceLockDao.setJdbcTemplate(lockJdbcTemplate);
+
+ this.lockHelper = new LockHelperImpl();
+ this.lockHelper.setResourceLockDao(resourceLockDao);
+ this.lockHelper.setRetryCount(10);
+ this.lockHelper.setLockWait(5);
+
+ this.resourceJdbcDao = new ResourceJdbcDaoImpl();
+ this.resourceJdbcDao.setJdbcTemplate(rmJdbcTemplate);
+
+ this.allocationItemJdbcDao = new AllocationItemJdbcDaoImpl();
+ this.allocationItemJdbcDao.setJdbcTemplate(rmJdbcTemplate);
+
+ this.resourceLoadJdbcDao = new ResourceLoadJdbcDaoImpl();
+ this.resourceLoadJdbcDao.setJdbcTemplate(rmJdbcTemplate);
+
+ this.resourceDao = new ResourceDaoImpl();
+ this.resourceDao.setResourceJdbcDao(resourceJdbcDao);
+ this.resourceDao.setAllocationItemJdbcDao(allocationItemJdbcDao);
+ this.resourceDao.setResourceLoadJdbcDao(resourceLoadJdbcDao);
+
+ this.resourceManager = new ResourceManagerImpl();
+ this.resourceManager.setLockHelper(lockHelper);
+ this.resourceManager.setResourceDao(resourceDao);
+ this.resourceManager.setLockTimeout(600);
+
+ this.resourceRuleDao = new ResourceRuleDaoImpl();
+ this.resourceRuleDao.setJdbcTemplate(rmJdbcTemplate);
+
+ this.rangeRuleDao = new RangeRuleDaoImpl();
+ this.rangeRuleDao.setJdbcTemplate(rmJdbcTemplate);
+
+ this.resourceLockNode = new ResourceLockNode();
+ this.resourceLockNode.setLockHelper(lockHelper);
+
+ this.speedUtil = new SpeedUtil();
+
+ this.dbAllocationRule = new DbAllocationRule();
+ this.dbAllocationRule.setResourceRuleDao(resourceRuleDao);
+ this.dbAllocationRule.setRangeRuleDao(rangeRuleDao);
+
+ this.endPointAllocator = new EndPointAllocatorImpl();
+ this.endPointAllocator.setResourceManager(resourceManager);
+ this.endPointAllocator.setAllocationRuleMap(
+ Collections.singletonMap("DEFAULT", Collections.singletonList(dbAllocationRule)));
+
+ this.resourceAllocator = new ResourceAllocator();
+ this.resourceAllocator.setResourceManager(resourceManager);
+ this.resourceAllocator.setEndPointAllocator(endPointAllocator);
+ this.resourceAllocator.setSpeedUtil(speedUtil);
+ return true;
+ }
+
+ @Override
+ protected boolean stopProcedure() {
+ return true;
+ }
+
+ public ResourceAllocator getResourceAllocator() {
+ return resourceAllocator;
+ }
+
+ public ResourceLockNode getResourceLockNode() {
+ return resourceLockNode;
+ }
+
+}
diff --git a/resource-assignment/pom.xml b/resource-assignment/pom.xml
index b17b31aa..4aa99ad7 100755
--- a/resource-assignment/pom.xml
+++ b/resource-assignment/pom.xml
@@ -21,6 +21,7 @@
<module>provider</module>
<module>features</module>
<module>installer</module>
+ <module>lighty</module>
</modules>