use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.
the class DebugStore method getReferencedSegmentIds.
private static List<SegmentId> getReferencedSegmentIds(ReadOnlyFileStore store, Segment segment) {
List<SegmentId> result = new ArrayList<>();
for (int i = 0; i < segment.getReferencedSegmentIdCount(); i++) {
UUID uuid = segment.getReferencedSegmentId(i);
long msb = uuid.getMostSignificantBits();
long lsb = uuid.getLeastSignificantBits();
result.add(store.getSegmentIdProvider().newSegmentId(msb, lsb));
}
return result;
}
use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.
the class DebugTars method filterNodeStates.
private void filterNodeStates(Set<UUID> uuids, List<String> paths, SegmentNodeState state, String path) {
Set<String> localPaths = newTreeSet();
for (PropertyState ps : state.getProperties()) {
if (ps instanceof SegmentPropertyState) {
SegmentPropertyState sps = (SegmentPropertyState) ps;
RecordId recordId = sps.getRecordId();
UUID id = recordId.getSegmentId().asUUID();
if (uuids.contains(id)) {
if (ps.getType().tag() == PropertyType.STRING) {
String val = "";
if (ps.count() > 0) {
// only shows the first value, do we need more?
val = displayString(ps.getValue(Type.STRING, 0));
}
localPaths.add(getLocalPath(path, ps, val, recordId));
} else {
localPaths.add(getLocalPath(path, ps, recordId));
}
}
if (ps.getType().tag() == PropertyType.BINARY) {
// look for extra segment references
for (int i = 0; i < ps.count(); i++) {
Blob b = ps.getValue(Type.BINARY, i);
for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) {
UUID bid = sbid.asUUID();
if (!bid.equals(id) && uuids.contains(bid)) {
localPaths.add(getLocalPath(path, ps, recordId));
}
}
}
}
}
}
RecordId stateId = state.getRecordId();
if (uuids.contains(stateId.getSegmentId().asUUID())) {
localPaths.add(path + " [SegmentNodeState@" + stateId + "]");
}
RecordId templateId = getTemplateId(state);
if (uuids.contains(templateId.getSegmentId().asUUID())) {
localPaths.add(path + "[Template@" + templateId + "]");
}
paths.addAll(localPaths);
for (ChildNodeEntry ce : state.getChildNodeEntries()) {
NodeState c = ce.getNodeState();
if (c instanceof SegmentNodeState) {
filterNodeStates(uuids, paths, (SegmentNodeState) c, path + ce.getName() + "/");
}
}
}
use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.
the class StandbyClientSyncExecution method copySegmentFromPrimary.
private void copySegmentFromPrimary(UUID uuid) throws Exception {
byte[] data = client.getSegment(uuid.toString());
if (data == null) {
throw new IllegalStateException("Unable to read segment " + uuid);
}
long msb = uuid.getMostSignificantBits();
long lsb = uuid.getLeastSignificantBits();
SegmentId segmentId = idProvider.newSegmentId(msb, lsb);
store.writeSegment(segmentId, data, 0, data.length);
}
use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.
the class StandbyTestUtils method mockSegment.
public static Segment mockSegment(UUID uuid, byte[] buffer) {
SegmentStore store = mock(SegmentStore.class);
SegmentIdProvider idProvider = mock(SegmentIdProvider.class);
SegmentReader reader = mock(SegmentReader.class);
long msb = uuid.getMostSignificantBits();
long lsb = uuid.getLeastSignificantBits();
SegmentId id = new SegmentId(store, msb, lsb);
ByteBuffer data = ByteBuffer.wrap(buffer);
return new Segment(idProvider, reader, id, data);
}
use of org.apache.jackrabbit.oak.segment.SegmentId in project jackrabbit-oak by apache.
the class SegmentTarFactory method hasExternalBlobReferences.
@Override
public boolean hasExternalBlobReferences() throws IOException {
final FileStoreBuilder builder = fileStoreBuilder(new File(dir, "segmentstore"));
builder.withMaxFileSize(256);
builder.withMemoryMapping(false);
ReadOnlyFileStore fs;
try {
fs = builder.buildReadOnly();
} catch (InvalidFileStoreVersionException e) {
throw new IOException(e);
}
try {
for (SegmentId id : fs.getSegmentIds()) {
if (!id.isDataSegmentId()) {
continue;
}
id.getSegment().forEachRecord(new Segment.RecordConsumer() {
@Override
public void consume(int number, RecordType type, int offset) {
// see java.nio.file.FileVisitor
if (type == RecordType.BLOB_ID) {
throw new ExternalBlobFound();
}
}
});
}
return false;
} catch (ExternalBlobFound e) {
return true;
} finally {
fs.close();
}
}
Aggregations