Skip to content

Commit

Permalink
Make DiscoveryServer stream ID global
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanie Tilden committed Dec 16, 2020
1 parent ff834cb commit 2dddc8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -21,7 +20,6 @@ public abstract class DiscoveryServer<T, U> {
final ConfigWatcher configWatcher;
final ProtoResourcesSerializer protoResourcesSerializer;
private final ExecutorGroup executorGroup;
private final AtomicLong streamCount = new AtomicLong();

/**
* Creates the server.
Expand Down Expand Up @@ -59,7 +57,7 @@ StreamObserver<T> createRequestHandler(
boolean ads,
String defaultTypeUrl) {

long streamId = streamCount.getAndIncrement();
long streamId = StreamCounter.getAndIncrement();
Executor executor = executorGroup.next();

LOGGER.debug("[{}] open stream from {}", streamId, defaultTypeUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.envoyproxy.controlplane.server;

import java.util.concurrent.atomic.AtomicLong;

public final class StreamCounter {
private static final AtomicLong streamCount = new AtomicLong();

public static long getAndIncrement() {
return streamCount.getAndIncrement();
}
}

0 comments on commit 2dddc8f

Please sign in to comment.