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

Commit b3dbbd4

Browse files
author
Liguang Xie
authored
[Network Config Mgr] Support on-demand service and GS persistence service (#607)
1 parent 1639de4 commit b3dbbd4

23 files changed

Lines changed: 1030 additions & 109 deletions

File tree

services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/cache/NodeInfoCache.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.dataplane.cache;
1817

1918
import com.futurewei.alcor.common.db.CacheFactory;

services/data_plane_manager/src/main/java/com/futurewei/alcor/dataplane/cache/NodeTopicCache.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
package com.futurewei.alcor.dataplane.cache;
21
/*
3-
*
4-
* Copyright 2019 The Alcor Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
* /
18-
*/
2+
MIT License
3+
Copyright(c) 2020 Futurewei Cloud
4+
5+
Permission is hereby granted,
6+
free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction,
7+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons
8+
to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
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,
14+
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.
15+
*/
16+
package com.futurewei.alcor.dataplane.cache;
1917

2018
import com.futurewei.alcor.common.db.CacheFactory;
2119
import com.futurewei.alcor.common.db.ICache;

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/NetworkConfigManagerApplication.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,35 @@ free of charge, to any person obtaining a copy of this software and associated d
1717

1818
import com.futurewei.alcor.netwconfigmanager.server.NetworkConfigServer;
1919
import com.futurewei.alcor.netwconfigmanager.server.grpc.GoalStateProvisionerServer;
20+
import org.springframework.beans.factory.annotation.Autowired;
2021
import org.springframework.boot.SpringApplication;
2122
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.context.ApplicationContext;
24+
import org.springframework.context.annotation.ComponentScan;
2225
import org.springframework.scheduling.annotation.EnableAsync;
26+
import org.springframework.stereotype.Component;
27+
28+
import javax.annotation.PostConstruct;
2329

2430
@SpringBootApplication
31+
@ComponentScan(value = "com.futurewei.alcor.netwconfigmanager.server")
2532
@EnableAsync
2633
public class NetworkConfigManagerApplication {
2734

28-
public static void main(String[] args) {
29-
SpringApplication.run(NetworkConfigManagerApplication.class, args);
35+
@Autowired
36+
private NetworkConfigServer networkConfigServer;
3037

31-
NetworkConfigServer networkConfigServer = new GoalStateProvisionerServer();
38+
@PostConstruct
39+
public void instantiateGrpcServer(){
3240
try {
3341
networkConfigServer.start();
3442
networkConfigServer.blockUntilShutdown();
3543
} catch (Exception e) {
3644
e.printStackTrace();
3745
}
3846
}
47+
48+
public static void main(String[] args) {
49+
SpringApplication.run(NetworkConfigManagerApplication.class, args);
50+
}
3951
}

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/cache/HostResourceMetadataCache.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.netwconfigmanager.cache;
1817

1918
import com.futurewei.alcor.common.db.CacheFactory;

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/cache/ResourceStateCache.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.netwconfigmanager.cache;
1817

1918
import com.futurewei.alcor.common.db.CacheFactory;

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/cache/VpcResourceCache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.netwconfigmanager.cache;
1817

1918
import com.futurewei.alcor.common.db.CacheFactory;
@@ -28,7 +27,7 @@ free of charge, to any person obtaining a copy of this software and associated d
2827
@ComponentScan(value = "com.futurewei.alcor.common.db")
2928
public class VpcResourceCache {
3029

31-
// Map <VNI, Map<PIP, List<ResoruceIDType>>
30+
// Map <VNI, Map<PIP, ResourceMetadata>
3231
private ICache<String, VpcResourceMeta> vpcResourceMetas;
3332

3433
@Autowired

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/client/gRPC/GoalStateClientImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ free of charge, to any person obtaining a copy of this software and associated d
1717

1818
import com.futurewei.alcor.common.logging.Logger;
1919
import com.futurewei.alcor.common.logging.LoggerFactory;
20+
import com.futurewei.alcor.common.stats.DurationStatistics;
2021
import com.futurewei.alcor.netwconfigmanager.client.GoalStateClient;
2122
import com.futurewei.alcor.netwconfigmanager.config.Config;
2223
import com.futurewei.alcor.netwconfigmanager.entity.HostGoalState;
@@ -63,6 +64,7 @@ public GoalStateClientImpl() {
6364
}
6465

6566
@Override
67+
@DurationStatistics
6668
public List<String> sendGoalStates(Map<String, HostGoalState> hostGoalStates) throws Exception {
6769
List<Future<HostGoalState>>
6870
futures = new ArrayList<>(hostGoalStates.size());

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/constant/Constants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.netwconfigmanager.constant;
1817

1918
public class Constants {

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/controller/NetworkConfigController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public class NetworkConfigController {
4444

4545
@Autowired
4646
private NodeService nodeService;
47+
4748
@Autowired
4849
private HttpServletRequest request;
50+
4951
@PostMapping({"/nodes", "/v4/nodes"})
5052
@ResponseStatus(HttpStatus.CREATED)
5153
@DurationStatistics

services/network_config_manager/src/main/java/com/futurewei/alcor/netwconfigmanager/entity/ResourceMeta.java

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ free of charge, to any person obtaining a copy of this software and associated d
1313
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,
1414
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.
1515
*/
16-
1716
package com.futurewei.alcor.netwconfigmanager.entity;
1817

1918
import com.futurewei.alcor.schema.Goalstate;
@@ -54,6 +53,9 @@ public void setOwnerId(String ownerId) {
5453
this.ownerId = ownerId;
5554
}
5655

56+
////////////////////////
57+
// Vpc related methods
58+
////////////////////////
5759
public Set<String> getVpcIds() {
5860
return this.vpcIds;
5961
}
@@ -62,14 +64,18 @@ public String getDefaultVpcId() {
6264
return this.vpcIds != null && this.vpcIds.size() > 0 ? this.vpcIds.iterator().next() : UNEXPECTED_RESOURCE_ID;
6365
}
6466

65-
public void addVpcId(String newId) {
67+
public ResourceMeta addVpcId(String newId) {
6668
this.vpcIds.add(newId);
69+
return this;
6770
}
6871

6972
public void deleteVpcId(String delId) {
7073
this.vpcIds.remove(delId);
7174
}
7275

76+
////////////////////////
77+
// Subnet related methods
78+
////////////////////////
7379
public Set<String> getSubnetIds() {
7480
return this.subnetIds;
7581
}
@@ -78,11 +84,96 @@ public String getDefaultSubnetId() {
7884
return this.subnetIds != null && this.subnetIds.size() > 0 ? this.subnetIds.iterator().next() : UNEXPECTED_RESOURCE_ID;
7985
}
8086

81-
public void addSubnetId(String newId) {
87+
public ResourceMeta addSubnetId(String newId) {
8288
this.subnetIds.add(newId);
89+
return this;
8390
}
8491

8592
public void deleteSubnetId(String delId) {
8693
this.subnetIds.remove(delId);
8794
}
95+
96+
////////////////////////
97+
// Port related methods
98+
////////////////////////
99+
public Set<String> getPortIds() {
100+
return this.portIds;
101+
}
102+
103+
public String getDefaultPortId() {
104+
return this.portIds != null && this.portIds.size() > 0 ? this.portIds.iterator().next() : UNEXPECTED_RESOURCE_ID;
105+
}
106+
107+
public ResourceMeta addPortId(String newId) {
108+
this.portIds.add(newId);
109+
return this;
110+
}
111+
112+
public void deletePortId(String delId) {
113+
this.portIds.remove(delId);
114+
}
115+
116+
////////////////////////
117+
// Neighbor related methods
118+
////////////////////////
119+
public Map<String, String> getNeighborIdMap() {
120+
return this.neighborMap;
121+
}
122+
123+
public ResourceMeta addNeighborEntry(String neighborIp, String neighborId) {
124+
this.neighborMap.put(neighborIp, neighborId);
125+
return this;
126+
}
127+
128+
public void deleteNeighborEntry(String neighborIp) {
129+
this.neighborMap.remove(neighborIp);
130+
}
131+
132+
////////////////////////
133+
// Dhcp related methods
134+
////////////////////////
135+
public Set<String> getDhcpIds() {
136+
return this.dhcpIds;
137+
}
138+
139+
public ResourceMeta addDhcpId(String newId) {
140+
this.dhcpIds.add(newId);
141+
return this;
142+
}
143+
144+
public void deleteDhcpId(String delId) {
145+
this.dhcpIds.remove(delId);
146+
}
147+
148+
////////////////////////
149+
// Router related methods
150+
////////////////////////
151+
public Set<String> getRouterIds() {
152+
return this.routerIds;
153+
}
154+
155+
public ResourceMeta addRouterId(String newId) {
156+
this.routerIds.add(newId);
157+
return this;
158+
}
159+
160+
public void deleteRouterId(String delId) {
161+
this.routerIds.remove(delId);
162+
}
163+
164+
////////////////////////
165+
// SG related methods
166+
////////////////////////
167+
public ResourceMeta addSecurityGroupId(String newId) {
168+
this.securityGroupIds.add(newId);
169+
return this;
170+
}
171+
172+
////////////////////////
173+
// Gateway related methods
174+
////////////////////////
175+
public ResourceMeta addGatewayId(String newId) {
176+
this.gatewayIds.add(newId);
177+
return this;
178+
}
88179
}

0 commit comments

Comments
 (0)