Exemplo n.º 1
0
        public MasterClientResolver(LogProvider logProvider, ResponseUnpacker responseUnpacker, InvalidEpochExceptionHandler invalidEpochHandler, int readTimeoutMillis, int lockReadTimeout, int channels, int chunkSize, System.Func <LogEntryReader <ReadableClosablePositionAwareChannel> > logEntryReader)
        {
            this._logEntryReader      = logEntryReader;
            this._log                 = logProvider.getLog(this.GetType());
            this._responseUnpacker    = responseUnpacker;
            this._invalidEpochHandler = invalidEpochHandler;

            _protocolToFactoryMapping = new Dictionary <ProtocolVersion, MasterClientFactory>(3, 1);
            _protocolToFactoryMapping[MasterClient214.PROTOCOL_VERSION] = new F214(this, logProvider, readTimeoutMillis, lockReadTimeout, channels, chunkSize);
            _protocolToFactoryMapping[MasterClient310.PROTOCOL_VERSION] = new F310(this, logProvider, readTimeoutMillis, lockReadTimeout, channels, chunkSize);
            _protocolToFactoryMapping[MasterClient320.PROTOCOL_VERSION] = new F320(this, logProvider, readTimeoutMillis, lockReadTimeout, channels, chunkSize);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void masterResponseShouldNotBeUnpackedIfRequestTypeDoesNotRequire()
        public virtual void MasterResponseShouldNotBeUnpackedIfRequestTypeDoesNotRequire()
        {
            // Given
            ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker));
            MadeUpClient     client           = _builder.clientWith(responseUnpacker);

            AddToLifeAndStart(_builder.server(), client);

            // When
            client.SendDataStream(new KnownDataByteChannel(100));

            // Then
            verifyZeroInteractions(responseUnpacker);
        }
Exemplo n.º 3
0
        public Client(string destinationHostNameOrIp, int destinationPort, string originHostNameOrIp, LogProvider logProvider, StoreId storeId, int frameLength, long readTimeout, int maxConcurrentChannels, int chunkSize, ResponseUnpacker responseUnpacker, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor, LogEntryReader <ReadableClosablePositionAwareChannel> entryReader)
        {
            this._entryReader = entryReader;
            Debug.Assert(byteCounterMonitor != null);
            Debug.Assert(requestMonitor != null);

            this._byteCounterMonitor = byteCounterMonitor;
            this._requestMonitor     = requestMonitor;
            assertChunkSizeIsWithinFrameSize(chunkSize, frameLength);

            this._msgLog      = logProvider.getLog(this.GetType());
            this._storeId     = storeId;
            this._frameLength = frameLength;
            this._readTimeout = readTimeout;
            // ResourcePool no longer controls max concurrent channels. Use this value for the pool size
            this._maxUnusedChannels   = maxConcurrentChannels;
            this._comExceptionHandler = NoOpComExceptionHandler;

            if (destinationHostNameOrIp.Equals("0.0.0.0"))
            {
                // So it turns out that on Windows, connecting to 0.0.0.0 when specifying
                // an origin address will not succeed. But since we know we are
                // connecting to ourselves, and that we are listening on everything,
                // replacing with localhost is the proper thing to do.
                this._destination = new InetSocketAddress(LocalAddress, destinationPort);
            }
            else
            {
                // An explicit destination address is always correct
                this._destination = new InetSocketAddress(destinationHostNameOrIp, destinationPort);
            }

            if (string.ReferenceEquals(originHostNameOrIp, null) || originHostNameOrIp.Equals("0.0.0.0"))
            {
                _origin = null;
            }
            else
            {
                _origin = new InetSocketAddress(originHostNameOrIp, 0);
            }

            ProtocolVersion protocolVersion = ProtocolVersion;

            this._protocol         = CreateProtocol(chunkSize, protocolVersion.ApplicationProtocol);
            this._responseUnpacker = responseUnpacker;

            _msgLog.info(this.GetType().Name + " communication channel created towards " + _destination);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("rawtypes") public void masterResponseShouldBeUnpackedIfRequestTypeRequires() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MasterResponseShouldBeUnpackedIfRequestTypeRequires()
        {
            // Given
            ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker));
            MadeUpClient     client           = _builder.clientWith(responseUnpacker);

            AddToLifeAndStart(_builder.server(), client);

            // When
            client.Multiply(42, 42);

            // Then
            ArgumentCaptor <Response> captor = ArgumentCaptor.forClass(typeof(Response));

            verify(responseUnpacker).unpackResponse(captor.capture(), eq(NO_OP_TX_HANDLER));
            assertEquals(_storeIdToUse, captor.Value.StoreId);
            assertEquals(42 * 42, captor.Value.response());
        }
Exemplo n.º 5
0
 internal BackupClient(string destinationHostNameOrIp, int destinationPort, string originHostNameOrIp, LogProvider logProvider, StoreId storeId, long timeout, ResponseUnpacker unpacker, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor, LogEntryReader <ReadableClosablePositionAwareChannel> reader) : base(destinationHostNameOrIp, destinationPort, originHostNameOrIp, logProvider, storeId, FRAME_LENGTH, timeout, Client.DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT, FRAME_LENGTH, unpacker, byteCounterMonitor, requestMonitor, reader)
 {
 }
Exemplo n.º 6
0
 public MadeUpClient(int port, StoreId storeIdToExpect, int chunkSize, ResponseUnpacker responseUnpacker) : base(Localhost(), port, null, NullLogProvider.Instance, storeIdToExpect, FRAME_LENGTH, Client.DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS * 1000, Client.DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT, chunkSize, responseUnpacker, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)), (new Monitors()).newMonitor(typeof(RequestMonitor)), new VersionAwareLogEntryReader <org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel>())
 {
 }
Exemplo n.º 7
0
 public MadeUpClientAnonymousInnerClass(Builder outerInstance, int port, StoreId storeId, int chunkSize, ResponseUnpacker responseUnpacker) : base(port, storeId, chunkSize, responseUnpacker)
 {
     this.outerInstance = outerInstance;
 }
Exemplo n.º 8
0
 internal virtual MadeUpClient ClientWith(ResponseUnpacker responseUnpacker)
 {
     return(new MadeUpClientAnonymousInnerClass(this, PortConflict, StoreIdConflict, ChunkSizeConflict, responseUnpacker));
 }