Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Node Manager - Meta data management #185

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
d933b0d
[Microservices] Mac address manager
kimeunju108 Apr 6, 2020
f6316b4
[Microservices] Mac address manager - APIs create, get, delete
kimeunju108 Apr 6, 2020
e4b5604
[Microservices] Mac manager - update pom file and lib files
kimeunju108 Apr 7, 2020
336e499
[Microservies] Macmanager document update
kimeunju108 Apr 8, 2020
969841b
Revert "[Microservies] Macmanager document update"
kimeunju108 Apr 8, 2020
55d9c59
update macmanager design such as api and data structure
kimeunju108 Apr 9, 2020
677cf6e
Add design sketch for new requirements
kimeunju108 Apr 9, 2020
449d6e6
Update mac manager design doc
Apr 9, 2020
5886a77
[Microservices] Mac manager - updated unit test cases
kimeunju108 Apr 10, 2020
feb5a20
[Microservices] Mac manager - updated unit test cases
kimeunju108 Apr 10, 2020
c5dd021
Merge branch 'eunju/macmanager' of https://github.com/kimeunju108/alc…
kimeunju108 Apr 10, 2020
391ba83
Merge from featurewei/alcor master and resolve conflicts on macmanage…
Apr 10, 2020
62957d3
[Microservices] Mac manager - updated pictures and unit test cases
kimeunju108 Apr 11, 2020
935e57f
[Microservices] Mac manager - added mac range and mac address pool
kimeunju108 Apr 13, 2020
4d1f37a
Merge branch 'eunju/macmanager' of https://github.com/kimeunju108/alc…
kimeunju108 Apr 13, 2020
ca953ae
Merge branch 'master' into eunju/macmanager
Apr 14, 2020
00e766c
[Microservices] Mac manager - added macmanager service interface and …
kimeunju108 Apr 14, 2020
3f44896
Merge branch 'eunju/macmanager' of https://github.com/kimeunju108/alc…
kimeunju108 Apr 14, 2020
33466fb
[Microservices] Mac manager - add MAC range APIs and MAC allocation a…
kimeunju108 Apr 14, 2020
a86d141
Merge pull request #1 from kimeunju108/eunju/macmanager
kimeunju108 Apr 14, 2020
6f05522
[Microservices] Macmanager - combined activate/deactivate APIs to upd…
kimeunju108 Apr 15, 2020
0d23506
Fix broken maven CI workflow
Apr 15, 2020
7ca5df6
[Microservices] MAC manager - update a pom file
kimeunju108 Apr 15, 2020
2137d4c
Merge branch 'eunju/macmanager' of https://github.com/kimeunju108/alc…
kimeunju108 Apr 15, 2020
42e4ca5
[Microservices] MAC manager - added concurrent handling and comparing…
kimeunju108 Apr 17, 2020
e30c48c
[Microservices] MAC manager - added two sections: concurrent handling…
kimeunju108 Apr 17, 2020
0b852b2
[Microservices] MAC manager - updated delete API response
kimeunju108 Apr 18, 2020
3c223d9
[Microservices] MAC manager - updated activate/deactivate APIs response
kimeunju108 Apr 18, 2020
6ac310e
[Microservices] MAC manager - updated activate/deactivate APIs response
kimeunju108 Apr 18, 2020
3d3a0f4
[Microservices] MAC manager - tested APIs and matched output formaat …
kimeunju108 Apr 18, 2020
f78c95e
[Microservices] MAC manager - tested APIs and matched I/O data format…
kimeunju108 Apr 18, 2020
e44d501
[Microservices] MAC manager - tested APIs and matched I/O data format…
kimeunju108 Apr 18, 2020
d1fc282
[Microservices] MAC manager - tested and verified the design document…
kimeunju108 Apr 18, 2020
1dc52ed
[Microservices] MAC manager - tested and verified the design document…
kimeunju108 Apr 18, 2020
d0745e7
Merge branch 'eunju/macmanager', remote-tracking branch 'origin'
kimeunju108 Apr 18, 2020
44aef16
Merge remote-tracking branch 'origin' into eunju/macmanager
kimeunju108 Apr 18, 2020
325720f
Merge branch 'master' into eunju/macmanager
kimeunju108 Apr 18, 2020
d23fd98
Merge pull request #2 from kimeunju108/eunju/macmanager
kimeunju108 Apr 18, 2020
a11ec2e
[Microservices] MAC manager - resolved github conflict
kimeunju108 Apr 18, 2020
3b7355d
Merge pull request #3 from kimeunju108/eunju/macmanager
kimeunju108 Apr 18, 2020
2d0b7a9
[Microservices] MAC manager - fixed 2 pictures
kimeunju108 Apr 19, 2020
5d4f0b8
Merge pull request #4 from kimeunju108/eunju/macmanager
kimeunju108 Apr 19, 2020
a94f372
[Microservices] MAC manager - add concurrent mac creation function
kimeunju108 Apr 20, 2020
b81ade7
[Microservices] MAC manager - reviewed and corrected the design document
kimeunju108 Apr 20, 2020
59f8837
Merge pull request #5 from kimeunju108/eunju/macmanager
kimeunju108 Apr 20, 2020
a2c0c5b
[Microservices] MAC manager - synchronized redis transaction methods
kimeunju108 Apr 22, 2020
6471dbc
Merge branch 'master' of https://github.com/futurewei-cloud/alcor int…
kimeunju108 Apr 22, 2020
9a3217a
Merge pull request #6 from kimeunju108/eunju/macmanager
kimeunju108 Apr 22, 2020
3addc2e
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kimeunju108 Apr 22, 2020
485ff9e
Merge pull request #7 from kimeunju108/eunju/macmanager
kimeunju108 Apr 22, 2020
d647d13
[Microservices] Node manager - add controller, service, dao, entity, …
kimeunju108 Apr 27, 2020
2200f24
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kimeunju108 Apr 27, 2020
27f8d72
Merge branch 'master' into eunju/nodemanager
kimeunju108 Apr 27, 2020
a88e4fa
Merge pull request #8 from kimeunju108/eunju/nodemanager
kimeunju108 Apr 27, 2020
ec24cf4
Microservices] Node Manager - implemented UT and tested APIs.
kimeunju108 Apr 28, 2020
60334f2
Merge branch 'eunju/nodemanager' of https://github.com/kimeunju108/al…
kimeunju108 Apr 28, 2020
7aef537
Merge pull request #9 from kimeunju108/eunju/nodemanager
kimeunju108 Apr 28, 2020
4fbcbaf
[Microservices Node Manager - Add exception handlings
kimeunju108 Apr 29, 2020
a07e2fd
Merge pull request #10 from kimeunju108/eunju/nodemanager
kimeunju108 Apr 29, 2020
cc26ef8
[Microservices] Node Manager Part 1 - Implemented and Tested
kimeunju108 Apr 30, 2020
0e72fd3
Merge pull request #11 from kimeunju108/eunju/nodemanager
kimeunju108 Apr 30, 2020
dcd9647
Microservices] new pull from upstream
kimeunju108 May 5, 2020
03ed86c
fix pom merge conflict
May 5, 2020
b5dd1ef
[Microservices] Node manager - (1) added API that read machine config…
kimeunju108 May 7, 2020
143185b
Merge pull request #12 from kimeunju108/eunju/nodemanager
kimeunju108 May 7, 2020
26ee027
[Microservices] Node manager - (1) added API that read machine config…
kimeunju108 May 7, 2020
dc85ee5
[Microservices] Node manager - removed
kimeunju108 May 7, 2020
68b6e01
[Microservices] Node manager - removed
kimeunju108 May 7, 2020
ce83658
[Microservices] Node manager - removed
kimeunju108 May 7, 2020
53b4f7a
[Microservices] changed pom file
kimeunju108 May 7, 2020
d6cd345
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kimeunju108 May 7, 2020
e7cb5d5
Merge branch 'eunju/nodemanager'
kimeunju108 May 7, 2020
18287ea
[Microservices] Node manager - (1) added API that read machine config…
kimeunju108 May 7, 2020
ae74048
[Micro-service] Node manager
kimeunju108 May 7, 2020
62c5e33
[Micro services] Node manager - implemented meta data management
kimeunju108 May 7, 2020
29706bb
[Micro services] Node manager - added an APIto upload node file (e.g.…
kimeunju108 May 8, 2020
0450f6a
[Micro services] Node manager - added an API to upload node file (e.g…
kimeunju108 May 8, 2020
f8c8f57
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kimeunju108 May 8, 2020
2cb920f
Merge branch 'eunju/nodemanager'
kimeunju108 May 8, 2020
43a8e7d
[Micro service] MACmanager - added allocation tracking function, test…
kimeunju108 May 8, 2020
9e2b3c6
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
kimeunju108 May 8, 2020
3510072
Merge branch 'eunju/macmanager'
kimeunju108 May 8, 2020
3fdf37f
Merge branch 'master' of https://github.com/kimeunju108/alcor
kimeunju108 May 8, 2020
dfc0611
test
kimeunju108 May 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@

package com.futurewei.alcor.controller.resourcemgr.physical.nodemgmt;

<<<<<<< HEAD:legacy/src/com/futurewei/alcor/controller/resourcemgr/physical/nodemgmt/DataCenterConfigLoader.java
xieus marked this conversation as resolved.
Show resolved Hide resolved
import com.futurewei.alcor.controller.logging.Logger;
import com.futurewei.alcor.controller.logging.LoggerFactory;
import com.futurewei.alcor.controller.model.HostInfo;
import com.futurewei.alcor.controller.utilities.Common;
=======
import com.futurewei.alcor.nodemanager.entity.NodeInfo;
>>>>>>> [Microservices] Node manager - (1) added API that read machine config file, (2) removed memory repository part:services/node_manager/src/main/java/com/futurewei/alcor/nodemanager/service/implement/DataCenterConfigLoader.java
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
<<<<<<< HEAD:legacy/src/com/futurewei/alcor/controller/resourcemgr/physical/nodemgmt/DataCenterConfigLoader.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ResourceLoader;
=======
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
>>>>>>> [Microservices] Node manager - (1) added API that read machine config file, (2) removed memory repository part:services/node_manager/src/main/java/com/futurewei/alcor/nodemanager/service/implement/DataCenterConfigLoader.java

import java.io.FileNotFoundException;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface ICacheRepository<T> {

Map<String, T> findAllItems() throws CacheException;

void addItem(T newItem) throws CacheException;
void addItem(T newItem) throws Exception;
xieus marked this conversation as resolved.
Show resolved Hide resolved

void deleteItem(String id) throws CacheException;
void deleteItem(String id) throws Exception;
}
64 changes: 64 additions & 0 deletions machine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"Hosts": [
xieus marked this conversation as resolved.
Show resolved Hide resolved
{
"id": "ephost_0",
"ip": "172.17.0.6",
"mac": "02:42:ac:11:00:06",
"veth": {}
},
{
"id": "ephost_1",
"ip": "172.17.0.7",
"mac": "02:42:ac:11:00:07",
"veth": {}
},
{
"id": "ephost_2",
"ip": "172.17.0.8",
"mac": "02:42:ac:11:00:08",
"veth": {}
},
{
"id": "ephost_3",
"ip": "172.17.0.9",
"mac": "02:42:ac:11:00:09",
"veth": {}
},
{
"id": "ephost_4",
"ip": "172.17.0.10",
"mac": "02:42:ac:11:00:0a",
"veth": {}
},
{
"id": "ephost_5",
"ip": "172.17.0.11",
"mac": "02:42:ac:11:00:0b",
"veth": {}
},
{
"id": "ephost_6",
"ip": "172.17.0.12",
"mac": "02:42:ac:11:00:0c",
"veth": {}
},
{
"id": "ephost_7",
"ip": "172.17.0.13",
"mac": "02:42:ac:11:00:0d",
"veth": {}
},
{
"id": "ephost_8",
"ip": "172.17.0.14",
"mac": "02:42:ac:11:00:0e",
"veth": {}
},
{
"id": "ephost_9",
"ip": "172.17.0.15",
"mac": "02:42:ac:11:00:0f",
"veth": {}
}
]
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<module>services/route_manager</module>
<module>services/mac_manager</module>
<module>services/private_ip_manager</module>
<module>services/node_manager</module>
</modules>
<packaging>pom</packaging>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*Copyright 2019 The Alcor Authors.

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.
*/
package com.futurewei.alcor.macmanager.dao;

import com.futurewei.alcor.common.db.CacheException;
import com.futurewei.alcor.common.db.CacheFactory;
import com.futurewei.alcor.common.db.ICache;
import com.futurewei.alcor.common.db.Transaction;
import com.futurewei.alcor.common.exception.ResourceNotFoundException;
import com.futurewei.alcor.common.repo.ICacheRepository;
import com.futurewei.alcor.macmanager.entity.MacAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ThreadLocalRandom;

@Repository
@ComponentScan(value = "com.futurewei.alcor.common.db")
public class MacPoolRepository implements ICacheRepository<MacAddress> {
private ICache<String, MacAddress> cache;

@Autowired
public MacPoolRepository(CacheFactory cacheFactory) {
cache = cacheFactory.getCache(MacAddress.class);
}

public ICache<String, MacAddress> getCache() {
return cache;
}

@PostConstruct
private void init() {

}

@Override
public MacAddress findItem(String strMacAddress) throws CacheException, ResourceNotFoundException {
if (cache.containsKey(strMacAddress))
return cache.get(strMacAddress);
else
return null;
}

@Override
public Map<String, MacAddress> findAllItems() throws CacheException {
return cache.getAll();
}

/**
kimeunju108 marked this conversation as resolved.
Show resolved Hide resolved
* add a MAC address to MAC pool repository
*
* @param macAddress MAC address
* @return void
* @throws Exception Db or cache operation exception
*/
@Override
public void addItem(MacAddress macAddress) throws Exception {
if (cache.containsKey(macAddress.getMacAddress()) == false) {
try (Transaction tx = cache.getTransaction().start()) {
cache.put(macAddress.getMacAddress(), macAddress);
tx.commit();
} catch (CacheException e) {
throw e;
} catch(Exception e1)
{

}
}
}

/**
* delete a MAC address from MAC pool repository
*
* @param strMacAddress MAC address
* @return void
* @throws Exception Db or cache operation exception
*/
@Override
public void deleteItem(String strMacAddress) throws Exception {
try (Transaction tx = cache.getTransaction().start()) {
cache.remove(strMacAddress);
tx.commit();
} catch (CacheException e) {
throw e;
}
}

public synchronized String getItem() throws CacheException {
String strMacAddress;
try {
long randomIndex = ThreadLocalRandom.current().nextLong(0, getSize());
Vector<String> sa = new Vector(Arrays.asList(cache.getAll().keySet().toArray()));
strMacAddress = sa.elementAt((int) randomIndex);
} catch (Exception e) {
throw e;
}
return strMacAddress;
}

public synchronized long getSize() throws CacheException {
int nSize = 0;
try {
nSize = cache.getAll().size();
} catch (Exception e) {
throw e;
}
return nSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.futurewei.alcor.common.db.CacheException;
import com.futurewei.alcor.common.db.CacheFactory;
import com.futurewei.alcor.common.db.ICache;
import com.futurewei.alcor.common.db.Transaction;
import com.futurewei.alcor.common.repo.ICacheRepository;
import com.futurewei.alcor.macmanager.entity.MacRange;
import com.futurewei.alcor.macmanager.entity.MacState;
Expand Down Expand Up @@ -75,22 +76,38 @@ public Map<String, MacRange> findAllItems() throws CacheException {
return hashMap;
}

/**
* add a MAC range to MAC range repository
*
* @param macRange MAC range
* @return void
* @throws Exception Db or cache operation exception
*/
@Override
public void addItem(MacRange macRange) throws CacheException {
try {
public void addItem(MacRange macRange) throws Exception {
xieus marked this conversation as resolved.
Show resolved Hide resolved
try (Transaction tx = cache.getTransaction().start()) {
cache.put(macRange.getRangeId(), macRange);
logger.info("MacRangeRepository addItem() {}: ", macRange.getRangeId());
tx.commit();
} catch (CacheException e) {
logger.error("MacRangeRepository addItem() exception:", e);
throw e;
}
}

/**
* delete a MAC range from MAC range repository
*
* @param rangeId MAC range identifier
* @return void
* @throws Exception Db or cache operation exception
*/
@Override
public void deleteItem(String rangeId) throws CacheException {
try {
public void deleteItem(String rangeId) throws CacheException, Exception {
try (Transaction tx = cache.getTransaction().start()) {
cache.remove(rangeId);
logger.info("MacRangeRepository deleteItem() {}: ", rangeId);
tx.commit();
} catch (CacheException e) {
logger.error("MacRangeRepository deleteItem() exception:", e);
throw e;
Expand Down
Loading