Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
04cbb1e
Update router manager api
DavidLiu506 Jun 29, 2021
4c100e5
Update code
DavidLiu506 Jun 29, 2021
e38bcf9
Update code
DavidLiu506 Jun 30, 2021
067a988
Update router manager
DavidLiu506 Jul 1, 2021
dd5dafd
Update router manager
DavidLiu506 Jul 1, 2021
aa76562
Merge router manager service api code
DavidLiu506 Jul 2, 2021
8ae37db
Fix getVpcRouteTables
DavidLiu506 Jul 2, 2021
f0462ae
Fix getVpcRouteTable
DavidLiu506 Jul 2, 2021
976883f
Update RouterController
DavidLiu506 Jul 6, 2021
ef7a2d2
Update code
DavidLiu506 Jul 6, 2021
670dcc6
Update code
DavidLiu506 Jun 29, 2021
59a65f0
Update code
DavidLiu506 Jun 30, 2021
1178f61
pull alcor code
DavidLiu506 Jul 9, 2021
5a98d10
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Jul 21, 2021
e4e0792
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Aug 13, 2021
ae15be0
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Aug 15, 2021
9c88b19
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Aug 21, 2021
9be2bb9
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Sep 13, 2021
733872a
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Oct 19, 2021
b3154ae
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Oct 21, 2021
e2bed17
Merge branch 'master' of https://github.com/DavidLiu506/alcor
DavidLiu506 Oct 21, 2021
7c5013e
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Oct 23, 2021
ac7acf8
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Oct 28, 2021
bcc0716
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Nov 3, 2021
c499d9c
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Nov 30, 2021
329e216
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Dec 9, 2021
43435bd
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Dec 11, 2021
9b51767
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Dec 13, 2021
2f68edb
Merge branch 'futurewei-cloud:master' into master
DavidLiu506 Dec 13, 2021
a6b1122
Merge branch 'master' of https://github.com/DavidLiu506/alcor
DavidLiu506 Dec 13, 2021
968fe2f
Add GoalStateV1 to port manager
DavidLiu506 Dec 14, 2021
b69e0a6
Add GoalStateV1 to port manager
DavidLiu506 Dec 14, 2021
89788dc
Update code
DavidLiu506 Dec 15, 2021
92b557b
Update code
DavidLiu506 Dec 15, 2021
6a74de1
Update code
DavidLiu506 Dec 15, 2021
29ba3ee
Update code
DavidLiu506 Dec 15, 2021
dfd2f28
Update code
DavidLiu506 Dec 15, 2021
d039e7d
Update code
DavidLiu506 Dec 15, 2021
2f998a2
Update code
DavidLiu506 Dec 15, 2021
a5e414d
Update code
DavidLiu506 Dec 15, 2021
51eaa3c
Update code
DavidLiu506 Dec 15, 2021
d8f3a71
Update code
DavidLiu506 Dec 15, 2021
d2f1b03
Update code
DavidLiu506 Dec 17, 2021
8cf31b3
Update code
DavidLiu506 Dec 17, 2021
cd89cc3
Update code
DavidLiu506 Dec 17, 2021
f55e0fe
Update code
DavidLiu506 Dec 17, 2021
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
2 changes: 1 addition & 1 deletion kubernetes/services/dpm_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data:

#logging.file.path=./
#logging.file.name=data-plane-manager.log
logging.level.root=DEBUG
logging.level.root=INFO

ignite.host=ignite-alcor-service.ignite-alcor.svc.cluster.local
ignite.port=10800
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/services/network_config_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data:
#ignite.key-store-password=123456
#ignite.trust-store-path=truststore.jks
#ignite.trust-store-password=123456
logging.level.root=DEBUG
logging.level.root=INFO
spring.servlet.multipart.enabled=true
spring.servlet.multipart.file-size-threshold=2KB
spring.servlet.multipart.max-file-size=200MB
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/services/port_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ data:
ignite.port=10802
server.max-http-header-size=16384
server.max-initial-line-length=65536
logging.level.root=DEBUG
protobuf.goal-state-message.version = 102
logging.level.root=INFO
microservices.vpc.service.url=http://vpcmanager-service.default.svc.cluster.local:9001
microservices.subnet.service.url=http://subnetmanager-service.default.svc.cluster.local:9002
microservices.ip.service.url=http://ipmanager-service.default.svc.cluster.local:9004/ips
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/services/private_ip_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data:
ignite.thin.client.enable=true
ignite.host=ignite-alcor-ip-service.ignite-alcor-ip.svc.cluster.local
ignite.port=10801
logging.level.root=DEBUG
logging.level.root=INFO

