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
27 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
8d75601
Update code
DavidLiu506 Nov 1, 2021
b83aef6
Update code
DavidLiu506 Nov 2, 2021
24e6641
Update code
DavidLiu506 Nov 3, 2021
06072ca
Update code
DavidLiu506 Nov 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,30 @@ private IpAddrAlloc doAllocateIpAddr(String vpcId, int ipVersion, String ipAddr)
if (ipAddrAlloc != null) {
break;
}

IpAddrRange ipAddrRange = ipAddrRangeCache.get(rangeId);
if (ipAddrRange == null) {
throw new IpRangeNotFoundException();
}

if (ipAddrRange.getIpVersion() != ipVersion) {
continue;
synchronized (this) {
try (Transaction tx = ipAddrRangeCache.getTransaction().start()) {
IpAddrRange ipAddrRange = ipAddrRangeCache.get(rangeId);
if (ipAddrRange == null) {
throw new IpRangeNotFoundException();
}

if (ipAddrRange.getIpVersion() != ipVersion) {
continue;
}

try {
ipAddrAlloc = ipAddrRange.allocate(ipAddr);
} catch (Exception e) {
LOG.warn("Allocate ip address from {} failed", ipAddrRange.getId());
continue;
}

ipAddrRangeCache.put(ipAddrRange.getId(), ipAddrRange);
tx.commit();
}
}

try {
ipAddrAlloc = ipAddrRange.allocate(ipAddr);
} catch (Exception e) {
LOG.warn("Allocate ip address from {} failed", ipAddrRange.getId());
continue;
}

ipAddrRangeCache.put(ipAddrRange.getId(), ipAddrRange);
break;
}

Expand All @@ -190,17 +196,9 @@ private IpAddrAlloc doAllocateIpAddr(String vpcId, int ipVersion, String ipAddr)
* @throws Exception Db operation or ip address assignment exception
*/
@DurationStatistics
public synchronized IpAddrAlloc allocateIpAddr(IpAddrRequest request) throws Exception {
IpAddrAlloc ipAddrAlloc = null;
try (Transaction tx = ipAddrRangeCache.getTransaction().start()) {
ipAddrAlloc = allocateIpAddrMethod(request);
tx.commit();
public IpAddrAlloc allocateIpAddr(IpAddrRequest request) throws Exception {
IpAddrAlloc ipAddrAlloc = allocateIpAddrMethod(request);
Comment on lines +199 to +200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidLiu506 Do we still need this function if we push all the process code into allocateIpAddrMethod?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It called by other functions.

return ipAddrAlloc;
} catch (Exception e) {
LOG.warn("Transaction exception: ");
LOG.warn(e.getMessage());
}
return ipAddrAlloc;
}

/**
Expand Down Expand Up @@ -520,18 +518,26 @@ private void allocateIpAddrBulkMethod(Map<String, List<IpAddrRequest>> rangeRequ

}

@DurationStatistics
private IpAddrAlloc allocateIpAddrMethod(IpAddrRequest request) throws Exception {
IpAddrAlloc ipAddrAlloc;
if (request.getRangeId() == null) {
ipAddrAlloc = doAllocateIpAddr(request.getVpcId(), request.getIpVersion(), request.getIp());
} else {
IpAddrRange ipAddrRange = ipAddrRangeCache.get(request.getRangeId());
if (ipAddrRange == null) {
throw new IpRangeNotFoundException();
synchronized (this) {
try (Transaction tx = ipAddrRangeCache.getTransaction().start()) {
IpAddrRange ipAddrRange = ipAddrRangeCache.get(request.getRangeId());
if (ipAddrRange == null) {
throw new IpRangeNotFoundException();
}

ipAddrAlloc = ipAddrRange.allocate(request.getIp());
ipAddrRangeCache.put(ipAddrRange.getId(), ipAddrRange);
tx.commit();
}
}

ipAddrAlloc = ipAddrRange.allocate(request.getIp());
ipAddrRangeCache.put(ipAddrRange.getId(), ipAddrRange);

}
return ipAddrAlloc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ public SubnetWebJson updateSubnetState(@PathVariable String projectId, @PathVari
}

// update subnet routing rule in route manager

if (hostRoutes != null && hostRoutes.size() > 0) {
this.subnetService.updateSubnetRoutingRuleInRM(projectId, subnetId, subnetEntity);
}


this.subnetDatabaseService.addSubnet(subnetEntity);
subnetEntity = this.subnetDatabaseService.getBySubnetId(subnetId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ free of charge, to any person obtaining a copy of this software and associated d
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.retry.annotation.Retryable;

import java.util.List;

Expand Down Expand Up @@ -82,6 +83,7 @@ public IpAddrRequest allocateIpAddress(IpVersion ipVersion, String vpcId, String
}

@DurationStatistics
@Retryable
public IpAddrRequest allocateIpAddress(IpAddrRequest ipAddrRequest) throws Exception {
HttpEntity<IpAddrRequest> request = new HttpEntity<>(ipAddrRequest);
IpAddrRequest result = restTemplate.postForObject(ipManagerUrl, request, IpAddrRequest.class);
Expand Down