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

Remove cache access from NCM gRPC client #740

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 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
3d350a7
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Jan 20, 2022
3499f7d
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Feb 1, 2022
22cc3af
Merge branch 'master' of https://github.com/futurewei-cloud/alcor
DavidLiu506 Feb 3, 2022
d11ae65
Update code
DavidLiu506 Feb 3, 2022
677e4a2
Update code
DavidLiu506 Feb 3, 2022
a0d4925
Update code
DavidLiu506 Feb 3, 2022
d00983f
Update code
DavidLiu506 Feb 3, 2022
12dc66d
Update code
DavidLiu506 Feb 3, 2022
676bbba
Update code
DavidLiu506 Feb 3, 2022
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 @@ -451,8 +451,12 @@ public void buildNeighborStatesL3(NetworkConfiguration networkConfiguration, Uni
e.printStackTrace();
}
});
unicastHostResourceBuilder.addAllResources(unicastGoalStateV2.getGoalStateBuilder().getHostResourcesMap().get(unicastGoalStateV2.getHostIp()).getResourcesList());
unicastGoalStateV2.getGoalStateBuilder().putHostResources(unicastGoalStateV2.getHostIp(), unicastHostResourceBuilder.build());
for (String hostIp : multicastGoalStateV2.getHostIps()) {
if (multicastGoalStateV2.getGoalStateBuilder().getHostResourcesMap(). containsKey(hostIp) && multicastGoalStateV2.getGoalStateBuilder().getHostResourcesMap().get(hostIp) != null) {
multicastHostResourceBuilder.addAllResources(multicastGoalStateV2.getGoalStateBuilder().getHostResourcesMap().get(hostIp).getResourcesList());
}
multicastGoalStateV2.getGoalStateBuilder().putHostResources(hostIp, multicastHostResourceBuilder.build());
}
unicastGoalStateV2.getGoalStateBuilder().putAllNeighborStates(neighborStateMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,20 @@ free of charge, to any person obtaining a copy of this software and associated d
import com.futurewei.alcor.common.logging.Logger;
import com.futurewei.alcor.common.logging.LoggerFactory;
import com.futurewei.alcor.common.stats.DurationStatistics;
import com.futurewei.alcor.netwconfigmanager.cache.ResourceStateCache;
import com.futurewei.alcor.netwconfigmanager.client.GoalStateClient;
import com.futurewei.alcor.netwconfigmanager.config.Config;
import com.futurewei.alcor.netwconfigmanager.entity.HostGoalState;
import com.futurewei.alcor.netwconfigmanager.service.ResourceInfo;
import com.futurewei.alcor.schema.*;
import io.grpc.ConnectivityState;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup;
import io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel;
import io.grpc.stub.ClientCallStreamObserver;
import io.grpc.stub.ServerCallStreamObserver;
import io.grpc.stub.StreamObserver;
import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import io.jaegertracing.internal.samplers.ConstSampler;
import io.lettuce.core.dynamic.annotation.Param;
import io.netty.util.concurrent.DefaultThreadFactory;
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.contrib.tracerresolver.TracerResolver;
import io.opentracing.util.GlobalTracer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.*;
Expand All @@ -61,9 +48,6 @@ public class GoalStateClientImpl implements GoalStateClient {

private final ExecutorService executor;

@Autowired
private ResourceInfo resourceInfo;

// each host_ip should have this amount of gRPC channels
@Value("${grpc.number-of-channels-per-host:1}")
private int numberOfGrpcChannelPerHost;
Expand Down Expand Up @@ -128,9 +112,8 @@ public List<String> sendGoalStates(Map<String, HostGoalState> hostGoalStates) th
logger.log(Level.INFO, "Host goal states size: " + hostGoalStates.values().size());
List<String> replies = new ArrayList<>();

boolean isAttache = !hostGoalStates.values().parallelStream().anyMatch(hostGoalState -> hostGoalState.getGoalState().getPortStatesCount() > 0);
for (HostGoalState hostGoalState : hostGoalStates.values()) {
doSendGoalState(hostGoalState, finishLatch, replies, isAttache);
doSendGoalState(hostGoalState, finishLatch, replies);
}

if (!finishLatch.await(5, TimeUnit.MINUTES)) {
Expand Down Expand Up @@ -256,7 +239,7 @@ private GrpcChannelStub createGrpcChannelStub(String hostIp) {

}

private void doSendGoalState(HostGoalState hostGoalState, CountDownLatch finishLatch, List<String> replies, boolean isAttache) throws InterruptedException {
private void doSendGoalState(HostGoalState hostGoalState, CountDownLatch finishLatch, List<String> replies) throws InterruptedException {
String hostIp = hostGoalState.getHostIp();
logger.log(Level.FINE, "Setting up a channel to ACA on: " + hostIp);
long start = System.currentTimeMillis();
Expand Down Expand Up @@ -302,19 +285,10 @@ public void onCompleted() {
try {
long before_get_goalState = System.currentTimeMillis();
Goalstate.GoalStateV2 goalState = hostGoalState.getGoalState();
Set<String> resourceIds = goalState.getHostResourcesMap().get(hostIp).getResourcesList().stream().filter(resourceIdType -> resourceIdType.getType().equals(Common.ResourceType.NEIGHBOR)).map(resourceIdType -> resourceIdType.getId()).collect(Collectors.toSet());
Goalstate.GoalStateV2.Builder goalstateBuilder = Goalstate.GoalStateV2.newBuilder();
goalstateBuilder.mergeFrom(goalState);
if (isAttache || goalstateBuilder.getPortStatesCount() > 0) {
Map<String, Neighbor.NeighborState> neighborStateMap = resourceInfo.getNeighborStates(resourceIds);
if (neighborStateMap.size() > 0) {
goalstateBuilder.putAllNeighborStates(neighborStateMap);
}
}
long after_get_goalState = System.currentTimeMillis();
logger.log(Level.FINE, "Sending GS with size " + goalState.getSerializedSize() + " to Host " + hostIp + " as follows | " + goalstateBuilder.build());
logger.log(Level.FINE, "Sending GS with size " + goalState.getSerializedSize() + " to Host " + hostIp + " as follows | " + goalState);

requestObserver.onNext(goalstateBuilder.build());
requestObserver.onNext(goalState);
long after_onNext = System.currentTimeMillis();
logger.log(Level.FINE, "[doSendGoalState] Get goalstatev2 from HostGoalState in milliseconds: " + (after_get_goalState - before_get_goalState));
logger.log(Level.FINE, "[doSendGoalState] Call onNext in milliseconds: " + (after_onNext - after_get_goalState));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public void onNext(Goalstate.GoalStateV2 value) {
Span storeGsSpan = tracer.buildSpan(serverStoreGsSpanName).asChildOf(span.context()).start();
Scope storageCscope = tracer.scopeManager().activate(storeGsSpan);


//store the goal state in cache
Map<String, HostGoalState> hostGoalStates = new HashMap<>();
try {
Expand All @@ -225,9 +224,7 @@ public void onNext(Goalstate.GoalStateV2 value) {
}

storeGsSpan.finish();

Set<String> processedResourceIds = new HashSet<>();

long end = System.currentTimeMillis();
logger.log(Level.FINE, "pushGoalStatesStream : finished putting GS into cache, elapsed time in milliseconds: " + + (end-start));
Span filterSendGsSpan = tracer.buildSpan(serverFilterSendGsSpanName).asChildOf(span.context()).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ public interface GoalStatePersistenceService {

Map<String, HostGoalState> updateGoalStates(Goalstate.GoalStateV2 goalStateV2) throws Exception;

void patchNeighbors(Map<String, HostGoalState> hostGoalStates) throws Exception;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ free of charge, to any person obtaining a copy of this software and associated d

import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;

@Service
@ComponentScan(value = "com.futurewei.alcor.netwconfigmanager.cache")
Expand Down Expand Up @@ -81,12 +82,27 @@ public Map<String, HostGoalState> updateGoalStates(Goalstate.GoalStateV2 goalSta
}
}
hostResourceMetadataCache.commit();
patchNeighbors(hostGoalStates);
}
return hostGoalStates;
}

public Map<String, Neighbor.NeighborState> getNeighborStates(Set<String> resourceIds) throws Exception {
return resourceStateCache.getResourceStates(resourceIds);
public void patchNeighbors(Map<String, HostGoalState> hostGoalStates) throws Exception {
boolean isAttache = !hostGoalStates.values().parallelStream().anyMatch(hostGoalState -> hostGoalState.getGoalState().getPortStatesCount() > 0);
for (Map.Entry<String, HostGoalState> hostGoalState : hostGoalStates.entrySet()) {
if (isAttache || hostGoalState.getValue().getGoalState().getPortStatesCount() > 0) {
String hostIp = hostGoalState.getValue().getHostIp();
Goalstate.GoalStateV2 goalState = hostGoalState.getValue().getGoalState();
Set<String> resourceIds = goalState.getHostResourcesMap().get(hostIp).getResourcesList().stream().filter(resourceIdType -> resourceIdType.getType().equals(Common.ResourceType.NEIGHBOR)).map(resourceIdType -> resourceIdType.getId()).collect(Collectors.toSet());
Goalstate.GoalStateV2.Builder goalstateBuilder = Goalstate.GoalStateV2.newBuilder();
goalstateBuilder.mergeFrom(goalState);
Map<String, Neighbor.NeighborState> neighborStateMap = resourceStateCache.getResourceStates(resourceIds);
if (neighborStateMap.size() > 0) {
goalstateBuilder.putAllNeighborStates(neighborStateMap);
}
hostGoalStates.put(hostGoalState.getKey(), new HostGoalState(hostIp, goalstateBuilder.build()));
}
}
}

@Override
Expand Down

This file was deleted.