示例#1
0
 private void InitializeInstanceFields()
 {
     _raftApplicationProtocolRepository      = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), _supportedRaftApplicationProtocol);
     _catchupApplicationProtocolRepository   = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), _supportedCatchupApplicationProtocol);
     _compressionModifierProtocolRepository  = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), _supportedCompressionModifierProtocols);
     _unsupportingModifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), _noSupportedModifierProtocols);
 }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols()
        public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols()
        {
            // given
            ISet <string>  requestedVersions         = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION));
            string         expectedNegotiatedVersion = SNAPPY.implementation();
            IList <string> configuredVersions        = singletonList(expectedNegotiatedVersion);

            IList <ModifierSupportedProtocols> supportedModifierProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, configuredVersions));

            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedModifierProtocols);

            HandshakeServer server = new HandshakeServer(_applicationProtocolRepository, modifierProtocolRepository, _channel);

            server.Handle(InitialMagicMessage.Instance());
            server.Handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(RAFT_1.implementation())));
            server.Handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), requestedVersions));

            // when
            IList <Pair <string, string> > modifierRequest = new IList <Pair <string, string> > {
                Pair.of(SNAPPY.category(), SNAPPY.implementation())
            };

            server.Handle(new SwitchOverRequest(RAFT_1.category(), RAFT_1.implementation(), modifierRequest));

            // then
            verify(_channel).writeAndFlush(InitialMagicMessage.Instance());
            verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS));
            ProtocolStack            protocolStack = server.ProtocolStackFuture().getNow(null);
            IList <ModifierProtocol> modifiers     = new IList <ModifierProtocol> {
                SNAPPY
            };

            assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, modifiers)));
        }
示例#3
0
 private void InitializeInstanceFields()
 {
     _supportedApplicationProtocol  = new ApplicationSupportedProtocols(_applicationProtocolIdentifier, emptyList());
     _applicationProtocolRepository = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), _supportedApplicationProtocol);
     _modifierProtocolRepository    = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), _supportedModifierProtocols);
     _expectedApplicationProtocol   = _applicationProtocolRepository.select(_applicationProtocolIdentifier.canonicalName(), _raftVersion).get();
 }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuccessfullyHandshakeKnownProtocolOnClientWithCompression() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSuccessfullyHandshakeKnownProtocolOnClientWithCompression()
        {
            // when
            CompletableFuture <ProtocolStack> clientHandshakeFuture = _handshakeClient.initiate(new SimpleNettyChannel(_client.channel, NullLog.Instance), _raftApplicationProtocolRepository, _compressionModifierProtocolRepository);

            // then
            ProtocolStack clientProtocolStack = clientHandshakeFuture.get(1, TimeUnit.MINUTES);

            assertThat(clientProtocolStack.ApplicationProtocol(), equalTo(TestProtocols_TestApplicationProtocols.latest(RAFT)));
            assertThat(clientProtocolStack.ModifierProtocols(), contains(TestProtocols_TestModifierProtocols.latest(COMPRESSION)));
        }
示例#5
0
            internal Fixture(Parameters parameters)
            {
                ApplicationProtocolRepository serverApplicationProtocolRepository = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), parameters.ServerApplicationProtocol);
                ModifierProtocolRepository    serverModifierProtocolRepository    = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), parameters.ServerModifierProtocols);

                ClientApplicationProtocolRepository = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), parameters.ClientApplicationProtocol);
                ClientModifierProtocolRepository    = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), parameters.ClientModifierProtocols);

                HandshakeClient = new HandshakeClient();
                HandshakeServer = new HandshakeServer(serverApplicationProtocolRepository, serverModifierProtocolRepository, new FakeServerChannel(HandshakeClient));
                ClientChannel   = new FakeClientChannel(HandshakeServer);
                this.Parameters = parameters;
            }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendModifierProtocolResponseForGivenProtocol()
        public void shouldSendModifierProtocolResponseForGivenProtocol()
        {
            // given
            ISet <string> versions = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION));

            _server.handle(InitialMagicMessage.Instance());

            // when
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), versions));

            // then
            ModifierProtocol expected = TestProtocols_TestModifierProtocols.latest(COMPRESSION);

            verify(_channel).writeAndFlush(new ModifierProtocolResponse(SUCCESS, expected.category(), expected.implementation()));
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendSwitchOverRequestIfNoModifierProtocolsToRequestOnApplicationProtocolResponse()
        public virtual void ShouldSendSwitchOverRequestIfNoModifierProtocolsToRequestOnApplicationProtocolResponse()
        {
            ModifierProtocolRepository repo = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), emptyList());
            // given
            CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, repo);

            _client.handle(InitialMagicMessage.Instance());

            // when
            _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), _raftVersion));

            // then
            verify(_channel).writeAndFlush(new SwitchOverRequest(_applicationProtocolIdentifier.canonicalName(), _raftVersion, emptyList()));
            assertFalse(protocolStackCompletableFuture.Done);
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSwitchoverResponse()
        public virtual void ShouldCompleteProtocolStackOnSwitchoverResponse()
        {
            // given
            ModifierProtocolRepository repo = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), asList(new ModifierSupportedProtocols(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocolCategory.Compression, emptyList())));

            CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, repo);

            _client.handle(InitialMagicMessage.Instance());
            _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), _raftVersion));
            _client.handle(new ModifierProtocolResponse(StatusCode.Success, SNAPPY.category(), SNAPPY.implementation()));

            // when
            _client.handle(new SwitchOverResponse(StatusCode.Success));

            // then
            ProtocolStack protocolStack = protocolStackCompletableFuture.getNow(null);

            assertThat(protocolStack, equalTo(new ProtocolStack(_expectedApplicationProtocol, singletonList(SNAPPY))));
        }
