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

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLiu506 committed Nov 23, 2021
1 parent d3c5e0c commit 55885e1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions kubernetes/services/dpm_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ data:
zetaGateway.enabled=false
zetaGateway.node.mac=e0:97:96:02:45:53
microservices.node.service.url=http://nodemanager-service.default.svc.cluster.local:9007/nodes
microservices.netwconfigmanager.service.url=netwconfigmanager-service
microservices.zeta.management.url=http://10.213.43.90
microservices.gateway.service.url=http://gatewaymanager-service.default.svc.cluster.local:9015
zetaGateway.check.timeout = 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class DataPlaneClientImplV2 implements DataPlaneClient<UnicastGoalStateV2
// when a channel is set up, send this amount of default GoalStates for warmup.
private int numberOfWarmupsPerChannel;

private String netwconfigmanagerHost;

// prints out UUID and time, when sending a GoalState to any of the monitorHosts
private ArrayList<String> monitorHosts;

Expand All @@ -64,22 +66,17 @@ public class DataPlaneClientImplV2 implements DataPlaneClient<UnicastGoalStateV2
public List<String> sendGoalStates(List<UnicastGoalStateV2> unicastGoalStates) throws Exception {
Goalstate.GoalStateV2.Builder goalStateBuilder = Goalstate.GoalStateV2.newBuilder();
final CountDownLatch finishLatch = new CountDownLatch(1);
final CountDownLatch exceptionLatch = new CountDownLatch(1);
List<String> results = new ArrayList<>();
for (UnicastGoalStateV2 unicastGoalState : unicastGoalStates) {
goalStateBuilder = getGoalState(goalStateBuilder, unicastGoalState);
}
System.out.println(goalStateBuilder.build());
doSendGoalState(goalStateBuilder.build(), finishLatch, exceptionLatch);
doSendGoalState(goalStateBuilder.build(), finishLatch, results);

if (!finishLatch.await(1, TimeUnit.MINUTES) && !exceptionLatch.await(1, TimeUnit.MINUTES)) {
if (exceptionLatch.getCount() == 0) {
return Arrays.asList("Goal states not correct");
}
if (!finishLatch.await(1, TimeUnit.MINUTES)) {
LOG.warn("Send goal states can not finish within 1 minutes");
return Arrays.asList("Send goal states can not finish within 1 minutes");
}
return new ArrayList<>();
return results;
}

public static DataPlaneClientImplV2 getInstance(Config globalConfig, ArrayList<String> monitorHosts) {
Expand All @@ -100,6 +97,10 @@ public DataPlaneClientImplV2(Config globalConfig, ArrayList<String> monitorHosts
numberOfWarmupsPerChannel = 0;
}

if (netwconfigmanagerHost == null || netwconfigmanagerHost.isEmpty()) {
netwconfigmanagerHost = globalConfig.netwconfigmanagerHost;
}

this.monitorHosts = monitorHosts;
LOG.info("Printing out all monitorHosts");
for(String host : this.monitorHosts){
Expand Down Expand Up @@ -181,7 +182,8 @@ private ArrayList<GrpcChannelStub> createGrpcChannelStubArrayList(String hostIp)
ArrayList<GrpcChannelStub> arr = new ArrayList<>();
for (int i = 0; i < numberOfGrpcChannelPerHost; i++) {
GrpcChannelStub channelStub = createGrpcChannelStub(hostIp);
warmUpChannelStub(channelStub, hostIp);
// Using Linkerd load balance
//warmUpChannelStub(channelStub, hostIp);
arr.add(channelStub);
}
long end = System.currentTimeMillis();
Expand Down Expand Up @@ -228,9 +230,8 @@ public void onCompleted() {
return;
}

private String doSendGoalState(Goalstate.GoalStateV2 goalStateV2, CountDownLatch finishLatch, CountDownLatch exceptionLatch) {
String hostIp = "netwconfigmanager-service";
//String hostIp = "netwconfigmanager-service.default.svc.cluster.local";
private String doSendGoalState(Goalstate.GoalStateV2 goalStateV2, CountDownLatch finishLatch, List<String> replies) {
String hostIp = netwconfigmanagerHost;
long start = System.currentTimeMillis();
GrpcChannelStub channelStub = getOrCreateGrpcChannel(hostIp);
long chan_established = System.currentTimeMillis();
Expand All @@ -246,12 +247,15 @@ private String doSendGoalState(Goalstate.GoalStateV2 goalStateV2, CountDownLatch
public void onNext(Goalstateprovisioner.GoalStateOperationReply reply) {
LOG.info("Receive response from ACA@" + hostIp + " | " + reply.toString());
result.put(hostIp, reply.getOperationStatusesList());
replies.add(reply.toString());
while (finishLatch.getCount() > 0) {
finishLatch.countDown();
}
}

@Override
public void onError(Throwable t) {
LOG.warn("Receive error from ACA@" + hostIp + " | " + t.getMessage());
exceptionLatch.countDown();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class Config {
@Value("${grpc.monitor-hosts}")
public ArrayList<String> monitorHosts;

@Value("${microservices.netwconfigmanager.service.url}")
public String netwconfigmanagerHost;

public static FileWriter TIME_STAMP_FILE;
public static BufferedWriter TIME_STAMP_WRITER;
public static String LOG_FILE_PATH = "timestamp.log";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ group.topic.to.multicast.topic.map=multicast-topic1:group-topic1,group-topic3 mu
#####Microservice url configuration######
microservices.zeta.management.url=http://10.213.43.90
microservices.gateway.service.url=http://localhost:9015
microservices.netwconfigmanager.service.url=netwconfigmanager-service

#####ZetaGateway#####
zetaGateway.node.mac=e0:97:96:02:45:53
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ public void onNext(Goalstateprovisioner.GoalStateOperationReply reply) {
finishLatch.countDown();
}
}
this.onCompleted();
}

@Override
Expand Down

0 comments on commit 55885e1

Please sign in to comment.