Pingping Lin
Committed by Gerrit Code Review

thread safe improvment

Change-Id: I09b6dc7a3003792ec975b5b8c8c423d38d65767b
...@@ -112,7 +112,8 @@ public class VbngConfigurationManager implements VbngConfigurationService { ...@@ -112,7 +112,8 @@ public class VbngConfigurationManager implements VbngConfigurationService {
112 // TODO handle the case: the number of public IP addresses is not enough 112 // TODO handle the case: the number of public IP addresses is not enough
113 // for 1:1 mapping from public IP to private IP. 113 // for 1:1 mapping from public IP to private IP.
114 @Override 114 @Override
115 - public IpAddress getAvailablePublicIpAddress(IpAddress privateIpAddress) { 115 + public synchronized IpAddress getAvailablePublicIpAddress(IpAddress
116 + privateIpAddress) {
116 // If there is already a mapping entry for the private IP address, 117 // If there is already a mapping entry for the private IP address,
117 // then fetch the public IP address in the mapping entry and return it. 118 // then fetch the public IP address in the mapping entry and return it.
118 IpAddress publicIpAddress = ipAddressMap.get(privateIpAddress); 119 IpAddress publicIpAddress = ipAddressMap.get(privateIpAddress);
......
...@@ -47,10 +47,8 @@ public class VbngResource extends BaseResource { ...@@ -47,10 +47,8 @@ public class VbngResource extends BaseResource {
47 VbngService vbngService = get(VbngService.class); 47 VbngService vbngService = get(VbngService.class);
48 48
49 IpAddress publicIpAddress = null; 49 IpAddress publicIpAddress = null;
50 - synchronized (this) { 50 + // Create a virtual BNG
51 - // Create a virtual BNG 51 + publicIpAddress = vbngService.createVbng(privateIpAddress);
52 - publicIpAddress = vbngService.createVbng(privateIpAddress);
53 - }
54 52
55 if (publicIpAddress != null) { 53 if (publicIpAddress != null) {
56 return publicIpAddress.toString(); 54 return publicIpAddress.toString();
......