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

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


                SegmentId id = store.getTracker().getSegmentId(
                        uuid.getMostSignificantBits(),
                        uuid.getLeastSignificantBits());
                System.out.println(id.getSegment());
            } else {
                RecordId id1 = store.getHead().getRecordId();
                RecordId id2 = null;
                if (matcher.group(2) != null) {
                    id1 = RecordId.fromString(store.getTracker(),
                            matcher.group(3));
                    if (matcher.group(4) != null) {
                        id2 = RecordId.fromString(store.getTracker(),
                                matcher.group(5));
                    }
                }
                String path = "/";
                if (matcher.group(6) != null) {
                    path = matcher.group(6);
                }

                if (id2 == null) {
                    NodeState node = new SegmentNodeState(id1);
                    System.out.println("/ (" + id1 + ") -> " + node);
                    for (String name : PathUtils.elements(path)) {
                        node = node.getChildNode(name);
                        RecordId nid = null;
                        if (node instanceof SegmentNodeState) {
                            nid = ((SegmentNodeState) node).getRecordId();
                        }
                        System.out.println("  " + name + " (" + nid + ") -> "
                                + node);
View Full Code Here


                writer.writeString(Strings.repeat("abcdefghijklmno".substring(k, k + 1),
                        Segment.MEDIUM_LIMIT - 1));
            }

            // adding 14280 bytes. 1 byte per char, and 2 bytes to store the length
            RecordId x = writer.writeString(Strings.repeat("x", 14278));
            // writer.length == 262052

            // Adding 765 bytes (255 recordIds)
            // This should cause the current segment to flush
            List<RecordId> list = Collections.nCopies(n, x);
View Full Code Here

        NodeState state = model.getState();
        String tarFile = "";

        if (state instanceof SegmentNodeState) {
            SegmentNodeState s = (SegmentNodeState) state;
            RecordId recordId = s.getRecordId();
            sb.append("Record " + recordId);
            tarFile = getFile(recordId);
            if (tarFile.length() > 0) {
                sb.append(" in " + tarFile);
            }
            sb.append(newline);

            RecordId templateId = SegmentNodeStateHelper.getTemplateId(s);
            String f = getFile(templateId);
            sb.append("TemplateId ");
            sb.append(templateId);
            if (!f.equals(tarFile)) {
                sb.append(" in " + f);
            }
            sb.append(newline);
        }

        sb.append("Size: ");
        sb.append("  direct: ");
        sb.append(FileUtils.byteCountToDisplaySize(model.getSize()[0]));
        sb.append(";  linked: ");
        sb.append(FileUtils.byteCountToDisplaySize(model.getSize()[1]));
        sb.append(newline);

        sb.append("Properties (count: " + state.getPropertyCount() + ")");
        sb.append(newline);
        Map<String, String> propLines = new TreeMap<String, String>();
        for (PropertyState ps : state.getProperties()) {
            StringBuilder l = new StringBuilder();
            l.append("  - " + ps.getName() + " = {" + ps.getType() + "} ");
            if (ps.getType().isArray()) {
                int count = ps.count();
                l.append("(count " + count + ") [");

                String separator = ", ";
                int max = 50;
                if (ps.getType() == Type.BINARIES) {
                    separator = newline + "      ";
                    max = Integer.MAX_VALUE;
                    l.append(separator);
                }
                for (int i = 0; i < Math.min(count, max); i++) {
                    if (i > 0) {
                        l.append(separator);
                    }
                    l.append(toString(ps, i, tarFile));
                }
                if (count > max) {
                    l.append(", ... (" + count + " values)");
                }
                if (ps.getType() == Type.BINARIES) {
                    l.append(separator);
                }
                l.append("]");

            } else {
                l.append(toString(ps, 0, tarFile));
            }
            if (ps instanceof SegmentPropertyState) {
                RecordId rid = ((SegmentPropertyState) ps).getRecordId();
                l.append(" (" + rid);
                String f = getFile(rid);
                if (!f.equals(tarFile)) {
                    l.append(" in " + f);
                }
                l.append(")");
            } else {
                l.append(" (" + ps.getClass().getSimpleName() + ")");
            }
            propLines.put(ps.getName(), l.toString());
        }

        for (String l : propLines.values()) {
            sb.append(l);
            sb.append(newline);
        }

        sb.append("Child nodes (count: " + state.getChildNodeCount(Long.MAX_VALUE)
                + ")");
        sb.append(newline);
        Map<String, String> childLines = new TreeMap<String, String>();
        for (ChildNodeEntry ce : state.getChildNodeEntries()) {
            StringBuilder l = new StringBuilder();
            l.append("  + " + ce.getName());
            NodeState c = ce.getNodeState();
            if (c instanceof SegmentNodeState) {
                RecordId rid = ((SegmentNodeState) c).getRecordId();
                l.append(" (" + rid);
                String f = getFile(rid);
                if (!f.equals(tarFile)) {
                    l.append(" in " + f);
                }
View Full Code Here

            SegmentNodeState state, String path) {
        Set<String> localPaths = new TreeSet<String>();
        for (PropertyState ps : state.getProperties()) {
            if (ps instanceof SegmentPropertyState) {
                SegmentPropertyState sps = (SegmentPropertyState) ps;
                RecordId recordId = sps.getRecordId();
                SegmentId sid = recordId.getSegmentId();
                UUID id = new UUID(sid.getMostSignificantBits(),
                        sid.getLeastSignificantBits());
                if (uuids.contains(id)) {
                    localPaths.add(path + "@" + ps + " [SegmentPropertyState@"
                            + recordId + "]");
                }
                if (ps.getType().tag() == PropertyType.BINARY) {
                    for (int i = 0; i < ps.count(); i++) {
                        Blob b = ps.getValue(Type.BINARY, i);
                        for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) {
                            UUID bid = new UUID(sbid.getMostSignificantBits(),
                                    sbid.getLeastSignificantBits());
                            if (!bid.equals(id) && uuids.contains(bid)) {
                                localPaths.add(path + "@" + ps
                                        + " [SegmentPropertyState@" + recordId
                                        + "]");
                            }
                        }
                    }
                }
            }
        }

        RecordId stateId = state.getRecordId();
        SegmentId segmentId = stateId.getSegmentId();
        if (uuids.contains(new UUID(segmentId.getMostSignificantBits(),
                segmentId.getLeastSignificantBits()))) {
            localPaths.add(path + " [SegmentNodeState@" + stateId + "]");
        }

        RecordId templateId = SegmentNodeStateHelper.getTemplateId(state);
        SegmentId template = templateId.getSegmentId();
        if (uuids.contains(new UUID(template.getMostSignificantBits(), template
                .getLeastSignificantBits()))) {
            localPaths.add(path + "[Template@" + templateId + "]");
        }
        paths.addAll(localPaths);
View Full Code Here

            sb.append(input);
            sb.append(newline);
            log.setText("Usage <recordId> <recordId> [<path>]");
            return;
        }
        RecordId id1 = null;
        RecordId id2 = null;
        try {
            id1 = RecordId.fromString(store.getTracker(), tokens[0]);
            id2 = RecordId.fromString(store.getTracker(), tokens[1]);
        } catch (IllegalArgumentException ex) {
            sb.append("Unknown argument: ");
View Full Code Here

                heads.add(line.substring(0, space));
            }
            line = journalFile.readLine();
        }

        RecordId id = null;
        while (id == null && !heads.isEmpty()) {
            RecordId last = RecordId.fromString(tracker, heads.removeLast());
            SegmentId segmentId = last.getSegmentId();
            if (containsSegment(
                    segmentId.getMostSignificantBits(),
                    segmentId.getLeastSignificantBits())) {
                id = last;
            } else {
View Full Code Here

        return estimate;
    }

    public void flush() throws IOException {
        synchronized (persistedHead) {
            RecordId before = persistedHead.get();
            RecordId after = head.get();
            boolean cleanup = cleanupNeeded.getAndSet(false);
            if (cleanup || !after.equals(before)) {
                // needs to happen outside the synchronization block below to
                // avoid a deadlock with another thread flushing the writer
                tracker.getWriter().flush();

                // needs to happen outside the synchronization block below to
                // prevent the flush from stopping concurrent reads and writes
                writer.flush();

                synchronized (this) {
                    log.debug("TarMK journal update {} -> {}", before, after);
                    journalFile.writeBytes(after.toString10() + " root\n");
                    journalFile.getChannel().force(false);
                    persistedHead.set(after);

                    if (cleanup) {
                        cleanup();
View Full Code Here

        return new SegmentNodeState(head.get());
    }

    @Override
    public boolean setHead(SegmentNodeState base, SegmentNodeState head) {
        RecordId id = this.head.get();
        return id.equals(base.getRecordId())
                && this.head.compareAndSet(id, head.getRecordId());
    }
View Full Code Here

        }
        else {
            String clientID = Messages.extractClientFrom(payload);
            observer.gotMessageFrom(clientID, request, client);
            if (Messages.GET_HEAD.equalsIgnoreCase(request)) {
                RecordId r = headId();
                if (r != null) {
                    ctx.writeAndFlush(r);
                    return;
                }
            } else if (request.startsWith(Messages.GET_SEGMENT)) {
View Full Code Here

        }

        journalFile = new RandomAccessFile(
                new File(directory, JOURNAL_FILE_NAME), "rw");

        RecordId id = null;
        String line = journalFile.readLine();
        while (line != null) {
            int space = line.indexOf(' ');
            if (space != -1) {
                id = RecordId.fromString(tracker, line.substring(0, space));
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.RecordId

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.