opentracing.jaeger.udp-sender.host=localhost
opentracing.jaeger.udp-sender.port=6831
Expand Down
1 change: 1 addition & 0 deletions kubernetes/services/route_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data:
microservices.subnet.service.url=http://subnetmanager-service.default.svc.cluster.local:9002
microservices.dpm.service.url=http://dataplanemanager-service.default.svc.cluster.local:9010
microservices.port.service.url=http://portmanager-service.default.svc.cluster.local:9006
protobuf.goal-state-message.version = 102
ignite.thin.client.enable=true
ignite.host=ignite-alcor-service.ignite-alcor.svc.cluster.local
ignite.port=10800
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ public class LocalCacheImpl implements LocalCache {
@Autowired
private SubnetPortsCache subnetPortsCache;

@Autowired
private PortHostInfoCache portHostInfoCache;

@Autowired
private NodeInfoCache nodeInfoCache;

@Override
public void setSubnetPorts(NetworkConfiguration networkConfig) throws Exception {

List<InternalPortEntity> portEntities = networkConfig.getPortEntities();
if (portEntities == null) {
return;
Expand All @@ -74,7 +70,6 @@ public void setSubnetPorts(NetworkConfiguration networkConfig) throws Exception
portHostInfo.setPortId(portEntity.getId());
portHostInfo.setHostIp(portEntity.getBindingHostIP());
portHostInfo.setHostId(portEntity.getBindingHostId());
portHostInfo.setSubnetId(subnetId);

InternalSubnetPorts subnetPorts = subnetPortsMap.get(subnetId);
if (subnetPorts == null) {
Expand All @@ -90,6 +85,7 @@ public void setSubnetPorts(NetworkConfiguration networkConfig) throws Exception
subnetPorts.setVpcId(subnetEntity.getVpcId());
subnetPorts.setTunnelId(subnetEntity.getTunnelId());
subnetPorts.setDhcpEnable(subnetEntity.getDhcpEnable());
subnetPorts.setPorts(new ArrayList<>());

List<InternalRouterInfo> routers = networkConfig.getInternalRouterInfos();
if (routers != null && routers.size() > 0) {
Expand All @@ -110,13 +106,14 @@ public void setSubnetPorts(NetworkConfiguration networkConfig) throws Exception

subnetPortsMap.put(subnetId, subnetPorts);
}

subnetPorts.getPorts().add(portHostInfo);
}
}

for (Map.Entry<String, InternalSubnetPorts> entry: subnetPortsMap.entrySet()) {
subnetPortsCache.updateSubnetPorts(entry.getValue());
}

}

private InternalSubnetEntity getSubnetEntity(NetworkConfiguration networkConfig, String subnetId) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ free of charge, to any person obtaining a copy of this software and associated d
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Expand All @@ -18,34 +18,22 @@ free of charge, to any person obtaining a copy of this software and associated d
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.stats.DurationStatistics;
import com.futurewei.alcor.dataplane.entity.InternalSubnetRouterMap;
import com.futurewei.alcor.dataplane.entity.InternalSubnets;
import com.futurewei.alcor.schema.Subnet;
import com.futurewei.alcor.web.entity.dataplane.InternalSubnetEntity;
import com.futurewei.alcor.web.entity.dataplane.v2.NetworkConfiguration;
import com.futurewei.alcor.web.entity.port.PortHostInfo;
import com.futurewei.alcor.web.entity.subnet.InternalSubnetPorts;
import com.futurewei.alcor.web.entity.subnet.SubnetEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Repository;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.Map;

@Repository
@ComponentScan(value="com.futurewei.alcor.common.db")
public class SubnetPortsCache {
// The cache is a map(subnetId, subnetPorts)
private ICache<String, InternalSubnetPorts> subnetPortsCache;
private CacheFactory cacheFactory;

@Autowired
public SubnetPortsCache(CacheFactory cacheFactory) {
this.cacheFactory = cacheFactory;
subnetPortsCache = cacheFactory.getCache(InternalSubnetPorts.class);
}

Expand All @@ -54,16 +42,6 @@ public InternalSubnetPorts getSubnetPorts(String subnetId) throws CacheException
return subnetPortsCache.get(subnetId);
}

@DurationStatistics
public Map<String, InternalSubnetPorts> getSubnetPortsByRouterId(String routerId) throws CacheException {
Map<String, Object[]> queryParams = new HashMap<>();
Object[] values = new Object[1];
values[0] = routerId;
queryParams.put("routerId", values);
// Use sql index
return subnetPortsCache.getAll(queryParams);
}

@DurationStatistics
public Map<String, InternalSubnetPorts> getAllSubnetPorts() throws CacheException {
return subnetPortsCache.getAll();
Expand All @@ -79,74 +57,6 @@ public synchronized void addSubnetPorts(InternalSubnetPorts internalSubnetPorts)
subnetPortsCache.put(internalSubnetPorts.getSubnetId(), internalSubnetPorts);
}

@DurationStatistics
public Map<String, String> getInternalSubnetRouterMap(NetworkConfiguration networkConfig) {
if (networkConfig.getInternalRouterInfos() != null) {
Map<String, String> internalSubnetsRouterMap = networkConfig
.getInternalRouterInfos()
.stream()
.filter(routerInfo -> routerInfo.getRouterConfiguration().getSubnetRoutingTables().size() > 0)
.flatMap(routerInfo -> routerInfo.getRouterConfiguration().getSubnetRoutingTables()
.stream()
.map(routingTable -> new InternalSubnetRouterMap(routerInfo.getRouterConfiguration().getId()
, routingTable.getSubnetId())))
.distinct()
.collect(Collectors.toMap(routerInfo -> routerInfo.getSubnetId(), routerInfo -> routerInfo.getRouterId()));
return internalSubnetsRouterMap;
}
return new HashMap<>();
}

@DurationStatistics
public Map<String, InternalSubnetPorts> attacheRouter(Map<String, String> subnetIdRouterIdMap) throws CacheException {
Map<String, InternalSubnetPorts> internalSubnetEntityMap = new TreeMap<>();
for (Map.Entry<String, String> subnetIdRouterId : subnetIdRouterIdMap.entrySet()) {
InternalSubnetPorts internalSubnetPorts = null;
try {
if (subnetPortsCache.containsKey(subnetIdRouterId.getKey())) {
internalSubnetPorts = subnetPortsCache.get(subnetIdRouterId.getKey());
internalSubnetPorts.setRouterId(subnetIdRouterId.getValue());
internalSubnetEntityMap.put(subnetIdRouterId.getKey(), internalSubnetPorts);
}
} catch (CacheException e) {
e.printStackTrace();
}
}

subnetPortsCache.putAll(internalSubnetEntityMap);
return internalSubnetEntityMap;
}


@DurationStatistics
public Map<String, InternalSubnetPorts> getSubnetPorts(NetworkConfiguration networkConfig) throws CacheException {
Map<String, String> internalSubnetsRouterMap = getInternalSubnetRouterMap(networkConfig);
Map<String, InternalSubnetPorts> internalSubnetPortsMap = new TreeMap<>();
for (InternalSubnetEntity subnetEntity : networkConfig.getSubnets()) {
internalSubnetPortsMap.put(subnetEntity.getId(), getInternalSubnetPorts(subnetEntity, internalSubnetsRouterMap.getOrDefault(subnetEntity.getId(), null)));
}
return internalSubnetPortsMap;
}

private InternalSubnetPorts getInternalSubnetPorts(InternalSubnetEntity subnetEntity, String routerId) {
InternalSubnetPorts internalSubnetPorts = new InternalSubnetPorts(subnetEntity.getId()
,subnetEntity.getGatewayPortDetail().getGatewayPortId()
,subnetEntity.getGatewayIp()
,subnetEntity.getGatewayPortDetail().getGatewayMacAddress()
,subnetEntity.getName()
,subnetEntity.getCidr()
,subnetEntity.getVpcId()
,subnetEntity.getTunnelId()
,subnetEntity.getDhcpEnable()
,routerId);
return internalSubnetPorts;
}

@DurationStatistics
public void updateSubnetPorts(Map<String, InternalSubnetPorts> internalSubnetPortsMap) throws Exception {
subnetPortsCache.putAll(internalSubnetPortsMap);
}

@DurationStatistics
public void updateSubnetPorts(InternalSubnetPorts internalSubnetPorts) throws Exception {
subnetPortsCache.put(internalSubnetPorts.getSubnetId(), internalSubnetPorts);
Expand All @@ -157,8 +67,4 @@ public void deleteSubnetPorts(String subnetId) throws Exception {
subnetPortsCache.remove(subnetId);
}

public Transaction getTransaction() {
return subnetPortsCache.getTransaction();
}

}
Loading