Skip to content

Commit

Permalink
Gardening: Simplify Node.addService
Browse files Browse the repository at this point in the history
Use NanoTimestamp.

Change-Id: I762f99b4ab1f38f7635f7b5fc44283180208e18b
Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/208840
Reviewed-by: Michael Reiche <michael.reiche@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
dnault committed Apr 19, 2024
1 parent e8bfe9c commit bff68d1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.couchbase.client.core.service.ViewService;
import com.couchbase.client.core.service.ViewServiceConfig;
import com.couchbase.client.core.util.CompositeStateful;
import com.couchbase.client.core.util.NanoTimestamp;
import com.couchbase.client.core.util.Stateful;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -236,16 +237,15 @@ public synchronized Mono<Void> addService(final ServiceType type, final int port
Map<ServiceType, Service> localMap = services.computeIfAbsent(name, key -> new ConcurrentHashMap<>());

if (!localMap.containsKey(type)) {
long start = System.nanoTime();
NanoTimestamp start = NanoTimestamp.now();
Service service = createService(type, port, bucket);
serviceStates.register(service, service);
localMap.put(type, service);
enabledServices.set(enabledServices.get() | 1 << type.ordinal());
// todo: only return once the service is connected?
service.connect();
long end = System.nanoTime();
ctx.environment().eventBus().publish(
new ServiceAddedEvent(Duration.ofNanos(end - start), service.context())
new ServiceAddedEvent(start.elapsed(), service.context())
);
return;
}
Expand Down

0 comments on commit bff68d1

Please sign in to comment.