Package com.taobao.metamorphosis.server.store.MessageStore

Examples of com.taobao.metamorphosis.server.store.MessageStore.Segment


    public void testSegmentContants() throws Exception {
        final File file = new File("testSegmentContants.test");
        if (!file.exists()) {
            file.createNewFile();
        }
        final Segment segment = new Segment(0, file);
        try {
            segment.fileMessageSet.setHighWaterMarker(1024);
            assertTrue(segment.contains(0));
            assertFalse(segment.contains(1024));
            assertFalse(segment.contains(1025));
            assertFalse(segment.contains(2048));
            assertTrue(segment.contains(1));
            assertTrue(segment.contains(100));
            assertTrue(segment.contains(512));
            assertTrue(segment.contains(1023));
        }
        finally {
            if (segment != null) {
                segment.fileMessageSet.close();
            }
View Full Code Here


        assertEquals(0, segmentList.contents.get().length);
        final File file = new File("testAppendSegmentDeleteSegment.test");
        if (!file.exists()) {
            file.createNewFile();
        }
        final Segment segment1 = new Segment(0, file);
        final Segment segment2 = new Segment(1024, file);
        final Segment segment3 = new Segment(2048, file);
        try {
            segmentList.append(segment1);
            assertEquals(1, segmentList.contents.get().length);
            assertSame(segment1, segmentList.first());
            assertSame(segment1, segmentList.last());
View Full Code Here

        assertEquals(0, segmentList.contents.get().length);
        final File file = new File("testGetNearestOffset.test");
        if (!file.exists()) {
            file.createNewFile();
        }
        final Segment segment1 = new Segment(0, file);
        segment1.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment2 = new Segment(1024, file);
        segment2.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment3 = new Segment(2048, file);
        segment3.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment4 = new Segment(3072, file);
        segment4.fileMessageSet.setHighWaterMarker(1024);

        segmentList.append(segment1);
        segmentList.append(segment2);
        segmentList.append(segment3);
View Full Code Here

        assertEquals(0, segmentList.contents.get().length);
        final File file = new File("testFindSegment.test");
        if (!file.exists()) {
            file.createNewFile();
        }
        final Segment segment1 = new Segment(0, file);
        segment1.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment2 = new Segment(1024, file);
        segment2.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment3 = new Segment(2048, file);
        segment3.fileMessageSet.setHighWaterMarker(1024);
        final Segment segment4 = new Segment(3072, file);
        segment4.fileMessageSet.setHighWaterMarker(1024);

        segmentList.append(segment1);
        segmentList.append(segment2);
        segmentList.append(segment3);
View Full Code Here

        final Segment[] newSegments = this.messageStore.getSegments().view();
        assertEquals(oldSegmentCount, newSegments.length);
        assertEquals(lastSegmentName, newSegments[newSegments.length - 1].file.getName());
        assertEquals(lastSegmentSize, newSegments[newSegments.length - 1].size());

        Segment prev = null;
        for (final Segment s : newSegments) {
            if (prev != null) {
                assertEquals(s.start, prev.start + prev.size());
            }
            prev = s;
        }
    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.server.store.MessageStore.Segment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.