示例#9
0
        public static string[] AllVersionsOf(ModifierProtocolCategory identifier)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(TestProtocols.allVersionsOf(identifier, TestProtocols_TestModifierProtocols.values(), string[] ::new));
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters public static java.util.Collection<Parameters> data()
        public static ICollection <Parameters> Data()
        {
            // Application protocols
            ApplicationSupportedProtocols allRaft          = new ApplicationSupportedProtocols(RAFT, TestProtocols_TestApplicationProtocols.listVersionsOf(RAFT));
            ApplicationSupportedProtocols raft1            = new ApplicationSupportedProtocols(RAFT, singletonList(RAFT_1.implementation()));
            ApplicationSupportedProtocols allRaftByDefault = new ApplicationSupportedProtocols(RAFT, emptyList());

            // Modifier protocols
            ICollection <ModifierSupportedProtocols> allModifiers = asList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION))
                                                                           );
            ICollection <ModifierSupportedProtocols> allCompressionModifiers          = singletonList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)));
            ICollection <ModifierSupportedProtocols> allObfuscationModifiers          = singletonList(new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION)));
            ICollection <ModifierSupportedProtocols> allCompressionModifiersByDefault = singletonList(new ModifierSupportedProtocols(COMPRESSION, emptyList()));

            IList <ModifierSupportedProtocols> onlyLzoCompressionModifiers    = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(LZO.implementation())));
            IList <ModifierSupportedProtocols> onlySnappyCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(SNAPPY.implementation())));

            ICollection <ModifierSupportedProtocols> noModifiers = emptyList();

            // Ordered modifier protocols
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), allModifiers);

            string[] lzoFirstVersions = new string[] { LZO.implementation(), LZ4.implementation(), SNAPPY.implementation() };
            IList <ModifierSupportedProtocols> lzoFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                lzoFirstVersions
            }));
            Protocol_ModifierProtocol preferredLzoFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(lzoFirstVersions)).get();

            string[] snappyFirstVersions = new string[] { SNAPPY.implementation(), LZ4.implementation(), LZO.implementation() };
            IList <ModifierSupportedProtocols> snappyFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                snappyFirstVersions
            }));
            Protocol_ModifierProtocol preferredSnappyFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(snappyFirstVersions)).get();

            return(asList(new Parameters(allRaft, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaftByDefault, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaftByDefault, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, raft1, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(raft1, allRaft, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiersByDefault, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiersByDefault, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allObfuscationModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allObfuscationModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, lzoFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { LZO }), new Parameters(allRaft, allRaft, lzoFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredLzoFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, snappyFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { SNAPPY }), new Parameters(allRaft, allRaft, snappyFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredSnappyFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlySnappyCompressionModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, onlySnappyCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, allModifiers, noModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, noModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {})
                          ));
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnModifierProtocolOfSingleConfiguredVersionIfOthersRequested()
        public virtual void ShouldReturnModifierProtocolOfSingleConfiguredVersionIfOthersRequested()
        {
            // given
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation()
            }));
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedProtocols);
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> modifierProtocol = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION)));

            // then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(modifierProtocol.map(Protocol::implementation), OptionalMatchers.contains(LZO.implementation()));
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        public virtual void ShouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        {
            // given
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation(), SNAPPY.implementation(), LZ4.implementation()
            }), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, new IList <string> {
                NAME_CLASH.implementation()
            }));
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedProtocols);
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> modifierProtocol = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet("bzip2", SNAPPY.implementation(), LZ4.implementation(), LZO.implementation(), "fast_lz"));

            // then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(modifierProtocol.map(Protocol::implementation), OptionalMatchers.contains(LZO.implementation()));
        }