Search in sources :

Example 36 with ClientConnection

use of io.pravega.client.netty.impl.ClientConnection in project pravega by pravega.

the class SegmentOutputStreamTest method testConnectAndSend.

@Test(timeout = 10000)
public void testConnectAndSend() throws SegmentSealedException, ConnectionFailedException {
    UUID cid = UUID.randomUUID();
    PravegaNodeUri uri = new PravegaNodeUri("endpoint", SERVICE_PORT);
    MockConnectionFactoryImpl cf = new MockConnectionFactoryImpl();
    @Cleanup("shutdown") InlineExecutor inlineExecutor = new InlineExecutor();
    cf.setExecutor(inlineExecutor);
    MockController controller = new MockController(uri.getEndpoint(), uri.getPort(), cf);
    ClientConnection connection = mock(ClientConnection.class);
    cf.provideConnection(uri, connection);
    SegmentOutputStreamImpl output = new SegmentOutputStreamImpl(SEGMENT, controller, cf, cid, segmentSealedCallback, RETRY_SCHEDULE, "");
    output.reconnect();
    verify(connection).send(new SetupAppend(1, cid, SEGMENT, ""));
    cf.getProcessor(uri).appendSetup(new AppendSetup(1, SEGMENT, cid, 0));
    sendAndVerifyEvent(cid, connection, output, getBuffer("test"), 1, null);
    verifyNoMoreInteractions(connection);
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) InlineExecutor(io.pravega.test.common.InlineExecutor) MockConnectionFactoryImpl(io.pravega.client.stream.mock.MockConnectionFactoryImpl) SetupAppend(io.pravega.shared.protocol.netty.WireCommands.SetupAppend) MockController(io.pravega.client.stream.mock.MockController) ClientConnection(io.pravega.client.netty.impl.ClientConnection) UUID(java.util.UUID) Cleanup(lombok.Cleanup) AppendSetup(io.pravega.shared.protocol.netty.WireCommands.AppendSetup) Test(org.junit.Test)

Example 37 with ClientConnection

use of io.pravega.client.netty.impl.ClientConnection in project pravega by pravega.

the class MockConnectionFactoryImpl method establishConnection.

@Override
@Synchronized
public CompletableFuture<ClientConnection> establishConnection(PravegaNodeUri location, ReplyProcessor rp) {
    ClientConnection connection = connections.get(location);
    Preconditions.checkState(connection != null, "Unexpected Endpoint");
    processors.put(location, rp);
    return CompletableFuture.completedFuture(connection);
}
Also used : ClientConnection(io.pravega.client.netty.impl.ClientConnection) Synchronized(lombok.Synchronized)

Aggregations

ClientConnection (io.pravega.client.netty.impl.ClientConnection)37 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)33 MockController (io.pravega.client.stream.mock.MockController)30 Test (org.junit.Test)30 MockConnectionFactoryImpl (io.pravega.client.stream.mock.MockConnectionFactoryImpl)29 UUID (java.util.UUID)23 WireCommands (io.pravega.shared.protocol.netty.WireCommands)21 SetupAppend (io.pravega.shared.protocol.netty.WireCommands.SetupAppend)21 Cleanup (lombok.Cleanup)19 AppendSetup (io.pravega.shared.protocol.netty.WireCommands.AppendSetup)17 CompletableFuture (java.util.concurrent.CompletableFuture)17 PendingEvent (io.pravega.client.stream.impl.PendingEvent)15 Append (io.pravega.shared.protocol.netty.Append)14 InOrder (org.mockito.InOrder)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 InvocationOnMock (org.mockito.invocation.InvocationOnMock)13 ConnectionFailedException (io.pravega.shared.protocol.netty.ConnectionFailedException)11 InlineExecutor (io.pravega.test.common.InlineExecutor)11 ByteBuffer (java.nio.ByteBuffer)11 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)10