From 7f4e26b0a2d4db6d69d878bcb69333e89a3a2c3c Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Sat, 10 Feb 2024 20:24:01 -0800 Subject: [PATCH 1/2] make single fork default, override in action --- .../java/com/salesforce/apollo/ring/RingCommunications.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memberships/src/main/java/com/salesforce/apollo/ring/RingCommunications.java b/memberships/src/main/java/com/salesforce/apollo/ring/RingCommunications.java index 249476077..eb329faac 100644 --- a/memberships/src/main/java/com/salesforce/apollo/ring/RingCommunications.java +++ b/memberships/src/main/java/com/salesforce/apollo/ring/RingCommunications.java @@ -66,7 +66,7 @@ public RingCommunications(Direction direction, Context context, SigningMember public void execute(BiFunction round, SyncHandler handler) { final var next = next(member.getId()); if (next == null || next.member == null) { - log.debug("No member for ring: {} on: {}", next.ring, member.getId()); + log.debug("No member for ring: {} on: {}", next == null ? "" : next.ring, member.getId()); handler.handle(Optional.empty(), next); return; } From a30c68c08b191a59ce31d179006f659fe3b0b10b Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Sat, 17 Feb 2024 16:32:53 -0800 Subject: [PATCH 2/2] correct naming --- .../salesforce/apollo/archipelago/Router.java | 88 +++++++++---------- .../DemultiplexerTest.java | 4 +- .../EnclaveTest.java | 7 +- .../LocalServerTest.java | 15 ++-- .../RouterTest.java | 13 ++- 5 files changed, 61 insertions(+), 66 deletions(-) rename memberships/src/test/java/com/salesforce/apollo/{archipeligo => archipelago}/DemultiplexerTest.java (98%) rename memberships/src/test/java/com/salesforce/apollo/{archipeligo => archipelago}/EnclaveTest.java (98%) rename memberships/src/test/java/com/salesforce/apollo/{archipeligo => archipelago}/LocalServerTest.java (96%) rename memberships/src/test/java/com/salesforce/apollo/{archipeligo => archipelago}/RouterTest.java (96%) diff --git a/memberships/src/main/java/com/salesforce/apollo/archipelago/Router.java b/memberships/src/main/java/com/salesforce/apollo/archipelago/Router.java index 40c760ab7..e0324704e 100644 --- a/memberships/src/main/java/com/salesforce/apollo/archipelago/Router.java +++ b/memberships/src/main/java/com/salesforce/apollo/archipelago/Router.java @@ -6,67 +6,56 @@ */ package com.salesforce.apollo.archipelago; -import java.time.Duration; -import java.util.function.Function; - import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications; import com.salesforce.apollo.archipelago.ServerConnectionCache.CreateClientCommunications; import com.salesforce.apollo.cryptography.Digest; import com.salesforce.apollo.membership.Member; import com.salesforce.apollo.protocols.ClientIdentity; - import io.grpc.BindableService; import io.grpc.Context; import io.grpc.Metadata; +import java.time.Duration; +import java.util.function.Function; + /** * @author hal.hildebrand - * */ public interface Router { - @FunctionalInterface - interface ClientConnector { - Client connect(Member to); - } - - interface ServiceRouting { - default String routing() { - return getClass().getCanonicalName(); - } - } - - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID = "agent.id"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID_SERVER = "agent.id.server"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID = "context.id"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID_SERVER = "context.id.server"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID = "from.id"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_CLIENT = "from.id.client"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_SERVER = "from.id.server"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID = "to.id"; - String COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID_SERVER = "to.id.server"; - Context.Key CLIENT_CLIENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_CLIENT); - Metadata.Key METADATA_AGENT_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID, - Metadata.ASCII_STRING_MARSHALLER); - Metadata.Key METADATA_CLIENT_ID_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID, - Metadata.ASCII_STRING_MARSHALLER); - Metadata.Key METADATA_CONTEXT_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID, - Metadata.ASCII_STRING_MARSHALLER); - Metadata.Key METADATA_TARGET_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID, - Metadata.ASCII_STRING_MARSHALLER); - Context.Key SERVER_AGENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID_SERVER); - Context.Key SERVER_CLIENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_SERVER); - Context.Key SERVER_CONTEXT_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID_SERVER); - Context.Key SERVER_TARGET_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID_SERVER); + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID = "agent.id"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID_SERVER = "agent.id.server"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID = "context.id"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID_SERVER = "context.id.server"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID = "from.id"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_CLIENT = "from.id.client"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_SERVER = "from.id.server"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID = "to.id"; + String COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID_SERVER = "to.id.server"; + Context.Key CLIENT_CLIENT_ID_KEY = Context.key( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_CLIENT); + Metadata.Key METADATA_AGENT_KEY = Metadata.Key.of( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID, Metadata.ASCII_STRING_MARSHALLER); + Metadata.Key METADATA_CLIENT_ID_KEY = Metadata.Key.of( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID, Metadata.ASCII_STRING_MARSHALLER); + Metadata.Key METADATA_CONTEXT_KEY = Metadata.Key.of( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID, Metadata.ASCII_STRING_MARSHALLER); + Metadata.Key METADATA_TARGET_KEY = Metadata.Key.of( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID, Metadata.ASCII_STRING_MARSHALLER); + Context.Key SERVER_AGENT_ID_KEY = Context.key( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID_SERVER); + Context.Key SERVER_CLIENT_ID_KEY = Context.key( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_SERVER); + Context.Key SERVER_CONTEXT_KEY = Context.key( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID_SERVER); + Context.Key SERVER_TARGET_KEY = Context.key( + COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID_SERVER); void close(Duration await); - CommonCommunications create(Member member, - Digest context, - Service service, - Function, BindableService> factory, - CreateClientCommunications createFunction, - Client localLoopback); + CommonCommunications create( + Member member, Digest context, Service service, Function, BindableService> factory, + CreateClientCommunications createFunction, Client localLoopback); CommonCommunications create(Member member, Digest context, Service service, String routingLabel, @@ -84,4 +73,15 @@ CommonCommunications create(Memb void start(); + @FunctionalInterface + interface ClientConnector { + Client connect(Member to); + } + + interface ServiceRouting { + default String routing() { + return getClass().getCanonicalName(); + } + } + } diff --git a/memberships/src/test/java/com/salesforce/apollo/archipeligo/DemultiplexerTest.java b/memberships/src/test/java/com/salesforce/apollo/archipelago/DemultiplexerTest.java similarity index 98% rename from memberships/src/test/java/com/salesforce/apollo/archipeligo/DemultiplexerTest.java rename to memberships/src/test/java/com/salesforce/apollo/archipelago/DemultiplexerTest.java index 3d061fad3..8ac959c34 100644 --- a/memberships/src/test/java/com/salesforce/apollo/archipeligo/DemultiplexerTest.java +++ b/memberships/src/test/java/com/salesforce/apollo/archipelago/DemultiplexerTest.java @@ -4,13 +4,11 @@ * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -package com.salesforce.apollo.archipeligo; +package com.salesforce.apollo.archipelago; import com.google.common.primitives.Ints; import com.google.protobuf.Any; import com.google.protobuf.ByteString; -import com.salesforce.apollo.archipelago.Demultiplexer; -import com.salesforce.apollo.archipelago.Router; import com.salesforce.apollo.comm.grpc.DomainSocketServerInterceptor; import com.salesforce.apollo.cryptography.DigestAlgorithm; import com.salesforce.apollo.test.proto.ByteMessage; diff --git a/memberships/src/test/java/com/salesforce/apollo/archipeligo/EnclaveTest.java b/memberships/src/test/java/com/salesforce/apollo/archipelago/EnclaveTest.java similarity index 98% rename from memberships/src/test/java/com/salesforce/apollo/archipeligo/EnclaveTest.java rename to memberships/src/test/java/com/salesforce/apollo/archipelago/EnclaveTest.java index 6aa17a496..b0c82f269 100644 --- a/memberships/src/test/java/com/salesforce/apollo/archipeligo/EnclaveTest.java +++ b/memberships/src/test/java/com/salesforce/apollo/archipelago/EnclaveTest.java @@ -4,11 +4,10 @@ * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -package com.salesforce.apollo.archipeligo; +package com.salesforce.apollo.archipelago; import com.google.protobuf.Any; import com.google.protobuf.ByteString; -import com.salesforce.apollo.archipelago.*; import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications; import com.salesforce.apollo.comm.grpc.DomainSocketServerInterceptor; import com.salesforce.apollo.cryptography.DigestAlgorithm; @@ -157,11 +156,11 @@ private ManagedChannel handler(DomainSocketAddress address) { .build(); } - public static interface TestIt { + public interface TestIt { void ping(Any request, StreamObserver responseObserver); } - public static interface TestItService extends Link { + public interface TestItService extends Link { Any ping(Any request); } diff --git a/memberships/src/test/java/com/salesforce/apollo/archipeligo/LocalServerTest.java b/memberships/src/test/java/com/salesforce/apollo/archipelago/LocalServerTest.java similarity index 96% rename from memberships/src/test/java/com/salesforce/apollo/archipeligo/LocalServerTest.java rename to memberships/src/test/java/com/salesforce/apollo/archipelago/LocalServerTest.java index dfa0388b3..c0264bc47 100644 --- a/memberships/src/test/java/com/salesforce/apollo/archipeligo/LocalServerTest.java +++ b/memberships/src/test/java/com/salesforce/apollo/archipelago/LocalServerTest.java @@ -4,19 +4,18 @@ * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -package com.salesforce.apollo.archipeligo; +package com.salesforce.apollo.archipelago; import com.google.protobuf.Any; import com.google.protobuf.ByteString; -import com.salesforce.apollo.test.proto.ByteMessage; -import com.salesforce.apollo.test.proto.TestItGrpc; -import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub; -import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase; -import com.salesforce.apollo.archipelago.*; import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications; import com.salesforce.apollo.cryptography.DigestAlgorithm; import com.salesforce.apollo.membership.Member; import com.salesforce.apollo.membership.impl.SigningMemberImpl; +import com.salesforce.apollo.test.proto.ByteMessage; +import com.salesforce.apollo.test.proto.TestItGrpc; +import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub; +import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase; import com.salesforce.apollo.utils.Utils; import io.grpc.stub.StreamObserver; import org.joou.ULong; @@ -89,11 +88,11 @@ public void smokin() throws Exception { routerB.close(Duration.ofSeconds(1)); } - public static interface TestIt { + public interface TestIt { void ping(Any request, StreamObserver responseObserver); } - public static interface TestItService extends Link { + public interface TestItService extends Link { Any ping(Any request); } diff --git a/memberships/src/test/java/com/salesforce/apollo/archipeligo/RouterTest.java b/memberships/src/test/java/com/salesforce/apollo/archipelago/RouterTest.java similarity index 96% rename from memberships/src/test/java/com/salesforce/apollo/archipeligo/RouterTest.java rename to memberships/src/test/java/com/salesforce/apollo/archipelago/RouterTest.java index da39e7b1d..4a9f543e8 100644 --- a/memberships/src/test/java/com/salesforce/apollo/archipeligo/RouterTest.java +++ b/memberships/src/test/java/com/salesforce/apollo/archipelago/RouterTest.java @@ -4,18 +4,17 @@ * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -package com.salesforce.apollo.archipeligo; +package com.salesforce.apollo.archipelago; import com.google.protobuf.Any; import com.google.protobuf.ByteString; +import com.salesforce.apollo.cryptography.DigestAlgorithm; +import com.salesforce.apollo.membership.Member; +import com.salesforce.apollo.membership.impl.SigningMemberImpl; import com.salesforce.apollo.test.proto.ByteMessage; import com.salesforce.apollo.test.proto.TestItGrpc; import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub; import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase; -import com.salesforce.apollo.archipelago.*; -import com.salesforce.apollo.cryptography.DigestAlgorithm; -import com.salesforce.apollo.membership.Member; -import com.salesforce.apollo.membership.impl.SigningMemberImpl; import com.salesforce.apollo.utils.Utils; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; @@ -87,11 +86,11 @@ public Any ping(Any request) { router.close(Duration.ofSeconds(1)); } - public static interface TestIt { + public interface TestIt { void ping(Any request, StreamObserver responseObserver); } - public static interface TestItService extends Link { + public interface TestItService extends Link { Any ping(Any request); }