From b1dd81ede363508f83c86ed497b8c0815045f8e5 Mon Sep 17 00:00:00 2001 From: Matej Perina Date: Wed, 3 Apr 2019 09:11:35 +0200 Subject: Proposal to remove OSGi dependencies from the CCSDK project Dependencies on the OSGi frameworks and libraries are removed by integrating the CCSDK project with the lighty.io. It's a toolkit that allows to use ODL services (in this case core services and the Restconf) without the dependency on the Karaf framework and the Blueprint DI. In this change are created the lighty.io modules which initialize and expose same services as the Blueprint DI in the blueprint.xml files. More info about the lighty.io - https://lighty.io Change-Id: Ia9eed2f60c71b7fc2e93b738c857d290b28e9420 Signed-off-by: Matej Perina Signed-off-by: Samuel Kontris --- resource-assignment/lighty/pom.xml | 58 ++++++++ .../adaptors/resource/lighty/ResourceModule.java | 152 +++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100755 resource-assignment/lighty/pom.xml create mode 100644 resource-assignment/lighty/src/main/java/org/onap/ccsdk/sli/adaptors/resource/lighty/ResourceModule.java (limited to 'resource-assignment/lighty') 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 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.adaptors + resource-assignment-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-adaptors :: resource-assignment :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.adaptors + resource-assignment-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + provided + + + 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; + } + +} -- cgit 1.2.3-korg