Package org.apache.jackrabbit.oak.plugins.segment

Examples of org.apache.jackrabbit.oak.plugins.segment.Segment


        try {
            URLConnection connection = get(id.toString());
            InputStream stream = connection.getInputStream();
            try {
                byte[] data = ByteStreams.toByteArray(stream);
                return new Segment(tracker, id, ByteBuffer.wrap(data));
            } finally {
                stream.close();
            }
        } catch (MalformedURLException e) {
            throw new IllegalStateException(e);
View Full Code Here


                id.getLeastSignificantBits());
        for (TarFile file : files) {
            try {
                ByteBuffer buffer = file.readEntry(uuid);
                if (buffer != null) {
                    return new Segment(tracker, id, buffer);
                }
            } catch (IOException e) {
                throw new RuntimeException(
                        "Failed to access file " + file, e);
            }
View Full Code Here

                    ro.limit(ro.position() + length);
                    ByteBuffer data = ro.slice();
                    ro.limit(rw.limit());

                    Segment segment = new Segment(
                            this, segmentId, data, referencedSegmentIds,
                            Collections.<String, RecordId>emptyMap(),
                            Collections.<Template, RecordId>emptyMap());
                    segments.put(segmentId, segment);
View Full Code Here

        return journal;
    }

    @Override
    public Segment readSegment(UUID id) {
        Segment segment = segments.get(id);
        if (segment != null) {
            return segment;
        } else {
            throw new IllegalArgumentException("Segment not found: " + id);
        }
View Full Code Here

        ro.limit(rw.limit());

        rw.position((rw.position() + 0x1ff) & ~0x1ff);
        ro.position(rw.position());

        Segment segment = new Segment(
                this, segmentId, buffer,
                referencedSegmentIds, strings, templates);
        checkState(segments.put(segmentId, segment) == null);
    }
View Full Code Here

        try {
            final URLConnection connection = get("s/" + id);
            InputStream stream = connection.getInputStream();
            try {
                byte[] data = ByteStreams.toByteArray(stream);
                return new Segment(this, factory, id, ByteBuffer.wrap(data));
            } finally {
                stream.close();
            }
        } catch (MalformedURLException e) {
            throw new IllegalStateException(e);
View Full Code Here

            } else {
                break;
            }
        }

        Segment segment = getWriter().getDummySegment();
        for (TarFile tar : treeFiles) {
            ByteBuffer buffer = tar.readEntry(JOURNALS_UUID);
            if (buffer != null) {
                checkState(JOURNAL_MAGIC == buffer.getLong());
                int count = buffer.getInt();
View Full Code Here

    @Override
    protected Segment loadSegment(UUID id) throws Exception {
        for (TarFile file : treeFiles) {
            ByteBuffer buffer = file.readEntry(id);
            if (buffer != null) {
                return new Segment(FileStore.this, id, buffer);
            }
        }
        for (TarFile file : bulkFiles) {
            ByteBuffer buffer = file.readEntry(id);
            if (buffer != null) {
                return new Segment(FileStore.this, id, buffer);
            }
        }
        throw new IllegalStateException("Segment " + id + " not found");
    }
View Full Code Here

        return journal;
    }

    @Override
    protected Segment loadSegment(UUID id) {
        Segment segment = segments.get(id);
        if (segment != null) {
            return segment;
        } else {
            throw new IllegalArgumentException("Segment not found: " + id);
        }
View Full Code Here

    public void writeSegment(
            UUID segmentId, byte[] data, int offset, int length) {
        ByteBuffer buffer = ByteBuffer.allocate(length);
        buffer.put(data, offset, length);
        buffer.rewind();
        Segment segment = new Segment(this, segmentId, buffer);
        if (segments.putIfAbsent(segment.getSegmentId(), segment) != null) {
            throw new IllegalStateException(
                    "Segment override: " + segment.getSegmentId());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.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.