Search in sources :

Example 11 with StreamCut

use of io.pravega.client.stream.StreamCut in project pravega by pravega.

the class ControllerImplTest method testGetSegmentsWithValidStreamCut.

/*
     Segment mapping of stream8 used for the below tests.

     +-------+------+-------
     |       |   8  |
     |   2   +------|
     |       |   7  |   10
     +-------+ -----|
     |       |   6  |
     |  1    +------+-------
     |       |   5  |
     +-------+------|
     |       |   4  |   9
     |  0    +------|
     |       |   3  |
     +-------+------+--------
     */
@Test
public void testGetSegmentsWithValidStreamCut() throws Exception {
    String scope = "scope1";
    String stream = "stream8";
    Stream s = new StreamImpl(scope, stream);
    Map<Segment, Long> startSegments = new HashMap<>();
    startSegments.put(new Segment(scope, stream, 0), 4L);
    startSegments.put(new Segment(scope, stream, 1), 6L);
    startSegments.put(new Segment(scope, stream, 7), 6L);
    startSegments.put(new Segment(scope, stream, 8), 6L);
    StreamCut cut = new StreamCutImpl(s, startSegments);
    Map<Segment, Long> endSegments = new HashMap<>();
    endSegments.put(new Segment(scope, stream, 3), 10L);
    endSegments.put(new Segment(scope, stream, 4), 10L);
    endSegments.put(new Segment(scope, stream, 5), 10L);
    endSegments.put(new Segment(scope, stream, 10), 10L);
    StreamCut endSC = new StreamCutImpl(s, endSegments);
    Set<Segment> segments = controllerClient.getSegments(cut, endSC).get().getSegments();
    assertEquals(ImmutableSet.of(new Segment(scope, stream, 0), new Segment(scope, stream, 1), new Segment(scope, stream, 8), new Segment(scope, stream, 7), new Segment(scope, stream, 3), new Segment(scope, stream, 4), new Segment(scope, stream, 5), new Segment(scope, stream, 10), new Segment(scope, stream, 6)), segments);
}
Also used : StreamCut(io.pravega.client.stream.StreamCut) HashMap(java.util.HashMap) Stream(io.pravega.client.stream.Stream) Segment(io.pravega.client.segment.impl.Segment) Test(org.junit.Test)

Aggregations

StreamCut (io.pravega.client.stream.StreamCut)11 HashMap (java.util.HashMap)11 Stream (io.pravega.client.stream.Stream)10 Test (org.junit.Test)8 Segment (io.pravega.client.segment.impl.Segment)7 Cleanup (lombok.Cleanup)4 ClientFactory (io.pravega.client.ClientFactory)2 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)2 ReaderGroup (io.pravega.client.stream.ReaderGroup)2 Map (java.util.Map)2 ReaderGroupManagerImpl (io.pravega.client.admin.impl.ReaderGroupManagerImpl)1 ConnectionFactory (io.pravega.client.netty.impl.ConnectionFactory)1 ConnectionFactoryImpl (io.pravega.client.netty.impl.ConnectionFactoryImpl)1 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)1 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)1 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)1 Controller (io.pravega.client.stream.impl.Controller)1 ReaderGroupStateInit (io.pravega.client.stream.impl.ReaderGroupState.ReaderGroupStateInit)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1